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/common/wm/panels/panel_layout_manager.h" | 5 #include "ash/common/wm/panels/panel_layout_manager.h" |
6 | 6 |
7 #include "ash/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
8 #include "ash/common/ash_switches.h" | 8 #include "ash/common/ash_switches.h" |
9 #include "ash/common/display/display_info.h" | |
9 #include "ash/common/shelf/shelf_button.h" | 10 #include "ash/common/shelf/shelf_button.h" |
10 #include "ash/common/shelf/shelf_model.h" | 11 #include "ash/common/shelf/shelf_model.h" |
11 #include "ash/common/shelf/shelf_types.h" | 12 #include "ash/common/shelf/shelf_types.h" |
12 #include "ash/common/shelf/shelf_view.h" | 13 #include "ash/common/shelf/shelf_view.h" |
13 #include "ash/common/shell_window_ids.h" | 14 #include "ash/common/shell_window_ids.h" |
14 #include "ash/common/system/web_notification/web_notification_tray.h" | 15 #include "ash/common/system/web_notification/web_notification_tray.h" |
15 #include "ash/common/wm/mru_window_tracker.h" | 16 #include "ash/common/wm/mru_window_tracker.h" |
16 #include "ash/common/wm/window_state.h" | 17 #include "ash/common/wm/window_state.h" |
17 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
19 #include "ash/display/display_manager.h" | |
18 #include "ash/screen_util.h" | 20 #include "ash/screen_util.h" |
19 #include "ash/shelf/shelf.h" | 21 #include "ash/shelf/shelf.h" |
20 #include "ash/shelf/shelf_layout_manager.h" | 22 #include "ash/shelf/shelf_layout_manager.h" |
21 #include "ash/shelf/shelf_util.h" | 23 #include "ash/shelf/shelf_util.h" |
22 #include "ash/shelf/shelf_widget.h" | 24 #include "ash/shelf/shelf_widget.h" |
23 #include "ash/shell.h" | 25 #include "ash/shell.h" |
24 #include "ash/test/ash_test_base.h" | 26 #include "ash/test/ash_test_base.h" |
25 #include "ash/test/shelf_test_api.h" | 27 #include "ash/test/shelf_test_api.h" |
26 #include "ash/test/shelf_view_test_api.h" | 28 #include "ash/test/shelf_view_test_api.h" |
27 #include "ash/test/test_shelf_delegate.h" | 29 #include "ash/test/test_shelf_delegate.h" |
28 #include "ash/wm/window_state_aura.h" | 30 #include "ash/wm/window_state_aura.h" |
29 #include "ash/wm/window_util.h" | 31 #include "ash/wm/window_util.h" |
30 #include "base/command_line.h" | 32 #include "base/command_line.h" |
31 #include "base/compiler_specific.h" | 33 #include "base/compiler_specific.h" |
32 #include "base/i18n/rtl.h" | 34 #include "base/i18n/rtl.h" |
33 #include "base/run_loop.h" | 35 #include "base/run_loop.h" |
36 #include "base/strings/string_number_conversions.h" | |
34 #include "ui/aura/client/aura_constants.h" | 37 #include "ui/aura/client/aura_constants.h" |
35 #include "ui/aura/test/test_windows.h" | 38 #include "ui/aura/test/test_windows.h" |
36 #include "ui/aura/window.h" | 39 #include "ui/aura/window.h" |
37 #include "ui/aura/window_event_dispatcher.h" | 40 #include "ui/aura/window_event_dispatcher.h" |
38 #include "ui/events/event_utils.h" | 41 #include "ui/events/event_utils.h" |
39 #include "ui/events/test/event_generator.h" | 42 #include "ui/events/test/event_generator.h" |
40 #include "ui/views/widget/widget.h" | 43 #include "ui/views/widget/widget.h" |
41 | 44 |
42 namespace ash { | 45 namespace ash { |
43 | 46 |
47 namespace { | |
48 | |
49 std::string ToDisplayName(int64_t id) { | |
50 return "x-" + base::Int64ToString(id); | |
51 } | |
52 | |
53 DisplayInfo CreateDisplayInfo(int64_t id, const gfx::Rect& bounds) { | |
54 DisplayInfo info(id, ToDisplayName(id), false); | |
55 info.SetBounds(bounds); | |
56 return info; | |
57 } | |
58 | |
59 DisplayManager* display_manager() { | |
60 return Shell::GetInstance()->display_manager(); | |
61 } | |
62 | |
63 } // namespace | |
64 | |
44 using aura::test::WindowIsAbove; | 65 using aura::test::WindowIsAbove; |
45 | 66 |
46 class PanelLayoutManagerTest : public test::AshTestBase { | 67 class PanelLayoutManagerTest : public test::AshTestBase { |
47 public: | 68 public: |
48 PanelLayoutManagerTest() {} | 69 PanelLayoutManagerTest() {} |
49 ~PanelLayoutManagerTest() override {} | 70 ~PanelLayoutManagerTest() override {} |
50 | 71 |
51 void SetUp() override { | 72 void SetUp() override { |
52 test::AshTestBase::SetUp(); | 73 test::AshTestBase::SetUp(); |
53 ASSERT_TRUE(test::TestShelfDelegate::instance()); | 74 ASSERT_TRUE(test::TestShelfDelegate::instance()); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 | 299 |
279 // Tests that a created panel window is above the shelf icon in LTR and RTL. | 300 // Tests that a created panel window is above the shelf icon in LTR and RTL. |
280 TEST_P(PanelLayoutManagerTextDirectionTest, AddOnePanel) { | 301 TEST_P(PanelLayoutManagerTextDirectionTest, AddOnePanel) { |
281 gfx::Rect bounds(0, 0, 201, 201); | 302 gfx::Rect bounds(0, 0, 201, 201); |
282 std::unique_ptr<aura::Window> window(CreatePanelWindow(bounds)); | 303 std::unique_ptr<aura::Window> window(CreatePanelWindow(bounds)); |
283 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); | 304 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); |
284 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); | 305 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); |
285 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get())); | 306 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get())); |
286 } | 307 } |
287 | 308 |
309 // Tests for crashes during undocking. | |
310 // See https://crbug.com/632755 | |
311 TEST_F(PanelLayoutManagerTest, UndockTest) { | |
312 std::vector<DisplayInfo> info_list; | |
313 | |
314 // Create the primary display info. | |
315 DisplayInfo primary_display = | |
316 CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 720)); | |
317 // Create the secondary external display info. This will be docked display. | |
318 DisplayInfo external_display_info = | |
319 CreateDisplayInfo(2, gfx::Rect(0, 0, 1920, 1080)); | |
320 | |
321 info_list.push_back(external_display_info); | |
322 // Docked state. | |
323 display_manager()->OnNativeDisplaysChanged(info_list); | |
324 | |
325 // Create a panel in the docked state | |
326 std::unique_ptr<aura::Window> p1_d2( | |
327 CreatePanelWindow(gfx::Rect(1555, 800, 50, 50))); | |
328 | |
329 info_list.clear(); | |
330 info_list.push_back(primary_display); | |
331 | |
332 // Undock and bring back the native device display as primary display. | |
333 display_manager()->OnNativeDisplaysChanged(info_list); | |
334 } | |
335 | |
336 // Tests for any crash during docking and then undocking. | |
337 // See https://crbug.com/632755 | |
338 TEST_F(PanelLayoutManagerTest, DockUndockTest) { | |
339 std::vector<DisplayInfo> info_list; | |
340 | |
341 // Create the primary display info. | |
342 DisplayInfo primary_display = | |
343 CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 720)); | |
oshima
2016/08/17 23:24:42
can you make this internal display?
const int64_t
| |
344 | |
345 info_list.push_back(primary_display); | |
346 display_manager()->OnNativeDisplaysChanged(info_list); | |
347 | |
348 // Create a panel in the undocked state. | |
349 std::unique_ptr<aura::Window> p1_d2( | |
350 CreatePanelWindow(gfx::Rect(600, 200, 50, 50))); | |
351 | |
352 // Create the secondary external display info. This will be docked display. | |
353 DisplayInfo external_display_info = | |
354 CreateDisplayInfo(2, gfx::Rect(0, 0, 1920, 1080)); | |
355 | |
356 info_list.push_back(external_display_info); | |
357 // Adding external Display | |
358 display_manager()->OnNativeDisplaysChanged(info_list); | |
359 | |
360 info_list.clear(); | |
361 info_list.push_back(external_display_info); | |
362 | |
363 // Docked state. | |
364 display_manager()->OnNativeDisplaysChanged(info_list); | |
365 | |
366 info_list.clear(); | |
367 info_list.push_back(primary_display); | |
368 | |
369 // Undock and bring back the native device display as primary display. | |
370 display_manager()->OnNativeDisplaysChanged(info_list); | |
371 } | |
372 | |
288 // Tests that a created panel window is successfully aligned over a hidden | 373 // Tests that a created panel window is successfully aligned over a hidden |
289 // shelf icon. | 374 // shelf icon. |
290 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIcon) { | 375 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIcon) { |
291 gfx::Rect bounds(0, 0, 201, 201); | 376 gfx::Rect bounds(0, 0, 201, 201); |
292 SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(), | 377 SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(), |
293 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 378 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
294 std::unique_ptr<aura::Window> normal_window(CreateNormalWindow(bounds)); | 379 std::unique_ptr<aura::Window> normal_window(CreateNormalWindow(bounds)); |
295 std::unique_ptr<aura::Window> window(CreatePanelWindow(bounds)); | 380 std::unique_ptr<aura::Window> window(CreatePanelWindow(bounds)); |
296 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); | 381 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); |
297 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); | 382 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
819 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); | 904 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); |
820 target = targeter->FindTargetForEvent(root, &touch); | 905 target = targeter->FindTargetForEvent(root, &touch); |
821 EXPECT_NE(w.get(), target); | 906 EXPECT_NE(w.get(), target); |
822 } | 907 } |
823 | 908 |
824 INSTANTIATE_TEST_CASE_P(LtrRtl, | 909 INSTANTIATE_TEST_CASE_P(LtrRtl, |
825 PanelLayoutManagerTextDirectionTest, | 910 PanelLayoutManagerTextDirectionTest, |
826 testing::Bool()); | 911 testing::Bool()); |
827 | 912 |
828 } // namespace ash | 913 } // namespace ash |
OLD | NEW |