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

Unified Diff: chrome/browser/ui/app_list/extension_app_model_builder_unittest.cc

Issue 148403007: Protect AppListItemList Add/Remove and fix sync bugs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/extension_app_model_builder_unittest.cc
diff --git a/chrome/browser/ui/app_list/extension_app_model_builder_unittest.cc b/chrome/browser/ui/app_list/extension_app_model_builder_unittest.cc
index eafff39bd290aed5d7f9ce6a608ee4a797d2d389..66b5c78df4f4d8c7a05e366a4e4d48375c512c84 100644
--- a/chrome/browser/ui/app_list/extension_app_model_builder_unittest.cc
+++ b/chrome/browser/ui/app_list/extension_app_model_builder_unittest.cc
@@ -122,19 +122,30 @@ class ExtensionAppModelBuilderTest : public ExtensionServiceTestBase {
const extensions::ExtensionSet* extensions = service_->extensions();
ASSERT_EQ(static_cast<size_t>(4), extensions->size());
+ CreateBuilder();
+ }
+
+ virtual void TearDown() OVERRIDE {
+ ResetBuilder();
+ }
+
+ protected:
+ // Creates a new builder, destroying any existing one.
+ void CreateBuilder() {
+ ResetBuilder(); // Destroy any existing builder in the correct order.
+
model_.reset(new app_list::AppListModel);
controller_.reset(new TestAppListControllerDelegate);
builder_.reset(new ExtensionAppModelBuilder(controller_.get()));
builder_->InitializeWithProfile(profile_.get(), model_.get());
}
- virtual void TearDown() OVERRIDE {
+ void ResetBuilder() {
builder_.reset();
controller_.reset();
model_.reset();
}
- protected:
scoped_ptr<app_list::AppListModel> model_;
scoped_ptr<TestAppListControllerDelegate> controller_;
scoped_ptr<ExtensionAppModelBuilder> builder_;
@@ -281,7 +292,7 @@ TEST_F(ExtensionAppModelBuilderTest, InvalidOrdinal) {
extensions::AppSorting* sorting = service_->extension_prefs()->app_sorting();
sorting->ClearOrdinals(kPackagedApp1Id);
- // Creates an corrupted ordinal case.
+ // Creates a corrupted ordinal case.
extensions::ExtensionScopedPrefs* scoped_prefs = service_->extension_prefs();
scoped_prefs->UpdateExtensionPref(
kHostedAppId,
@@ -289,8 +300,7 @@ TEST_F(ExtensionAppModelBuilderTest, InvalidOrdinal) {
base::Value::CreateStringValue("a corrupted ordinal"));
// This should not assert or crash.
- ExtensionAppModelBuilder builder1(controller_.get());
- builder1.InitializeWithProfile(profile_.get(), model_.get());
+ CreateBuilder();
}
TEST_F(ExtensionAppModelBuilderTest, OrdinalConfilicts) {
@@ -309,8 +319,7 @@ TEST_F(ExtensionAppModelBuilderTest, OrdinalConfilicts) {
sorting->SetAppLaunchOrdinal(kPackagedApp2Id, conflict_ordinal);
// This should not assert or crash.
- ExtensionAppModelBuilder builder1(controller_.get());
- builder1.InitializeWithProfile(profile_.get(), model_.get());
+ CreateBuilder();
// By default, conflicted items are sorted by their app ids (= order added).
EXPECT_EQ(std::string("Hosted App,Packaged App 1,Packaged App 2"),

Powered by Google App Engine
This is Rietveld 408576698