OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extension_sorting.h" | 5 #include "chrome/browser/extensions/extension_sorting.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "chrome/browser/extensions/extension_prefs_unittest.h" | 9 #include "chrome/browser/extensions/extension_prefs_unittest.h" |
10 #include "chrome/common/extensions/extension_manifest_constants.h" | 10 #include "chrome/common/extensions/extension_manifest_constants.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 // A preference determining the order of which the apps appear on the NTP. | 158 // A preference determining the order of which the apps appear on the NTP. |
159 const char kPrefAppLaunchIndexDeprecated[] = "app_launcher_index"; | 159 const char kPrefAppLaunchIndexDeprecated[] = "app_launcher_index"; |
160 // A preference determining the page on which an app appears in the NTP. | 160 // A preference determining the page on which an app appears in the NTP. |
161 const char kPrefPageIndexDeprecated[] = "page_index"; | 161 const char kPrefPageIndexDeprecated[] = "page_index"; |
162 | 162 |
163 // Setup the deprecated preferences. | 163 // Setup the deprecated preferences. |
164 ExtensionScopedPrefs* scoped_prefs = | 164 ExtensionScopedPrefs* scoped_prefs = |
165 static_cast<ExtensionScopedPrefs*>(prefs()); | 165 static_cast<ExtensionScopedPrefs*>(prefs()); |
166 scoped_prefs->UpdateExtensionPref(extension1()->id(), | 166 scoped_prefs->UpdateExtensionPref(extension1()->id(), |
167 kPrefAppLaunchIndexDeprecated, | 167 kPrefAppLaunchIndexDeprecated, |
168 Value::CreateIntegerValue(0)); | 168 new base::FundamentalValue(0)); |
169 scoped_prefs->UpdateExtensionPref(extension1()->id(), | 169 scoped_prefs->UpdateExtensionPref(extension1()->id(), |
170 kPrefPageIndexDeprecated, | 170 kPrefPageIndexDeprecated, |
171 Value::CreateIntegerValue(0)); | 171 new base::FundamentalValue(0)); |
172 | 172 |
173 scoped_prefs->UpdateExtensionPref(extension2()->id(), | 173 scoped_prefs->UpdateExtensionPref(extension2()->id(), |
174 kPrefAppLaunchIndexDeprecated, | 174 kPrefAppLaunchIndexDeprecated, |
175 Value::CreateIntegerValue(1)); | 175 new base::FundamentalValue(1)); |
176 scoped_prefs->UpdateExtensionPref(extension2()->id(), | 176 scoped_prefs->UpdateExtensionPref(extension2()->id(), |
177 kPrefPageIndexDeprecated, | 177 kPrefPageIndexDeprecated, |
178 Value::CreateIntegerValue(0)); | 178 new base::FundamentalValue(0)); |
179 | 179 |
180 scoped_prefs->UpdateExtensionPref(extension3()->id(), | 180 scoped_prefs->UpdateExtensionPref(extension3()->id(), |
181 kPrefAppLaunchIndexDeprecated, | 181 kPrefAppLaunchIndexDeprecated, |
182 Value::CreateIntegerValue(0)); | 182 new base::FundamentalValue(0)); |
183 scoped_prefs->UpdateExtensionPref(extension3()->id(), | 183 scoped_prefs->UpdateExtensionPref(extension3()->id(), |
184 kPrefPageIndexDeprecated, | 184 kPrefPageIndexDeprecated, |
185 Value::CreateIntegerValue(1)); | 185 new base::FundamentalValue(1)); |
186 | 186 |
187 // We insert the ids in reserve order so that we have to deal with the | 187 // We insert the ids in reserve order so that we have to deal with the |
188 // element on the 2nd page before the 1st page is seen. | 188 // element on the 2nd page before the 1st page is seen. |
189 extensions::ExtensionIdList ids; | 189 extensions::ExtensionIdList ids; |
190 ids.push_back(extension3()->id()); | 190 ids.push_back(extension3()->id()); |
191 ids.push_back(extension2()->id()); | 191 ids.push_back(extension2()->id()); |
192 ids.push_back(extension1()->id()); | 192 ids.push_back(extension1()->id()); |
193 | 193 |
194 prefs()->extension_sorting()->Initialize(ids); | 194 prefs()->extension_sorting()->Initialize(ids); |
195 } | 195 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 // A preference determining the order of which the apps appear on the NTP. | 274 // A preference determining the order of which the apps appear on the NTP. |
275 const char kPrefAppLaunchIndexDeprecated[] = "app_launcher_index"; | 275 const char kPrefAppLaunchIndexDeprecated[] = "app_launcher_index"; |
276 // A preference determining the page on which an app appears in the NTP. | 276 // A preference determining the page on which an app appears in the NTP. |
277 const char kPrefPageIndexDeprecated[] = "page_index"; | 277 const char kPrefPageIndexDeprecated[] = "page_index"; |
278 | 278 |
279 // Setup the deprecated preference. | 279 // Setup the deprecated preference. |
280 ExtensionScopedPrefs* scoped_prefs = | 280 ExtensionScopedPrefs* scoped_prefs = |
281 static_cast<ExtensionScopedPrefs*>(prefs()); | 281 static_cast<ExtensionScopedPrefs*>(prefs()); |
282 scoped_prefs->UpdateExtensionPref(extension1()->id(), | 282 scoped_prefs->UpdateExtensionPref(extension1()->id(), |
283 kPrefAppLaunchIndexDeprecated, | 283 kPrefAppLaunchIndexDeprecated, |
284 Value::CreateIntegerValue(0)); | 284 new base::FundamentalValue(0)); |
285 scoped_prefs->UpdateExtensionPref(extension1()->id(), | 285 scoped_prefs->UpdateExtensionPref(extension1()->id(), |
286 kPrefPageIndexDeprecated, | 286 kPrefPageIndexDeprecated, |
287 Value::CreateIntegerValue(-1)); | 287 new base::FundamentalValue(-1)); |
288 | 288 |
289 extensions::ExtensionIdList ids; | 289 extensions::ExtensionIdList ids; |
290 ids.push_back(extension1()->id()); | 290 ids.push_back(extension1()->id()); |
291 | 291 |
292 prefs()->extension_sorting()->Initialize(ids); | 292 prefs()->extension_sorting()->Initialize(ids); |
293 } | 293 } |
294 virtual void Verify() OVERRIDE { | 294 virtual void Verify() OVERRIDE { |
295 // Make sure that the invalid page_index wasn't converted over. | 295 // Make sure that the invalid page_index wasn't converted over. |
296 EXPECT_FALSE(prefs()->extension_sorting()->GetAppLaunchOrdinal( | 296 EXPECT_FALSE(prefs()->extension_sorting()->GetAppLaunchOrdinal( |
297 extension1()->id()).IsValid()); | 297 extension1()->id()).IsValid()); |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 extension_sorting->SetAppLaunchOrdinal(yet_another_app_->id(), | 966 extension_sorting->SetAppLaunchOrdinal(yet_another_app_->id(), |
967 default_app_launch_ordinal_); | 967 default_app_launch_ordinal_); |
968 } | 968 } |
969 | 969 |
970 private: | 970 private: |
971 scoped_refptr<Extension> other_app_; | 971 scoped_refptr<Extension> other_app_; |
972 scoped_refptr<Extension> yet_another_app_; | 972 scoped_refptr<Extension> yet_another_app_; |
973 }; | 973 }; |
974 TEST_F(ExtensionSortingDefaultOrdinalNoCollision, | 974 TEST_F(ExtensionSortingDefaultOrdinalNoCollision, |
975 ExtensionSortingDefaultOrdinalNoCollision) {} | 975 ExtensionSortingDefaultOrdinalNoCollision) {} |
OLD | NEW |