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

Side by Side Diff: ash/screen_util_unittest.cc

Issue 2692663002: Gut ash::MaterialDesignController, and remove the about:flags entry. (Closed)
Patch Set: yet another rebase Created 3 years, 10 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/root_window_controller_unittest.cc ('k') | ash/shelf/shelf_widget_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/screen_util.h" 5 #include "ash/screen_util.h"
6 6
7 #include "ash/common/wm/wm_screen_util.h" 7 #include "ash/common/wm/wm_screen_util.h"
8 #include "ash/common/wm_lookup.h" 8 #include "ash/common/wm_lookup.h"
9 #include "ash/common/wm_window.h" 9 #include "ash/common/wm_window.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/test/ash_md_test_base.h" 11 #include "ash/test/ash_test_base.h"
12 #include "ash/wm/window_util.h" 12 #include "ash/wm/window_util.h"
13 #include "ui/aura/env.h" 13 #include "ui/aura/env.h"
14 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
15 #include "ui/aura/window_event_dispatcher.h" 15 #include "ui/aura/window_event_dispatcher.h"
16 #include "ui/display/manager/display_manager.h" 16 #include "ui/display/manager/display_manager.h"
17 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
18 #include "ui/views/widget/widget_delegate.h" 18 #include "ui/views/widget/widget_delegate.h"
19 19
20 namespace ash { 20 namespace ash {
21 namespace test { 21 namespace test {
22 22
23 using ScreenUtilTest = AshMDTestBase; 23 using ScreenUtilTest = AshTestBase;
24 24
25 INSTANTIATE_TEST_CASE_P( 25 TEST_F(ScreenUtilTest, Bounds) {
26 /* prefix intentionally left blank due to only one parameterization */,
27 ScreenUtilTest,
28 testing::Values(MaterialDesignController::NON_MATERIAL,
29 MaterialDesignController::MATERIAL_NORMAL,
30 MaterialDesignController::MATERIAL_EXPERIMENTAL));
31
32 TEST_P(ScreenUtilTest, Bounds) {
33 const int height_offset = GetMdMaximizedWindowHeightOffset();
34
35 UpdateDisplay("600x600,500x500"); 26 UpdateDisplay("600x600,500x500");
36 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( 27 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds(
37 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); 28 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
38 primary->Show(); 29 primary->Show();
39 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( 30 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
40 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); 31 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
41 secondary->Show(); 32 secondary->Show();
42 33
43 // Maximized bounds. By default the shelf is 47px tall (ash::kShelfSize). 34 // Maximized bounds. By default the shelf is 47px tall (ash::kShelfSize).
44 EXPECT_EQ( 35 EXPECT_EQ(
45 gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), 36 gfx::Rect(0, 0, 600, 552).ToString(),
46 ScreenUtil::GetMaximizedWindowBoundsInParent(primary->GetNativeView()) 37 ScreenUtil::GetMaximizedWindowBoundsInParent(primary->GetNativeView())
47 .ToString()); 38 .ToString());
48 EXPECT_EQ( 39 EXPECT_EQ(
49 gfx::Rect(0, 0, 500, 453 + height_offset).ToString(), 40 gfx::Rect(0, 0, 500, 452).ToString(),
50 ScreenUtil::GetMaximizedWindowBoundsInParent(secondary->GetNativeView()) 41 ScreenUtil::GetMaximizedWindowBoundsInParent(secondary->GetNativeView())
51 .ToString()); 42 .ToString());
52 43
53 // Display bounds 44 // Display bounds
54 EXPECT_EQ("0,0 600x600", 45 EXPECT_EQ("0,0 600x600",
55 ScreenUtil::GetDisplayBoundsInParent(primary->GetNativeView()) 46 ScreenUtil::GetDisplayBoundsInParent(primary->GetNativeView())
56 .ToString()); 47 .ToString());
57 EXPECT_EQ("0,0 500x500", 48 EXPECT_EQ("0,0 500x500",
58 ScreenUtil::GetDisplayBoundsInParent(secondary->GetNativeView()) 49 ScreenUtil::GetDisplayBoundsInParent(secondary->GetNativeView())
59 .ToString()); 50 .ToString());
60 51
61 // Work area bounds 52 // Work area bounds
62 EXPECT_EQ( 53 EXPECT_EQ(
63 gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), 54 gfx::Rect(0, 0, 600, 552).ToString(),
64 ScreenUtil::GetDisplayWorkAreaBoundsInParent(primary->GetNativeView()) 55 ScreenUtil::GetDisplayWorkAreaBoundsInParent(primary->GetNativeView())
65 .ToString()); 56 .ToString());
66 EXPECT_EQ( 57 EXPECT_EQ(
67 gfx::Rect(0, 0, 500, 453 + height_offset).ToString(), 58 gfx::Rect(0, 0, 500, 452).ToString(),
68 ScreenUtil::GetDisplayWorkAreaBoundsInParent(secondary->GetNativeView()) 59 ScreenUtil::GetDisplayWorkAreaBoundsInParent(secondary->GetNativeView())
69 .ToString()); 60 .ToString());
70 } 61 }
71 62
72 // Test verifies a stable handling of secondary screen widget changes 63 // Test verifies a stable handling of secondary screen widget changes
73 // (crbug.com/226132). 64 // (crbug.com/226132).
74 TEST_P(ScreenUtilTest, StabilityTest) { 65 TEST_F(ScreenUtilTest, StabilityTest) {
75 UpdateDisplay("600x600,500x500"); 66 UpdateDisplay("600x600,500x500");
76 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( 67 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
77 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); 68 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
78 EXPECT_EQ(Shell::GetAllRootWindows()[1], 69 EXPECT_EQ(Shell::GetAllRootWindows()[1],
79 secondary->GetNativeView()->GetRootWindow()); 70 secondary->GetNativeView()->GetRootWindow());
80 secondary->Show(); 71 secondary->Show();
81 secondary->Maximize(); 72 secondary->Maximize();
82 secondary->Show(); 73 secondary->Show();
83 secondary->SetFullscreen(true); 74 secondary->SetFullscreen(true);
84 secondary->Hide(); 75 secondary->Hide();
85 secondary->Close(); 76 secondary->Close();
86 } 77 }
87 78
88 TEST_P(ScreenUtilTest, ConvertRect) { 79 TEST_F(ScreenUtilTest, ConvertRect) {
89 UpdateDisplay("600x600,500x500"); 80 UpdateDisplay("600x600,500x500");
90 81
91 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( 82 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds(
92 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); 83 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
93 primary->Show(); 84 primary->Show();
94 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( 85 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
95 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); 86 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
96 secondary->Show(); 87 secondary->Show();
97 88
98 EXPECT_EQ("0,0 100x100", 89 EXPECT_EQ("0,0 100x100",
99 ScreenUtil::ConvertRectFromScreen(primary->GetNativeView(), 90 ScreenUtil::ConvertRectFromScreen(primary->GetNativeView(),
100 gfx::Rect(10, 10, 100, 100)) 91 gfx::Rect(10, 10, 100, 100))
101 .ToString()); 92 .ToString());
102 EXPECT_EQ("10,10 100x100", 93 EXPECT_EQ("10,10 100x100",
103 ScreenUtil::ConvertRectFromScreen(secondary->GetNativeView(), 94 ScreenUtil::ConvertRectFromScreen(secondary->GetNativeView(),
104 gfx::Rect(620, 20, 100, 100)) 95 gfx::Rect(620, 20, 100, 100))
105 .ToString()); 96 .ToString());
106 97
107 EXPECT_EQ("40,40 100x100", 98 EXPECT_EQ("40,40 100x100",
108 ScreenUtil::ConvertRectToScreen(primary->GetNativeView(), 99 ScreenUtil::ConvertRectToScreen(primary->GetNativeView(),
109 gfx::Rect(30, 30, 100, 100)) 100 gfx::Rect(30, 30, 100, 100))
110 .ToString()); 101 .ToString());
111 EXPECT_EQ("650,50 100x100", 102 EXPECT_EQ("650,50 100x100",
112 ScreenUtil::ConvertRectToScreen(secondary->GetNativeView(), 103 ScreenUtil::ConvertRectToScreen(secondary->GetNativeView(),
113 gfx::Rect(40, 40, 100, 100)) 104 gfx::Rect(40, 40, 100, 100))
114 .ToString()); 105 .ToString());
115 } 106 }
116 107
117 TEST_P(ScreenUtilTest, ShelfDisplayBoundsInUnifiedDesktop) { 108 TEST_F(ScreenUtilTest, ShelfDisplayBoundsInUnifiedDesktop) {
118 display_manager()->SetUnifiedDesktopEnabled(true); 109 display_manager()->SetUnifiedDesktopEnabled(true);
119 110
120 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( 111 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
121 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); 112 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
122 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget); 113 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget);
123 114
124 UpdateDisplay("500x400"); 115 UpdateDisplay("500x400");
125 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); 116 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString());
126 117
127 UpdateDisplay("500x400,600x400"); 118 UpdateDisplay("500x400,600x400");
128 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); 119 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString());
129 120
130 // Move to the 2nd physical display. Shelf's display still should be 121 // Move to the 2nd physical display. Shelf's display still should be
131 // the first. 122 // the first.
132 widget->SetBounds(gfx::Rect(800, 0, 100, 100)); 123 widget->SetBounds(gfx::Rect(800, 0, 100, 100));
133 ASSERT_EQ("800,0 100x100", widget->GetWindowBoundsInScreen().ToString()); 124 ASSERT_EQ("800,0 100x100", widget->GetWindowBoundsInScreen().ToString());
134 125
135 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); 126 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString());
136 127
137 UpdateDisplay("600x500"); 128 UpdateDisplay("600x500");
138 EXPECT_EQ("0,0 600x500", wm::GetDisplayBoundsWithShelf(window).ToString()); 129 EXPECT_EQ("0,0 600x500", wm::GetDisplayBoundsWithShelf(window).ToString());
139 } 130 }
140 131
141 } // namespace test 132 } // namespace test
142 } // namespace ash 133 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller_unittest.cc ('k') | ash/shelf/shelf_widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698