From 1d212cd0ed055ce7851510c5e750402838053d87 Mon Sep 17 00:00:00 2001 From: "xiyuan@chromium.org" Date: Wed, 25 Apr 2012 02:50:05 +0000 Subject: ash: Fix missing launcher icon regression. The regression is introduced in r133603 where we use opacity to hide newly added view but did not restore it properly on animation cancellation, which happens when adding launcher item before animation finishes. BUG=124855 TEST=Verify fix for issue 124855. Review URL: http://codereview.chromium.org/10169038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133853 0039d316-1c4b-4281-b951-d872f2087c98 --- ash/launcher/launcher_view_unittest.cc | 39 +++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'ash/launcher/launcher_view_unittest.cc') diff --git a/ash/launcher/launcher_view_unittest.cc b/ash/launcher/launcher_view_unittest.cc index 14727dc..38162c5 100644 --- a/ash/launcher/launcher_view_unittest.cc +++ b/ash/launcher/launcher_view_unittest.cc @@ -132,19 +132,24 @@ class LauncherViewTest : public aura::test::AuraTestBase { item.type = TYPE_APP_SHORTCUT; item.status = STATUS_CLOSED; - int id = model_->next_id(); + LauncherID id = model_->next_id(); model_->Add(item); test_api_->RunMessageLoopUntilAnimationsDone(); return id; } - LauncherID AddTabbedBrowser() { + LauncherID AddTabbedBrowserNoWait() { LauncherItem item; item.type = TYPE_TABBED; item.status = STATUS_RUNNING; - int id = model_->next_id(); + LauncherID id = model_->next_id(); model_->Add(item); + return id; + } + + LauncherID AddTabbedBrowser() { + LauncherID id = AddTabbedBrowserNoWait(); test_api_->RunMessageLoopUntilAnimationsDone(); return id; } @@ -255,5 +260,33 @@ TEST_F(LauncherViewTest, RemoveLastOverflowed) { EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); } +// Adds browser button without waiting for animation to finish and verifies +// that all added buttons are visible. +TEST_F(LauncherViewTest, AddButtonQuickly) { + // All buttons should be visible. + ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, + test_api_->GetButtonCount()); + + // Add a few tabbed browser quickly without wait for animation. + int added_count = 0; + while (!test_api_->IsOverflowButtonVisible()) { + AddTabbedBrowserNoWait(); + ++added_count; + } + + // LauncherView should be big enough to hold at least 3 new buttons. + ASSERT_GE(added_count, 3); + + // Wait for the last animation to finish. + test_api_->RunMessageLoopUntilAnimationsDone(); + + // Verifies non-overflow buttons are visible. + for (int i = 0; i <= test_api_->GetLastVisibleIndex(); ++i) { + internal::LauncherButton* button = test_api_->GetButton(i); + EXPECT_TRUE(button->visible()) << "button index=" << i; + EXPECT_EQ(1.0f, button->layer()->opacity()) << "button index=" << i; + } +} + } // namespace test } // namespace ash -- cgit v1.1