OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_window_resizer.h" | 5 #include "ash/wm/panels/panel_window_resizer.h" |
6 | 6 |
7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
8 #include "ash/launcher/launcher_model.h" | 8 #include "ash/launcher/launcher_model.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
11 #include "ash/shelf/shelf_types.h" | 11 #include "ash/shelf/shelf_types.h" |
12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
15 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
16 #include "ash/test/cursor_manager_test_api.h" | 16 #include "ash/test/cursor_manager_test_api.h" |
17 #include "ash/test/shell_test_api.h" | 17 #include "ash/test/shell_test_api.h" |
18 #include "ash/test/test_launcher_delegate.h" | 18 #include "ash/test/test_launcher_delegate.h" |
19 #include "ash/wm/drag_window_resizer.h" | 19 #include "ash/wm/drag_window_resizer.h" |
20 #include "ash/wm/panels/panel_layout_manager.h" | 20 #include "ash/wm/panels/panel_layout_manager.h" |
21 #include "ash/wm/window_properties.h" | 21 #include "ash/wm/window_properties.h" |
22 #include "ui/aura/client/aura_constants.h" | 22 #include "ui/aura/client/aura_constants.h" |
23 #include "ui/aura/root_window.h" | 23 #include "ui/aura/root_window.h" |
24 #include "ui/base/hit_test.h" | 24 #include "ui/base/hit_test.h" |
| 25 #include "ui/base/l10n/l10n_util.h" |
25 #include "ui/base/ui_base_types.h" | 26 #include "ui/base/ui_base_types.h" |
26 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
27 | 28 |
28 namespace ash { | 29 namespace ash { |
29 namespace internal { | 30 namespace internal { |
30 | 31 |
31 class PanelWindowResizerTest : public test::AshTestBase { | 32 class PanelWindowResizerTest : public test::AshTestBase { |
32 public: | 33 public: |
33 PanelWindowResizerTest() {} | 34 PanelWindowResizerTest() {} |
34 virtual ~PanelWindowResizerTest() {} | 35 virtual ~PanelWindowResizerTest() {} |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 } | 188 } |
188 | 189 |
189 private: | 190 private: |
190 scoped_ptr<PanelWindowResizer> resizer_; | 191 scoped_ptr<PanelWindowResizer> resizer_; |
191 internal::PanelLayoutManager* panel_layout_manager_; | 192 internal::PanelLayoutManager* panel_layout_manager_; |
192 LauncherModel* model_; | 193 LauncherModel* model_; |
193 | 194 |
194 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTest); | 195 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTest); |
195 }; | 196 }; |
196 | 197 |
| 198 class PanelWindowResizerTextDirectionTest |
| 199 : public PanelWindowResizerTest, |
| 200 public testing::WithParamInterface<bool> { |
| 201 public: |
| 202 PanelWindowResizerTextDirectionTest() : is_rtl_(GetParam()) {} |
| 203 virtual ~PanelWindowResizerTextDirectionTest() {} |
| 204 |
| 205 virtual void SetUp() OVERRIDE { |
| 206 original_locale = l10n_util::GetApplicationLocale(std::string()); |
| 207 if (is_rtl_) |
| 208 base::i18n::SetICUDefaultLocale("he"); |
| 209 PanelWindowResizerTest::SetUp(); |
| 210 ASSERT_EQ(is_rtl_, base::i18n::IsRTL()); |
| 211 } |
| 212 |
| 213 virtual void TearDown() OVERRIDE { |
| 214 if (is_rtl_) |
| 215 base::i18n::SetICUDefaultLocale(original_locale); |
| 216 PanelWindowResizerTest::TearDown(); |
| 217 } |
| 218 |
| 219 private: |
| 220 bool is_rtl_; |
| 221 std::string original_locale; |
| 222 |
| 223 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTextDirectionTest); |
| 224 }; |
| 225 |
197 // Verifies a window can be dragged from the panel and detached and then | 226 // Verifies a window can be dragged from the panel and detached and then |
198 // reattached. | 227 // reattached. |
199 TEST_F(PanelWindowResizerTest, PanelDetachReattachBottom) { | 228 TEST_F(PanelWindowResizerTest, PanelDetachReattachBottom) { |
200 scoped_ptr<aura::Window> window( | 229 scoped_ptr<aura::Window> window( |
201 CreatePanelWindow(gfx::Rect(0, 0, 201, 201))); | 230 CreatePanelWindow(gfx::Rect(0, 0, 201, 201))); |
202 DetachReattachTest(window.get(), 0, -1); | 231 DetachReattachTest(window.get(), 0, -1); |
203 } | 232 } |
204 | 233 |
205 TEST_F(PanelWindowResizerTest, PanelDetachReattachLeft) { | 234 TEST_F(PanelWindowResizerTest, PanelDetachReattachLeft) { |
206 ash::Shell* shell = ash::Shell::GetInstance(); | 235 ash::Shell* shell = ash::Shell::GetInstance(); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 DragStart(window.get()); | 433 DragStart(window.get()); |
405 DragMove(20, 0); | 434 DragMove(20, 0); |
406 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 435 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); |
407 DragEnd(); | 436 DragEnd(); |
408 | 437 |
409 // When dropped it should return to the default container. | 438 // When dropped it should return to the default container. |
410 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer, | 439 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer, |
411 window->parent()->id()); | 440 window->parent()->id()); |
412 } | 441 } |
413 | 442 |
414 TEST_F(PanelWindowResizerTest, DragReordersPanelsHorizontal) { | 443 TEST_P(PanelWindowResizerTextDirectionTest, DragReordersPanelsHorizontal) { |
415 DragAlongShelfReorder(-1, 0); | 444 DragAlongShelfReorder(base::i18n::IsRTL() ? 1 : -1, 0); |
416 } | 445 } |
417 | 446 |
418 TEST_F(PanelWindowResizerTest, DragReordersPanelsVertical) { | 447 TEST_F(PanelWindowResizerTest, DragReordersPanelsVertical) { |
419 ash::Shell* shell = ash::Shell::GetInstance(); | 448 ash::Shell* shell = ash::Shell::GetInstance(); |
420 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, shell->GetPrimaryRootWindow()); | 449 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, shell->GetPrimaryRootWindow()); |
421 DragAlongShelfReorder(0, -1); | 450 DragAlongShelfReorder(0, -1); |
422 } | 451 } |
423 | 452 |
| 453 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, |
| 454 testing::Bool()); |
| 455 |
424 } // namespace internal | 456 } // namespace internal |
425 } // namespace ash | 457 } // namespace ash |
OLD | NEW |