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

Side by Side Diff: ash/screen_util_unittest.cc

Issue 2067223003: Parameterize Ash unittests to pass with material design enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address trybot failures Created 4 years, 6 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
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/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_md_test_base.h"
10 #include "ash/test/display_manager_test_api.h" 10 #include "ash/test/display_manager_test_api.h"
11 #include "ash/wm/window_util.h" 11 #include "ash/wm/window_util.h"
12 #include "ui/aura/env.h" 12 #include "ui/aura/env.h"
13 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
14 #include "ui/aura/window_event_dispatcher.h" 14 #include "ui/aura/window_event_dispatcher.h"
15 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
16 #include "ui/views/widget/widget_delegate.h" 16 #include "ui/views/widget/widget_delegate.h"
17 17
18 namespace ash { 18 namespace ash {
19 namespace test { 19 namespace test {
20 20
21 typedef test::AshTestBase ScreenUtilTest; 21 using ScreenUtilTest = AshMDTestBase;
22 22
23 TEST_F(ScreenUtilTest, Bounds) { 23 // Note: First argument is optional and intentionally left blank.
24 // (it's a prefix for the generated test cases)
25 INSTANTIATE_TEST_CASE_P(
26 ,
27 ScreenUtilTest,
28 testing::Values(MaterialDesignController::NON_MATERIAL,
29 MaterialDesignController::MATERIAL_NORMAL,
30 MaterialDesignController::MATERIAL_EXPERIMENTAL));
31
32 TEST_P(ScreenUtilTest, Bounds) {
24 if (!SupportsMultipleDisplays()) 33 if (!SupportsMultipleDisplays())
25 return; 34 return;
35 const int height_offset = GetMdMaximizedWindowHeightOffset();
26 36
27 UpdateDisplay("600x600,500x500"); 37 UpdateDisplay("600x600,500x500");
28 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( 38 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds(
29 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); 39 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
30 primary->Show(); 40 primary->Show();
31 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( 41 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
32 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); 42 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
33 secondary->Show(); 43 secondary->Show();
34 44
35 // Maximized bounds. By default the shelf is 47px tall (ash::kShelfSize). 45 // Maximized bounds. By default the shelf is 47px tall (ash::kShelfSize).
36 EXPECT_EQ("0,0 600x553", ScreenUtil::GetMaximizedWindowBoundsInParent( 46 EXPECT_EQ(
37 primary->GetNativeView()) 47 gfx::Rect(0, 0, 600, 553 + height_offset).ToString(),
38 .ToString()); 48 ScreenUtil::GetMaximizedWindowBoundsInParent(primary->GetNativeView())
39 EXPECT_EQ("0,0 500x453", 49 .ToString());
40 ScreenUtil::GetMaximizedWindowBoundsInParent( 50 EXPECT_EQ(
41 secondary->GetNativeView()).ToString()); 51 gfx::Rect(0, 0, 500, 453 + height_offset).ToString(),
52 ScreenUtil::GetMaximizedWindowBoundsInParent(secondary->GetNativeView())
53 .ToString());
42 54
43 // Display bounds 55 // Display bounds
44 EXPECT_EQ("0,0 600x600", 56 EXPECT_EQ("0,0 600x600",
45 ScreenUtil::GetDisplayBoundsInParent( 57 ScreenUtil::GetDisplayBoundsInParent(
46 primary->GetNativeView()).ToString()); 58 primary->GetNativeView()).ToString());
47 EXPECT_EQ("0,0 500x500", 59 EXPECT_EQ("0,0 500x500",
48 ScreenUtil::GetDisplayBoundsInParent( 60 ScreenUtil::GetDisplayBoundsInParent(
49 secondary->GetNativeView()).ToString()); 61 secondary->GetNativeView()).ToString());
50 62
51 // Work area bounds 63 // Work area bounds
52 EXPECT_EQ("0,0 600x553", ScreenUtil::GetDisplayWorkAreaBoundsInParent( 64 EXPECT_EQ(
53 primary->GetNativeView()) 65 gfx::Rect(0, 0, 600, 553 + height_offset).ToString(),
54 .ToString()); 66 ScreenUtil::GetDisplayWorkAreaBoundsInParent(primary->GetNativeView())
55 EXPECT_EQ("0,0 500x453", 67 .ToString());
56 ScreenUtil::GetDisplayWorkAreaBoundsInParent( 68 EXPECT_EQ(
57 secondary->GetNativeView()).ToString()); 69 gfx::Rect(0, 0, 500, 453 + height_offset).ToString(),
70 ScreenUtil::GetDisplayWorkAreaBoundsInParent(secondary->GetNativeView())
71 .ToString());
58 } 72 }
59 73
60 // Test verifies a stable handling of secondary screen widget changes 74 // Test verifies a stable handling of secondary screen widget changes
61 // (crbug.com/226132). 75 // (crbug.com/226132).
62 TEST_F(ScreenUtilTest, StabilityTest) { 76 TEST_P(ScreenUtilTest, StabilityTest) {
63 if (!SupportsMultipleDisplays()) 77 if (!SupportsMultipleDisplays())
64 return; 78 return;
65 79
66 UpdateDisplay("600x600,500x500"); 80 UpdateDisplay("600x600,500x500");
67 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( 81 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
68 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); 82 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
69 EXPECT_EQ(Shell::GetAllRootWindows()[1], 83 EXPECT_EQ(Shell::GetAllRootWindows()[1],
70 secondary->GetNativeView()->GetRootWindow()); 84 secondary->GetNativeView()->GetRootWindow());
71 secondary->Show(); 85 secondary->Show();
72 secondary->Maximize(); 86 secondary->Maximize();
73 secondary->Show(); 87 secondary->Show();
74 secondary->SetFullscreen(true); 88 secondary->SetFullscreen(true);
75 secondary->Hide(); 89 secondary->Hide();
76 secondary->Close(); 90 secondary->Close();
77 } 91 }
78 92
79 TEST_F(ScreenUtilTest, ConvertRect) { 93 TEST_P(ScreenUtilTest, ConvertRect) {
80 if (!SupportsMultipleDisplays()) 94 if (!SupportsMultipleDisplays())
81 return; 95 return;
82 96
83 UpdateDisplay("600x600,500x500"); 97 UpdateDisplay("600x600,500x500");
84 98
85 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( 99 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds(
86 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); 100 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
87 primary->Show(); 101 primary->Show();
88 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( 102 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
89 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); 103 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
(...skipping 11 matching lines...) Expand all
101 EXPECT_EQ( 115 EXPECT_EQ(
102 "40,40 100x100", 116 "40,40 100x100",
103 ScreenUtil::ConvertRectToScreen( 117 ScreenUtil::ConvertRectToScreen(
104 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString()); 118 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString());
105 EXPECT_EQ( 119 EXPECT_EQ(
106 "650,50 100x100", 120 "650,50 100x100",
107 ScreenUtil::ConvertRectToScreen( 121 ScreenUtil::ConvertRectToScreen(
108 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString()); 122 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString());
109 } 123 }
110 124
111 TEST_F(ScreenUtilTest, ShelfDisplayBoundsInUnifiedDesktop) { 125 TEST_P(ScreenUtilTest, ShelfDisplayBoundsInUnifiedDesktop) {
112 if (!SupportsMultipleDisplays()) 126 if (!SupportsMultipleDisplays())
113 return; 127 return;
114 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 128 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
115 129
116 display_manager->SetUnifiedDesktopEnabled(true); 130 display_manager->SetUnifiedDesktopEnabled(true);
117 131
118 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( 132 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
119 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); 133 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
120 134
121 UpdateDisplay("500x400"); 135 UpdateDisplay("500x400");
(...skipping 16 matching lines...) Expand all
138 .ToString()); 152 .ToString());
139 153
140 UpdateDisplay("600x500"); 154 UpdateDisplay("600x500");
141 EXPECT_EQ("0,0 600x500", 155 EXPECT_EQ("0,0 600x500",
142 ScreenUtil::GetShelfDisplayBoundsInRoot(widget->GetNativeWindow()) 156 ScreenUtil::GetShelfDisplayBoundsInRoot(widget->GetNativeWindow())
143 .ToString()); 157 .ToString());
144 } 158 }
145 159
146 } // namespace test 160 } // namespace test
147 } // namespace ash 161 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698