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/ui/app_list/extension_app_model_builder.h" | 5 #include "chrome/browser/ui/app_list/extension_app_model_builder.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 } | 264 } |
265 | 265 |
266 TEST_F(ExtensionAppModelBuilderTest, InvalidOrdinal) { | 266 TEST_F(ExtensionAppModelBuilderTest, InvalidOrdinal) { |
267 // Creates a no-ordinal case. | 267 // Creates a no-ordinal case. |
268 AppSorting* sorting = ExtensionSystem::Get(profile_.get())->app_sorting(); | 268 AppSorting* sorting = ExtensionSystem::Get(profile_.get())->app_sorting(); |
269 sorting->ClearOrdinals(kPackagedApp1Id); | 269 sorting->ClearOrdinals(kPackagedApp1Id); |
270 | 270 |
271 // Creates a corrupted ordinal case. | 271 // Creates a corrupted ordinal case. |
272 extensions::ExtensionScopedPrefs* scoped_prefs = | 272 extensions::ExtensionScopedPrefs* scoped_prefs = |
273 extensions::ExtensionPrefs::Get(profile_.get()); | 273 extensions::ExtensionPrefs::Get(profile_.get()); |
274 scoped_prefs->UpdateExtensionPref( | 274 scoped_prefs->UpdateExtensionPref(kHostedAppId, "page_ordinal", |
275 kHostedAppId, | 275 new base::Value("a corrupted ordinal")); |
276 "page_ordinal", | |
277 new base::StringValue("a corrupted ordinal")); | |
278 | 276 |
279 // This should not assert or crash. | 277 // This should not assert or crash. |
280 CreateBuilder(); | 278 CreateBuilder(); |
281 } | 279 } |
282 | 280 |
283 TEST_F(ExtensionAppModelBuilderTest, OrdinalConfilicts) { | 281 TEST_F(ExtensionAppModelBuilderTest, OrdinalConfilicts) { |
284 // Creates conflict ordinals for app1 and app2. | 282 // Creates conflict ordinals for app1 and app2. |
285 syncer::StringOrdinal conflict_ordinal = | 283 syncer::StringOrdinal conflict_ordinal = |
286 syncer::StringOrdinal::CreateInitialOrdinal(); | 284 syncer::StringOrdinal::CreateInitialOrdinal(); |
287 | 285 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 extensions::Extension::WAS_INSTALLED_BY_DEFAULT | | 320 extensions::Extension::WAS_INSTALLED_BY_DEFAULT | |
323 extensions::Extension::FROM_BOOKMARK, | 321 extensions::Extension::FROM_BOOKMARK, |
324 kAppId, | 322 kAppId, |
325 &err); | 323 &err); |
326 EXPECT_TRUE(err.empty()); | 324 EXPECT_TRUE(err.empty()); |
327 | 325 |
328 service_->AddExtension(bookmark_app.get()); | 326 service_->AddExtension(bookmark_app.get()); |
329 EXPECT_EQ(kDefaultAppCount + 1, model_->top_level_item_list()->item_count()); | 327 EXPECT_EQ(kDefaultAppCount + 1, model_->top_level_item_list()->item_count()); |
330 EXPECT_NE(std::string::npos, GetModelContent(model_.get()).find(kAppName)); | 328 EXPECT_NE(std::string::npos, GetModelContent(model_.get()).find(kAppName)); |
331 } | 329 } |
OLD | NEW |