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

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 further feedback 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 typedef test::AshMDTestBase ScreenUtilTest;
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(ash::MaterialDesignController::NON_MATERIAL,
29 ash::MaterialDesignController::MATERIAL_NORMAL,
30 ash::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(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(),
37 primary->GetNativeView()) 47 ScreenUtil::GetMaximizedWindowBoundsInParent(
38 .ToString()); 48 primary->GetNativeView()).ToString());
39 EXPECT_EQ("0,0 500x453", 49 EXPECT_EQ(gfx::Rect(0, 0, 500, 453 + height_offset).ToString(),
40 ScreenUtil::GetMaximizedWindowBoundsInParent( 50 ScreenUtil::GetMaximizedWindowBoundsInParent(
41 secondary->GetNativeView()).ToString()); 51 secondary->GetNativeView()).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(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(),
53 primary->GetNativeView()) 63 ScreenUtil::GetDisplayWorkAreaBoundsInParent(
54 .ToString()); 64 primary->GetNativeView()).ToString());
55 EXPECT_EQ("0,0 500x453", 65 EXPECT_EQ(gfx::Rect(0, 0, 500, 453 + height_offset).ToString(),
56 ScreenUtil::GetDisplayWorkAreaBoundsInParent( 66 ScreenUtil::GetDisplayWorkAreaBoundsInParent(
57 secondary->GetNativeView()).ToString()); 67 secondary->GetNativeView()).ToString());
58 } 68 }
59 69
60 // Test verifies a stable handling of secondary screen widget changes 70 // Test verifies a stable handling of secondary screen widget changes
61 // (crbug.com/226132). 71 // (crbug.com/226132).
62 TEST_F(ScreenUtilTest, StabilityTest) { 72 TEST_P(ScreenUtilTest, StabilityTest) {
63 if (!SupportsMultipleDisplays()) 73 if (!SupportsMultipleDisplays())
64 return; 74 return;
65 75
66 UpdateDisplay("600x600,500x500"); 76 UpdateDisplay("600x600,500x500");
67 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( 77 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
68 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); 78 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
69 EXPECT_EQ(Shell::GetAllRootWindows()[1], 79 EXPECT_EQ(Shell::GetAllRootWindows()[1],
70 secondary->GetNativeView()->GetRootWindow()); 80 secondary->GetNativeView()->GetRootWindow());
71 secondary->Show(); 81 secondary->Show();
72 secondary->Maximize(); 82 secondary->Maximize();
73 secondary->Show(); 83 secondary->Show();
74 secondary->SetFullscreen(true); 84 secondary->SetFullscreen(true);
75 secondary->Hide(); 85 secondary->Hide();
76 secondary->Close(); 86 secondary->Close();
77 } 87 }
78 88
79 TEST_F(ScreenUtilTest, ConvertRect) { 89 TEST_P(ScreenUtilTest, ConvertRect) {
80 if (!SupportsMultipleDisplays()) 90 if (!SupportsMultipleDisplays())
81 return; 91 return;
82 92
83 UpdateDisplay("600x600,500x500"); 93 UpdateDisplay("600x600,500x500");
84 94
85 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( 95 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds(
86 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); 96 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
87 primary->Show(); 97 primary->Show();
88 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( 98 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
89 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); 99 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
(...skipping 11 matching lines...) Expand all
101 EXPECT_EQ( 111 EXPECT_EQ(
102 "40,40 100x100", 112 "40,40 100x100",
103 ScreenUtil::ConvertRectToScreen( 113 ScreenUtil::ConvertRectToScreen(
104 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString()); 114 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString());
105 EXPECT_EQ( 115 EXPECT_EQ(
106 "650,50 100x100", 116 "650,50 100x100",
107 ScreenUtil::ConvertRectToScreen( 117 ScreenUtil::ConvertRectToScreen(
108 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString()); 118 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString());
109 } 119 }
110 120
111 TEST_F(ScreenUtilTest, ShelfDisplayBoundsInUnifiedDesktop) { 121 TEST_P(ScreenUtilTest, ShelfDisplayBoundsInUnifiedDesktop) {
112 if (!SupportsMultipleDisplays()) 122 if (!SupportsMultipleDisplays())
113 return; 123 return;
114 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 124 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
115 125
116 display_manager->SetUnifiedDesktopEnabled(true); 126 display_manager->SetUnifiedDesktopEnabled(true);
117 127
118 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( 128 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
119 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); 129 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
120 130
121 UpdateDisplay("500x400"); 131 UpdateDisplay("500x400");
(...skipping 16 matching lines...) Expand all
138 .ToString()); 148 .ToString());
139 149
140 UpdateDisplay("600x500"); 150 UpdateDisplay("600x500");
141 EXPECT_EQ("0,0 600x500", 151 EXPECT_EQ("0,0 600x500",
142 ScreenUtil::GetShelfDisplayBoundsInRoot(widget->GetNativeWindow()) 152 ScreenUtil::GetShelfDisplayBoundsInRoot(widget->GetNativeWindow())
143 .ToString()); 153 .ToString());
144 } 154 }
145 155
146 } // namespace test 156 } // namespace test
147 } // namespace ash 157 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698