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

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: for landing 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
« 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/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 INSTANTIATE_TEST_CASE_P(
24 /* prefix intentionally left blank due to only one parameterization */,
25 ScreenUtilTest,
26 testing::Values(MaterialDesignController::NON_MATERIAL,
27 MaterialDesignController::MATERIAL_NORMAL,
28 MaterialDesignController::MATERIAL_EXPERIMENTAL));
29
30 TEST_P(ScreenUtilTest, Bounds) {
24 if (!SupportsMultipleDisplays()) 31 if (!SupportsMultipleDisplays())
25 return; 32 return;
33 const int height_offset = GetMdMaximizedWindowHeightOffset();
26 34
27 UpdateDisplay("600x600,500x500"); 35 UpdateDisplay("600x600,500x500");
28 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( 36 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds(
29 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); 37 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
30 primary->Show(); 38 primary->Show();
31 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( 39 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
32 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); 40 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
33 secondary->Show(); 41 secondary->Show();
34 42
35 // Maximized bounds. By default the shelf is 47px tall (ash::kShelfSize). 43 // Maximized bounds. By default the shelf is 47px tall (ash::kShelfSize).
36 EXPECT_EQ("0,0 600x553", ScreenUtil::GetMaximizedWindowBoundsInParent( 44 EXPECT_EQ(
37 primary->GetNativeView()) 45 gfx::Rect(0, 0, 600, 553 + height_offset).ToString(),
38 .ToString()); 46 ScreenUtil::GetMaximizedWindowBoundsInParent(primary->GetNativeView())
39 EXPECT_EQ("0,0 500x453", 47 .ToString());
40 ScreenUtil::GetMaximizedWindowBoundsInParent( 48 EXPECT_EQ(
41 secondary->GetNativeView()).ToString()); 49 gfx::Rect(0, 0, 500, 453 + height_offset).ToString(),
50 ScreenUtil::GetMaximizedWindowBoundsInParent(secondary->GetNativeView())
51 .ToString());
42 52
43 // Display bounds 53 // Display bounds
44 EXPECT_EQ("0,0 600x600", 54 EXPECT_EQ("0,0 600x600",
45 ScreenUtil::GetDisplayBoundsInParent( 55 ScreenUtil::GetDisplayBoundsInParent(
46 primary->GetNativeView()).ToString()); 56 primary->GetNativeView()).ToString());
47 EXPECT_EQ("0,0 500x500", 57 EXPECT_EQ("0,0 500x500",
48 ScreenUtil::GetDisplayBoundsInParent( 58 ScreenUtil::GetDisplayBoundsInParent(
49 secondary->GetNativeView()).ToString()); 59 secondary->GetNativeView()).ToString());
50 60
51 // Work area bounds 61 // Work area bounds
52 EXPECT_EQ("0,0 600x553", ScreenUtil::GetDisplayWorkAreaBoundsInParent( 62 EXPECT_EQ(
53 primary->GetNativeView()) 63 gfx::Rect(0, 0, 600, 553 + height_offset).ToString(),
54 .ToString()); 64 ScreenUtil::GetDisplayWorkAreaBoundsInParent(primary->GetNativeView())
55 EXPECT_EQ("0,0 500x453", 65 .ToString());
56 ScreenUtil::GetDisplayWorkAreaBoundsInParent( 66 EXPECT_EQ(
57 secondary->GetNativeView()).ToString()); 67 gfx::Rect(0, 0, 500, 453 + height_offset).ToString(),
68 ScreenUtil::GetDisplayWorkAreaBoundsInParent(secondary->GetNativeView())
69 .ToString());
58 } 70 }
59 71
60 // Test verifies a stable handling of secondary screen widget changes 72 // Test verifies a stable handling of secondary screen widget changes
61 // (crbug.com/226132). 73 // (crbug.com/226132).
62 TEST_F(ScreenUtilTest, StabilityTest) { 74 TEST_P(ScreenUtilTest, StabilityTest) {
63 if (!SupportsMultipleDisplays()) 75 if (!SupportsMultipleDisplays())
64 return; 76 return;
65 77
66 UpdateDisplay("600x600,500x500"); 78 UpdateDisplay("600x600,500x500");
67 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( 79 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
68 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); 80 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
69 EXPECT_EQ(Shell::GetAllRootWindows()[1], 81 EXPECT_EQ(Shell::GetAllRootWindows()[1],
70 secondary->GetNativeView()->GetRootWindow()); 82 secondary->GetNativeView()->GetRootWindow());
71 secondary->Show(); 83 secondary->Show();
72 secondary->Maximize(); 84 secondary->Maximize();
73 secondary->Show(); 85 secondary->Show();
74 secondary->SetFullscreen(true); 86 secondary->SetFullscreen(true);
75 secondary->Hide(); 87 secondary->Hide();
76 secondary->Close(); 88 secondary->Close();
77 } 89 }
78 90
79 TEST_F(ScreenUtilTest, ConvertRect) { 91 TEST_P(ScreenUtilTest, ConvertRect) {
80 if (!SupportsMultipleDisplays()) 92 if (!SupportsMultipleDisplays())
81 return; 93 return;
82 94
83 UpdateDisplay("600x600,500x500"); 95 UpdateDisplay("600x600,500x500");
84 96
85 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( 97 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds(
86 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); 98 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
87 primary->Show(); 99 primary->Show();
88 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( 100 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
89 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); 101 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
(...skipping 11 matching lines...) Expand all
101 EXPECT_EQ( 113 EXPECT_EQ(
102 "40,40 100x100", 114 "40,40 100x100",
103 ScreenUtil::ConvertRectToScreen( 115 ScreenUtil::ConvertRectToScreen(
104 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString()); 116 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString());
105 EXPECT_EQ( 117 EXPECT_EQ(
106 "650,50 100x100", 118 "650,50 100x100",
107 ScreenUtil::ConvertRectToScreen( 119 ScreenUtil::ConvertRectToScreen(
108 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString()); 120 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString());
109 } 121 }
110 122
111 TEST_F(ScreenUtilTest, ShelfDisplayBoundsInUnifiedDesktop) { 123 TEST_P(ScreenUtilTest, ShelfDisplayBoundsInUnifiedDesktop) {
112 if (!SupportsMultipleDisplays()) 124 if (!SupportsMultipleDisplays())
113 return; 125 return;
114 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 126 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
115 127
116 display_manager->SetUnifiedDesktopEnabled(true); 128 display_manager->SetUnifiedDesktopEnabled(true);
117 129
118 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( 130 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
119 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); 131 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
120 132
121 UpdateDisplay("500x400"); 133 UpdateDisplay("500x400");
(...skipping 16 matching lines...) Expand all
138 .ToString()); 150 .ToString());
139 151
140 UpdateDisplay("600x500"); 152 UpdateDisplay("600x500");
141 EXPECT_EQ("0,0 600x500", 153 EXPECT_EQ("0,0 600x500",
142 ScreenUtil::GetShelfDisplayBoundsInRoot(widget->GetNativeWindow()) 154 ScreenUtil::GetShelfDisplayBoundsInRoot(widget->GetNativeWindow())
143 .ToString()); 155 .ToString());
144 } 156 }
145 157
146 } // namespace test 158 } // namespace test
147 } // namespace ash 159 } // 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