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

Side by Side Diff: components/flags_ui/flags_state_unittest.cc

Issue 2774203002: Migrate about:flags messages to const char* (Closed)
Patch Set: fix iOS compilation Created 3 years, 9 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 | « components/flags_ui/flags_state.cc ('k') | components/flags_ui_strings.grdp » ('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 "components/flags_ui/flags_state.h" 5 #include "components/flags_ui/flags_state.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 const FeatureEntry::FeatureParam kTestVariationOther1[] = { 76 const FeatureEntry::FeatureParam kTestVariationOther1[] = {
77 {kTestParam1, kTestParamValue}}; 77 {kTestParam1, kTestParamValue}};
78 const FeatureEntry::FeatureParam kTestVariationOther2[] = { 78 const FeatureEntry::FeatureParam kTestVariationOther2[] = {
79 {kTestParam2, kTestParamValue}}; 79 {kTestParam2, kTestParamValue}};
80 80
81 const FeatureEntry::FeatureVariation kTestVariations1[] = { 81 const FeatureEntry::FeatureVariation kTestVariations1[] = {
82 {"dummy description 1", kTestVariationOther1, 1, nullptr}}; 82 {"dummy description 1", kTestVariationOther1, 1, nullptr}};
83 const FeatureEntry::FeatureVariation kTestVariations2[] = { 83 const FeatureEntry::FeatureVariation kTestVariations2[] = {
84 {"dummy description 2", kTestVariationOther2, 1, nullptr}}; 84 {"dummy description 2", kTestVariationOther2, 1, nullptr}};
85 85
86 // Those have to be valid ids for the translation system but the value are 86 const char* kDummyName = nullptr;
87 // never used, so pick one at random from the current component. 87 const char* kDummyDescription = nullptr;
88 const int kDummyNameId = IDS_FLAGS_UI_WARNING_HEADER;
89 const int kDummyDescriptionId = IDS_FLAGS_UI_WARNING_TEXT;
90 88
91 bool SkipFeatureEntry(const FeatureEntry& feature_entry) { 89 bool SkipFeatureEntry(const FeatureEntry& feature_entry) {
92 return false; 90 return false;
93 } 91 }
94 92
95 } // namespace 93 } // namespace
96 94
97 const FeatureEntry::Choice kMultiChoices[] = { 95 const FeatureEntry::Choice kMultiChoices[] = {
98 {kDummyDescriptionId, "", ""}, 96 {kDummyDescription, "", ""},
99 {kDummyDescriptionId, kMultiSwitch1, ""}, 97 {kDummyDescription, kMultiSwitch1, ""},
100 {kDummyDescriptionId, kMultiSwitch2, kValueForMultiSwitch2}, 98 {kDummyDescription, kMultiSwitch2, kValueForMultiSwitch2},
101 }; 99 };
102 100
103 // The entries that are set for these tests. The 3rd entry is not supported on 101 // The entries that are set for these tests. The 3rd entry is not supported on
104 // the current platform, all others are. 102 // the current platform, all others are.
105 static FeatureEntry kEntries[] = { 103 static FeatureEntry kEntries[] = {
106 {kFlags1, kDummyNameId, kDummyDescriptionId, 104 {kFlags1, kDummyName, kDummyDescription,
107 0, // Ends up being mapped to the current platform. 105 0, // Ends up being mapped to the current platform.
108 FeatureEntry::SINGLE_VALUE, kSwitch1, "", nullptr, nullptr, nullptr, 0, 106 FeatureEntry::SINGLE_VALUE, kSwitch1, "", nullptr, nullptr, nullptr, 0,
109 nullptr, nullptr, nullptr}, 107 nullptr, nullptr, nullptr},
110 {kFlags2, kDummyNameId, kDummyDescriptionId, 108 {kFlags2, kDummyName, kDummyDescription,
111 0, // Ends up being mapped to the current platform. 109 0, // Ends up being mapped to the current platform.
112 FeatureEntry::SINGLE_VALUE, kSwitch2, kValueForSwitch2, nullptr, nullptr, 110 FeatureEntry::SINGLE_VALUE, kSwitch2, kValueForSwitch2, nullptr, nullptr,
113 nullptr, 0, nullptr, nullptr, nullptr}, 111 nullptr, 0, nullptr, nullptr, nullptr},
114 {kFlags3, kDummyNameId, kDummyDescriptionId, 112 {kFlags3, kDummyName, kDummyDescription,
115 0, // This ends up enabling for an OS other than the current. 113 0, // This ends up enabling for an OS other than the current.
116 FeatureEntry::SINGLE_VALUE, kSwitch3, "", nullptr, nullptr, nullptr, 0, 114 FeatureEntry::SINGLE_VALUE, kSwitch3, "", nullptr, nullptr, nullptr, 0,
117 nullptr, nullptr, nullptr}, 115 nullptr, nullptr, nullptr},
118 {kFlags4, kDummyNameId, kDummyDescriptionId, 116 {kFlags4, kDummyName, kDummyDescription,
119 0, // Ends up being mapped to the current platform. 117 0, // Ends up being mapped to the current platform.
120 FeatureEntry::MULTI_VALUE, "", "", "", "", nullptr, 118 FeatureEntry::MULTI_VALUE, "", "", "", "", nullptr,
121 arraysize(kMultiChoices), kMultiChoices, nullptr, nullptr}, 119 arraysize(kMultiChoices), kMultiChoices, nullptr, nullptr},
122 {kFlags5, kDummyNameId, kDummyDescriptionId, 120 {kFlags5, kDummyName, kDummyDescription,
123 0, // Ends up being mapped to the current platform. 121 0, // Ends up being mapped to the current platform.
124 FeatureEntry::ENABLE_DISABLE_VALUE, kSwitch1, kEnableDisableValue1, 122 FeatureEntry::ENABLE_DISABLE_VALUE, kSwitch1, kEnableDisableValue1,
125 kSwitch2, kEnableDisableValue2, nullptr, 3, nullptr, nullptr, nullptr}, 123 kSwitch2, kEnableDisableValue2, nullptr, 3, nullptr, nullptr, nullptr},
126 {kFlags6, kDummyNameId, kDummyDescriptionId, 0, 124 {kFlags6, kDummyName, kDummyDescription, 0,
127 FeatureEntry::SINGLE_DISABLE_VALUE, kSwitch6, "", nullptr, nullptr, 125 FeatureEntry::SINGLE_DISABLE_VALUE, kSwitch6, "", nullptr, nullptr,
128 nullptr, 0, nullptr, nullptr, nullptr}, 126 nullptr, 0, nullptr, nullptr, nullptr},
129 {kFlags7, kDummyNameId, kDummyDescriptionId, 127 {kFlags7, kDummyName, kDummyDescription,
130 0, // Ends up being mapped to the current platform. 128 0, // Ends up being mapped to the current platform.
131 FeatureEntry::FEATURE_VALUE, nullptr, nullptr, nullptr, nullptr, 129 FeatureEntry::FEATURE_VALUE, nullptr, nullptr, nullptr, nullptr,
132 &kTestFeature1, 3, nullptr, nullptr, nullptr}, 130 &kTestFeature1, 3, nullptr, nullptr, nullptr},
133 {kFlags8, kDummyNameId, kDummyDescriptionId, 131 {kFlags8, kDummyName, kDummyDescription,
134 0, // Ends up being mapped to the current platform. 132 0, // Ends up being mapped to the current platform.
135 FeatureEntry::FEATURE_WITH_PARAMS_VALUE, nullptr, nullptr, nullptr, 133 FeatureEntry::FEATURE_WITH_PARAMS_VALUE, nullptr, nullptr, nullptr,
136 nullptr, &kTestFeature1, 4, nullptr, kTestVariations1, kTestTrial}, 134 nullptr, &kTestFeature1, 4, nullptr, kTestVariations1, kTestTrial},
137 {kFlags9, kDummyNameId, kDummyDescriptionId, 135 {kFlags9, kDummyName, kDummyDescription,
138 0, // Ends up being mapped to the current platform. 136 0, // Ends up being mapped to the current platform.
139 FeatureEntry::FEATURE_WITH_PARAMS_VALUE, nullptr, nullptr, nullptr, 137 FeatureEntry::FEATURE_WITH_PARAMS_VALUE, nullptr, nullptr, nullptr,
140 nullptr, &kTestFeature1, 4, nullptr, kTestVariations1, kTestTrial}, 138 nullptr, &kTestFeature1, 4, nullptr, kTestVariations1, kTestTrial},
141 {kFlags10, kDummyNameId, kDummyDescriptionId, 139 {kFlags10, kDummyName, kDummyDescription,
142 0, // Ends up being mapped to the current platform. 140 0, // Ends up being mapped to the current platform.
143 FeatureEntry::FEATURE_WITH_PARAMS_VALUE, nullptr, nullptr, nullptr, 141 FeatureEntry::FEATURE_WITH_PARAMS_VALUE, nullptr, nullptr, nullptr,
144 nullptr, &kTestFeature2, 4, nullptr, kTestVariations2, kTestTrial}, 142 nullptr, &kTestFeature2, 4, nullptr, kTestVariations2, kTestTrial},
145 }; 143 };
146 144
147 class FlagsStateTest : public ::testing::Test { 145 class FlagsStateTest : public ::testing::Test {
148 protected: 146 protected:
149 FlagsStateTest() : flags_storage_(&prefs_), trial_list_(nullptr) { 147 FlagsStateTest() : flags_storage_(&prefs_), trial_list_(nullptr) {
150 prefs_.registry()->RegisterListPref(prefs::kEnabledLabsExperiments); 148 prefs_.registry()->RegisterListPref(prefs::kEnabledLabsExperiments);
151 149
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 &supported_entries, &unsupported_entries, 823 &supported_entries, &unsupported_entries,
826 base::Bind(&SkipFeatureEntry)); 824 base::Bind(&SkipFeatureEntry));
827 // All |kEntries| except for |kFlags3| should be supported. 825 // All |kEntries| except for |kFlags3| should be supported.
828 EXPECT_EQ(9u, supported_entries.GetSize()); 826 EXPECT_EQ(9u, supported_entries.GetSize());
829 EXPECT_EQ(1u, unsupported_entries.GetSize()); 827 EXPECT_EQ(1u, unsupported_entries.GetSize());
830 EXPECT_EQ(arraysize(kEntries), 828 EXPECT_EQ(arraysize(kEntries),
831 supported_entries.GetSize() + unsupported_entries.GetSize()); 829 supported_entries.GetSize() + unsupported_entries.GetSize());
832 } 830 }
833 831
834 } // namespace flags_ui 832 } // namespace flags_ui
OLDNEW
« no previous file with comments | « components/flags_ui/flags_state.cc ('k') | components/flags_ui_strings.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698