OLD | NEW |
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 <set> | 11 #include <set> |
11 #include <string> | 12 #include <string> |
12 | 13 |
13 #include "base/bind.h" | 14 #include "base/bind.h" |
14 #include "base/feature_list.h" | 15 #include "base/feature_list.h" |
15 #include "base/format_macros.h" | 16 #include "base/format_macros.h" |
16 #include "base/macros.h" | 17 #include "base/macros.h" |
17 #include "base/memory/scoped_ptr.h" | |
18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
19 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
21 #include "base/values.h" | 21 #include "base/values.h" |
22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
23 #include "components/flags_ui/feature_entry.h" | 23 #include "components/flags_ui/feature_entry.h" |
24 #include "components/flags_ui/flags_ui_pref_names.h" | 24 #include "components/flags_ui/flags_ui_pref_names.h" |
25 #include "components/flags_ui/flags_ui_switches.h" | 25 #include "components/flags_ui/flags_ui_switches.h" |
26 #include "components/flags_ui/pref_service_flags_storage.h" | 26 #include "components/flags_ui/pref_service_flags_storage.h" |
27 #include "components/prefs/pref_registry_simple.h" | 27 #include "components/prefs/pref_registry_simple.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 int os_other_than_current = 1; | 120 int os_other_than_current = 1; |
121 while (os_other_than_current == FlagsState::GetCurrentPlatform()) | 121 while (os_other_than_current == FlagsState::GetCurrentPlatform()) |
122 os_other_than_current <<= 1; | 122 os_other_than_current <<= 1; |
123 kEntries[2].supported_platforms = os_other_than_current; | 123 kEntries[2].supported_platforms = os_other_than_current; |
124 flags_state_.reset(new FlagsState(kEntries, arraysize(kEntries))); | 124 flags_state_.reset(new FlagsState(kEntries, arraysize(kEntries))); |
125 } | 125 } |
126 | 126 |
127 TestingPrefServiceSimple prefs_; | 127 TestingPrefServiceSimple prefs_; |
128 PrefServiceFlagsStorage flags_storage_; | 128 PrefServiceFlagsStorage flags_storage_; |
129 scoped_ptr<FlagsState> flags_state_; | 129 std::unique_ptr<FlagsState> flags_state_; |
130 }; | 130 }; |
131 | 131 |
132 TEST_F(FlagsStateTest, NoChangeNoRestart) { | 132 TEST_F(FlagsStateTest, NoChangeNoRestart) { |
133 EXPECT_FALSE(flags_state_->IsRestartNeededToCommitChanges()); | 133 EXPECT_FALSE(flags_state_->IsRestartNeededToCommitChanges()); |
134 flags_state_->SetFeatureEntryEnabled(&flags_storage_, kFlags1, false); | 134 flags_state_->SetFeatureEntryEnabled(&flags_storage_, kFlags1, false); |
135 EXPECT_FALSE(flags_state_->IsRestartNeededToCommitChanges()); | 135 EXPECT_FALSE(flags_state_->IsRestartNeededToCommitChanges()); |
136 | 136 |
137 // kFlags6 is enabled by default, so enabling should not require a restart. | 137 // kFlags6 is enabled by default, so enabling should not require a restart. |
138 flags_state_->SetFeatureEntryEnabled(&flags_storage_, kFlags6, true); | 138 flags_state_->SetFeatureEntryEnabled(&flags_storage_, kFlags6, true); |
139 EXPECT_FALSE(flags_state_->IsRestartNeededToCommitChanges()); | 139 EXPECT_FALSE(flags_state_->IsRestartNeededToCommitChanges()); |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 &supported_entries, &unsupported_entries, | 691 &supported_entries, &unsupported_entries, |
692 base::Bind(&SkipFeatureEntry)); | 692 base::Bind(&SkipFeatureEntry)); |
693 // All |kEntries| except for |kFlags3| should be supported. | 693 // All |kEntries| except for |kFlags3| should be supported. |
694 EXPECT_EQ(6u, supported_entries.GetSize()); | 694 EXPECT_EQ(6u, supported_entries.GetSize()); |
695 EXPECT_EQ(1u, unsupported_entries.GetSize()); | 695 EXPECT_EQ(1u, unsupported_entries.GetSize()); |
696 EXPECT_EQ(arraysize(kEntries), | 696 EXPECT_EQ(arraysize(kEntries), |
697 supported_entries.GetSize() + unsupported_entries.GetSize()); | 697 supported_entries.GetSize() + unsupported_entries.GetSize()); |
698 } | 698 } |
699 | 699 |
700 } // namespace flags_ui | 700 } // namespace flags_ui |
OLD | NEW |