Chromium Code Reviews| 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 <memory> | |
| 6 | |
| 5 #include "base/macros.h" | 7 #include "base/macros.h" |
| 6 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 7 #include "chrome/browser/extensions/browser_action_test_util.h" | 9 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 8 #include "chrome/browser/signin/fake_signin_manager_builder.h" | 10 #include "chrome/browser/signin/fake_signin_manager_builder.h" |
| 9 #include "chrome/browser/signin/signin_manager_factory.h" | 11 #include "chrome/browser/signin/signin_manager_factory.h" |
| 10 #include "chrome/browser/ui/toolbar/media_router_action.h" | 12 #include "chrome/browser/ui/toolbar/media_router_action.h" |
| 11 #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h" | 13 #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h" |
| 12 #include "chrome/test/base/browser_with_test_window_test.h" | 14 #include "chrome/test/base/browser_with_test_window_test.h" |
| 13 | 15 |
| 14 class MediaRouterContextualMenuUnitTest : public BrowserWithTestWindowTest { | 16 class MediaRouterContextualMenuUnitTest : public BrowserWithTestWindowTest { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 28 } | 30 } |
| 29 | 31 |
| 30 void TearDown() override { | 32 void TearDown() override { |
| 31 action_.reset(); | 33 action_.reset(); |
| 32 browser_action_test_util_.reset(); | 34 browser_action_test_util_.reset(); |
| 33 BrowserWithTestWindowTest::TearDown(); | 35 BrowserWithTestWindowTest::TearDown(); |
| 34 } | 36 } |
| 35 | 37 |
| 36 SigninManagerBase* signin_manager() { return signin_manager_; } | 38 SigninManagerBase* signin_manager() { return signin_manager_; } |
| 37 ui::SimpleMenuModel* model() { return model_; } | 39 ui::SimpleMenuModel* model() { return model_; } |
| 40 MediaRouterAction* action() { return action_.get(); } | |
| 38 | 41 |
| 39 private: | 42 private: |
| 40 std::unique_ptr<BrowserActionTestUtil> browser_action_test_util_; | 43 std::unique_ptr<BrowserActionTestUtil> browser_action_test_util_; |
| 41 std::unique_ptr<MediaRouterAction> action_; | 44 std::unique_ptr<MediaRouterAction> action_; |
| 42 SigninManagerBase* signin_manager_; | 45 SigninManagerBase* signin_manager_; |
| 43 ui::SimpleMenuModel* model_; | 46 ui::SimpleMenuModel* model_; |
| 44 | 47 |
| 45 DISALLOW_COPY_AND_ASSIGN(MediaRouterContextualMenuUnitTest); | 48 DISALLOW_COPY_AND_ASSIGN(MediaRouterContextualMenuUnitTest); |
| 46 }; | 49 }; |
| 47 | 50 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 EXPECT_TRUE(model()->IsVisibleAt(i)); | 92 EXPECT_TRUE(model()->IsVisibleAt(i)); |
| 90 } | 93 } |
| 91 } | 94 } |
| 92 | 95 |
| 93 #if defined(GOOGLE_CHROME_BUILD) | 96 #if defined(GOOGLE_CHROME_BUILD) |
| 94 // Tests whether the cloud services item is correctly toggled. This menu item | 97 // Tests whether the cloud services item is correctly toggled. This menu item |
| 95 // is only availble on official Chrome builds. | 98 // is only availble on official Chrome builds. |
| 96 TEST_F(MediaRouterContextualMenuUnitTest, ToggleCloudServicesItem) { | 99 TEST_F(MediaRouterContextualMenuUnitTest, ToggleCloudServicesItem) { |
| 97 // The Media Router Action has a getter for the model, but not the delegate. | 100 // The Media Router Action has a getter for the model, but not the delegate. |
| 98 // Create the MediaRouterContextualMenu ui::SimpleMenuModel::Delegate here. | 101 // Create the MediaRouterContextualMenu ui::SimpleMenuModel::Delegate here. |
| 99 MediaRouterContextualMenu menu(browser()); | 102 MediaRouterContextualMenu menu(browser(), action()); |
|
imcheng
2016/09/16 21:47:49
Could you add a test for the new option?
takumif
2016/09/20 14:50:46
Added a test.
| |
| 100 | 103 |
| 101 // Set up an authenticated account such that the cloud services menu item is | 104 // 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. | 105 // surfaced. Whether or not it is surfaced is tested in the "Basic" test. |
| 103 signin_manager()->SetAuthenticatedAccountInfo("foo@bar.com", "password"); | 106 signin_manager()->SetAuthenticatedAccountInfo("foo@bar.com", "password"); |
| 104 | 107 |
| 105 // By default, the command is not checked. | 108 // By default, the command is not checked. |
| 106 EXPECT_FALSE(menu.IsCommandIdChecked( | 109 EXPECT_FALSE(menu.IsCommandIdChecked( |
| 107 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); | 110 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); |
| 108 | 111 |
| 109 menu.ExecuteCommand(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE, 0); | 112 menu.ExecuteCommand(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE, 0); |
| 110 EXPECT_TRUE(menu.IsCommandIdChecked( | 113 EXPECT_TRUE(menu.IsCommandIdChecked( |
| 111 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); | 114 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); |
| 112 | 115 |
| 113 menu.ExecuteCommand(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE, 0); | 116 menu.ExecuteCommand(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE, 0); |
| 114 EXPECT_FALSE(menu.IsCommandIdChecked( | 117 EXPECT_FALSE(menu.IsCommandIdChecked( |
| 115 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); | 118 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); |
| 116 } | 119 } |
| 117 #endif // GOOGLE_CHROME_BUILD | 120 #endif // GOOGLE_CHROME_BUILD |
| OLD | NEW |