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

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

Issue 345037: Fifth patch in getting rid of caching MessageLoop pointers. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/renderer_host/test/test_render_view_host.h" 5 #include "chrome/browser/renderer_host/test/test_render_view_host.h"
6 6
7 #include "chrome/browser/chrome_thread.h" 7 #include "chrome/browser/chrome_thread.h"
8 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 8 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
9 #include "chrome/browser/tab_contents/navigation_entry.h" 9 #include "chrome/browser/tab_contents/navigation_entry.h"
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/render_messages.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 public SafeBrowsingService::Client { 68 public SafeBrowsingService::Client {
69 public: 69 public:
70 // The decision the user made. 70 // The decision the user made.
71 enum UserResponse { 71 enum UserResponse {
72 PENDING, 72 PENDING,
73 OK, 73 OK,
74 CANCEL 74 CANCEL
75 }; 75 };
76 76
77 SafeBrowsingBlockingPageTest() 77 SafeBrowsingBlockingPageTest()
78 : io_thread_(ChromeThread::IO, MessageLoop::current()) { 78 : ui_thread_(ChromeThread::UI, MessageLoop::current()),
79 io_thread_(ChromeThread::IO, MessageLoop::current()) {
79 ResetUserResponse(); 80 ResetUserResponse();
80 service_ = new SafeBrowsingService(); 81 service_ = new SafeBrowsingService();
81 } 82 }
82 83
83 virtual void SetUp() { 84 virtual void SetUp() {
84 RenderViewHostTestHarness::SetUp(); 85 RenderViewHostTestHarness::SetUp();
85 SafeBrowsingBlockingPage::RegisterFactory(&factory_); 86 SafeBrowsingBlockingPage::RegisterFactory(&factory_);
86 ResetUserResponse(); 87 ResetUserResponse();
87 } 88 }
88 89
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 resource->url = url; 153 resource->url = url;
153 resource->resource_type = resource_type; 154 resource->resource_type = resource_type;
154 resource->threat_type = SafeBrowsingService::URL_MALWARE; 155 resource->threat_type = SafeBrowsingService::URL_MALWARE;
155 resource->render_process_host_id = contents_->process()->id(); 156 resource->render_process_host_id = contents_->process()->id();
156 resource->render_view_id = contents_->render_view_host()->routing_id(); 157 resource->render_view_id = contents_->render_view_host()->routing_id();
157 } 158 }
158 159
159 UserResponse user_response_; 160 UserResponse user_response_;
160 scoped_refptr<SafeBrowsingService> service_; 161 scoped_refptr<SafeBrowsingService> service_;
161 TestSafeBrowsingBlockingPageFactory factory_; 162 TestSafeBrowsingBlockingPageFactory factory_;
163 ChromeThread ui_thread_;
162 ChromeThread io_thread_; 164 ChromeThread io_thread_;
163 }; 165 };
164 166
165 // Tests showing a blocking page for a malware page and not proceeding. 167 // Tests showing a blocking page for a malware page and not proceeding.
166 TEST_F(SafeBrowsingBlockingPageTest, MalwarePageDontProceed) { 168 TEST_F(SafeBrowsingBlockingPageTest, MalwarePageDontProceed) {
167 // Start a load. 169 // Start a load.
168 controller().LoadURL(GURL(kBadURL), GURL(), PageTransition::TYPED); 170 controller().LoadURL(GURL(kBadURL), GURL(), PageTransition::TYPED);
169 171
170 // Simulate the load causing a safe browsing interstitial to be shown. 172 // Simulate the load causing a safe browsing interstitial to be shown.
171 ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL); 173 ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 ASSERT_TRUE(sb_interstitial); 399 ASSERT_TRUE(sb_interstitial);
398 400
399 // Let's proceed and make sure everything is OK (bug 17627). 401 // Let's proceed and make sure everything is OK (bug 17627).
400 ProceedThroughInterstitial(sb_interstitial); 402 ProceedThroughInterstitial(sb_interstitial);
401 Navigate(kBadURL, 2); // Commit the navigation. 403 Navigate(kBadURL, 2); // Commit the navigation.
402 sb_interstitial = GetSafeBrowsingBlockingPage(); 404 sb_interstitial = GetSafeBrowsingBlockingPage();
403 ASSERT_FALSE(sb_interstitial); 405 ASSERT_FALSE(sb_interstitial);
404 ASSERT_EQ(2, controller().entry_count()); 406 ASSERT_EQ(2, controller().entry_count());
405 EXPECT_EQ(kBadURL, controller().GetActiveEntry()->url().spec()); 407 EXPECT_EQ(kBadURL, controller().GetActiveEntry()->url().spec());
406 } 408 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698