| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/subresource_filter/content/browser/subresource_filter_safe_
browsing_activation_throttle.h" | 5 #include "components/subresource_filter/content/browser/subresource_filter_safe_
browsing_activation_throttle.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <tuple> | 8 #include <tuple> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 : field_trial_list_(nullptr) {} | 123 : field_trial_list_(nullptr) {} |
| 124 ~SubresourceFilterSafeBrowsingActivationThrottleTest() override {} | 124 ~SubresourceFilterSafeBrowsingActivationThrottleTest() override {} |
| 125 | 125 |
| 126 void SetUp() override { | 126 void SetUp() override { |
| 127 content::RenderViewHostTestHarness::SetUp(); | 127 content::RenderViewHostTestHarness::SetUp(); |
| 128 scoped_configuration_.ResetConfiguration(Configuration( | 128 scoped_configuration_.ResetConfiguration(Configuration( |
| 129 ActivationLevel::ENABLED, ActivationScope::ACTIVATION_LIST, | 129 ActivationLevel::ENABLED, ActivationScope::ACTIVATION_LIST, |
| 130 ActivationList::SUBRESOURCE_FILTER)); | 130 ActivationList::SUBRESOURCE_FILTER)); |
| 131 test_io_task_runner_ = new base::TestMockTimeTaskRunner(); | 131 test_io_task_runner_ = new base::TestMockTimeTaskRunner(); |
| 132 // Note: Using NiceMock to allow uninteresting calls and suppress warnings. | 132 // Note: Using NiceMock to allow uninteresting calls and suppress warnings. |
| 133 auto client = | 133 client_ = |
| 134 base::MakeUnique<::testing::NiceMock<MockSubresourceFilterClient>>(); | 134 base::MakeUnique<::testing::NiceMock<MockSubresourceFilterClient>>(); |
| 135 ContentSubresourceFilterDriverFactory::CreateForWebContents( | 135 ContentSubresourceFilterDriverFactory::CreateForWebContents( |
| 136 RenderViewHostTestHarness::web_contents(), std::move(client)); | 136 RenderViewHostTestHarness::web_contents(), client_.get()); |
| 137 fake_safe_browsing_database_ = new FakeSafeBrowsingDatabaseManager(); | 137 fake_safe_browsing_database_ = new FakeSafeBrowsingDatabaseManager(); |
| 138 NavigateAndCommit(GURL("https://test.com")); | 138 NavigateAndCommit(GURL("https://test.com")); |
| 139 Observe(RenderViewHostTestHarness::web_contents()); | 139 Observe(RenderViewHostTestHarness::web_contents()); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void TearDown() override { | 142 void TearDown() override { |
| 143 RunUntilIdle(); | 143 RunUntilIdle(); |
| 144 content::RenderViewHostTestHarness::TearDown(); | 144 content::RenderViewHostTestHarness::TearDown(); |
| 145 } | 145 } |
| 146 | 146 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 228 |
| 229 base::TestMockTimeTaskRunner* test_io_task_runner() const { | 229 base::TestMockTimeTaskRunner* test_io_task_runner() const { |
| 230 return test_io_task_runner_.get(); | 230 return test_io_task_runner_.get(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 private: | 233 private: |
| 234 base::FieldTrialList field_trial_list_; | 234 base::FieldTrialList field_trial_list_; |
| 235 testing::ScopedSubresourceFilterConfigurator scoped_configuration_; | 235 testing::ScopedSubresourceFilterConfigurator scoped_configuration_; |
| 236 scoped_refptr<base::TestMockTimeTaskRunner> test_io_task_runner_; | 236 scoped_refptr<base::TestMockTimeTaskRunner> test_io_task_runner_; |
| 237 std::unique_ptr<content::NavigationSimulator> navigation_simulator_; | 237 std::unique_ptr<content::NavigationSimulator> navigation_simulator_; |
| 238 std::unique_ptr<SubresourceFilterClient> client_; |
| 238 scoped_refptr<FakeSafeBrowsingDatabaseManager> fake_safe_browsing_database_; | 239 scoped_refptr<FakeSafeBrowsingDatabaseManager> fake_safe_browsing_database_; |
| 239 base::HistogramTester tester_; | 240 base::HistogramTester tester_; |
| 240 | 241 |
| 241 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterSafeBrowsingActivationThrottleTest); | 242 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterSafeBrowsingActivationThrottleTest); |
| 242 }; | 243 }; |
| 243 | 244 |
| 244 class SubresourceFilterSafeBrowsingActivationThrottleTestWithCancelling | 245 class SubresourceFilterSafeBrowsingActivationThrottleTestWithCancelling |
| 245 : public SubresourceFilterSafeBrowsingActivationThrottleTest, | 246 : public SubresourceFilterSafeBrowsingActivationThrottleTest, |
| 246 public ::testing::WithParamInterface< | 247 public ::testing::WithParamInterface< |
| 247 std::tuple<content::CancellingNavigationThrottle::CancelTime, | 248 std::tuple<content::CancellingNavigationThrottle::CancelTime, |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 ::testing::Combine( | 487 ::testing::Combine( |
| 487 ::testing::Values( | 488 ::testing::Values( |
| 488 content::CancellingNavigationThrottle::WILL_START_REQUEST, | 489 content::CancellingNavigationThrottle::WILL_START_REQUEST, |
| 489 content::CancellingNavigationThrottle::WILL_REDIRECT_REQUEST, | 490 content::CancellingNavigationThrottle::WILL_REDIRECT_REQUEST, |
| 490 content::CancellingNavigationThrottle::WILL_PROCESS_RESPONSE), | 491 content::CancellingNavigationThrottle::WILL_PROCESS_RESPONSE), |
| 491 ::testing::Values( | 492 ::testing::Values( |
| 492 content::CancellingNavigationThrottle::SYNCHRONOUS, | 493 content::CancellingNavigationThrottle::SYNCHRONOUS, |
| 493 content::CancellingNavigationThrottle::ASYNCHRONOUS))); | 494 content::CancellingNavigationThrottle::ASYNCHRONOUS))); |
| 494 | 495 |
| 495 } // namespace subresource_filter | 496 } // namespace subresource_filter |
| OLD | NEW |