Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Unified Diff: ash/test/launcher_view_test_api.cc

Issue 10068027: ash: Fix launcher icon overlaps with status. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/test/launcher_view_test_api.h ('k') | ui/views/animation/bounds_animator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/test/launcher_view_test_api.cc
diff --git a/ash/test/launcher_view_test_api.cc b/ash/test/launcher_view_test_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3dc45bffa28897e93315f1fb0c526e1ee917919f
--- /dev/null
+++ b/ash/test/launcher_view_test_api.cc
@@ -0,0 +1,83 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/test/launcher_view_test_api.h"
+
+#include "ash/launcher/launcher_button.h"
+#include "ash/launcher/launcher_view.h"
+#include "base/message_loop.h"
+#include "ui/views/animation/bounds_animator.h"
+#include "ui/views/controls/button/image_button.h"
+#include "ui/views/view_model.h"
+
+namespace {
+
+// A class used to wait for animations.
+class TestAPIAnimationObserver : public views::BoundsAnimatorObserver {
+ public:
+ TestAPIAnimationObserver() {}
+ virtual ~TestAPIAnimationObserver() {}
+
+ // views::BoundsAnimatorObserver overrides:
+ virtual void OnBoundsAnimatorDone(views::BoundsAnimator* animator) OVERRIDE {
+ MessageLoop::current()->Quit();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TestAPIAnimationObserver);
+};
+
+} // namespace
+
+namespace ash {
+namespace test {
+
+LauncherViewTestAPI::LauncherViewTestAPI(internal::LauncherView* launcher_view)
+ : launcher_view_(launcher_view) {
+}
+
+LauncherViewTestAPI::~LauncherViewTestAPI() {
+}
+
+int LauncherViewTestAPI::GetButtonCount() {
+ return launcher_view_->view_model_->view_size();
+}
+
+internal::LauncherButton* LauncherViewTestAPI::GetButton(int index) {
+ // App list button is not a LauncherButton.
+ if (index == GetButtonCount() - 1)
+ return NULL;
+
+ return static_cast<internal::LauncherButton*>(
+ launcher_view_->view_model_->view_at(index));
+}
+
+int LauncherViewTestAPI::GetLastVisibleIndex() {
+ return launcher_view_->last_visible_index_;
+}
+
+bool LauncherViewTestAPI::IsOverflowButtonVisible() {
+ return launcher_view_->overflow_button_->visible();
+}
+
+void LauncherViewTestAPI::SetAnimationDuration(int duration_ms) {
+ launcher_view_->bounds_animator_->SetAnimationDuration(duration_ms);
+}
+
+void LauncherViewTestAPI::RunMessageLoopUntilAnimationsDone() {
+ if (!launcher_view_->bounds_animator_->IsAnimating())
+ return;
+
+ scoped_ptr<TestAPIAnimationObserver> observer(new TestAPIAnimationObserver());
+ launcher_view_->bounds_animator_->AddObserver(observer.get());
+
+ // This nested loop will quit when TestAPIAnimationObserver's
+ // OnBoundsAnimatorDone is called.
+ MessageLoop::current()->Run();
+
+ launcher_view_->bounds_animator_->RemoveObserver(observer.get());
+}
+
+} // namespace test
+} // namespace ash
« no previous file with comments | « ash/test/launcher_view_test_api.h ('k') | ui/views/animation/bounds_animator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698