Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This test creates a fake safebrowsing service, where we can inject 5 // This test creates a fake safebrowsing service, where we can inject
6 // malware and phishing urls. It then uses a real browser to go to 6 // malware and phishing urls. It then uses a real browser to go to
7 // these urls, and sends "goback" or "proceed" commands and verifies 7 // these urls, and sends "goback" or "proceed" commands and verifies
8 // they work. 8 // they work.
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 const std::string& serialized) OVERRIDE { 126 const std::string& serialized) OVERRIDE {
127 reports_.push_back(serialized); 127 reports_.push_back(serialized);
128 // Notify the UI thread that we got a report. 128 // Notify the UI thread that we got a report.
129 BrowserThread::PostTask( 129 BrowserThread::PostTask(
130 BrowserThread::UI, FROM_HERE, 130 BrowserThread::UI, FROM_HERE,
131 base::Bind(&FakeSafeBrowsingUIManager::OnMalwareDetailsDone, this)); 131 base::Bind(&FakeSafeBrowsingUIManager::OnMalwareDetailsDone, this));
132 } 132 }
133 133
134 void OnMalwareDetailsDone() { 134 void OnMalwareDetailsDone() {
135 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); 135 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
136 MessageLoopForUI::current()->Quit(); 136 base::MessageLoopForUI::current()->Quit();
137 } 137 }
138 138
139 std::string GetReport() { 139 std::string GetReport() {
140 EXPECT_TRUE(reports_.size() == 1); 140 EXPECT_TRUE(reports_.size() == 1);
141 return reports_[0]; 141 return reports_[0];
142 } 142 }
143 143
144 protected: 144 protected:
145 virtual ~FakeSafeBrowsingUIManager() { } 145 virtual ~FakeSafeBrowsingUIManager() { }
146 146
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 content::RunMessageLoop(); 240 content::RunMessageLoop();
241 EXPECT_TRUE(got_dom_); 241 EXPECT_TRUE(got_dom_);
242 } 242 }
243 243
244 private: 244 private:
245 virtual ~FakeMalwareDetails() {} 245 virtual ~FakeMalwareDetails() {}
246 246
247 void OnDOMDetailsDone() { 247 void OnDOMDetailsDone() {
248 got_dom_ = true; 248 got_dom_ = true;
249 if (waiting_) { 249 if (waiting_) {
250 MessageLoopForUI::current()->Quit(); 250 base::MessageLoopForUI::current()->Quit();
251 } 251 }
252 } 252 }
253 253
254 // Some logic to figure out if we should wait for the dom details or not. 254 // Some logic to figure out if we should wait for the dom details or not.
255 // These variables should only be accessed in the UI thread. 255 // These variables should only be accessed in the UI thread.
256 bool got_dom_; 256 bool got_dom_;
257 bool waiting_; 257 bool waiting_;
258 }; 258 };
259 259
260 class TestMalwareDetailsFactory : public MalwareDetailsFactory { 260 class TestMalwareDetailsFactory : public MalwareDetailsFactory {
(...skipping 28 matching lines...) Expand all
289 wait_for_delete_(false) { 289 wait_for_delete_(false) {
290 // Don't wait the whole 3 seconds for the browser test. 290 // Don't wait the whole 3 seconds for the browser test.
291 malware_details_proceed_delay_ms_ = 100; 291 malware_details_proceed_delay_ms_ = 100;
292 } 292 }
293 293
294 virtual ~TestSafeBrowsingBlockingPage() { 294 virtual ~TestSafeBrowsingBlockingPage() {
295 if (!wait_for_delete_) 295 if (!wait_for_delete_)
296 return; 296 return;
297 297
298 // Notify that we are gone 298 // Notify that we are gone
299 MessageLoopForUI::current()->Quit(); 299 base::MessageLoopForUI::current()->Quit();
300 wait_for_delete_ = false; 300 wait_for_delete_ = false;
301 } 301 }
302 302
303 void WaitForDelete() { 303 void WaitForDelete() {
304 wait_for_delete_ = true; 304 wait_for_delete_ = true;
305 content::RunMessageLoop(); 305 content::RunMessageLoop();
306 } 306 }
307 307
308 private: 308 private:
309 bool wait_for_delete_; 309 bool wait_for_delete_;
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); 817 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING);
818 818
819 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); 819 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link"));
820 AssertNoInterstitial(false); // Assert the interstitial is gone 820 AssertNoInterstitial(false); // Assert the interstitial is gone
821 821
822 // We are in the help page. 822 // We are in the help page.
823 EXPECT_EQ( 823 EXPECT_EQ(
824 "/goodtoknow/online-safety/phishing/", 824 "/goodtoknow/online-safety/phishing/",
825 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); 825 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path());
826 } 826 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698