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

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

Issue 2155293002: Show the Cast toolbar icon ephemerally when Cast is in use (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Mark's comment, trybot failures, rebase Created 4 years, 4 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/component_migration_helper.cc ('k') | chrome/browser/profiles/profile.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/component_migration_helper_unittest.cc
diff --git a/chrome/browser/extensions/component_migration_helper_unittest.cc b/chrome/browser/extensions/component_migration_helper_unittest.cc
index 8168c7748b19fcf49eabf07957459a3ce742e6cf..1a869cd5816a5b13864b5077d8a539bcbbfcba7b 100644
--- a/chrome/browser/extensions/component_migration_helper_unittest.cc
+++ b/chrome/browser/extensions/component_migration_helper_unittest.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_service_test_base.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_registry_simple.h"
#include "extensions/browser/extension_registry.h"
@@ -47,6 +48,11 @@ class MockComponentMigrationHelper : public ComponentMigrationHelper {
SetComponentActionPref(kTestActionId, enabled);
}
+ void SetMediaRouterActionPref(bool enabled) {
+ SetComponentActionPref(
+ ComponentToolbarActionsFactory::kMediaRouterActionId, enabled);
+ }
+
void EnableTestFeature() { enabled_actions_.insert(kTestActionId); }
void DisableTestFeature() { enabled_actions_.erase(kTestActionId); }
@@ -95,6 +101,11 @@ class ComponentMigrationHelperTest : public ExtensionServiceTestBase {
return enable_value;
}
+ bool IsMediaRouterActionAlwaysShown() {
+ return profile()->GetPrefs()->
+ GetBoolean(prefs::kMediaRouterAlwaysShowActionIcon);
+ }
+
StrictMock<MockComponentActionDelegate> mock_delegate_;
std::unique_ptr<StrictMock<MockComponentMigrationHelper>> mock_helper_;
std::unique_ptr<FeatureSwitch::ScopedOverride> extension_action_redesign_;
@@ -209,4 +220,32 @@ TEST_F(ComponentMigrationHelperTest, RemoveComponentAction) {
EXPECT_FALSE(IsTestComponentActionEnabled());
}
+TEST_F(ComponentMigrationHelperTest, EnableAndDisableMediaRouterAction) {
+ mock_helper_->SetMediaRouterActionPref(true);
+ mock_helper_->Register(
+ ComponentToolbarActionsFactory::kMediaRouterActionId,
+ "test_cast_extension");
+ EXPECT_FALSE(IsMediaRouterActionAlwaysShown());
+
+ EXPECT_CALL(mock_delegate_, HasComponentAction(
+ ComponentToolbarActionsFactory::kMediaRouterActionId))
+ .WillOnce(Return(false));
+ EXPECT_CALL(mock_delegate_, AddComponentAction(
+ ComponentToolbarActionsFactory::kMediaRouterActionId));
+
+ mock_helper_->OnFeatureEnabled(
+ ComponentToolbarActionsFactory::kMediaRouterActionId);
+ EXPECT_TRUE(IsMediaRouterActionAlwaysShown());
+
+ EXPECT_CALL(mock_delegate_, HasComponentAction(
+ ComponentToolbarActionsFactory::kMediaRouterActionId))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_delegate_, RemoveComponentAction(
+ ComponentToolbarActionsFactory::kMediaRouterActionId));
+
+ mock_helper_->OnFeatureDisabled(
+ ComponentToolbarActionsFactory::kMediaRouterActionId);
+ EXPECT_FALSE(IsMediaRouterActionAlwaysShown());
+}
+
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/component_migration_helper.cc ('k') | chrome/browser/profiles/profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698