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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "ash/common/ash_switches.h" | 8 #include "ash/common/ash_switches.h" |
9 #include "ash/common/material_design/material_design_controller.h" | |
9 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
10 #include "ash/shelf/shelf.h" | 11 #include "ash/shelf/shelf.h" |
11 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
12 #include "ash/shell.h" | 13 #include "ash/shell.h" |
13 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_md_test_base.h" |
14 #include "ash/wm/window_properties.h" | 15 #include "ash/wm/window_properties.h" |
15 #include "ash/wm/window_util.h" | 16 #include "ash/wm/window_util.h" |
16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
17 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
18 #include "ui/aura/window_event_dispatcher.h" | 19 #include "ui/aura/window_event_dispatcher.h" |
19 #include "ui/compositor/layer.h" | 20 #include "ui/compositor/layer.h" |
20 #include "ui/display/display.h" | 21 #include "ui/display/display.h" |
21 #include "ui/display/screen.h" | 22 #include "ui/display/screen.h" |
22 #include "ui/gfx/geometry/insets.h" | 23 #include "ui/gfx/geometry/insets.h" |
23 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
24 #include "ui/wm/core/shadow.h" | 25 #include "ui/wm/core/shadow.h" |
25 #include "ui/wm/core/shadow_controller.h" | 26 #include "ui/wm/core/shadow_controller.h" |
26 #include "ui/wm/core/shadow_types.h" | 27 #include "ui/wm/core/shadow_types.h" |
27 #include "ui/wm/public/activation_client.h" | 28 #include "ui/wm/public/activation_client.h" |
28 | 29 |
29 namespace ash { | 30 namespace ash { |
30 | 31 |
31 typedef ash::test::AshTestBase DIPTest; | 32 using DIPTest = test::AshMDTestBase; |
33 | |
34 // The prefix has intentionally been left blank since there is only one | |
James Cook
2016/06/22 19:41:36
optional: Feel free to remove these comments now t
tdanderson
2016/06/22 20:57:27
Done.
| |
35 // parameterization of this test fixture. | |
36 INSTANTIATE_TEST_CASE_P( | |
37 /* prefix intentionally left blank */, | |
38 DIPTest, | |
39 testing::Values(MaterialDesignController::NON_MATERIAL, | |
40 MaterialDesignController::MATERIAL_NORMAL, | |
41 MaterialDesignController::MATERIAL_EXPERIMENTAL)); | |
32 | 42 |
33 // Test if the WM sets correct work area under different density. | 43 // Test if the WM sets correct work area under different density. |
34 #if defined(OS_WIN) && !defined(USE_ASH) | |
35 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 44 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
36 #define MAYBE_WorkArea DISABLED_WorkArea | 45 #if defined(OS_CHROMEOS) |
37 #else | 46 TEST_P(DIPTest, WorkArea) { |
38 #define MAYBE_WorkArea WorkArea | 47 const int height_offset = GetMdMaximizedWindowHeightOffset(); |
39 #endif | |
40 TEST_F(DIPTest, MAYBE_WorkArea) { | |
41 UpdateDisplay("1000x900*1.0f"); | 48 UpdateDisplay("1000x900*1.0f"); |
42 | 49 |
43 aura::Window* root = Shell::GetPrimaryRootWindow(); | 50 aura::Window* root = Shell::GetPrimaryRootWindow(); |
44 const display::Display display = | 51 const display::Display display = |
45 display::Screen::GetScreen()->GetDisplayNearestWindow(root); | 52 display::Screen::GetScreen()->GetDisplayNearestWindow(root); |
46 | 53 |
47 EXPECT_EQ("0,0 1000x900", display.bounds().ToString()); | 54 EXPECT_EQ("0,0 1000x900", display.bounds().ToString()); |
48 gfx::Rect work_area = display.work_area(); | 55 gfx::Rect work_area = display.work_area(); |
49 EXPECT_EQ("0,0 1000x853", work_area.ToString()); | 56 EXPECT_EQ(gfx::Rect(0, 0, 1000, 853 + height_offset).ToString(), |
50 EXPECT_EQ("0,0,47,0", display.bounds().InsetsFrom(work_area).ToString()); | 57 work_area.ToString()); |
58 EXPECT_EQ(gfx::Insets(0, 0, 47 - height_offset, 0).ToString(), | |
59 display.bounds().InsetsFrom(work_area).ToString()); | |
51 | 60 |
52 UpdateDisplay("2000x1800*2.0f"); | 61 UpdateDisplay("2000x1800*2.0f"); |
53 display::Screen* screen = display::Screen::GetScreen(); | 62 display::Screen* screen = display::Screen::GetScreen(); |
54 | 63 |
55 const display::Display display_2x = screen->GetDisplayNearestWindow(root); | 64 const display::Display display_2x = screen->GetDisplayNearestWindow(root); |
56 const DisplayInfo display_info_2x = | 65 const DisplayInfo display_info_2x = |
57 Shell::GetInstance()->display_manager()->GetDisplayInfo(display_2x.id()); | 66 Shell::GetInstance()->display_manager()->GetDisplayInfo(display_2x.id()); |
58 | 67 |
59 // The |bounds_in_pixel()| should report bounds in pixel coordinate. | 68 // The |bounds_in_pixel()| should report bounds in pixel coordinate. |
60 EXPECT_EQ("1,1 2000x1800", | 69 EXPECT_EQ("1,1 2000x1800", |
61 display_info_2x.bounds_in_native().ToString()); | 70 display_info_2x.bounds_in_native().ToString()); |
62 | 71 |
63 // Aura and views coordinates are in DIP, so they their bounds do not change. | 72 // Aura and views coordinates are in DIP, so they their bounds do not change. |
64 EXPECT_EQ("0,0 1000x900", display_2x.bounds().ToString()); | 73 EXPECT_EQ("0,0 1000x900", display_2x.bounds().ToString()); |
65 work_area = display_2x.work_area(); | 74 work_area = display_2x.work_area(); |
66 EXPECT_EQ("0,0 1000x853", work_area.ToString()); | 75 EXPECT_EQ(gfx::Rect(0, 0, 1000, 853 + height_offset).ToString(), |
67 EXPECT_EQ("0,0,47,0", display_2x.bounds().InsetsFrom(work_area).ToString()); | 76 work_area.ToString()); |
77 EXPECT_EQ(gfx::Insets(0, 0, 47 - height_offset, 0).ToString(), | |
78 display_2x.bounds().InsetsFrom(work_area).ToString()); | |
68 | 79 |
69 // Sanity check if the workarea's inset hight is same as | 80 // Sanity check if the workarea's inset hight is same as |
70 // the shelf's height. | 81 // the shelf's height. |
71 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 82 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
72 EXPECT_EQ( | 83 EXPECT_EQ( |
73 display_2x.bounds().InsetsFrom(work_area).height(), | 84 display_2x.bounds().InsetsFrom(work_area).height(), |
74 shelf->shelf_widget()->GetNativeView()->layer()->bounds().height()); | 85 shelf->shelf_widget()->GetNativeView()->layer()->bounds().height()); |
75 } | 86 } |
87 #endif // defined(OS_CHROMEOS) | |
76 | 88 |
77 } // namespace ash | 89 } // namespace ash |
OLD | NEW |