| 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/wm/panels/panel_layout_manager.h" | 5 #include "ash/wm/panels/panel_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
| 9 #include "ash/launcher/launcher_button.h" | 9 #include "ash/launcher/launcher_button.h" |
| 10 #include "ash/launcher/launcher_model.h" | 10 #include "ash/launcher/launcher_model.h" |
| 11 #include "ash/launcher/launcher_view.h" | 11 #include "ash/launcher/launcher_view.h" |
| 12 #include "ash/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
| 13 #include "ash/screen_ash.h" | 13 #include "ash/screen_ash.h" |
| 14 #include "ash/shelf/shelf_layout_manager.h" | 14 #include "ash/shelf/shelf_layout_manager.h" |
| 15 #include "ash/shelf/shelf_types.h" | 15 #include "ash/shelf/shelf_types.h" |
| 16 #include "ash/shelf/shelf_widget.h" | 16 #include "ash/shelf/shelf_widget.h" |
| 17 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| 18 #include "ash/shell_window_ids.h" | 18 #include "ash/shell_window_ids.h" |
| 19 #include "ash/test/ash_test_base.h" | 19 #include "ash/test/ash_test_base.h" |
| 20 #include "ash/test/launcher_view_test_api.h" | 20 #include "ash/test/launcher_view_test_api.h" |
| 21 #include "ash/test/shell_test_api.h" | 21 #include "ash/test/shell_test_api.h" |
| 22 #include "ash/test/test_launcher_delegate.h" | 22 #include "ash/test/test_launcher_delegate.h" |
| 23 #include "ash/wm/window_util.h" | 23 #include "ash/wm/window_util.h" |
| 24 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
| 25 #include "base/command_line.h" | 25 #include "base/command_line.h" |
| 26 #include "base/compiler_specific.h" | 26 #include "base/compiler_specific.h" |
| 27 #include "base/i18n/rtl.h" |
| 27 #include "base/run_loop.h" | 28 #include "base/run_loop.h" |
| 28 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
| 29 #include "ui/aura/root_window.h" | 30 #include "ui/aura/root_window.h" |
| 30 #include "ui/aura/test/event_generator.h" | 31 #include "ui/aura/test/event_generator.h" |
| 31 #include "ui/aura/test/test_windows.h" | 32 #include "ui/aura/test/test_windows.h" |
| 32 #include "ui/aura/window.h" | 33 #include "ui/aura/window.h" |
| 34 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/views/corewm/corewm_switches.h" | 35 #include "ui/views/corewm/corewm_switches.h" |
| 34 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
| 35 | 37 |
| 36 namespace ash { | 38 namespace ash { |
| 37 namespace internal { | 39 namespace internal { |
| 38 | 40 |
| 39 using aura::test::WindowIsAbove; | 41 using aura::test::WindowIsAbove; |
| 40 | 42 |
| 41 class PanelLayoutManagerTest : public test::AshTestBase { | 43 class PanelLayoutManagerTest : public test::AshTestBase { |
| 42 public: | 44 public: |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 scoped_ptr<test::LauncherViewTestAPI> launcher_view_test_; | 263 scoped_ptr<test::LauncherViewTestAPI> launcher_view_test_; |
| 262 | 264 |
| 263 bool IsHorizontal(ShelfAlignment alignment) { | 265 bool IsHorizontal(ShelfAlignment alignment) { |
| 264 return alignment == SHELF_ALIGNMENT_BOTTOM || | 266 return alignment == SHELF_ALIGNMENT_BOTTOM || |
| 265 alignment == SHELF_ALIGNMENT_TOP; | 267 alignment == SHELF_ALIGNMENT_TOP; |
| 266 } | 268 } |
| 267 | 269 |
| 268 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTest); | 270 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTest); |
| 269 }; | 271 }; |
| 270 | 272 |
| 271 // Tests that a created panel window is successfully added to the panel | 273 class PanelLayoutManagerTextDirectionTest |
| 272 // layout manager. | 274 : public PanelLayoutManagerTest, |
| 273 TEST_F(PanelLayoutManagerTest, AddOnePanel) { | 275 public testing::WithParamInterface<bool> { |
| 276 public: |
| 277 PanelLayoutManagerTextDirectionTest() : is_rtl_(GetParam()) {} |
| 278 virtual ~PanelLayoutManagerTextDirectionTest() {} |
| 279 |
| 280 virtual void SetUp() OVERRIDE { |
| 281 original_locale = l10n_util::GetApplicationLocale(std::string()); |
| 282 if (is_rtl_) |
| 283 base::i18n::SetICUDefaultLocale("he"); |
| 284 PanelLayoutManagerTest::SetUp(); |
| 285 ASSERT_EQ(is_rtl_, base::i18n::IsRTL()); |
| 286 } |
| 287 |
| 288 virtual void TearDown() OVERRIDE { |
| 289 if (is_rtl_) |
| 290 base::i18n::SetICUDefaultLocale(original_locale); |
| 291 PanelLayoutManagerTest::TearDown(); |
| 292 } |
| 293 |
| 294 private: |
| 295 bool is_rtl_; |
| 296 std::string original_locale; |
| 297 |
| 298 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTextDirectionTest); |
| 299 }; |
| 300 |
| 301 // Tests that a created panel window is above the launcher icon in LTR and RTL. |
| 302 TEST_P(PanelLayoutManagerTextDirectionTest, AddOnePanel) { |
| 274 gfx::Rect bounds(0, 0, 201, 201); | 303 gfx::Rect bounds(0, 0, 201, 201); |
| 275 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); | 304 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); |
| 276 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); | 305 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); |
| 277 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); | 306 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); |
| 307 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get())); |
| 278 } | 308 } |
| 279 | 309 |
| 280 // Tests that a created panel window is successfully aligned over a hidden | 310 // Tests that a created panel window is successfully aligned over a hidden |
| 281 // launcher icon. | 311 // launcher icon. |
| 282 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIcon) { | 312 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIcon) { |
| 283 gfx::Rect bounds(0, 0, 201, 201); | 313 gfx::Rect bounds(0, 0, 201, 201); |
| 284 SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(), | 314 SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(), |
| 285 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 315 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 286 RunAllPendingInMessageLoop(); | 316 RunAllPendingInMessageLoop(); |
| 287 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); | 317 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 | 705 |
| 676 SetShelfVisibilityState(Shell::GetPrimaryRootWindow(), SHELF_VISIBLE); | 706 SetShelfVisibilityState(Shell::GetPrimaryRootWindow(), SHELF_VISIBLE); |
| 677 RunAllPendingInMessageLoop(); | 707 RunAllPendingInMessageLoop(); |
| 678 | 708 |
| 679 // Windows should be restored to their prior state. | 709 // Windows should be restored to their prior state. |
| 680 EXPECT_TRUE(w1->IsVisible()); | 710 EXPECT_TRUE(w1->IsVisible()); |
| 681 EXPECT_FALSE(w2->IsVisible()); | 711 EXPECT_FALSE(w2->IsVisible()); |
| 682 EXPECT_TRUE(w3->IsVisible()); | 712 EXPECT_TRUE(w3->IsVisible()); |
| 683 } | 713 } |
| 684 | 714 |
| 715 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, |
| 716 testing::Bool()); |
| 717 |
| 685 } // namespace internal | 718 } // namespace internal |
| 686 } // namespace ash | 719 } // namespace ash |
| OLD | NEW |