OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/chrome_app_sorting.h" | 5 #include "chrome/browser/extensions/chrome_app_sorting.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_prefs_unittest.h" | 7 #include "chrome/browser/extensions/extension_prefs_unittest.h" |
8 #include "components/crx_file/id_util.h" | 8 #include "components/crx_file/id_util.h" |
9 #include "components/sync/model/string_ordinal.h" | 9 #include "components/sync/model/string_ordinal.h" |
10 #include "extensions/common/constants.h" | 10 #include "extensions/common/constants.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 void Initialize() override { | 146 void Initialize() override { |
147 // A preference determining the order of which the apps appear on the NTP. | 147 // A preference determining the order of which the apps appear on the NTP. |
148 const char kPrefAppLaunchIndexDeprecated[] = "app_launcher_index"; | 148 const char kPrefAppLaunchIndexDeprecated[] = "app_launcher_index"; |
149 // A preference determining the page on which an app appears in the NTP. | 149 // A preference determining the page on which an app appears in the NTP. |
150 const char kPrefPageIndexDeprecated[] = "page_index"; | 150 const char kPrefPageIndexDeprecated[] = "page_index"; |
151 | 151 |
152 // Setup the deprecated preferences. | 152 // Setup the deprecated preferences. |
153 ExtensionScopedPrefs* scoped_prefs = | 153 ExtensionScopedPrefs* scoped_prefs = |
154 static_cast<ExtensionScopedPrefs*>(prefs()); | 154 static_cast<ExtensionScopedPrefs*>(prefs()); |
155 scoped_prefs->UpdateExtensionPref(extension1()->id(), | 155 scoped_prefs->UpdateExtensionPref( |
156 kPrefAppLaunchIndexDeprecated, | 156 extension1()->id(), kPrefAppLaunchIndexDeprecated, new base::Value(0)); |
157 new base::FundamentalValue(0)); | 157 scoped_prefs->UpdateExtensionPref( |
158 scoped_prefs->UpdateExtensionPref(extension1()->id(), | 158 extension1()->id(), kPrefPageIndexDeprecated, new base::Value(0)); |
159 kPrefPageIndexDeprecated, | |
160 new base::FundamentalValue(0)); | |
161 | 159 |
162 scoped_prefs->UpdateExtensionPref(extension2()->id(), | 160 scoped_prefs->UpdateExtensionPref( |
163 kPrefAppLaunchIndexDeprecated, | 161 extension2()->id(), kPrefAppLaunchIndexDeprecated, new base::Value(1)); |
164 new base::FundamentalValue(1)); | 162 scoped_prefs->UpdateExtensionPref( |
165 scoped_prefs->UpdateExtensionPref(extension2()->id(), | 163 extension2()->id(), kPrefPageIndexDeprecated, new base::Value(0)); |
166 kPrefPageIndexDeprecated, | |
167 new base::FundamentalValue(0)); | |
168 | 164 |
169 scoped_prefs->UpdateExtensionPref(extension3()->id(), | 165 scoped_prefs->UpdateExtensionPref( |
170 kPrefAppLaunchIndexDeprecated, | 166 extension3()->id(), kPrefAppLaunchIndexDeprecated, new base::Value(0)); |
171 new base::FundamentalValue(0)); | 167 scoped_prefs->UpdateExtensionPref( |
172 scoped_prefs->UpdateExtensionPref(extension3()->id(), | 168 extension3()->id(), kPrefPageIndexDeprecated, new base::Value(1)); |
173 kPrefPageIndexDeprecated, | |
174 new base::FundamentalValue(1)); | |
175 | 169 |
176 // We insert the ids in reverse order so that we have to deal with the | 170 // We insert the ids in reverse order so that we have to deal with the |
177 // element on the 2nd page before the 1st page is seen. | 171 // element on the 2nd page before the 1st page is seen. |
178 ExtensionIdList ids; | 172 ExtensionIdList ids; |
179 ids.push_back(extension3()->id()); | 173 ids.push_back(extension3()->id()); |
180 ids.push_back(extension2()->id()); | 174 ids.push_back(extension2()->id()); |
181 ids.push_back(extension1()->id()); | 175 ids.push_back(extension1()->id()); |
182 | 176 |
183 app_sorting()->MigrateAppIndex(ids); | 177 app_sorting()->MigrateAppIndex(ids); |
184 } | 178 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 246 |
253 void Initialize() override { | 247 void Initialize() override { |
254 // A preference determining the order of which the apps appear on the NTP. | 248 // A preference determining the order of which the apps appear on the NTP. |
255 const char kPrefAppLaunchIndexDeprecated[] = "app_launcher_index"; | 249 const char kPrefAppLaunchIndexDeprecated[] = "app_launcher_index"; |
256 // A preference determining the page on which an app appears in the NTP. | 250 // A preference determining the page on which an app appears in the NTP. |
257 const char kPrefPageIndexDeprecated[] = "page_index"; | 251 const char kPrefPageIndexDeprecated[] = "page_index"; |
258 | 252 |
259 // Setup the deprecated preference. | 253 // Setup the deprecated preference. |
260 ExtensionScopedPrefs* scoped_prefs = | 254 ExtensionScopedPrefs* scoped_prefs = |
261 static_cast<ExtensionScopedPrefs*>(prefs()); | 255 static_cast<ExtensionScopedPrefs*>(prefs()); |
262 scoped_prefs->UpdateExtensionPref(extension1()->id(), | 256 scoped_prefs->UpdateExtensionPref( |
263 kPrefAppLaunchIndexDeprecated, | 257 extension1()->id(), kPrefAppLaunchIndexDeprecated, new base::Value(0)); |
264 new base::FundamentalValue(0)); | 258 scoped_prefs->UpdateExtensionPref( |
265 scoped_prefs->UpdateExtensionPref(extension1()->id(), | 259 extension1()->id(), kPrefPageIndexDeprecated, new base::Value(-1)); |
266 kPrefPageIndexDeprecated, | |
267 new base::FundamentalValue(-1)); | |
268 } | 260 } |
269 void Verify() override { | 261 void Verify() override { |
270 // Make sure that the invalid page_index wasn't converted over. | 262 // Make sure that the invalid page_index wasn't converted over. |
271 EXPECT_FALSE(app_sorting()->GetAppLaunchOrdinal( | 263 EXPECT_FALSE(app_sorting()->GetAppLaunchOrdinal( |
272 extension1()->id()).IsValid()); | 264 extension1()->id()).IsValid()); |
273 } | 265 } |
274 }; | 266 }; |
275 TEST_F(ChromeAppSortingMigrateAppIndexInvalid, | 267 TEST_F(ChromeAppSortingMigrateAppIndexInvalid, |
276 ChromeAppSortingMigrateAppIndexInvalid) {} | 268 ChromeAppSortingMigrateAppIndexInvalid) {} |
277 | 269 |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 | 928 |
937 private: | 929 private: |
938 scoped_refptr<Extension> first_app_; | 930 scoped_refptr<Extension> first_app_; |
939 scoped_refptr<Extension> second_app_; | 931 scoped_refptr<Extension> second_app_; |
940 }; | 932 }; |
941 TEST_F(ChromeAppSortingSetExtensionVisible, | 933 TEST_F(ChromeAppSortingSetExtensionVisible, |
942 ChromeAppSortingSetExtensionVisible) { | 934 ChromeAppSortingSetExtensionVisible) { |
943 } | 935 } |
944 | 936 |
945 } // namespace extensions | 937 } // namespace extensions |
OLD | NEW |