OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/profile_resetter/profile_resetter.h" | 5 #include "chrome/browser/profile_resetter/profile_resetter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/profile_resetter/profile_resetter_test_base.h" | 8 #include "chrome/browser/profile_resetter/profile_resetter_test_base.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 BrowserThread::UI, FROM_HERE, | 130 BrowserThread::UI, FROM_HERE, |
131 base::Bind(&RemoveCookieTester::SetCookieCallback, | 131 base::Bind(&RemoveCookieTester::SetCookieCallback, |
132 base::Unretained(this), result)); | 132 base::Unretained(this), result)); |
133 return; | 133 return; |
134 } | 134 } |
135 ASSERT_TRUE(result); | 135 ASSERT_TRUE(result); |
136 Notify(); | 136 Notify(); |
137 } | 137 } |
138 | 138 |
139 void RemoveCookieTester::BlockUntilNotified() { | 139 void RemoveCookieTester::BlockUntilNotified() { |
140 DCHECK(!runner_); | 140 DCHECK(!runner_.get()); |
141 if (waiting_callback_) { | 141 if (waiting_callback_) { |
142 runner_ = new content::MessageLoopRunner; | 142 runner_ = new content::MessageLoopRunner; |
143 runner_->Run(); | 143 runner_->Run(); |
144 runner_ = NULL; | 144 runner_ = NULL; |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 void RemoveCookieTester::Notify() { | 148 void RemoveCookieTester::Notify() { |
149 DCHECK(waiting_callback_); | 149 DCHECK(waiting_callback_); |
150 waiting_callback_ = false; | 150 waiting_callback_ = false; |
151 if (runner_) | 151 if (runner_.get()) |
152 runner_->Quit(); | 152 runner_->Quit(); |
153 } | 153 } |
154 | 154 |
155 class ProfileResetTest : public InProcessBrowserTest, | 155 class ProfileResetTest : public InProcessBrowserTest, |
156 public ProfileResetterTestBase { | 156 public ProfileResetterTestBase { |
157 protected: | 157 protected: |
158 virtual void SetUpOnMainThread() OVERRIDE { | 158 virtual void SetUpOnMainThread() OVERRIDE { |
159 resetter_.reset(new ProfileResetter(browser()->profile())); | 159 resetter_.reset(new ProfileResetter(browser()->profile())); |
160 } | 160 } |
161 }; | 161 }; |
162 | 162 |
163 | 163 |
164 IN_PROC_BROWSER_TEST_F(ProfileResetTest, ResetCookiesAndSiteData) { | 164 IN_PROC_BROWSER_TEST_F(ProfileResetTest, ResetCookiesAndSiteData) { |
165 RemoveCookieTester tester(browser()->profile()); | 165 RemoveCookieTester tester(browser()->profile()); |
166 tester.AddCookie(kCookieHostname, kCookieDefinition); | 166 tester.AddCookie(kCookieHostname, kCookieDefinition); |
167 ASSERT_EQ(kCookieDefinition, tester.GetCookie(kCookieHostname)); | 167 ASSERT_EQ(kCookieDefinition, tester.GetCookie(kCookieHostname)); |
168 | 168 |
169 resetter_->Reset(ProfileResetter::COOKIES_AND_SITE_DATA, | 169 resetter_->Reset(ProfileResetter::COOKIES_AND_SITE_DATA, |
170 base::Bind(&ProfileResetterMockObject::StopLoop, | 170 base::Bind(&ProfileResetterMockObject::StopLoop, |
171 base::Unretained(&mock_object_))); | 171 base::Unretained(&mock_object_))); |
172 mock_object_.RunLoop(); | 172 mock_object_.RunLoop(); |
173 | 173 |
174 EXPECT_EQ("", tester.GetCookie(kCookieHostname)); | 174 EXPECT_EQ("", tester.GetCookie(kCookieHostname)); |
175 } | 175 } |
176 | 176 |
177 } // namespace | 177 } // namespace |
OLD | NEW |