summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-30 00:15:52 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-30 00:15:52 +0000
commit5f9a4b0893a4898bcb7c28751bc02b4f210f630c (patch)
tree9b65634a393483900c395a2ecdbb2e4ba08bc02d
parent0d6dcd1f6ccb4a9f01b143744dd802ec81a482b6 (diff)
downloadchromium_src-5f9a4b0893a4898bcb7c28751bc02b4f210f630c.zip
chromium_src-5f9a4b0893a4898bcb7c28751bc02b4f210f630c.tar.gz
chromium_src-5f9a4b0893a4898bcb7c28751bc02b4f210f630c.tar.bz2
ash: Fix app list icon off position.
BUG=135198 TEST=Starting with an overflown launcher bar and verify app list button is at the right position. Also covered by a new test. Review URL: https://chromiumcodereview.appspot.com/10704043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145038 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/launcher/launcher_view.cc7
-rw-r--r--ash/launcher/launcher_view_unittest.cc36
-rw-r--r--ash/test/launcher_view_test_api.cc8
-rw-r--r--ash/test/launcher_view_test_api.h8
4 files changed, 57 insertions, 2 deletions
diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc
index d5112c2..ff1e992 100644
--- a/ash/launcher/launcher_view.cc
+++ b/ash/launcher/launcher_view.cc
@@ -379,7 +379,12 @@ View* LauncherView::GetFocusTraversableParentView() {
void LauncherView::LayoutToIdealBounds() {
IdealBounds ideal_bounds;
CalculateIdealBounds(&ideal_bounds);
- views::ViewModelUtils::SetViewBoundsToIdealBounds(*view_model_);
+
+ if (bounds_animator_->IsAnimating())
+ AnimateToIdealBounds();
+ else
+ views::ViewModelUtils::SetViewBoundsToIdealBounds(*view_model_);
+
overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds);
}
diff --git a/ash/launcher/launcher_view_unittest.cc b/ash/launcher/launcher_view_unittest.cc
index 556c99d..fb34c33 100644
--- a/ash/launcher/launcher_view_unittest.cc
+++ b/ash/launcher/launcher_view_unittest.cc
@@ -583,10 +583,44 @@ TEST_F(LauncherViewTest, ShouldHideTooltipTest) {
EXPECT_TRUE(launcher_view_->ShouldHideTooltip(
gfx::Point(all_area.x() - 1, all_area.y())));
EXPECT_TRUE(launcher_view_->ShouldHideTooltip(
- gfx::Point(all_area.x(), all_area.y() - 1 )));
+ gfx::Point(all_area.x(), all_area.y() - 1)));
EXPECT_TRUE(launcher_view_->ShouldHideTooltip(
gfx::Point(all_area.x(), all_area.bottom())));
}
+// Resizing launcher view while an add animation without fade-in is running,
+// which happens when overflow happens. App list button should end up in its
+// new ideal bounds.
+TEST_F(LauncherViewTest, ResizeDuringOverflowAddAnimation) {
+ // All buttons should be visible.
+ ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1,
+ test_api_->GetButtonCount());
+
+ // Add buttons until overflow. Let the non-overflow add animations finish but
+ // leave the last running.
+ AddTabbedBrowserNoWait();
+ while (!test_api_->IsOverflowButtonVisible()) {
+ test_api_->RunMessageLoopUntilAnimationsDone();
+ AddTabbedBrowserNoWait();
+ }
+
+ // Resize launcher view with that animation running and stay overflown.
+ gfx::Rect bounds = launcher_view_->bounds();
+ bounds.set_width(bounds.width() - kLauncherPreferredSize);
+ launcher_view_->SetBoundsRect(bounds);
+ ASSERT_TRUE(test_api_->IsOverflowButtonVisible());
+
+ // Finish the animation.
+ test_api_->RunMessageLoopUntilAnimationsDone();
+
+ // App list button should ends up in its new ideal bounds.
+ const int app_list_button_index = test_api_->GetButtonCount() - 1;
+ const gfx::Rect& app_list_ideal_bounds =
+ test_api_->GetIdealBoundsByIndex(app_list_button_index);
+ const gfx::Rect& app_list_bounds =
+ test_api_->GetBoundsByIndex(app_list_button_index);
+ EXPECT_EQ(app_list_bounds, app_list_ideal_bounds);
+}
+
} // namespace test
} // namespace ash
diff --git a/ash/test/launcher_view_test_api.cc b/ash/test/launcher_view_test_api.cc
index 0f8893b..7237196 100644
--- a/ash/test/launcher_view_test_api.cc
+++ b/ash/test/launcher_view_test_api.cc
@@ -63,6 +63,14 @@ bool LauncherViewTestAPI::IsOverflowButtonVisible() {
return launcher_view_->overflow_button_->visible();
}
+const gfx::Rect& LauncherViewTestAPI::GetBoundsByIndex(int index) {
+ return launcher_view_->view_model_->view_at(index)->bounds();
+}
+
+const gfx::Rect& LauncherViewTestAPI::GetIdealBoundsByIndex(int index) {
+ return launcher_view_->view_model_->ideal_bounds(index);
+}
+
void LauncherViewTestAPI::SetAnimationDuration(int duration_ms) {
launcher_view_->bounds_animator_->SetAnimationDuration(duration_ms);
}
diff --git a/ash/test/launcher_view_test_api.h b/ash/test/launcher_view_test_api.h
index 651e2a0..41e74db 100644
--- a/ash/test/launcher_view_test_api.h
+++ b/ash/test/launcher_view_test_api.h
@@ -8,6 +8,10 @@
#include "base/basictypes.h"
+namespace gfx {
+class Rect;
+}
+
namespace ash {
namespace internal {
@@ -32,6 +36,10 @@ class LauncherViewTestAPI {
// Last visible button index.
int GetLastVisibleIndex();
+ // Gets current/ideal bounds for button at |index|.
+ const gfx::Rect& GetBoundsByIndex(int index);
+ const gfx::Rect& GetIdealBoundsByIndex(int index);
+
// Returns true if overflow button is visible.
bool IsOverflowButtonVisible();