Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/ui/toolbar/browser_actions_bar_browsertest.h" | 5 #include "chrome/browser/ui/toolbar/browser_actions_bar_browsertest.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions()); | 250 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions()); |
| 251 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(0)); | 251 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(0)); |
| 252 | 252 |
| 253 // Enable A. State becomes: A, B, C. | 253 // Enable A. State becomes: A, B, C. |
| 254 EnableExtension(extension_a()->id()); | 254 EnableExtension(extension_a()->id()); |
| 255 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions()); | 255 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions()); |
| 256 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions()); | 256 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions()); |
| 257 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0)); | 257 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0)); |
| 258 | 258 |
| 259 // Shrink the browser actions bar to zero visible icons. | 259 // Shrink the browser actions bar to zero visible icons. |
| 260 // No icons should be visible, but we *should* show the chevron and have a | |
| 261 // non-empty size. | |
| 262 toolbar_model()->SetVisibleIconCount(0); | 260 toolbar_model()->SetVisibleIconCount(0); |
| 263 EXPECT_EQ(0, browser_actions_bar()->VisibleBrowserActions()); | 261 EXPECT_EQ(0, browser_actions_bar()->VisibleBrowserActions()); |
| 264 EXPECT_TRUE(browser_actions_bar()->IsChevronShowing()); | |
| 265 | 262 |
| 266 // Reset visibility count to 2. State should be A, B, [C], and the chevron | 263 // Reset visibility count to 2. State should be A, B, [C]. |
| 267 // should be visible. | |
| 268 toolbar_model()->SetVisibleIconCount(2); | 264 toolbar_model()->SetVisibleIconCount(2); |
| 269 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions()); | 265 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions()); |
| 270 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0)); | 266 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0)); |
| 271 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1)); | 267 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1)); |
| 272 EXPECT_TRUE(browser_actions_bar()->IsChevronShowing()); | |
| 273 | |
| 274 // Disable C (the overflowed extension). State should now be A, B, and the | |
| 275 // chevron should be hidden. | |
| 276 DisableExtension(extension_c()->id()); | |
| 277 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions()); | |
| 278 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0)); | |
| 279 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1)); | |
| 280 EXPECT_FALSE(browser_actions_bar()->IsChevronShowing()); | |
|
Devlin
2016/05/11 00:01:02
Instead of removing these pieces, can you do:
Tool
Evan Stade
2016/05/11 21:05:35
yes
| |
| 281 | |
| 282 // Re-enable C. We should still only have 2 visible icons, and the chevron | |
| 283 // should be visible. | |
| 284 EnableExtension(extension_c()->id()); | |
| 285 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions()); | |
| 286 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0)); | |
| 287 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1)); | |
| 288 EXPECT_TRUE(browser_actions_bar()->IsChevronShowing()); | |
| 289 } | 268 } |
| 290 | 269 |
| 291 // Test that, with the toolbar action redesign, actions that want to run have | 270 // Test that, with the toolbar action redesign, actions that want to run have |
| 292 // the proper appearance. | 271 // the proper appearance. |
| 293 IN_PROC_BROWSER_TEST_F(BrowserActionsBarRedesignBrowserTest, | 272 IN_PROC_BROWSER_TEST_F(BrowserActionsBarRedesignBrowserTest, |
| 294 TestUiForActionsWantToRun) { | 273 TestUiForActionsWantToRun) { |
| 295 LoadExtensions(); | 274 LoadExtensions(); |
| 296 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions()); | 275 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions()); |
| 297 | 276 |
| 298 // Load an extension with a page action. | 277 // Load an extension with a page action. |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 546 EXPECT_EQ(page_action_extension->id(), | 525 EXPECT_EQ(page_action_extension->id(), |
| 547 browser_actions_bar()->GetExtensionId(0)); | 526 browser_actions_bar()->GetExtensionId(0)); |
| 548 browser_actions_bar()->Press(0); | 527 browser_actions_bar()->Press(0); |
| 549 base::RunLoop().RunUntilIdle(); | 528 base::RunLoop().RunUntilIdle(); |
| 550 EXPECT_TRUE(browser_actions_bar()->HasPopup()); | 529 EXPECT_TRUE(browser_actions_bar()->HasPopup()); |
| 551 // Cleanup the popup (to avoid having windows open at tear down). | 530 // Cleanup the popup (to avoid having windows open at tear down). |
| 552 browser_actions_bar()->HidePopup(); | 531 browser_actions_bar()->HidePopup(); |
| 553 content::RunAllBlockingPoolTasksUntilIdle(); | 532 content::RunAllBlockingPoolTasksUntilIdle(); |
| 554 EXPECT_FALSE(browser_actions_bar()->HasPopup()); | 533 EXPECT_FALSE(browser_actions_bar()->HasPopup()); |
| 555 } | 534 } |
| OLD | NEW |