OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/task.h" | 8 #include "base/task.h" |
9 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" | 9 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
10 #include "chrome/browser/safe_browsing/client_side_detection_host.h" | 10 #include "chrome/browser/safe_browsing/client_side_detection_host.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 | 143 |
144 class ClientSideDetectionHostTest : public TabContentsWrapperTestHarness { | 144 class ClientSideDetectionHostTest : public TabContentsWrapperTestHarness { |
145 public: | 145 public: |
146 virtual void SetUp() { | 146 virtual void SetUp() { |
147 // Set custom profile object so that we can mock calls to IsOffTheRecord. | 147 // Set custom profile object so that we can mock calls to IsOffTheRecord. |
148 // This needs to happen before we call the parent SetUp() function. We use | 148 // This needs to happen before we call the parent SetUp() function. We use |
149 // a nice mock because other parts of the code are calling IsOffTheRecord. | 149 // a nice mock because other parts of the code are calling IsOffTheRecord. |
150 mock_profile_ = new NiceMock<MockTestingProfile>(); | 150 mock_profile_ = new NiceMock<MockTestingProfile>(); |
151 profile_.reset(mock_profile_); | 151 profile_.reset(mock_profile_); |
152 | 152 |
153 TabContentsWrapperTestHarness::SetUp(); | |
154 ui_thread_.reset(new BrowserThread(BrowserThread::UI, &message_loop_)); | 153 ui_thread_.reset(new BrowserThread(BrowserThread::UI, &message_loop_)); |
155 // Note: we're starting a real IO thread to make sure our DCHECKs that | 154 // Note: we're starting a real IO thread to make sure our DCHECKs that |
156 // verify which thread is running are actually tested. | 155 // verify which thread is running are actually tested. |
157 io_thread_.reset(new BrowserThread(BrowserThread::IO)); | 156 io_thread_.reset(new BrowserThread(BrowserThread::IO)); |
158 ASSERT_TRUE(io_thread_->Start()); | 157 ASSERT_TRUE(io_thread_->Start()); |
159 | 158 |
159 TabContentsWrapperTestHarness::SetUp(); | |
160 | |
ycxiao
2011/07/26 17:24:14
Change the place, otherwise the DCHECK of current
| |
160 // Inject service classes. | 161 // Inject service classes. |
161 csd_service_.reset(new StrictMock<MockClientSideDetectionService>()); | 162 csd_service_.reset(new StrictMock<MockClientSideDetectionService>()); |
162 sb_service_ = new StrictMock<MockSafeBrowsingService>(); | 163 sb_service_ = new StrictMock<MockSafeBrowsingService>(); |
163 csd_host_.reset(safe_browsing::ClientSideDetectionHost::Create( | 164 csd_host_.reset(safe_browsing::ClientSideDetectionHost::Create( |
164 contents_wrapper()->tab_contents())); | 165 contents_wrapper()->tab_contents())); |
165 csd_host_->set_client_side_detection_service(csd_service_.get()); | 166 csd_host_->set_client_side_detection_service(csd_service_.get()); |
166 csd_host_->set_safe_browsing_service(sb_service_.get()); | 167 csd_host_->set_safe_browsing_service(sb_service_.get()); |
167 } | 168 } |
168 | 169 |
169 virtual void TearDown() { | 170 virtual void TearDown() { |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); | 713 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); |
713 EXPECT_EQ(url, resource.url); | 714 EXPECT_EQ(url, resource.url); |
714 EXPECT_EQ(url, resource.original_url); | 715 EXPECT_EQ(url, resource.original_url); |
715 delete resource.client; | 716 delete resource.client; |
716 msg = process()->sink().GetFirstMessageMatching( | 717 msg = process()->sink().GetFirstMessageMatching( |
717 SafeBrowsingMsg_StartPhishingDetection::ID); | 718 SafeBrowsingMsg_StartPhishingDetection::ID); |
718 ASSERT_FALSE(msg); | 719 ASSERT_FALSE(msg); |
719 } | 720 } |
720 | 721 |
721 } // namespace safe_browsing | 722 } // namespace safe_browsing |
OLD | NEW |