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

Side by Side Diff: components/safe_browsing_db/safe_browsing_prefs_unittest.cc

Issue 2695883003: Change uses of base::JoinString to pass StringPieces where possible. (Closed)
Patch Set: Remove dependency CL. 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/strings/string_piece.h"
9 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
10 #include "base/test/scoped_feature_list.h" 11 #include "base/test/scoped_feature_list.h"
11 #include "components/prefs/pref_registry_simple.h" 12 #include "components/prefs/pref_registry_simple.h"
12 #include "components/prefs/testing_pref_service.h" 13 #include "components/prefs/testing_pref_service.h"
13 #include "components/safe_browsing_db/safe_browsing_prefs.h" 14 #include "components/safe_browsing_db/safe_browsing_prefs.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace safe_browsing { 17 namespace safe_browsing {
17 18
18 class SafeBrowsingPrefsTest : public ::testing::Test { 19 class SafeBrowsingPrefsTest : public ::testing::Test {
(...skipping 15 matching lines...) Expand all
34 35
35 void ResetPrefs(bool sber_reporting, bool scout_reporting, bool scout_group) { 36 void ResetPrefs(bool sber_reporting, bool scout_reporting, bool scout_group) {
36 prefs_.SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, 37 prefs_.SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled,
37 sber_reporting); 38 sber_reporting);
38 prefs_.SetBoolean(prefs::kSafeBrowsingScoutReportingEnabled, 39 prefs_.SetBoolean(prefs::kSafeBrowsingScoutReportingEnabled,
39 scout_reporting); 40 scout_reporting);
40 prefs_.SetBoolean(prefs::kSafeBrowsingScoutGroupSelected, scout_group); 41 prefs_.SetBoolean(prefs::kSafeBrowsingScoutGroupSelected, scout_group);
41 } 42 }
42 43
43 void ResetExperiments(bool can_show_scout, bool only_show_scout) { 44 void ResetExperiments(bool can_show_scout, bool only_show_scout) {
44 std::vector<std::string> enabled_features; 45 std::vector<base::StringPiece> enabled_features;
45 std::vector<std::string> disabled_features; 46 std::vector<base::StringPiece> disabled_features;
46 47
47 auto* target_vector = 48 auto* target_vector =
48 can_show_scout ? &enabled_features : &disabled_features; 49 can_show_scout ? &enabled_features : &disabled_features;
49 target_vector->push_back(kCanShowScoutOptIn.name); 50 target_vector->push_back(kCanShowScoutOptIn.name);
50 51
51 target_vector = only_show_scout ? &enabled_features : &disabled_features; 52 target_vector = only_show_scout ? &enabled_features : &disabled_features;
52 target_vector->push_back(kOnlyShowScoutOptIn.name); 53 target_vector->push_back(kOnlyShowScoutOptIn.name);
53 54
54 feature_list_.reset(new base::test::ScopedFeatureList); 55 feature_list_.reset(new base::test::ScopedFeatureList);
55 feature_list_->InitFromCommandLine( 56 feature_list_->InitFromCommandLine(
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 EXPECT_EQ(SBER_LEVEL_OFF, GetExtendedReportingLevel(prefs_)); 453 EXPECT_EQ(SBER_LEVEL_OFF, GetExtendedReportingLevel(prefs_));
453 // Turning on Scout gives us Scout level reporting 454 // Turning on Scout gives us Scout level reporting
454 ResetPrefs(/*sber=*/false, /*scout_reporting=*/true, /*scout_group=*/true); 455 ResetPrefs(/*sber=*/false, /*scout_reporting=*/true, /*scout_group=*/true);
455 EXPECT_EQ(SBER_LEVEL_SCOUT, GetExtendedReportingLevel(prefs_)); 456 EXPECT_EQ(SBER_LEVEL_SCOUT, GetExtendedReportingLevel(prefs_));
456 // .. and the legacy pref doesn't affect this. 457 // .. and the legacy pref doesn't affect this.
457 ResetPrefs(/*sber=*/true, /*scout_reporting=*/true, /*scout_group=*/true); 458 ResetPrefs(/*sber=*/true, /*scout_reporting=*/true, /*scout_group=*/true);
458 EXPECT_EQ(SBER_LEVEL_SCOUT, GetExtendedReportingLevel(prefs_)); 459 EXPECT_EQ(SBER_LEVEL_SCOUT, GetExtendedReportingLevel(prefs_));
459 } 460 }
460 461
461 } // namespace safe_browsing 462 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/policy/core/browser/policy_error_map.cc ('k') | components/search_engines/keyword_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698