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(); |
152 ui_thread_.reset(new BrowserThread(BrowserThread::UI, &message_loop_)); | 153 ui_thread_.reset(new BrowserThread(BrowserThread::UI, &message_loop_)); |
153 // 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 |
154 // verify which thread is running are actually tested. | 155 // verify which thread is running are actually tested. |
155 io_thread_.reset(new BrowserThread(BrowserThread::IO)); | 156 io_thread_.reset(new BrowserThread(BrowserThread::IO)); |
156 ASSERT_TRUE(io_thread_->Start()); | 157 ASSERT_TRUE(io_thread_->Start()); |
157 | 158 |
158 TabContentsWrapperTestHarness::SetUp(); | |
159 | |
160 // Inject service classes. | 159 // Inject service classes. |
161 csd_service_.reset(new StrictMock<MockClientSideDetectionService>()); | 160 csd_service_.reset(new StrictMock<MockClientSideDetectionService>()); |
162 sb_service_ = new StrictMock<MockSafeBrowsingService>(); | 161 sb_service_ = new StrictMock<MockSafeBrowsingService>(); |
163 csd_host_.reset(safe_browsing::ClientSideDetectionHost::Create( | 162 csd_host_.reset(safe_browsing::ClientSideDetectionHost::Create( |
164 contents_wrapper()->tab_contents())); | 163 contents_wrapper()->tab_contents())); |
165 csd_host_->set_client_side_detection_service(csd_service_.get()); | 164 csd_host_->set_client_side_detection_service(csd_service_.get()); |
166 csd_host_->set_safe_browsing_service(sb_service_.get()); | 165 csd_host_->set_safe_browsing_service(sb_service_.get()); |
167 } | 166 } |
168 | 167 |
169 virtual void TearDown() { | 168 virtual void TearDown() { |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); | 739 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); |
741 EXPECT_EQ(url, resource.url); | 740 EXPECT_EQ(url, resource.url); |
742 EXPECT_EQ(url, resource.original_url); | 741 EXPECT_EQ(url, resource.original_url); |
743 delete resource.client; | 742 delete resource.client; |
744 msg = process()->sink().GetFirstMessageMatching( | 743 msg = process()->sink().GetFirstMessageMatching( |
745 SafeBrowsingMsg_StartPhishingDetection::ID); | 744 SafeBrowsingMsg_StartPhishingDetection::ID); |
746 ASSERT_FALSE(msg); | 745 ASSERT_FALSE(msg); |
747 } | 746 } |
748 | 747 |
749 } // namespace safe_browsing | 748 } // namespace safe_browsing |
OLD | NEW |