| Index: ash/launcher/launcher_view_unittest.cc
|
| diff --git a/ash/launcher/launcher_view_unittest.cc b/ash/launcher/launcher_view_unittest.cc
|
| index 468e8f90084654723b5192595bddfa11253627b6..7b776b593975031ca342d7120629129a3f8fe4d5 100644
|
| --- a/ash/launcher/launcher_view_unittest.cc
|
| +++ b/ash/launcher/launcher_view_unittest.cc
|
| @@ -220,6 +220,12 @@ class LauncherViewTest : public AshTestBase {
|
| return id;
|
| }
|
|
|
| + LauncherID AddPanel() {
|
| + LauncherID id = AddPanelNoWait();
|
| + test_api_->RunMessageLoopUntilAnimationsDone();
|
| + return id;
|
| + }
|
| +
|
| LauncherID AddPlatformAppNoWait() {
|
| LauncherItem item;
|
| item.type = TYPE_PLATFORM_APP;
|
| @@ -230,6 +236,16 @@ class LauncherViewTest : public AshTestBase {
|
| return id;
|
| }
|
|
|
| + LauncherID AddPanelNoWait() {
|
| + LauncherItem item;
|
| + item.type = TYPE_APP_PANEL;
|
| + item.status = STATUS_RUNNING;
|
| +
|
| + LauncherID id = model_->next_id();
|
| + model_->Add(item);
|
| + return id;
|
| + }
|
| +
|
| LauncherID AddPlatformApp() {
|
| LauncherID id = AddPlatformAppNoWait();
|
| test_api_->RunMessageLoopUntilAnimationsDone();
|
| @@ -333,12 +349,15 @@ TEST_F(LauncherViewTest, AddBrowserUntilOverflow) {
|
| test_api_->GetButtonCount());
|
|
|
| // Add tabbed browser until overflow.
|
| + int items_added = 0;
|
| LauncherID last_added = AddTabbedBrowser();
|
| while (!test_api_->IsOverflowButtonVisible()) {
|
| // Added button is visible after animation while in this loop.
|
| EXPECT_TRUE(GetButtonByID(last_added)->visible());
|
|
|
| last_added = AddTabbedBrowser();
|
| + ++items_added;
|
| + ASSERT_LT(items_added, 10000);
|
| }
|
|
|
| // The last added button should be invisible.
|
| @@ -356,12 +375,15 @@ TEST_F(LauncherViewTest, AddAppShortcutWithBrowserButtonUntilOverflow) {
|
| LauncherID browser_button_id = AddTabbedBrowser();
|
|
|
| // Add app shortcut until overflow.
|
| + int items_added = 0;
|
| LauncherID last_added = AddAppShortcut();
|
| while (!test_api_->IsOverflowButtonVisible()) {
|
| // Added button is visible after animation while in this loop.
|
| EXPECT_TRUE(GetButtonByID(last_added)->visible());
|
|
|
| last_added = AddAppShortcut();
|
| + ++items_added;
|
| + ASSERT_LT(items_added, 10000);
|
| }
|
|
|
| // The last added app short button should be visible.
|
| @@ -370,6 +392,58 @@ TEST_F(LauncherViewTest, AddAppShortcutWithBrowserButtonUntilOverflow) {
|
| EXPECT_FALSE(GetButtonByID(browser_button_id)->visible());
|
| }
|
|
|
| +TEST_F(LauncherViewTest, AddPanelHidesTabbedBrowser) {
|
| + ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1,
|
| + test_api_->GetButtonCount());
|
| +
|
| + // Add tabbed browser until overflow, remember last visible tabbed browser.
|
| + int items_added = 0;
|
| + LauncherID first_added = AddTabbedBrowser();
|
| + EXPECT_TRUE(GetButtonByID(first_added)->visible());
|
| + LauncherID last_visible = first_added;
|
| + while (true) {
|
| + LauncherID added = AddTabbedBrowser();
|
| + if (test_api_->IsOverflowButtonVisible()) {
|
| + EXPECT_FALSE(GetButtonByID(added)->visible());
|
| + break;
|
| + }
|
| + last_visible = added;
|
| + ++items_added;
|
| + ASSERT_LT(items_added, 10000);
|
| + }
|
| +
|
| + LauncherID panel = AddPanel();
|
| + EXPECT_TRUE(GetButtonByID(panel)->visible());
|
| + EXPECT_FALSE(GetButtonByID(last_visible)->visible());
|
| +
|
| + RemoveByID(panel);
|
| + EXPECT_TRUE(GetButtonByID(last_visible)->visible());
|
| +}
|
| +
|
| +TEST_F(LauncherViewTest, PanelsHideLast) {
|
| + ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1,
|
| + test_api_->GetButtonCount());
|
| +
|
| + // Add tabbed browser.
|
| + LauncherID browser = AddTabbedBrowser();
|
| + LauncherID first_panel = AddPanel();
|
| +
|
| + EXPECT_TRUE(GetButtonByID(browser)->visible());
|
| + EXPECT_TRUE(GetButtonByID(first_panel)->visible());
|
| +
|
| + LauncherID last_panel = first_panel;
|
| + int items_added = 0;
|
| + while (!test_api_->IsOverflowButtonVisible()) {
|
| + last_panel = AddPanel();
|
| + ++items_added;
|
| + ASSERT_LT(items_added, 10000);
|
| + }
|
| +
|
| + EXPECT_TRUE(GetButtonByID(last_panel)->visible());
|
| + EXPECT_TRUE(GetButtonByID(first_panel)->visible());
|
| + EXPECT_FALSE(GetButtonByID(browser)->visible());
|
| +}
|
| +
|
| // Adds button until overflow then removes first added one. Verifies that
|
| // the last added one changes from invisible to visible and overflow
|
| // chevron is gone.
|
| @@ -379,10 +453,14 @@ TEST_F(LauncherViewTest, RemoveButtonRevealsOverflowed) {
|
| test_api_->GetButtonCount());
|
|
|
| // Add tabbed browser until overflow.
|
| - LauncherID first_added= AddTabbedBrowser();
|
| + int items_added = 0;
|
| + LauncherID first_added = AddTabbedBrowser();
|
| LauncherID last_added = first_added;
|
| - while (!test_api_->IsOverflowButtonVisible())
|
| + while (!test_api_->IsOverflowButtonVisible()) {
|
| last_added = AddTabbedBrowser();
|
| + ++items_added;
|
| + ASSERT_LT(items_added, 10000);
|
| + }
|
|
|
| // Expect add more than 1 button. First added is visible and last is not.
|
| EXPECT_NE(first_added, last_added);
|
| @@ -405,9 +483,13 @@ TEST_F(LauncherViewTest, RemoveLastOverflowed) {
|
| test_api_->GetButtonCount());
|
|
|
| // Add tabbed browser until overflow.
|
| - LauncherID last_added= AddTabbedBrowser();
|
| - while (!test_api_->IsOverflowButtonVisible())
|
| + int items_added = 0;
|
| + LauncherID last_added = AddTabbedBrowser();
|
| + while (!test_api_->IsOverflowButtonVisible()) {
|
| last_added = AddTabbedBrowser();
|
| + ++items_added;
|
| + ASSERT_LT(items_added, 10000);
|
| + }
|
|
|
| RemoveByID(last_added);
|
| EXPECT_FALSE(test_api_->IsOverflowButtonVisible());
|
| @@ -425,6 +507,7 @@ TEST_F(LauncherViewTest, AddButtonQuickly) {
|
| while (!test_api_->IsOverflowButtonVisible()) {
|
| AddTabbedBrowserNoWait();
|
| ++added_count;
|
| + ASSERT_LT(added_count, 10000);
|
| }
|
|
|
| // LauncherView should be big enough to hold at least 3 new buttons.
|
| @@ -702,10 +785,13 @@ TEST_F(LauncherViewTest, ResizeDuringOverflowAddAnimation) {
|
|
|
| // Add buttons until overflow. Let the non-overflow add animations finish but
|
| // leave the last running.
|
| + int items_added = 0;
|
| AddTabbedBrowserNoWait();
|
| while (!test_api_->IsOverflowButtonVisible()) {
|
| test_api_->RunMessageLoopUntilAnimationsDone();
|
| AddTabbedBrowserNoWait();
|
| + ++items_added;
|
| + ASSERT_LT(items_added, 10000);
|
| }
|
|
|
| // Resize launcher view with that animation running and stay overflown.
|
|
|