Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: ash/wm/panels/panel_layout_manager_unittest.cc

Issue 2254603002: Temporary fix to return only the active displays. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Temporary fix to return only the active displays. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/display/screen_ash.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
27 #include "ash/test/display_manager_test_api.h"
25 #include "ash/test/shelf_test_api.h" 28 #include "ash/test/shelf_test_api.h"
26 #include "ash/test/shelf_view_test_api.h" 29 #include "ash/test/shelf_view_test_api.h"
27 #include "ash/test/test_shelf_delegate.h" 30 #include "ash/test/test_shelf_delegate.h"
28 #include "ash/wm/window_state_aura.h" 31 #include "ash/wm/window_state_aura.h"
29 #include "ash/wm/window_util.h" 32 #include "ash/wm/window_util.h"
30 #include "base/command_line.h" 33 #include "base/command_line.h"
31 #include "base/compiler_specific.h" 34 #include "base/compiler_specific.h"
32 #include "base/i18n/rtl.h" 35 #include "base/i18n/rtl.h"
33 #include "base/run_loop.h" 36 #include "base/run_loop.h"
37 #include "base/strings/string_number_conversions.h"
34 #include "ui/aura/client/aura_constants.h" 38 #include "ui/aura/client/aura_constants.h"
35 #include "ui/aura/test/test_windows.h" 39 #include "ui/aura/test/test_windows.h"
36 #include "ui/aura/window.h" 40 #include "ui/aura/window.h"
37 #include "ui/aura/window_event_dispatcher.h" 41 #include "ui/aura/window_event_dispatcher.h"
38 #include "ui/events/event_utils.h" 42 #include "ui/events/event_utils.h"
39 #include "ui/events/test/event_generator.h" 43 #include "ui/events/test/event_generator.h"
40 #include "ui/views/widget/widget.h" 44 #include "ui/views/widget/widget.h"
41 45
42 namespace ash { 46 namespace ash {
43 47
48 namespace {
49
50 std::string ToDisplayName(int64_t id) {
51 return "x-" + base::Int64ToString(id);
52 }
53
54 DisplayInfo CreateDisplayInfo(int64_t id, const gfx::Rect& bounds) {
55 DisplayInfo info(id, ToDisplayName(id), false);
56 info.SetBounds(bounds);
57 return info;
58 }
59
60 DisplayManager* display_manager() {
61 return Shell::GetInstance()->display_manager();
62 }
63
64 } // namespace
65
44 using aura::test::WindowIsAbove; 66 using aura::test::WindowIsAbove;
45 67
46 class PanelLayoutManagerTest : public test::AshTestBase { 68 class PanelLayoutManagerTest : public test::AshTestBase {
47 public: 69 public:
48 PanelLayoutManagerTest() {} 70 PanelLayoutManagerTest() {}
49 ~PanelLayoutManagerTest() override {} 71 ~PanelLayoutManagerTest() override {}
50 72
51 void SetUp() override { 73 void SetUp() override {
52 test::AshTestBase::SetUp(); 74 test::AshTestBase::SetUp();
53 ASSERT_TRUE(test::TestShelfDelegate::instance()); 75 ASSERT_TRUE(test::TestShelfDelegate::instance());
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 300
279 // Tests that a created panel window is above the shelf icon in LTR and RTL. 301 // Tests that a created panel window is above the shelf icon in LTR and RTL.
280 TEST_P(PanelLayoutManagerTextDirectionTest, AddOnePanel) { 302 TEST_P(PanelLayoutManagerTextDirectionTest, AddOnePanel) {
281 gfx::Rect bounds(0, 0, 201, 201); 303 gfx::Rect bounds(0, 0, 201, 201);
282 std::unique_ptr<aura::Window> window(CreatePanelWindow(bounds)); 304 std::unique_ptr<aura::Window> window(CreatePanelWindow(bounds));
283 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); 305 EXPECT_EQ(GetPanelContainer(window.get()), window->parent());
284 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); 306 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get()));
285 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get())); 307 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get()));
286 } 308 }
287 309
310 // Tests for crashes during undocking.
311 // See https://crbug.com/632755
312 TEST_F(PanelLayoutManagerTest, UndockTest) {
313 std::vector<DisplayInfo> info_list;
314
315 const int64_t internal_display_id =
316 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay();
317
318 // Create the primary display info.
319 DisplayInfo internal_display =
320 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 1280, 720));
321 // Create the secondary external display info. This will be docked display.
322 DisplayInfo external_display_info =
323 CreateDisplayInfo(2, gfx::Rect(0, 0, 1920, 1080));
324
325 info_list.push_back(external_display_info);
326 // Docked state.
327 display_manager()->OnNativeDisplaysChanged(info_list);
328
329 // Create a panel in the docked state
330 std::unique_ptr<aura::Window> p1_d2(
331 CreatePanelWindow(gfx::Rect(1555, 800, 50, 50)));
332
333 info_list.clear();
334 info_list.push_back(internal_display);
335
336 // Undock and bring back the native device display as primary display.
337 display_manager()->OnNativeDisplaysChanged(info_list);
338 }
339
340 // Tests for any crash during docking and then undocking.
341 // See https://crbug.com/632755
342 TEST_F(PanelLayoutManagerTest, DockUndockTest) {
343 std::vector<DisplayInfo> info_list;
344
345 const int64_t internal_display_id =
346 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay();
347
348 // Create the primary display info.
349 DisplayInfo internal_display =
350 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 1280, 720));
351
352 info_list.push_back(internal_display);
353 display_manager()->OnNativeDisplaysChanged(info_list);
354
355 // Create a panel in the undocked state.
356 std::unique_ptr<aura::Window> p1_d2(
357 CreatePanelWindow(gfx::Rect(600, 200, 50, 50)));
358
359 // Create the secondary external display info. This will be docked display.
360 DisplayInfo external_display_info =
361 CreateDisplayInfo(2, gfx::Rect(0, 0, 1920, 1080));
362
363 info_list.push_back(external_display_info);
364 // Adding external Display
365 display_manager()->OnNativeDisplaysChanged(info_list);
366
367 info_list.clear();
368 info_list.push_back(external_display_info);
369
370 // Docked state.
371 display_manager()->OnNativeDisplaysChanged(info_list);
372
373 info_list.clear();
374 info_list.push_back(internal_display);
375
376 // Undock and bring back the native device display as primary display.
377 display_manager()->OnNativeDisplaysChanged(info_list);
378 }
379
288 // Tests that a created panel window is successfully aligned over a hidden 380 // Tests that a created panel window is successfully aligned over a hidden
289 // shelf icon. 381 // shelf icon.
290 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIcon) { 382 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIcon) {
291 gfx::Rect bounds(0, 0, 201, 201); 383 gfx::Rect bounds(0, 0, 201, 201);
292 SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(), 384 SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(),
293 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 385 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
294 std::unique_ptr<aura::Window> normal_window(CreateNormalWindow(bounds)); 386 std::unique_ptr<aura::Window> normal_window(CreateNormalWindow(bounds));
295 std::unique_ptr<aura::Window> window(CreatePanelWindow(bounds)); 387 std::unique_ptr<aura::Window> window(CreatePanelWindow(bounds));
296 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); 388 EXPECT_EQ(GetPanelContainer(window.get()), window->parent());
297 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); 389 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get()));
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); 911 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5));
820 target = targeter->FindTargetForEvent(root, &touch); 912 target = targeter->FindTargetForEvent(root, &touch);
821 EXPECT_NE(w.get(), target); 913 EXPECT_NE(w.get(), target);
822 } 914 }
823 915
824 INSTANTIATE_TEST_CASE_P(LtrRtl, 916 INSTANTIATE_TEST_CASE_P(LtrRtl,
825 PanelLayoutManagerTextDirectionTest, 917 PanelLayoutManagerTextDirectionTest,
826 testing::Bool()); 918 testing::Bool());
827 919
828 } // namespace ash 920 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/screen_ash.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698