OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/launcher/launcher_view.h" | 5 #include "ash/launcher/launcher_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/launcher/launcher.h" | 10 #include "ash/launcher/launcher.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
25 #include "base/compiler_specific.h" | 25 #include "base/compiler_specific.h" |
26 #include "base/memory/scoped_ptr.h" | 26 #include "base/memory/scoped_ptr.h" |
27 #include "grit/ash_resources.h" | 27 #include "grit/ash_resources.h" |
28 #include "ui/aura/root_window.h" | 28 #include "ui/aura/root_window.h" |
29 #include "ui/aura/test/aura_test_base.h" | 29 #include "ui/aura/test/aura_test_base.h" |
30 #include "ui/aura/window.h" | 30 #include "ui/aura/window.h" |
31 #include "ui/base/events/event.h" | 31 #include "ui/base/events/event.h" |
32 #include "ui/base/events/event_constants.h" | 32 #include "ui/base/events/event_constants.h" |
33 #include "ui/compositor/layer.h" | 33 #include "ui/compositor/layer.h" |
| 34 #include "ui/views/view_model.h" |
34 #include "ui/views/widget/widget.h" | 35 #include "ui/views/widget/widget.h" |
35 #include "ui/views/widget/widget_delegate.h" | 36 #include "ui/views/widget/widget_delegate.h" |
36 | 37 |
37 namespace { | 38 namespace { |
38 const int kExpectedAppIndex = 1; | 39 const int kExpectedAppIndex = 1; |
39 } | 40 } |
40 | 41 |
41 namespace ash { | 42 namespace ash { |
42 namespace test { | 43 namespace test { |
43 | 44 |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 371 |
371 LauncherModel* model_; | 372 LauncherModel* model_; |
372 internal::LauncherView* launcher_view_; | 373 internal::LauncherView* launcher_view_; |
373 | 374 |
374 scoped_ptr<LauncherViewTestAPI> test_api_; | 375 scoped_ptr<LauncherViewTestAPI> test_api_; |
375 | 376 |
376 private: | 377 private: |
377 DISALLOW_COPY_AND_ASSIGN(LauncherViewTest); | 378 DISALLOW_COPY_AND_ASSIGN(LauncherViewTest); |
378 }; | 379 }; |
379 | 380 |
| 381 class LauncherViewRTLTest : public LauncherViewTest { |
| 382 public: |
| 383 LauncherViewRTLTest() {} |
| 384 virtual ~LauncherViewRTLTest() {} |
| 385 |
| 386 virtual void SetUp() OVERRIDE { |
| 387 base::i18n::SetICUDefaultLocale("ar"); |
| 388 LauncherViewTest::SetUp(); |
| 389 ASSERT_TRUE(base::i18n::IsRTL()); |
| 390 } |
| 391 |
| 392 private: |
| 393 DISALLOW_COPY_AND_ASSIGN(LauncherViewRTLTest); |
| 394 }; |
| 395 |
| 396 // Checks that the ideal item icon bounds match the view's bounds in the screen. |
| 397 TEST_F(LauncherViewTest, IdealBoundsOfItemIcon) { |
| 398 LauncherID id = AddTabbedBrowser(); |
| 399 internal::LauncherButton* button = GetButtonByID(id); |
| 400 gfx::Rect item_bounds = button->GetBoundsInScreen(); |
| 401 gfx::Rect ideal_bounds = launcher_view_->GetIdealBoundsOfItemIcon(id); |
| 402 gfx::Point screen_origin; |
| 403 views::View::ConvertPointToScreen(launcher_view_, &screen_origin); |
| 404 ideal_bounds.Offset(screen_origin.x(), screen_origin.y()); |
| 405 EXPECT_EQ(item_bounds.x(), ideal_bounds.x()); |
| 406 EXPECT_EQ(item_bounds.y(), ideal_bounds.y()); |
| 407 } |
| 408 |
| 409 // Checks that the ideal item icon bounds are correct in RTL. |
| 410 TEST_F(LauncherViewRTLTest, IdealBoundsOfItemIcon) { |
| 411 LauncherID id = AddTabbedBrowser(); |
| 412 internal::LauncherButton* button = GetButtonByID(id); |
| 413 gfx::Rect item_bounds = button->GetBoundsInScreen(); |
| 414 gfx::Rect ideal_bounds = launcher_view_->GetIdealBoundsOfItemIcon(id); |
| 415 gfx::Point screen_origin; |
| 416 views::View::ConvertPointToScreen(launcher_view_, &screen_origin); |
| 417 ideal_bounds.Offset(screen_origin.x(), screen_origin.y()); |
| 418 EXPECT_EQ(item_bounds.x(), ideal_bounds.x()); |
| 419 EXPECT_EQ(item_bounds.y(), ideal_bounds.y()); |
| 420 } |
| 421 |
380 // Checks that the icon positions do not shift with a state change. | 422 // Checks that the icon positions do not shift with a state change. |
381 TEST_F(LauncherViewTest, NoStateChangeIconMovement) { | 423 TEST_F(LauncherViewTest, NoStateChangeIconMovement) { |
382 LauncherID last_added = AddAppShortcut(); | 424 LauncherID last_added = AddAppShortcut(); |
383 internal::LauncherButton* button = GetButtonByID(last_added); | 425 internal::LauncherButton* button = GetButtonByID(last_added); |
384 EXPECT_EQ(button->state(), ash::internal::LauncherButton::STATE_NORMAL); | 426 EXPECT_EQ(button->state(), ash::internal::LauncherButton::STATE_NORMAL); |
385 gfx::Rect old_bounds = button->GetIconBounds(); | 427 gfx::Rect old_bounds = button->GetIconBounds(); |
386 | 428 |
387 button->AddState(ash::internal::LauncherButton::STATE_HOVERED); | 429 button->AddState(ash::internal::LauncherButton::STATE_HOVERED); |
388 gfx::Rect hovered_bounds = button->GetIconBounds(); | 430 gfx::Rect hovered_bounds = button->GetIconBounds(); |
389 EXPECT_EQ(old_bounds.ToString(), hovered_bounds.ToString()); | 431 EXPECT_EQ(old_bounds.ToString(), hovered_bounds.ToString()); |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 // All buttons should be visible. | 948 // All buttons should be visible. |
907 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, | 949 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, |
908 test_api_->GetButtonCount()); | 950 test_api_->GetButtonCount()); |
909 gfx::Rect ideal_bounds_0 = test_api_->GetIdealBoundsByIndex(0); | 951 gfx::Rect ideal_bounds_0 = test_api_->GetIdealBoundsByIndex(0); |
910 gfx::Rect ideal_bounds_1 = test_api_->GetIdealBoundsByIndex(1); | 952 gfx::Rect ideal_bounds_1 = test_api_->GetIdealBoundsByIndex(1); |
911 EXPECT_GT(ideal_bounds_0.width(), ideal_bounds_1.width()); | 953 EXPECT_GT(ideal_bounds_0.width(), ideal_bounds_1.width()); |
912 } | 954 } |
913 | 955 |
914 } // namespace test | 956 } // namespace test |
915 } // namespace ash | 957 } // namespace ash |
OLD | NEW |