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

Unified Diff: chrome/browser/extensions/extension_toolbar_model_unittest.cc

Issue 731353002: [Extensions Toolbar] Notify observers of extensions re-added after a pref change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Marijn's Created 6 years, 1 month 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
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_toolbar_model_unittest.cc
diff --git a/chrome/browser/extensions/extension_toolbar_model_unittest.cc b/chrome/browser/extensions/extension_toolbar_model_unittest.cc
index d7765a438388de38e29e955d1e3f54ef63fb6c23..952527ca1b6ced39c5b994537edd0d21adf02dd7 100644
--- a/chrome/browser/extensions/extension_toolbar_model_unittest.cc
+++ b/chrome/browser/extensions/extension_toolbar_model_unittest.cc
@@ -1311,4 +1311,40 @@ TEST_F(ExtensionToolbarModelUnitTest, ModelWaitsForExtensionSystemReady) {
EXPECT_EQ(1u, model_observer.initialized_count());
}
+// Check that the toolbar model correctly clears and reorders when it detects
+// a preference change.
+TEST_F(ExtensionToolbarModelUnitTest, ToolbarModelPrefChange) {
+ Init();
+
+ ASSERT_TRUE(AddBrowserActionExtensions());
+
+ // We should start in the basic A B C order.
+ ASSERT_TRUE(browser_action_a());
+ EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0));
+ EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(1));
+ EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(2));
+ // Record the difference between the inserted and removed counts. The actual
+ // value of the counts is not important, but we need to be sure that if we
+ // call to remove any, we also add them back.
+ size_t inserted_and_removed_difference =
+ observer()->inserted_count() - observer()->removed_count();
+
+ // Assign a new order, B C A, and write it in the prefs.
+ ExtensionIdList new_order;
+ new_order.push_back(browser_action_b()->id());
+ new_order.push_back(browser_action_c()->id());
+ new_order.push_back(browser_action_a()->id());
+ ExtensionPrefs::Get(profile())->SetToolbarOrder(new_order);
+
+ // Ensure everything has time to run.
+ base::RunLoop().RunUntilIdle();
+
+ // The new order should be reflected in the model.
+ EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(0));
+ EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(1));
+ EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(2));
+ EXPECT_EQ(inserted_and_removed_difference,
+ observer()->inserted_count() - observer()->removed_count());
+}
+
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698