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

Side by Side Diff: ui/ozone/platform/dri/screen_manager_unittest.cc

Issue 522463005: [Ozone-GBM] Handle GPU crashes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated to allow proper restore of secondary displays Created 6 years, 3 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "ui/ozone/platform/dri/dri_buffer.h" 6 #include "ui/ozone/platform/dri/dri_buffer.h"
7 #include "ui/ozone/platform/dri/hardware_display_controller.h" 7 #include "ui/ozone/platform/dri/hardware_display_controller.h"
8 #include "ui/ozone/platform/dri/screen_manager.h" 8 #include "ui/ozone/platform/dri/screen_manager.h"
9 #include "ui/ozone/platform/dri/test/mock_dri_wrapper.h" 9 #include "ui/ozone/platform/dri/test/mock_dri_wrapper.h"
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 private: 69 private:
70 DISALLOW_COPY_AND_ASSIGN(ScreenManagerTest); 70 DISALLOW_COPY_AND_ASSIGN(ScreenManagerTest);
71 }; 71 };
72 72
73 TEST_F(ScreenManagerTest, CheckWithNoControllers) { 73 TEST_F(ScreenManagerTest, CheckWithNoControllers) {
74 EXPECT_FALSE(screen_manager_->GetDisplayController(GetPrimaryBounds())); 74 EXPECT_FALSE(screen_manager_->GetDisplayController(GetPrimaryBounds()));
75 } 75 }
76 76
77 TEST_F(ScreenManagerTest, CheckWithValidController) { 77 TEST_F(ScreenManagerTest, CheckWithValidController) {
78 screen_manager_->AddDisplayController(kPrimaryCrtc, kPrimaryConnector);
78 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, 79 screen_manager_->ConfigureDisplayController(kPrimaryCrtc,
79 kPrimaryConnector, 80 kPrimaryConnector,
80 GetPrimaryBounds().origin(), 81 GetPrimaryBounds().origin(),
81 kDefaultMode); 82 kDefaultMode);
82 base::WeakPtr<ui::HardwareDisplayController> controller = 83 base::WeakPtr<ui::HardwareDisplayController> controller =
83 screen_manager_->GetDisplayController(GetPrimaryBounds()); 84 screen_manager_->GetDisplayController(GetPrimaryBounds());
84 85
85 EXPECT_TRUE(controller); 86 EXPECT_TRUE(controller);
86 EXPECT_TRUE(controller->HasCrtc(kPrimaryCrtc)); 87 EXPECT_TRUE(controller->HasCrtc(kPrimaryCrtc));
87 } 88 }
88 89
89 TEST_F(ScreenManagerTest, CheckWithInvalidBounds) { 90 TEST_F(ScreenManagerTest, CheckWithInvalidBounds) {
91 screen_manager_->AddDisplayController(kPrimaryCrtc, kPrimaryConnector);
90 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, 92 screen_manager_->ConfigureDisplayController(kPrimaryCrtc,
91 kPrimaryConnector, 93 kPrimaryConnector,
92 GetPrimaryBounds().origin(), 94 GetPrimaryBounds().origin(),
93 kDefaultMode); 95 kDefaultMode);
94 96
95 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); 97 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds()));
96 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); 98 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds()));
97 } 99 }
98 100
99 TEST_F(ScreenManagerTest, CheckForSecondValidController) { 101 TEST_F(ScreenManagerTest, CheckForSecondValidController) {
102 screen_manager_->AddDisplayController(kPrimaryCrtc, kPrimaryConnector);
100 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, 103 screen_manager_->ConfigureDisplayController(kPrimaryCrtc,
101 kPrimaryConnector, 104 kPrimaryConnector,
102 GetPrimaryBounds().origin(), 105 GetPrimaryBounds().origin(),
103 kDefaultMode); 106 kDefaultMode);
104 screen_manager_->ConfigureDisplayController( 107 screen_manager_->AddDisplayController(kSecondaryCrtc, kSecondaryConnector);
105 3, 4, GetSecondaryBounds().origin(), kDefaultMode); 108 screen_manager_->ConfigureDisplayController(kSecondaryCrtc,
109 kSecondaryConnector,
110 GetSecondaryBounds().origin(),
111 kDefaultMode);
106 112
107 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); 113 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds()));
108 EXPECT_TRUE(screen_manager_->GetDisplayController(GetSecondaryBounds())); 114 EXPECT_TRUE(screen_manager_->GetDisplayController(GetSecondaryBounds()));
109 } 115 }
110 116
111 TEST_F(ScreenManagerTest, CheckControllerAfterItIsRemoved) { 117 TEST_F(ScreenManagerTest, CheckControllerAfterItIsRemoved) {
118 screen_manager_->AddDisplayController(kPrimaryCrtc, kPrimaryConnector);
112 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, 119 screen_manager_->ConfigureDisplayController(kPrimaryCrtc,
113 kPrimaryConnector, 120 kPrimaryConnector,
114 GetPrimaryBounds().origin(), 121 GetPrimaryBounds().origin(),
115 kDefaultMode); 122 kDefaultMode);
116 base::WeakPtr<ui::HardwareDisplayController> controller = 123 base::WeakPtr<ui::HardwareDisplayController> controller =
117 screen_manager_->GetDisplayController(GetPrimaryBounds()); 124 screen_manager_->GetDisplayController(GetPrimaryBounds());
118 125
119 EXPECT_TRUE(controller); 126 EXPECT_TRUE(controller);
120 screen_manager_->RemoveDisplayController(kPrimaryCrtc); 127 screen_manager_->RemoveDisplayController(kPrimaryCrtc);
121 EXPECT_FALSE(controller); 128 EXPECT_FALSE(controller);
122 } 129 }
123 130
124 TEST_F(ScreenManagerTest, CheckDuplicateConfiguration) { 131 TEST_F(ScreenManagerTest, CheckDuplicateConfiguration) {
132 screen_manager_->AddDisplayController(kPrimaryCrtc, kPrimaryConnector);
125 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, 133 screen_manager_->ConfigureDisplayController(kPrimaryCrtc,
126 kPrimaryConnector, 134 kPrimaryConnector,
127 GetPrimaryBounds().origin(), 135 GetPrimaryBounds().origin(),
128 kDefaultMode); 136 kDefaultMode);
129 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, 137 screen_manager_->ConfigureDisplayController(kPrimaryCrtc,
130 kPrimaryConnector, 138 kPrimaryConnector,
131 GetPrimaryBounds().origin(), 139 GetPrimaryBounds().origin(),
132 kDefaultMode); 140 kDefaultMode);
133 141
134 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); 142 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds()));
135 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); 143 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds()));
136 } 144 }
137 145
138 TEST_F(ScreenManagerTest, CheckChangingMode) { 146 TEST_F(ScreenManagerTest, CheckChangingMode) {
147 screen_manager_->AddDisplayController(kPrimaryCrtc, kPrimaryConnector);
139 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, 148 screen_manager_->ConfigureDisplayController(kPrimaryCrtc,
140 kPrimaryConnector, 149 kPrimaryConnector,
141 GetPrimaryBounds().origin(), 150 GetPrimaryBounds().origin(),
142 kDefaultMode); 151 kDefaultMode);
143 drmModeModeInfo new_mode = kDefaultMode; 152 drmModeModeInfo new_mode = kDefaultMode;
144 new_mode.vdisplay = 10; 153 new_mode.vdisplay = 10;
145 screen_manager_->ConfigureDisplayController( 154 screen_manager_->ConfigureDisplayController(
146 kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), new_mode); 155 kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), new_mode);
147 156
148 gfx::Rect new_bounds(0, 0, new_mode.hdisplay, new_mode.vdisplay); 157 gfx::Rect new_bounds(0, 0, new_mode.hdisplay, new_mode.vdisplay);
149 EXPECT_TRUE(screen_manager_->GetDisplayController(new_bounds)); 158 EXPECT_TRUE(screen_manager_->GetDisplayController(new_bounds));
150 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); 159 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds()));
151 drmModeModeInfo mode = 160 drmModeModeInfo mode =
152 screen_manager_->GetDisplayController(new_bounds)->get_mode(); 161 screen_manager_->GetDisplayController(new_bounds)->get_mode();
153 EXPECT_EQ(new_mode.vdisplay, mode.vdisplay); 162 EXPECT_EQ(new_mode.vdisplay, mode.vdisplay);
154 EXPECT_EQ(new_mode.hdisplay, mode.hdisplay); 163 EXPECT_EQ(new_mode.hdisplay, mode.hdisplay);
155 } 164 }
156 165
157 TEST_F(ScreenManagerTest, CheckForControllersInMirroredMode) { 166 TEST_F(ScreenManagerTest, CheckForControllersInMirroredMode) {
167 screen_manager_->AddDisplayController(kPrimaryCrtc, kPrimaryConnector);
158 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, 168 screen_manager_->ConfigureDisplayController(kPrimaryCrtc,
159 kPrimaryConnector, 169 kPrimaryConnector,
160 GetPrimaryBounds().origin(), 170 GetPrimaryBounds().origin(),
161 kDefaultMode); 171 kDefaultMode);
172 screen_manager_->AddDisplayController(kSecondaryCrtc, kSecondaryConnector);
162 screen_manager_->ConfigureDisplayController(kSecondaryCrtc, 173 screen_manager_->ConfigureDisplayController(kSecondaryCrtc,
163 kSecondaryConnector, 174 kSecondaryConnector,
164 GetPrimaryBounds().origin(), 175 GetPrimaryBounds().origin(),
165 kDefaultMode); 176 kDefaultMode);
166 177
167 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); 178 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds()));
168 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); 179 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds()));
169 } 180 }
170 181
171 TEST_F(ScreenManagerTest, CheckMirrorModeTransitions) { 182 TEST_F(ScreenManagerTest, CheckMirrorModeTransitions) {
183 screen_manager_->AddDisplayController(kPrimaryCrtc, kPrimaryConnector);
172 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, 184 screen_manager_->ConfigureDisplayController(kPrimaryCrtc,
173 kPrimaryConnector, 185 kPrimaryConnector,
174 GetPrimaryBounds().origin(), 186 GetPrimaryBounds().origin(),
175 kDefaultMode); 187 kDefaultMode);
188 screen_manager_->AddDisplayController(kSecondaryCrtc, kSecondaryConnector);
176 screen_manager_->ConfigureDisplayController(kSecondaryCrtc, 189 screen_manager_->ConfigureDisplayController(kSecondaryCrtc,
177 kSecondaryConnector, 190 kSecondaryConnector,
178 GetSecondaryBounds().origin(), 191 GetSecondaryBounds().origin(),
179 kDefaultMode); 192 kDefaultMode);
180 193
181 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); 194 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds()));
182 EXPECT_TRUE(screen_manager_->GetDisplayController(GetSecondaryBounds())); 195 EXPECT_TRUE(screen_manager_->GetDisplayController(GetSecondaryBounds()));
183 196
184 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, 197 screen_manager_->ConfigureDisplayController(kPrimaryCrtc,
185 kPrimaryConnector, 198 kPrimaryConnector,
(...skipping 12 matching lines...) Expand all
198 kDefaultMode); 211 kDefaultMode);
199 screen_manager_->ConfigureDisplayController(kSecondaryCrtc, 212 screen_manager_->ConfigureDisplayController(kSecondaryCrtc,
200 kSecondaryConnector, 213 kSecondaryConnector,
201 GetPrimaryBounds().origin(), 214 GetPrimaryBounds().origin(),
202 kDefaultMode); 215 kDefaultMode);
203 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); 216 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds()));
204 EXPECT_TRUE(screen_manager_->GetDisplayController(GetSecondaryBounds())); 217 EXPECT_TRUE(screen_manager_->GetDisplayController(GetSecondaryBounds()));
205 } 218 }
206 219
207 TEST_F(ScreenManagerTest, MonitorGoneInMirrorMode) { 220 TEST_F(ScreenManagerTest, MonitorGoneInMirrorMode) {
221 screen_manager_->AddDisplayController(kPrimaryCrtc, kPrimaryConnector);
208 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, 222 screen_manager_->ConfigureDisplayController(kPrimaryCrtc,
209 kPrimaryConnector, 223 kPrimaryConnector,
210 GetPrimaryBounds().origin(), 224 GetPrimaryBounds().origin(),
211 kDefaultMode); 225 kDefaultMode);
226 screen_manager_->AddDisplayController(kSecondaryCrtc, kSecondaryConnector);
212 screen_manager_->ConfigureDisplayController(kSecondaryCrtc, 227 screen_manager_->ConfigureDisplayController(kSecondaryCrtc,
213 kSecondaryConnector, 228 kSecondaryConnector,
214 GetPrimaryBounds().origin(), 229 GetPrimaryBounds().origin(),
215 kDefaultMode); 230 kDefaultMode);
216 231
217 screen_manager_->RemoveDisplayController(kSecondaryCrtc); 232 screen_manager_->RemoveDisplayController(kSecondaryCrtc);
218 EXPECT_TRUE( 233 EXPECT_TRUE(
219 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, 234 screen_manager_->ConfigureDisplayController(kPrimaryCrtc,
220 kPrimaryConnector, 235 kPrimaryConnector,
221 GetPrimaryBounds().origin(), 236 GetPrimaryBounds().origin(),
222 kDefaultMode)); 237 kDefaultMode));
223 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); 238 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds()));
224 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); 239 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds()));
225 } 240 }
OLDNEW
« ui/ozone/platform/dri/screen_manager.cc ('K') | « ui/ozone/platform/dri/screen_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698