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 12 matching lines...) Expand all Loading... |
23 #include "ash/test/test_launcher_delegate.h" | 23 #include "ash/test/test_launcher_delegate.h" |
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/base/l10n/l10n_util.h" |
33 #include "ui/compositor/layer.h" | 34 #include "ui/compositor/layer.h" |
| 35 #include "ui/views/view_model.h" |
34 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
35 #include "ui/views/widget/widget_delegate.h" | 37 #include "ui/views/widget/widget_delegate.h" |
36 | 38 |
37 namespace ash { | 39 namespace ash { |
38 namespace test { | 40 namespace test { |
39 | 41 |
40 //////////////////////////////////////////////////////////////////////////////// | 42 //////////////////////////////////////////////////////////////////////////////// |
41 // LauncherIconObserver tests. | 43 // LauncherIconObserver tests. |
42 | 44 |
43 class TestLauncherIconObserver : public LauncherIconObserver { | 45 class TestLauncherIconObserver : public LauncherIconObserver { |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 | 381 |
380 LauncherModel* model_; | 382 LauncherModel* model_; |
381 internal::LauncherView* launcher_view_; | 383 internal::LauncherView* launcher_view_; |
382 | 384 |
383 scoped_ptr<LauncherViewTestAPI> test_api_; | 385 scoped_ptr<LauncherViewTestAPI> test_api_; |
384 | 386 |
385 private: | 387 private: |
386 DISALLOW_COPY_AND_ASSIGN(LauncherViewTest); | 388 DISALLOW_COPY_AND_ASSIGN(LauncherViewTest); |
387 }; | 389 }; |
388 | 390 |
| 391 class LauncherViewTextDirectionTest |
| 392 : public LauncherViewTest, |
| 393 public testing::WithParamInterface<bool> { |
| 394 public: |
| 395 LauncherViewTextDirectionTest() : is_rtl_(GetParam()) {} |
| 396 virtual ~LauncherViewTextDirectionTest() {} |
| 397 |
| 398 virtual void SetUp() OVERRIDE { |
| 399 LauncherViewTest::SetUp(); |
| 400 original_locale_ = l10n_util::GetApplicationLocale(std::string()); |
| 401 if (is_rtl_) |
| 402 base::i18n::SetICUDefaultLocale("he"); |
| 403 ASSERT_EQ(is_rtl_, base::i18n::IsRTL()); |
| 404 } |
| 405 |
| 406 virtual void TearDown() OVERRIDE { |
| 407 if (is_rtl_) |
| 408 base::i18n::SetICUDefaultLocale(original_locale_); |
| 409 LauncherViewTest::TearDown(); |
| 410 } |
| 411 |
| 412 private: |
| 413 bool is_rtl_; |
| 414 std::string original_locale_; |
| 415 |
| 416 DISALLOW_COPY_AND_ASSIGN(LauncherViewTextDirectionTest); |
| 417 }; |
| 418 |
| 419 // Checks that the ideal item icon bounds match the view's bounds in the screen |
| 420 // in both LTR and RTL. |
| 421 TEST_P(LauncherViewTextDirectionTest, IdealBoundsOfItemIcon) { |
| 422 LauncherID id = AddTabbedBrowser(); |
| 423 internal::LauncherButton* button = GetButtonByID(id); |
| 424 gfx::Rect item_bounds = button->GetBoundsInScreen(); |
| 425 gfx::Point icon_offset = button->GetIconBounds().origin(); |
| 426 item_bounds.Offset(icon_offset.OffsetFromOrigin()); |
| 427 gfx::Rect ideal_bounds = launcher_view_->GetIdealBoundsOfItemIcon(id); |
| 428 gfx::Point screen_origin; |
| 429 views::View::ConvertPointToScreen(launcher_view_, &screen_origin); |
| 430 ideal_bounds.Offset(screen_origin.x(), screen_origin.y()); |
| 431 EXPECT_EQ(item_bounds.x(), ideal_bounds.x()); |
| 432 EXPECT_EQ(item_bounds.y(), ideal_bounds.y()); |
| 433 } |
| 434 |
389 // Adds browser button until overflow and verifies that the last added browser | 435 // Adds browser button until overflow and verifies that the last added browser |
390 // button is hidden. | 436 // button is hidden. |
391 TEST_F(LauncherViewTest, AddBrowserUntilOverflow) { | 437 TEST_F(LauncherViewTest, AddBrowserUntilOverflow) { |
392 // All buttons should be visible. | 438 // All buttons should be visible. |
393 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, | 439 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, |
394 test_api_->GetButtonCount()); | 440 test_api_->GetButtonCount()); |
395 | 441 |
396 // Add tabbed browser until overflow. | 442 // Add tabbed browser until overflow. |
397 int items_added = 0; | 443 int items_added = 0; |
398 LauncherID last_added = AddTabbedBrowser(); | 444 LauncherID last_added = AddTabbedBrowser(); |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 // first pixel and being therefore bigger then the others. | 960 // first pixel and being therefore bigger then the others. |
915 TEST_F(LauncherViewTest, CheckFittsLaw) { | 961 TEST_F(LauncherViewTest, CheckFittsLaw) { |
916 // All buttons should be visible. | 962 // All buttons should be visible. |
917 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, | 963 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, |
918 test_api_->GetButtonCount()); | 964 test_api_->GetButtonCount()); |
919 gfx::Rect ideal_bounds_0 = test_api_->GetIdealBoundsByIndex(0); | 965 gfx::Rect ideal_bounds_0 = test_api_->GetIdealBoundsByIndex(0); |
920 gfx::Rect ideal_bounds_1 = test_api_->GetIdealBoundsByIndex(1); | 966 gfx::Rect ideal_bounds_1 = test_api_->GetIdealBoundsByIndex(1); |
921 EXPECT_GT(ideal_bounds_0.width(), ideal_bounds_1.width()); | 967 EXPECT_GT(ideal_bounds_0.width(), ideal_bounds_1.width()); |
922 } | 968 } |
923 | 969 |
| 970 INSTANTIATE_TEST_CASE_P(LtrRtl, LauncherViewTextDirectionTest, testing::Bool()); |
| 971 |
924 } // namespace test | 972 } // namespace test |
925 } // namespace ash | 973 } // namespace ash |
OLD | NEW |