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

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

Issue 2539153003: Ensure that new toolbar actions added to incognito toolbars become visible (Closed)
Patch Set: Created 4 years 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/ui/toolbar/toolbar_actions_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_model_unittest.cc
diff --git a/chrome/browser/ui/toolbar/toolbar_actions_model_unittest.cc b/chrome/browser/ui/toolbar/toolbar_actions_model_unittest.cc
index ae08f5555aeb2391e4fcaa12ff5581870f139b8a..c39f29ddc3d5d4d4f0456de878752f52404d80ce 100644
--- a/chrome/browser/ui/toolbar/toolbar_actions_model_unittest.cc
+++ b/chrome/browser/ui/toolbar/toolbar_actions_model_unittest.cc
@@ -1456,6 +1456,50 @@ TEST_F(ToolbarActionsModelUnitTest, AddAndRemoveComponentActionWithOVerflow) {
EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(2u));
}
+TEST_F(ToolbarActionsModelUnitTest, AddComponentActionInIncognito) {
+ Init();
+ // Add three extension actions: A, B, C.
+ ASSERT_TRUE(AddBrowserActionExtensions());
+ EXPECT_EQ(3u, num_toolbar_items());
+
+ // Enable extension C in incognito.
+ extensions::ExtensionPrefs* extension_prefs =
+ extensions::ExtensionPrefs::Get(profile());
+ extension_prefs->SetIsIncognitoEnabled(browser_action_c()->id(), true);
+ extensions::util::SetIsIncognitoEnabled(browser_action_c()->id(), profile(),
+ true);
+
+ // Get an incognito toolbar.
+ ToolbarActionsModel* incognito_model =
+ extensions::extension_action_test_util::CreateToolbarModelForProfile(
+ profile()->GetOffTheRecordProfile());
+
+ // The incognito toolbar should only have extension C.
+ EXPECT_EQ(1u, incognito_model->toolbar_items().size());
+
+ // Add a component action to the incognito toolbar. It shouldn't appear on the
+ // non-incognito toolbar.
+ incognito_model->AddComponentAction(component_action_id());
+ EXPECT_EQ(2u, incognito_model->toolbar_items().size());
+ EXPECT_EQ(2u, incognito_model->visible_icon_count());
+ EXPECT_EQ(component_action_id(), GetActionIdAtIndex(1u, incognito_model));
+ EXPECT_EQ(3u, num_toolbar_items());
+ incognito_model->RemoveComponentAction(component_action_id());
+
+ // Set visible count to 2 so that C is overflowed on the non-incognito
+ // toolbar. Its state is A, B, [C]. C stays visible on the incognito toolbar.
+ toolbar_model()->SetVisibleIconCount(2);
+ EXPECT_EQ(1u, incognito_model->toolbar_items().size());
+ EXPECT_EQ(1u, incognito_model->visible_icon_count());
+
+ // Add a component action to the incognito toolbar. It shouldn't appear in the
+ // overflow menu.
+ incognito_model->AddComponentAction(component_action_id());
+ EXPECT_EQ(2u, incognito_model->toolbar_items().size());
+ EXPECT_EQ(2u, incognito_model->visible_icon_count());
+ EXPECT_EQ(component_action_id(), GetActionIdAtIndex(1u, incognito_model));
+}
+
TEST_F(ToolbarActionsModelUnitTest,
TestUninstallVisibleExtensionDoesntBringOutOther) {
Init();
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_actions_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698