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

Side by Side Diff: chrome/browser/about_flags_unittest.cc

Issue 1415953005: Componentize about_flags::FeatureEntry in flags_ui component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 1 month 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 | « chrome/browser/about_flags.cc ('k') | chrome/browser/profiles/profile_window.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/about_flags.h" 5 #include "chrome/browser/about_flags.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/prefs/pref_registry_simple.h" 14 #include "base/prefs/pref_registry_simple.h"
15 #include "base/prefs/testing_pref_service.h" 15 #include "base/prefs/testing_pref_service.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "base/values.h" 20 #include "base/values.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/grit/chromium_strings.h" 22 #include "chrome/grit/chromium_strings.h"
23 #include "components/flags_ui/flags_ui_pref_names.h" 23 #include "components/flags_ui/flags_ui_pref_names.h"
24 #include "components/flags_ui/pref_service_flags_storage.h" 24 #include "components/flags_ui/pref_service_flags_storage.h"
25 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 #include "third_party/libxml/chromium/libxml_utils.h" 27 #include "third_party/libxml/chromium/libxml_utils.h"
28 28
29 using flags_ui::FeatureEntry;
30
29 namespace about_flags { 31 namespace about_flags {
30 32
31 namespace { 33 namespace {
32 34
33 const char kFlags1[] = "flag1"; 35 const char kFlags1[] = "flag1";
34 const char kFlags2[] = "flag2"; 36 const char kFlags2[] = "flag2";
35 const char kFlags3[] = "flag3"; 37 const char kFlags3[] = "flag3";
36 const char kFlags4[] = "flag4"; 38 const char kFlags4[] = "flag4";
37 const char kFlags5[] = "flag5"; 39 const char kFlags5[] = "flag5";
38 const char kFlags6[] = "flag6"; 40 const char kFlags6[] = "flag6";
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 cases[i].existing_enable_features); 523 cases[i].existing_enable_features);
522 } 524 }
523 if (cases[i].existing_disable_features) { 525 if (cases[i].existing_disable_features) {
524 command_line.AppendSwitchASCII(switches::kDisableFeatures, 526 command_line.AppendSwitchASCII(switches::kDisableFeatures,
525 cases[i].existing_disable_features); 527 cases[i].existing_disable_features);
526 } 528 }
527 529
528 testing::ClearState(); 530 testing::ClearState();
529 531
530 const std::string entry_name = base::StringPrintf( 532 const std::string entry_name = base::StringPrintf(
531 "%s%s%d", kFlags7, testing::kMultiSeparator, cases[i].enabled_choice); 533 "%s%s%d", kFlags7, flags_ui::testing::kMultiSeparator,
534 cases[i].enabled_choice);
532 SetFeatureEntryEnabled(&flags_storage_, entry_name, true); 535 SetFeatureEntryEnabled(&flags_storage_, entry_name, true);
533 536
534 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); 537 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels);
535 auto switch_list = command_line.GetSwitches(); 538 auto switch_list = command_line.GetSwitches();
536 EXPECT_EQ(cases[i].expected_enable_features != nullptr, 539 EXPECT_EQ(cases[i].expected_enable_features != nullptr,
537 ContainsKey(switch_list, switches::kEnableFeatures)); 540 ContainsKey(switch_list, switches::kEnableFeatures));
538 if (cases[i].expected_enable_features) 541 if (cases[i].expected_enable_features)
539 EXPECT_EQ(CreateSwitch(cases[i].expected_enable_features), 542 EXPECT_EQ(CreateSwitch(cases[i].expected_enable_features),
540 switch_list[switches::kEnableFeatures]); 543 switch_list[switches::kEnableFeatures]);
541 544
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 } 809 }
807 } 810 }
808 811
809 // Makes sure there are no separators in any of the entry names. 812 // Makes sure there are no separators in any of the entry names.
810 TEST_F(AboutFlagsTest, NoSeparators) { 813 TEST_F(AboutFlagsTest, NoSeparators) {
811 testing::SetFeatureEntries(nullptr, 0); 814 testing::SetFeatureEntries(nullptr, 0);
812 size_t count; 815 size_t count;
813 const FeatureEntry* entries = testing::GetFeatureEntries(&count); 816 const FeatureEntry* entries = testing::GetFeatureEntries(&count);
814 for (size_t i = 0; i < count; ++i) { 817 for (size_t i = 0; i < count; ++i) {
815 std::string name = entries[i].internal_name; 818 std::string name = entries[i].internal_name;
816 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; 819 EXPECT_EQ(std::string::npos, name.find(flags_ui::testing::kMultiSeparator))
820 << i;
817 } 821 }
818 } 822 }
819 823
820 TEST_F(AboutFlagsTest, GetFlagFeatureEntries) { 824 TEST_F(AboutFlagsTest, GetFlagFeatureEntries) {
821 base::ListValue supported_entries; 825 base::ListValue supported_entries;
822 base::ListValue unsupported_entries; 826 base::ListValue unsupported_entries;
823 GetFlagFeatureEntries(&flags_storage_, kGeneralAccessFlagsOnly, 827 GetFlagFeatureEntries(&flags_storage_, kGeneralAccessFlagsOnly,
824 &supported_entries, &unsupported_entries); 828 &supported_entries, &unsupported_entries);
825 // All |kEntries| except for |kFlags3| should be supported. 829 // All |kEntries| except for |kFlags3| should be supported.
826 EXPECT_EQ(6u, supported_entries.GetSize()); 830 EXPECT_EQ(6u, supported_entries.GetSize());
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 EXPECT_TRUE(enum_entry != histograms_xml_switches_ids.end() && 922 EXPECT_TRUE(enum_entry != histograms_xml_switches_ids.end() &&
919 enum_entry->first == flag) 923 enum_entry->first == flag)
920 << "histograms.xml enum LoginCustomFlags doesn't contain switch '" 924 << "histograms.xml enum LoginCustomFlags doesn't contain switch '"
921 << flag << "' (value=" << uma_id 925 << flag << "' (value=" << uma_id
922 << " expected). Consider adding entry:\n" 926 << " expected). Consider adding entry:\n"
923 << " " << GetHistogramEnumEntryText(flag, uma_id); 927 << " " << GetHistogramEnumEntryText(flag, uma_id);
924 } 928 }
925 } 929 }
926 930
927 } // namespace about_flags 931 } // namespace about_flags
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/profiles/profile_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698