| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "chrome/app/chrome_command_ids.h" | 6 #include "chrome/app/chrome_command_ids.h" |
| 7 #include "chrome/browser/extensions/browser_action_test_util.h" | 7 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 8 #include "chrome/browser/signin/fake_signin_manager_builder.h" | 8 #include "chrome/browser/signin/fake_signin_manager_builder.h" |
| 9 #include "chrome/browser/signin/signin_manager_factory.h" | 9 #include "chrome/browser/signin/signin_manager_factory.h" |
| 10 #include "chrome/browser/ui/toolbar/media_router_action.h" | 10 #include "chrome/browser/ui/toolbar/media_router_action.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 } | 28 } |
| 29 | 29 |
| 30 void TearDown() override { | 30 void TearDown() override { |
| 31 action_.reset(); | 31 action_.reset(); |
| 32 browser_action_test_util_.reset(); | 32 browser_action_test_util_.reset(); |
| 33 BrowserWithTestWindowTest::TearDown(); | 33 BrowserWithTestWindowTest::TearDown(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 SigninManagerBase* signin_manager() { return signin_manager_; } | 36 SigninManagerBase* signin_manager() { return signin_manager_; } |
| 37 ui::SimpleMenuModel* model() { return model_; } | 37 ui::SimpleMenuModel* model() { return model_; } |
| 38 MediaRouterAction* action() { return action_.get(); } |
| 38 | 39 |
| 39 private: | 40 private: |
| 40 std::unique_ptr<BrowserActionTestUtil> browser_action_test_util_; | 41 std::unique_ptr<BrowserActionTestUtil> browser_action_test_util_; |
| 41 std::unique_ptr<MediaRouterAction> action_; | 42 std::unique_ptr<MediaRouterAction> action_; |
| 42 SigninManagerBase* signin_manager_; | 43 SigninManagerBase* signin_manager_; |
| 43 ui::SimpleMenuModel* model_; | 44 ui::SimpleMenuModel* model_; |
| 44 | 45 |
| 45 DISALLOW_COPY_AND_ASSIGN(MediaRouterContextualMenuUnitTest); | 46 DISALLOW_COPY_AND_ASSIGN(MediaRouterContextualMenuUnitTest); |
| 46 }; | 47 }; |
| 47 | 48 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 EXPECT_TRUE(model()->IsVisibleAt(i)); | 90 EXPECT_TRUE(model()->IsVisibleAt(i)); |
| 90 } | 91 } |
| 91 } | 92 } |
| 92 | 93 |
| 93 #if defined(GOOGLE_CHROME_BUILD) | 94 #if defined(GOOGLE_CHROME_BUILD) |
| 94 // Tests whether the cloud services item is correctly toggled. This menu item | 95 // Tests whether the cloud services item is correctly toggled. This menu item |
| 95 // is only availble on official Chrome builds. | 96 // is only availble on official Chrome builds. |
| 96 TEST_F(MediaRouterContextualMenuUnitTest, ToggleCloudServicesItem) { | 97 TEST_F(MediaRouterContextualMenuUnitTest, ToggleCloudServicesItem) { |
| 97 // The Media Router Action has a getter for the model, but not the delegate. | 98 // The Media Router Action has a getter for the model, but not the delegate. |
| 98 // Create the MediaRouterContextualMenu ui::SimpleMenuModel::Delegate here. | 99 // Create the MediaRouterContextualMenu ui::SimpleMenuModel::Delegate here. |
| 99 MediaRouterContextualMenu menu(browser()); | 100 MediaRouterContextualMenu menu(browser(), action()); |
| 100 | 101 |
| 101 // Set up an authenticated account such that the cloud services menu item is | 102 // Set up an authenticated account such that the cloud services menu item is |
| 102 // surfaced. Whether or not it is surfaced is tested in the "Basic" test. | 103 // surfaced. Whether or not it is surfaced is tested in the "Basic" test. |
| 103 signin_manager()->SetAuthenticatedAccountInfo("foo@bar.com", "password"); | 104 signin_manager()->SetAuthenticatedAccountInfo("foo@bar.com", "password"); |
| 104 | 105 |
| 105 // By default, the command is not checked. | 106 // By default, the command is not checked. |
| 106 EXPECT_FALSE(menu.IsCommandIdChecked( | 107 EXPECT_FALSE(menu.IsCommandIdChecked( |
| 107 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); | 108 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); |
| 108 | 109 |
| 109 menu.ExecuteCommand(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE, 0); | 110 menu.ExecuteCommand(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE, 0); |
| 110 EXPECT_TRUE(menu.IsCommandIdChecked( | 111 EXPECT_TRUE(menu.IsCommandIdChecked( |
| 111 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); | 112 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); |
| 112 | 113 |
| 113 menu.ExecuteCommand(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE, 0); | 114 menu.ExecuteCommand(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE, 0); |
| 114 EXPECT_FALSE(menu.IsCommandIdChecked( | 115 EXPECT_FALSE(menu.IsCommandIdChecked( |
| 115 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); | 116 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); |
| 116 } | 117 } |
| 117 #endif // GOOGLE_CHROME_BUILD | 118 #endif // GOOGLE_CHROME_BUILD |
| OLD | NEW |