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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 signin_manager()->SetAuthenticatedAccountInfo("foo@bar.com", "password"); | 82 signin_manager()->SetAuthenticatedAccountInfo("foo@bar.com", "password"); |
83 | 83 |
84 // Run the same checks as before. All existing menu items should be now | 84 // Run the same checks as before. All existing menu items should be now |
85 // enabled and visible. | 85 // enabled and visible. |
86 EXPECT_EQ(model()->GetItemCount(), expected_number_items); | 86 EXPECT_EQ(model()->GetItemCount(), expected_number_items); |
87 for (int i = 0; i < expected_number_items; i++) { | 87 for (int i = 0; i < expected_number_items; i++) { |
88 EXPECT_TRUE(model()->IsEnabledAt(i)); | 88 EXPECT_TRUE(model()->IsEnabledAt(i)); |
89 EXPECT_TRUE(model()->IsVisibleAt(i)); | 89 EXPECT_TRUE(model()->IsVisibleAt(i)); |
90 } | 90 } |
91 } | 91 } |
92 | |
93 #if defined(GOOGLE_CHROME_BUILD) | |
94 // Tests whether the cloud services item is correctly toggled. This menu item | |
95 // is only availble on official Chrome builds. | |
96 TEST_F(MediaRouterContextualMenuUnitTest, ToggleCloudServicesItem) { | |
97 // The Media Router Action has a getter for the model, but not the delegate. | |
98 // Create the MediaRouterContextualMenu ui::SimpleMenuModel::Delegate here. | |
99 MediaRouterContextualMenu menu(browser()); | |
100 | |
101 // 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 signin_manager()->SetAuthenticatedAccountInfo("foo@bar.com", "password"); | |
104 | |
105 // By default, the command is not checked. | |
106 EXPECT_FALSE(menu.IsCommandIdChecked( | |
107 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); | |
108 | |
109 menu.ExecuteCommand(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE, 0); | |
110 EXPECT_TRUE(menu.IsCommandIdChecked( | |
111 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); | |
112 | |
113 menu.ExecuteCommand(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE, 0); | |
114 EXPECT_FALSE(menu.IsCommandIdChecked( | |
115 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); | |
116 } | |
117 #endif // GOOGLE_CHROME_BUILD | |
OLD | NEW |