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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 class ClientSideDetectionHostTest : public TabContentsWrapperTestHarness { | 143 class ClientSideDetectionHostTest : public TabContentsWrapperTestHarness { |
144 public: | 144 public: |
145 virtual void SetUp() { | 145 virtual void SetUp() { |
146 // Set custom profile object so that we can mock calls to IsOffTheRecord. | 146 // Set custom profile object so that we can mock calls to IsOffTheRecord. |
147 // This needs to happen before we call the parent SetUp() function. We use | 147 // This needs to happen before we call the parent SetUp() function. We use |
148 // a nice mock because other parts of the code are calling IsOffTheRecord. | 148 // a nice mock because other parts of the code are calling IsOffTheRecord. |
149 mock_profile_ = new NiceMock<MockTestingProfile>(); | 149 mock_profile_ = new NiceMock<MockTestingProfile>(); |
150 profile_.reset(mock_profile_); | 150 profile_.reset(mock_profile_); |
151 | 151 |
152 TabContentsWrapperTestHarness::SetUp(); | |
153 ui_thread_.reset(new BrowserThread(BrowserThread::UI, &message_loop_)); | 152 ui_thread_.reset(new BrowserThread(BrowserThread::UI, &message_loop_)); |
154 // Note: we're starting a real IO thread to make sure our DCHECKs that | 153 // Note: we're starting a real IO thread to make sure our DCHECKs that |
155 // verify which thread is running are actually tested. | 154 // verify which thread is running are actually tested. |
156 io_thread_.reset(new BrowserThread(BrowserThread::IO)); | 155 io_thread_.reset(new BrowserThread(BrowserThread::IO)); |
157 ASSERT_TRUE(io_thread_->Start()); | 156 ASSERT_TRUE(io_thread_->Start()); |
158 | 157 |
| 158 TabContentsWrapperTestHarness::SetUp(); |
| 159 |
159 // Inject service classes. | 160 // Inject service classes. |
160 csd_service_.reset(new StrictMock<MockClientSideDetectionService>()); | 161 csd_service_.reset(new StrictMock<MockClientSideDetectionService>()); |
161 sb_service_ = new StrictMock<MockSafeBrowsingService>(); | 162 sb_service_ = new StrictMock<MockSafeBrowsingService>(); |
162 csd_host_.reset(safe_browsing::ClientSideDetectionHost::Create( | 163 csd_host_.reset(safe_browsing::ClientSideDetectionHost::Create( |
163 contents_wrapper()->tab_contents())); | 164 contents_wrapper()->tab_contents())); |
164 csd_host_->set_client_side_detection_service(csd_service_.get()); | 165 csd_host_->set_client_side_detection_service(csd_service_.get()); |
165 csd_host_->set_safe_browsing_service(sb_service_.get()); | 166 csd_host_->set_safe_browsing_service(sb_service_.get()); |
166 } | 167 } |
167 | 168 |
168 virtual void TearDown() { | 169 virtual void TearDown() { |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); | 740 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); |
740 EXPECT_EQ(url, resource.url); | 741 EXPECT_EQ(url, resource.url); |
741 EXPECT_EQ(url, resource.original_url); | 742 EXPECT_EQ(url, resource.original_url); |
742 delete resource.client; | 743 delete resource.client; |
743 msg = process()->sink().GetFirstMessageMatching( | 744 msg = process()->sink().GetFirstMessageMatching( |
744 SafeBrowsingMsg_StartPhishingDetection::ID); | 745 SafeBrowsingMsg_StartPhishingDetection::ID); |
745 ASSERT_FALSE(msg); | 746 ASSERT_FALSE(msg); |
746 } | 747 } |
747 | 748 |
748 } // namespace safe_browsing | 749 } // namespace safe_browsing |
OLD | NEW |