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

Side by Side Diff: base/feature_list_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
« no previous file with comments | « base/feature_list.cc ('k') | base/test/launcher/test_launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/feature_list.h" 5 #include "base/feature_list.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/metrics/field_trial.h" 15 #include "base/metrics/field_trial.h"
16 #include "base/metrics/persistent_memory_allocator.h" 16 #include "base/metrics/persistent_memory_allocator.h"
17 #include "base/strings/string_piece.h"
17 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace base { 22 namespace base {
22 23
23 namespace { 24 namespace {
24 25
25 constexpr char kFeatureOnByDefaultName[] = "OnByDefault"; 26 constexpr char kFeatureOnByDefaultName[] = "OnByDefault";
26 struct Feature kFeatureOnByDefault { 27 struct Feature kFeatureOnByDefault {
27 kFeatureOnByDefaultName, FEATURE_ENABLED_BY_DEFAULT 28 kFeatureOnByDefaultName, FEATURE_ENABLED_BY_DEFAULT
28 }; 29 };
29 30
30 constexpr char kFeatureOffByDefaultName[] = "OffByDefault"; 31 constexpr char kFeatureOffByDefaultName[] = "OffByDefault";
31 struct Feature kFeatureOffByDefault { 32 struct Feature kFeatureOffByDefault {
32 kFeatureOffByDefaultName, FEATURE_DISABLED_BY_DEFAULT 33 kFeatureOffByDefaultName, FEATURE_DISABLED_BY_DEFAULT
33 }; 34 };
34 35
35 std::string SortFeatureListString(const std::string& feature_list) { 36 std::string SortFeatureListString(const std::string& feature_list) {
36 std::vector<std::string> features = 37 std::vector<base::StringPiece> features =
37 FeatureList::SplitFeatureListString(feature_list); 38 FeatureList::SplitFeatureListString(feature_list);
38 std::sort(features.begin(), features.end()); 39 std::sort(features.begin(), features.end());
39 return JoinString(features, ","); 40 return JoinString(features, ",");
40 } 41 }
41 42
42 } // namespace 43 } // namespace
43 44
44 class FeatureListTest : public testing::Test { 45 class FeatureListTest : public testing::Test {
45 public: 46 public:
46 FeatureListTest() : feature_list_(nullptr) { 47 FeatureListTest() : feature_list_(nullptr) {
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 // Check that the field trials are still associated. 528 // Check that the field trials are still associated.
528 FieldTrial* associated_trial1 = 529 FieldTrial* associated_trial1 =
529 feature_list2->GetAssociatedFieldTrial(kFeatureOnByDefault); 530 feature_list2->GetAssociatedFieldTrial(kFeatureOnByDefault);
530 FieldTrial* associated_trial2 = 531 FieldTrial* associated_trial2 =
531 feature_list2->GetAssociatedFieldTrial(kFeatureOffByDefault); 532 feature_list2->GetAssociatedFieldTrial(kFeatureOffByDefault);
532 EXPECT_EQ(associated_trial1, trial1); 533 EXPECT_EQ(associated_trial1, trial1);
533 EXPECT_EQ(associated_trial2, trial2); 534 EXPECT_EQ(associated_trial2, trial2);
534 } 535 }
535 536
536 } // namespace base 537 } // namespace base
OLDNEW
« no previous file with comments | « base/feature_list.cc ('k') | base/test/launcher/test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698