| 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/shelf/shelf_button.h" | 8 #include "ash/common/shelf/shelf_button.h" |
| 9 #include "ash/common/shelf/shelf_layout_manager.h" | 9 #include "ash/common/shelf/shelf_layout_manager.h" |
| 10 #include "ash/common/shelf/shelf_model.h" | 10 #include "ash/common/shelf/shelf_model.h" |
| 11 #include "ash/common/shelf/shelf_view.h" | 11 #include "ash/common/shelf/shelf_view.h" |
| 12 #include "ash/common/shelf/shelf_widget.h" | 12 #include "ash/common/shelf/shelf_widget.h" |
| 13 #include "ash/common/shelf/wm_shelf.h" | 13 #include "ash/common/shelf/wm_shelf.h" |
| 14 #include "ash/common/system/web_notification/web_notification_tray.h" | 14 #include "ash/common/system/web_notification/web_notification_tray.h" |
| 15 #include "ash/common/test/test_shelf_delegate.h" | 15 #include "ash/common/test/test_shelf_delegate.h" |
| 16 #include "ash/common/wm/mru_window_tracker.h" | 16 #include "ash/common/wm/mru_window_tracker.h" |
| 17 #include "ash/common/wm/window_state.h" | 17 #include "ash/common/wm/window_state.h" |
| 18 #include "ash/common/wm_root_window_controller.h" | 18 #include "ash/common/wm_root_window_controller.h" |
| 19 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
| 20 #include "ash/common/wm_window_property.h" | 20 #include "ash/common/wm_window_property.h" |
| 21 #include "ash/display/display_manager.h" | |
| 22 #include "ash/public/cpp/shelf_types.h" | 21 #include "ash/public/cpp/shelf_types.h" |
| 23 #include "ash/public/cpp/shell_window_ids.h" | 22 #include "ash/public/cpp/shell_window_ids.h" |
| 24 #include "ash/screen_util.h" | 23 #include "ash/screen_util.h" |
| 25 #include "ash/shell.h" | 24 #include "ash/shell.h" |
| 26 #include "ash/test/ash_test_base.h" | 25 #include "ash/test/ash_test_base.h" |
| 27 #include "ash/test/display_manager_test_api.h" | |
| 28 #include "ash/test/shelf_view_test_api.h" | 26 #include "ash/test/shelf_view_test_api.h" |
| 29 #include "ash/wm/window_state_aura.h" | 27 #include "ash/wm/window_state_aura.h" |
| 30 #include "ash/wm/window_util.h" | 28 #include "ash/wm/window_util.h" |
| 31 #include "base/command_line.h" | 29 #include "base/command_line.h" |
| 32 #include "base/compiler_specific.h" | 30 #include "base/compiler_specific.h" |
| 33 #include "base/i18n/rtl.h" | 31 #include "base/i18n/rtl.h" |
| 34 #include "base/run_loop.h" | 32 #include "base/run_loop.h" |
| 35 #include "base/strings/string_number_conversions.h" | 33 #include "base/strings/string_number_conversions.h" |
| 36 #include "ui/aura/client/aura_constants.h" | 34 #include "ui/aura/client/aura_constants.h" |
| 37 #include "ui/aura/test/test_windows.h" | 35 #include "ui/aura/test/test_windows.h" |
| 38 #include "ui/aura/window.h" | 36 #include "ui/aura/window.h" |
| 39 #include "ui/aura/window_event_dispatcher.h" | 37 #include "ui/aura/window_event_dispatcher.h" |
| 38 #include "ui/display/manager/display_manager.h" |
| 40 #include "ui/display/manager/managed_display_info.h" | 39 #include "ui/display/manager/managed_display_info.h" |
| 40 #include "ui/display/test/display_manager_test_api.h" |
| 41 #include "ui/events/event_utils.h" | 41 #include "ui/events/event_utils.h" |
| 42 #include "ui/events/test/event_generator.h" | 42 #include "ui/events/test/event_generator.h" |
| 43 #include "ui/views/widget/widget.h" | 43 #include "ui/views/widget/widget.h" |
| 44 | 44 |
| 45 namespace ash { | 45 namespace ash { |
| 46 | 46 |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 std::string ToDisplayName(int64_t id) { | 49 std::string ToDisplayName(int64_t id) { |
| 50 return "x-" + base::Int64ToString(id); | 50 return "x-" + base::Int64ToString(id); |
| 51 } | 51 } |
| 52 | 52 |
| 53 display::ManagedDisplayInfo CreateDisplayInfo(int64_t id, | 53 display::ManagedDisplayInfo CreateDisplayInfo(int64_t id, |
| 54 const gfx::Rect& bounds) { | 54 const gfx::Rect& bounds) { |
| 55 display::ManagedDisplayInfo info(id, ToDisplayName(id), false); | 55 display::ManagedDisplayInfo info(id, ToDisplayName(id), false); |
| 56 info.SetBounds(bounds); | 56 info.SetBounds(bounds); |
| 57 return info; | 57 return info; |
| 58 } | 58 } |
| 59 | 59 |
| 60 DisplayManager* display_manager() { | |
| 61 return Shell::GetInstance()->display_manager(); | |
| 62 } | |
| 63 | |
| 64 } // namespace | 60 } // namespace |
| 65 | 61 |
| 66 using aura::test::WindowIsAbove; | 62 using aura::test::WindowIsAbove; |
| 67 | 63 |
| 68 class PanelLayoutManagerTest : public test::AshTestBase { | 64 class PanelLayoutManagerTest : public test::AshTestBase { |
| 69 public: | 65 public: |
| 70 PanelLayoutManagerTest() {} | 66 PanelLayoutManagerTest() {} |
| 71 ~PanelLayoutManagerTest() override {} | 67 ~PanelLayoutManagerTest() override {} |
| 72 | 68 |
| 73 void SetUp() override { | 69 void SetUp() override { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); | 300 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); |
| 305 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get())); | 301 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get())); |
| 306 } | 302 } |
| 307 | 303 |
| 308 // Tests for crashes during undocking. | 304 // Tests for crashes during undocking. |
| 309 // See https://crbug.com/632755 | 305 // See https://crbug.com/632755 |
| 310 TEST_F(PanelLayoutManagerTest, UndockTest) { | 306 TEST_F(PanelLayoutManagerTest, UndockTest) { |
| 311 std::vector<display::ManagedDisplayInfo> info_list; | 307 std::vector<display::ManagedDisplayInfo> info_list; |
| 312 | 308 |
| 313 const int64_t internal_display_id = | 309 const int64_t internal_display_id = |
| 314 test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) | 310 display::test::DisplayManagerTestApi( |
| 311 Shell::GetInstance()->display_manager()) |
| 315 .SetFirstDisplayAsInternalDisplay(); | 312 .SetFirstDisplayAsInternalDisplay(); |
| 316 | 313 |
| 317 // Create the primary display info. | 314 // Create the primary display info. |
| 318 display::ManagedDisplayInfo internal_display = | 315 display::ManagedDisplayInfo internal_display = |
| 319 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 1280, 720)); | 316 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 1280, 720)); |
| 320 // Create the secondary external display info. This will be docked display. | 317 // Create the secondary external display info. This will be docked display. |
| 321 display::ManagedDisplayInfo external_display_info = | 318 display::ManagedDisplayInfo external_display_info = |
| 322 CreateDisplayInfo(2, gfx::Rect(0, 0, 1920, 1080)); | 319 CreateDisplayInfo(2, gfx::Rect(0, 0, 1920, 1080)); |
| 323 | 320 |
| 324 info_list.push_back(external_display_info); | 321 info_list.push_back(external_display_info); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 335 // Undock and bring back the native device display as primary display. | 332 // Undock and bring back the native device display as primary display. |
| 336 display_manager()->OnNativeDisplaysChanged(info_list); | 333 display_manager()->OnNativeDisplaysChanged(info_list); |
| 337 } | 334 } |
| 338 | 335 |
| 339 // Tests for any crash during docking and then undocking. | 336 // Tests for any crash during docking and then undocking. |
| 340 // See https://crbug.com/632755 | 337 // See https://crbug.com/632755 |
| 341 TEST_F(PanelLayoutManagerTest, DockUndockTest) { | 338 TEST_F(PanelLayoutManagerTest, DockUndockTest) { |
| 342 std::vector<display::ManagedDisplayInfo> info_list; | 339 std::vector<display::ManagedDisplayInfo> info_list; |
| 343 | 340 |
| 344 const int64_t internal_display_id = | 341 const int64_t internal_display_id = |
| 345 test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) | 342 display::test::DisplayManagerTestApi( |
| 343 Shell::GetInstance()->display_manager()) |
| 346 .SetFirstDisplayAsInternalDisplay(); | 344 .SetFirstDisplayAsInternalDisplay(); |
| 347 | 345 |
| 348 // Create the primary display info. | 346 // Create the primary display info. |
| 349 display::ManagedDisplayInfo internal_display = | 347 display::ManagedDisplayInfo internal_display = |
| 350 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 1280, 720)); | 348 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 1280, 720)); |
| 351 | 349 |
| 352 info_list.push_back(internal_display); | 350 info_list.push_back(internal_display); |
| 353 display_manager()->OnNativeDisplaysChanged(info_list); | 351 display_manager()->OnNativeDisplaysChanged(info_list); |
| 354 | 352 |
| 355 // Create a panel in the undocked state. | 353 // Create a panel in the undocked state. |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); | 909 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); |
| 912 target = targeter->FindTargetForEvent(root, &touch); | 910 target = targeter->FindTargetForEvent(root, &touch); |
| 913 EXPECT_NE(w.get(), target); | 911 EXPECT_NE(w.get(), target); |
| 914 } | 912 } |
| 915 | 913 |
| 916 INSTANTIATE_TEST_CASE_P(LtrRtl, | 914 INSTANTIATE_TEST_CASE_P(LtrRtl, |
| 917 PanelLayoutManagerTextDirectionTest, | 915 PanelLayoutManagerTextDirectionTest, |
| 918 testing::Bool()); | 916 testing::Bool()); |
| 919 | 917 |
| 920 } // namespace ash | 918 } // namespace ash |
| OLD | NEW |