1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/toolbar/browser_actions_bar_browsertest.h"
7 #include "base/run_loop.h"
8 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
9 #include "chrome/browser/extensions/browser_action_test_util.h"
10 #include "chrome/browser/extensions/extension_action.h"
11 #include "chrome/browser/extensions/extension_action_manager.h"
12 #include "chrome/browser/extensions/extension_action_test_util.h"
13 #include "chrome/browser/extensions/extension_browsertest.h"
14 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/sessions/session_tab_helper.h"
16 #include "chrome/browser/ui/extensions/extension_action_view_controller.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
19 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
20 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
21 #include "components/crx_file/id_util.h"
22 #include "content/public/browser/notification_service.h"
23 #include "content/public/test/test_utils.h"
24 #include "extensions/browser/extension_prefs.h"
25 #include "extensions/browser/extension_registry.h"
26 #include "extensions/browser/notification_types.h"
27 #include "extensions/common/extension.h"
28 #include "extensions/common/extension_builder.h"
29 #include "extensions/common/value_builder.h"
30 #include "extensions/test/extension_test_message_listener.h"
34 scoped_refptr
<const extensions::Extension
> CreateExtension(
35 const std::string
& name
,
36 bool has_browser_action
) {
37 extensions::DictionaryBuilder manifest
;
38 manifest
.Set("name", name
).
39 Set("description", "an extension").
40 Set("manifest_version", 2).
41 Set("version", "1.0");
42 if (has_browser_action
)
43 manifest
.Set("browser_action", extensions::DictionaryBuilder().Pass());
44 return extensions::ExtensionBuilder().
45 SetManifest(manifest
.Pass()).
46 SetID(crx_file::id_util::GenerateId(name
)).
52 // BrowserActionsBarBrowserTest:
54 BrowserActionsBarBrowserTest::BrowserActionsBarBrowserTest()
55 : toolbar_model_(nullptr) {
58 BrowserActionsBarBrowserTest::~BrowserActionsBarBrowserTest() {
61 void BrowserActionsBarBrowserTest::SetUpCommandLine(
62 base::CommandLine
* command_line
) {
63 ToolbarActionsBar::disable_animations_for_testing_
= true;
64 ExtensionBrowserTest::SetUpCommandLine(command_line
);
67 void BrowserActionsBarBrowserTest::SetUpOnMainThread() {
68 ExtensionBrowserTest::SetUpOnMainThread();
69 browser_actions_bar_
.reset(new BrowserActionTestUtil(browser()));
70 toolbar_model_
= ToolbarActionsModel::Get(profile());
73 void BrowserActionsBarBrowserTest::TearDownOnMainThread() {
74 ToolbarActionsBar::disable_animations_for_testing_
= false;
75 ExtensionBrowserTest::TearDownOnMainThread();
78 void BrowserActionsBarBrowserTest::LoadExtensions() {
79 // Create three extensions with browser actions.
80 extension_a_
= CreateExtension("alpha", true);
81 extension_b_
= CreateExtension("beta", true);
82 extension_c_
= CreateExtension("gamma", true);
84 const extensions::Extension
* extensions
[] =
85 { extension_a(), extension_b(), extension_c() };
86 extensions::ExtensionRegistry
* registry
=
87 extensions::ExtensionRegistry::Get(profile());
88 // Add each, and verify that it is both correctly added to the extension
89 // registry and to the browser actions container.
90 for (size_t i
= 0; i
< arraysize(extensions
); ++i
) {
91 extension_service()->AddExtension(extensions
[i
]);
92 EXPECT_TRUE(registry
->enabled_extensions().GetByID(extensions
[i
]->id())) <<
93 extensions
[i
]->name();
94 EXPECT_EQ(static_cast<int>(i
+ 1),
95 browser_actions_bar_
->NumberOfBrowserActions());
96 EXPECT_TRUE(browser_actions_bar_
->HasIcon(i
));
97 EXPECT_EQ(static_cast<int>(i
+ 1),
98 browser_actions_bar()->VisibleBrowserActions());
102 // BrowserActionsBarRedesignBrowserTest:
104 BrowserActionsBarRedesignBrowserTest::BrowserActionsBarRedesignBrowserTest() {
107 BrowserActionsBarRedesignBrowserTest::~BrowserActionsBarRedesignBrowserTest() {
110 void BrowserActionsBarRedesignBrowserTest::SetUpCommandLine(
111 base::CommandLine
* command_line
) {
112 BrowserActionsBarBrowserTest::SetUpCommandLine(command_line
);
113 enable_redesign_
.reset(new extensions::FeatureSwitch::ScopedOverride(
114 extensions::FeatureSwitch::extension_action_redesign(),
118 // Test the basic functionality.
119 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest
, Basic
) {
120 // Load an extension with no browser action.
121 extension_service()->AddExtension(CreateExtension("alpha", false).get());
122 // This extension should not be in the model (has no browser action).
123 EXPECT_EQ(0, browser_actions_bar()->NumberOfBrowserActions());
125 // Load an extension with a browser action.
126 extension_service()->AddExtension(CreateExtension("beta", true).get());
127 EXPECT_EQ(1, browser_actions_bar()->NumberOfBrowserActions());
128 EXPECT_TRUE(browser_actions_bar()->HasIcon(0));
130 // Unload the extension.
131 std::string id
= browser_actions_bar()->GetExtensionId(0);
133 EXPECT_EQ(0, browser_actions_bar()->NumberOfBrowserActions());
136 // Test moving various browser actions. This is not to check the logic of the
137 // move (that's in the toolbar model tests), but just to check our ui.
138 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest
, MoveBrowserActions
) {
141 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions());
142 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions());
144 // Order is now A B C.
145 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0));
146 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1));
147 EXPECT_EQ(extension_c()->id(), browser_actions_bar()->GetExtensionId(2));
149 // Move C to first position. Order is C A B.
150 toolbar_model()->MoveActionIcon(extension_c()->id(), 0);
151 EXPECT_EQ(extension_c()->id(), browser_actions_bar()->GetExtensionId(0));
152 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(1));
153 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(2));
155 // Move B to third position. Order is still C A B.
156 toolbar_model()->MoveActionIcon(extension_b()->id(), 2);
157 EXPECT_EQ(extension_c()->id(), browser_actions_bar()->GetExtensionId(0));
158 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(1));
159 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(2));
161 // Move B to middle position. Order is C B A.
162 toolbar_model()->MoveActionIcon(extension_b()->id(), 1);
163 EXPECT_EQ(extension_c()->id(), browser_actions_bar()->GetExtensionId(0));
164 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1));
165 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(2));
168 // Test that explicitly hiding an extension action results in it disappearing
169 // from the browser actions bar.
170 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest
, ForceHide
) {
173 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions());
174 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0));
175 // Force hide one of the extensions' browser action.
176 extensions::ExtensionActionAPI::Get(browser()->profile())->
177 SetBrowserActionVisibility(extension_a()->id(), false);
178 // The browser action for Extension A should be removed.
179 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions());
180 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(0));
183 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest
, Visibility
) {
186 // Change container to show only one action, rest in overflow: A, [B, C].
187 toolbar_model()->SetVisibleIconCount(1);
188 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
190 // Disable extension A (should disappear). State becomes: B [C].
191 DisableExtension(extension_a()->id());
192 EXPECT_EQ(2, browser_actions_bar()->NumberOfBrowserActions());
193 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
194 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(0));
196 // Enable A again. A should get its spot in the same location and the bar
197 // should not grow (chevron is showing). For details: http://crbug.com/35349.
198 // State becomes: A, [B, C].
199 EnableExtension(extension_a()->id());
200 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions());
201 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
202 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0));
204 // Disable C (in overflow). State becomes: A, [B].
205 DisableExtension(extension_c()->id());
206 EXPECT_EQ(2, browser_actions_bar()->NumberOfBrowserActions());
207 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
208 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0));
210 // Enable C again. State becomes: A, [B, C].
211 EnableExtension(extension_c()->id());
212 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions());
213 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
214 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0));
216 // Now we have 3 extensions. Make sure they are all visible. State: A, B, C.
217 toolbar_model()->SetVisibleIconCount(3);
218 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions());
220 // Disable extension A (should disappear). State becomes: B, C.
221 DisableExtension(extension_a()->id());
222 EXPECT_EQ(2, browser_actions_bar()->NumberOfBrowserActions());
223 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions());
224 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(0));
226 // Disable extension B (should disappear). State becomes: C.
227 DisableExtension(extension_b()->id());
228 EXPECT_EQ(1, browser_actions_bar()->NumberOfBrowserActions());
229 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
230 EXPECT_EQ(extension_c()->id(), browser_actions_bar()->GetExtensionId(0));
232 // Enable B. State becomes: B, C.
233 EnableExtension(extension_b()->id());
234 EXPECT_EQ(2, browser_actions_bar()->NumberOfBrowserActions());
235 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions());
236 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(0));
238 // Enable A. State becomes: A, B, C.
239 EnableExtension(extension_a()->id());
240 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions());
241 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions());
242 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0));
244 // Shrink the browser actions bar to zero visible icons.
245 // No icons should be visible, but we *should* show the chevron and have a
247 toolbar_model()->SetVisibleIconCount(0);
248 EXPECT_EQ(0, browser_actions_bar()->VisibleBrowserActions());
249 EXPECT_TRUE(browser_actions_bar()->IsChevronShowing());
251 // Reset visibility count to 2. State should be A, B, [C], and the chevron
252 // should be visible.
253 toolbar_model()->SetVisibleIconCount(2);
254 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions());
255 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0));
256 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1));
257 EXPECT_TRUE(browser_actions_bar()->IsChevronShowing());
259 // Disable C (the overflowed extension). State should now be A, B, and the
260 // chevron should be hidden.
261 DisableExtension(extension_c()->id());
262 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions());
263 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0));
264 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1));
265 EXPECT_FALSE(browser_actions_bar()->IsChevronShowing());
267 // Re-enable C. We should still only have 2 visible icons, and the chevron
268 // should be visible.
269 EnableExtension(extension_c()->id());
270 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions());
271 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0));
272 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1));
273 EXPECT_TRUE(browser_actions_bar()->IsChevronShowing());
276 // Test that, with the toolbar action redesign, actions that want to run have
277 // the proper appearance.
278 IN_PROC_BROWSER_TEST_F(BrowserActionsBarRedesignBrowserTest
,
279 TestUiForActionsWantToRun
) {
281 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions());
283 // Load an extension with a page action.
284 scoped_refptr
<const extensions::Extension
> page_action_extension
=
285 extensions::extension_action_test_util::CreateActionExtension(
286 "page action", extensions::extension_action_test_util::PAGE_ACTION
);
287 extension_service()->AddExtension(page_action_extension
.get());
289 // Verify that the extension was added at the last index.
290 EXPECT_EQ(4, browser_actions_bar()->VisibleBrowserActions());
291 EXPECT_EQ(page_action_extension
->id(),
292 browser_actions_bar()->GetExtensionId(3));
293 EXPECT_FALSE(browser_actions_bar()->ActionButtonWantsToRun(3));
295 // Make the extension want to run on the current page.
296 ExtensionAction
* action
= extensions::ExtensionActionManager::Get(profile())->
297 GetExtensionAction(*page_action_extension
);
299 content::WebContents
* web_contents
=
300 browser()->tab_strip_model()->GetActiveWebContents();
301 int tab_id
= SessionTabHelper::IdForTab(web_contents
);
302 action
->SetIsVisible(tab_id
, true);
303 extensions::ExtensionActionAPI
* extension_action_api
=
304 extensions::ExtensionActionAPI::Get(profile());
305 extension_action_api
->NotifyChange(action
, web_contents
, profile());
306 // Verify that the extension's button has the proper UI.
307 EXPECT_TRUE(browser_actions_bar()->ActionButtonWantsToRun(3));
309 // Make the extension not want to run, and check that the special UI goes
311 action
->SetIsVisible(tab_id
, false);
312 extension_action_api
->NotifyChange(action
, web_contents
, profile());
313 EXPECT_FALSE(browser_actions_bar()->ActionButtonWantsToRun(3));
315 // Reduce the visible icon count so that the extension is hidden.
316 toolbar_model()->SetVisibleIconCount(3);
318 // The extension should want to run whether or not it's hidden.
319 action
->SetIsVisible(tab_id
, true);
320 extension_action_api
->NotifyChange(action
, web_contents
, profile());
321 EXPECT_TRUE(browser_actions_bar()->ActionButtonWantsToRun(3));
324 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest
,
325 BrowserActionPopupTest
) {
326 // Load up two extensions that have browser action popups.
327 base::FilePath data_dir
=
328 test_data_dir_
.AppendASCII("api_test").AppendASCII("browser_action");
329 const extensions::Extension
* first_extension
=
330 LoadExtension(data_dir
.AppendASCII("open_popup"));
331 ASSERT_TRUE(first_extension
);
332 const extensions::Extension
* second_extension
=
333 LoadExtension(data_dir
.AppendASCII("remove_popup"));
334 ASSERT_TRUE(second_extension
);
336 // Verify state: two actions, in the order of [first, second].
337 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions());
338 EXPECT_EQ(first_extension
->id(), browser_actions_bar()->GetExtensionId(0));
339 EXPECT_EQ(second_extension
->id(), browser_actions_bar()->GetExtensionId(1));
341 // Do a little piping to get at the underlying ExtensionActionViewControllers.
342 ToolbarActionsBar
* toolbar_actions_bar
=
343 browser_actions_bar()->GetToolbarActionsBar();
344 const std::vector
<ToolbarActionViewController
*>& toolbar_actions
=
345 toolbar_actions_bar
->GetActions();
346 ASSERT_EQ(2u, toolbar_actions
.size());
347 EXPECT_EQ(first_extension
->id(), toolbar_actions
[0]->GetId());
348 EXPECT_EQ(second_extension
->id(), toolbar_actions
[1]->GetId());
349 ExtensionActionViewController
* first_controller
=
350 static_cast<ExtensionActionViewController
*>(toolbar_actions
[0]);
351 ExtensionActionViewController
* second_controller
=
352 static_cast<ExtensionActionViewController
*>(toolbar_actions
[1]);
354 // Neither should yet be showing a popup.
355 EXPECT_FALSE(browser_actions_bar()->HasPopup());
356 EXPECT_FALSE(first_controller
->is_showing_popup());
357 EXPECT_FALSE(second_controller
->is_showing_popup());
359 // Click on the first extension's browser action. This should open a popup.
360 browser_actions_bar()->Press(0);
361 EXPECT_TRUE(browser_actions_bar()->HasPopup());
362 EXPECT_TRUE(first_controller
->is_showing_popup());
363 EXPECT_FALSE(second_controller
->is_showing_popup());
366 content::WindowedNotificationObserver
observer(
367 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED
,
368 content::NotificationService::AllSources());
369 // Clicking on the second extension's browser action should open the
370 // second's popup. Since we only allow one extension popup at a time, this
371 // should also close the first popup.
372 browser_actions_bar()->Press(1);
373 // Closing an extension popup isn't always synchronous; wait for a
376 EXPECT_TRUE(browser_actions_bar()->HasPopup());
377 EXPECT_FALSE(first_controller
->is_showing_popup());
378 EXPECT_TRUE(second_controller
->is_showing_popup());
382 // Clicking on the second extension's browser action a second time should
383 // result in closing the popup.
384 content::WindowedNotificationObserver
observer(
385 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED
,
386 content::NotificationService::AllSources());
387 browser_actions_bar()->Press(1);
389 EXPECT_FALSE(browser_actions_bar()->HasPopup());
390 EXPECT_FALSE(first_controller
->is_showing_popup());
391 EXPECT_FALSE(second_controller
->is_showing_popup());
395 IN_PROC_BROWSER_TEST_F(BrowserActionsBarRedesignBrowserTest
,
396 OverflowedBrowserActionPopupTest
) {
397 scoped_ptr
<BrowserActionTestUtil
> overflow_bar
=
398 browser_actions_bar()->CreateOverflowBar();
400 // Load up two extensions that have browser action popups.
401 base::FilePath data_dir
=
402 test_data_dir_
.AppendASCII("api_test").AppendASCII("browser_action");
403 const extensions::Extension
* first_extension
=
404 LoadExtension(data_dir
.AppendASCII("open_popup"));
405 ASSERT_TRUE(first_extension
);
406 const extensions::Extension
* second_extension
=
407 LoadExtension(data_dir
.AppendASCII("remove_popup"));
408 ASSERT_TRUE(second_extension
);
410 // Verify state: two actions, in the order of [first, second].
411 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions());
412 EXPECT_EQ(first_extension
->id(), browser_actions_bar()->GetExtensionId(0));
413 EXPECT_EQ(second_extension
->id(), browser_actions_bar()->GetExtensionId(1));
415 // Do a little piping to get at the underlying ExtensionActionViewControllers.
416 ToolbarActionsBar
* main_tab
= browser_actions_bar()->GetToolbarActionsBar();
417 std::vector
<ToolbarActionViewController
*> toolbar_actions
=
418 main_tab
->GetActions();
419 ASSERT_EQ(2u, toolbar_actions
.size());
420 EXPECT_EQ(first_extension
->id(), toolbar_actions
[0]->GetId());
421 EXPECT_EQ(second_extension
->id(), toolbar_actions
[1]->GetId());
422 ExtensionActionViewController
* first_controller_main
=
423 static_cast<ExtensionActionViewController
*>(toolbar_actions
[0]);
424 ExtensionActionViewController
* second_controller_main
=
425 static_cast<ExtensionActionViewController
*>(toolbar_actions
[1]);
427 ToolbarActionsBar
* overflow_tab
= overflow_bar
->GetToolbarActionsBar();
428 toolbar_actions
= overflow_tab
->GetActions();
429 ExtensionActionViewController
* second_controller_overflow
=
430 static_cast<ExtensionActionViewController
*>(toolbar_actions
[1]);
432 toolbar_model()->SetVisibleIconCount(0);
434 EXPECT_EQ(0, browser_actions_bar()->VisibleBrowserActions());
435 EXPECT_EQ(2, overflow_bar
->VisibleBrowserActions());
437 // Neither should yet be showing a popup.
438 EXPECT_FALSE(browser_actions_bar()->HasPopup());
439 EXPECT_FALSE(second_controller_main
->is_showing_popup());
440 EXPECT_FALSE(second_controller_overflow
->is_showing_popup());
442 // Click on the first extension's browser action. This should open a popup.
443 overflow_bar
->Press(1);
444 base::RunLoop().RunUntilIdle();
445 EXPECT_TRUE(browser_actions_bar()->HasPopup());
446 EXPECT_FALSE(overflow_bar
->HasPopup());
447 EXPECT_TRUE(second_controller_main
->is_showing_popup());
448 EXPECT_FALSE(second_controller_overflow
->is_showing_popup());
450 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
451 EXPECT_EQ(1u, main_tab
->GetIconCount());
452 EXPECT_EQ(second_controller_main
->GetId(),
453 browser_actions_bar()->GetExtensionId(0));
454 EXPECT_EQ(2, overflow_bar
->VisibleBrowserActions());
455 EXPECT_EQ(2u, overflow_tab
->GetIconCount());
456 EXPECT_EQ(first_controller_main
->GetId(),
457 overflow_bar
->GetExtensionId(0));
460 content::WindowedNotificationObserver
observer(
461 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED
,
462 content::NotificationService::AllSources());
463 second_controller_main
->HidePopup();
467 EXPECT_FALSE(browser_actions_bar()->HasPopup());
468 EXPECT_FALSE(overflow_bar
->HasPopup());
469 EXPECT_FALSE(second_controller_main
->is_showing_popup());
470 EXPECT_FALSE(second_controller_overflow
->is_showing_popup());
471 EXPECT_EQ(0, browser_actions_bar()->VisibleBrowserActions());
472 EXPECT_EQ(2, overflow_bar
->VisibleBrowserActions());
473 base::RunLoop().RunUntilIdle();
474 EXPECT_EQ(first_controller_main
->GetId(),
475 browser_actions_bar()->GetExtensionId(0));
476 EXPECT_EQ(second_controller_main
->GetId(),
477 browser_actions_bar()->GetExtensionId(1));
480 // Test that page action popups work with the toolbar redesign.
481 IN_PROC_BROWSER_TEST_F(BrowserActionsBarRedesignBrowserTest
,
482 PageActionPopupsTest
) {
483 ExtensionTestMessageListener
listener("ready", false);
484 const extensions::Extension
* page_action_extension
=
485 LoadExtension(test_data_dir_
.AppendASCII("trigger_actions").
486 AppendASCII("page_action_popup"));
487 ASSERT_TRUE(page_action_extension
);
488 listener
.WaitUntilSatisfied();
489 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
490 EXPECT_EQ(page_action_extension
->id(),
491 browser_actions_bar()->GetExtensionId(0));
492 browser_actions_bar()->Press(0);
493 base::RunLoop().RunUntilIdle();
494 EXPECT_TRUE(browser_actions_bar()->HasPopup());
495 // Cleanup the popup (to avoid having windows open at tear down).
496 browser_actions_bar()->HidePopup();
497 content::RunAllBlockingPoolTasksUntilIdle();
498 EXPECT_FALSE(browser_actions_bar()->HasPopup());