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

Unified Diff: chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc

Issue 1007083003: [Extensions Toolbar] Make pref update non-destructive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment Created 5 years, 9 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
« 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/ui/toolbar/toolbar_actions_bar_unittest.cc
diff --git a/chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc b/chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc
index 29ee6843480e4bc3292b4a6fd9dc70ee321f5945..9e74c2f01cea439200d7e8f1c5fabfd3190bc6c0 100644
--- a/chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc
+++ b/chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/browser_with_test_window_test.h"
+#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
#include "extensions/common/feature_switch.h"
@@ -390,6 +391,36 @@ TEST_F(ToolbarActionsBarUnitTest, BasicToolbarActionsBarTest) {
EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount());
}
+TEST_F(ToolbarActionsBarUnitTest, ToolbarActionsReorderOnPrefChange) {
+ for (int i = 0; i < 3; ++i) {
+ CreateAndAddExtension(
+ base::StringPrintf("extension %d", i),
+ extensions::extension_action_test_util::BROWSER_ACTION);
+ }
+ EXPECT_EQ(3u, toolbar_actions_bar()->GetIconCount());
+ // Change the value of the toolbar preference.
+ // Test drag-and-drop logic.
+ const char kExtension0[] = "extension 0";
+ const char kExtension1[] = "extension 1";
+ const char kExtension2[] = "extension 2";
+ {
+ // The order should start as 0, 1, 2.
+ const char* expected_names[] = { kExtension0, kExtension1, kExtension2 };
+ EXPECT_TRUE(VerifyToolbarOrder(expected_names, 3u, 3u));
+ }
+
+ extensions::ExtensionIdList new_order;
+ new_order.push_back(toolbar_actions_bar()->toolbar_actions()[1]->GetId());
+ new_order.push_back(toolbar_actions_bar()->toolbar_actions()[2]->GetId());
+ extensions::ExtensionPrefs::Get(profile())->SetToolbarOrder(new_order);
+
+ {
+ // The order should now reflect the prefs, and be 1, 2, 0.
+ const char* expected_names[] = { kExtension1, kExtension2, kExtension0 };
+ EXPECT_TRUE(VerifyToolbarOrder(expected_names, 3u, 3u));
+ }
+}
+
class ToolbarActionsBarRedesignUnitTest : public ToolbarActionsBarUnitTest {
public:
ToolbarActionsBarRedesignUnitTest() : ToolbarActionsBarUnitTest(true) {}
« 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