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

Side by Side Diff: chrome/browser/subresource_filter/subresource_filter_browsertest.cc

Issue 2798983002: Introduce subresource_filter::Configuration. (Closed)
Patch Set: Address comments from csharrison@. Created 3 years, 8 months 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <map> 5 #include <map>
6 #include <memory> 6 #include <memory>
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 base::FilePath test_data_dir; 254 base::FilePath test_data_dir;
255 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); 255 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
256 embedded_test_server()->ServeFilesFromDirectory(test_data_dir); 256 embedded_test_server()->ServeFilesFromDirectory(test_data_dir);
257 host_resolver()->AddSimulatedFailure("host-with-dns-lookup-failure"); 257 host_resolver()->AddSimulatedFailure("host-with-dns-lookup-failure");
258 host_resolver()->AddRule("*", "127.0.0.1"); 258 host_resolver()->AddRule("*", "127.0.0.1");
259 content::SetupCrossSiteRedirector(embedded_test_server()); 259 content::SetupCrossSiteRedirector(embedded_test_server());
260 ASSERT_TRUE(embedded_test_server()->Start()); 260 ASSERT_TRUE(embedded_test_server()->Start());
261 } 261 }
262 262
263 virtual void SetUpActivationFeature() { 263 virtual void SetUpActivationFeature() {
264 scoped_feature_toggle_.reset(new ScopedSubresourceFilterFeatureToggle( 264 ToggleFeatures(base::MakeUnique<ScopedSubresourceFilterFeatureToggle>(
265 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, 265 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled,
266 kActivationScopeActivationList, kActivationListPhishingInterstitial, 266 kActivationScopeActivationList, kActivationListPhishingInterstitial,
267 measure_performance_ ? "1" : "0", "" /* suppress_notifications */, 267 measure_performance_ ? "1" : "0", "" /* suppress_notifications */,
268 whitelist_site_on_reload_ ? "true" : "false")); 268 whitelist_site_on_reload_ ? "true" : "false"));
269 } 269 }
270 270
271 GURL GetTestUrl(const std::string& relative_url) { 271 GURL GetTestUrl(const std::string& relative_url) {
272 return embedded_test_server()->base_url().Resolve(relative_url); 272 return embedded_test_server()->base_url().Resolve(relative_url);
273 } 273 }
274 274
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 test_ruleset_publisher_.SetRuleset(test_ruleset_pair.unindexed)); 356 test_ruleset_publisher_.SetRuleset(test_ruleset_pair.unindexed));
357 } 357 }
358 358
359 void SetRulesetWithRules(const std::vector<proto::UrlRule>& rules) { 359 void SetRulesetWithRules(const std::vector<proto::UrlRule>& rules) {
360 TestRulesetPair test_ruleset_pair; 360 TestRulesetPair test_ruleset_pair;
361 ruleset_creator_.CreateRulesetWithRules(rules, &test_ruleset_pair); 361 ruleset_creator_.CreateRulesetWithRules(rules, &test_ruleset_pair);
362 ASSERT_NO_FATAL_FAILURE( 362 ASSERT_NO_FATAL_FAILURE(
363 test_ruleset_publisher_.SetRuleset(test_ruleset_pair.unindexed)); 363 test_ruleset_publisher_.SetRuleset(test_ruleset_pair.unindexed));
364 } 364 }
365 365
366 void set_scoped_feature_toggle(ScopedSubresourceFilterFeatureToggle* toggle) { 366 void ToggleFeatures(
367 scoped_feature_toggle_.reset(toggle); 367 std::unique_ptr<ScopedSubresourceFilterFeatureToggle> features) {
368 scoped_feature_toggle_ = std::move(features);
369 ContentSubresourceFilterDriverFactory* driver_factory =
370 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents());
371 driver_factory->set_configuration_for_testing(GetActiveConfiguration());
368 } 372 }
369 373
370 private: 374 private:
371 TestRulesetCreator ruleset_creator_; 375 TestRulesetCreator ruleset_creator_;
372 376
373 std::unique_ptr<ScopedSubresourceFilterFeatureToggle> scoped_feature_toggle_; 377 std::unique_ptr<ScopedSubresourceFilterFeatureToggle> scoped_feature_toggle_;
374 TestRulesetPublisher test_ruleset_publisher_; 378 TestRulesetPublisher test_ruleset_publisher_;
375 const bool measure_performance_; 379 const bool measure_performance_;
376 const bool whitelist_site_on_reload_; 380 const bool whitelist_site_on_reload_;
377 381
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 }; 457 };
454 458
455 #if defined(GOOGLE_CHROME_BUILD) 459 #if defined(GOOGLE_CHROME_BUILD)
456 class SubresourceFilterListBrowserTest 460 class SubresourceFilterListBrowserTest
457 : public SubresourceFilterBrowserTestImpl { 461 : public SubresourceFilterBrowserTestImpl {
458 public: 462 public:
459 SubresourceFilterListBrowserTest() 463 SubresourceFilterListBrowserTest()
460 : SubresourceFilterBrowserTestImpl(false, false) {} 464 : SubresourceFilterBrowserTestImpl(false, false) {}
461 465
462 void SetUpActivationFeature() override { 466 void SetUpActivationFeature() override {
463 set_scoped_feature_toggle(new ScopedSubresourceFilterFeatureToggle( 467 ToggleFeatures(base::MakeUnique<ScopedSubresourceFilterFeatureToggle>(
464 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, 468 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled,
465 kActivationScopeActivationList, kActivationListSubresourceFilter, "0", 469 kActivationScopeActivationList, kActivationListSubresourceFilter, "0",
466 "" /* suppress_notifications */, "false")); 470 "" /* suppress_notifications */, "false"));
467 } 471 }
468 }; 472 };
469 #endif 473 #endif
470 474
471 // Tests ----------------------------------------------------------------------- 475 // Tests -----------------------------------------------------------------------
472 476
473 IN_PROC_BROWSER_TEST_F(SubresourceFilterBrowserTest, MainFrameActivation) { 477 IN_PROC_BROWSER_TEST_F(SubresourceFilterBrowserTest, MainFrameActivation) {
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 std::string(kSubresourceFilterOnlySuffix)), 1329 std::string(kSubresourceFilterOnlySuffix)),
1326 ::testing::IsEmpty()); 1330 ::testing::IsEmpty());
1327 1331
1328 EXPECT_THAT(tester.GetAllSamples(std::string(kNavigationChainSize) + 1332 EXPECT_THAT(tester.GetAllSamples(std::string(kNavigationChainSize) +
1329 std::string(kSubresourceFilterOnlySuffix)), 1333 std::string(kSubresourceFilterOnlySuffix)),
1330 ::testing::IsEmpty()); 1334 ::testing::IsEmpty());
1331 } 1335 }
1332 #endif 1336 #endif
1333 1337
1334 } // namespace subresource_filter 1338 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698