OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/message_loop/message_loop.h" | |
9 #include "mojo/public/cpp/bindings/binding_set.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/display/display.h" | 9 #include "ui/display/display.h" |
12 #include "ui/display/display_layout.h" | 10 #include "ui/display/display_layout.h" |
13 #include "ui/display/mojo/display_struct_traits_test.mojom.h" | 11 #include "ui/display/mojo/display_layout_struct_traits.h" |
| 12 #include "ui/display/mojo/display_mode_struct_traits.h" |
| 13 #include "ui/display/mojo/display_snapshot_mojo_struct_traits.h" |
| 14 #include "ui/display/mojo/display_struct_traits.h" |
| 15 #include "ui/display/mojo/gamma_ramp_rgb_entry_struct_traits.h" |
14 #include "ui/display/types/display_constants.h" | 16 #include "ui/display/types/display_constants.h" |
15 #include "ui/display/types/display_mode.h" | 17 #include "ui/display/types/display_mode.h" |
16 #include "ui/display/types/display_snapshot_mojo.h" | 18 #include "ui/display/types/display_snapshot_mojo.h" |
17 #include "ui/display/types/gamma_ramp_rgb_entry.h" | 19 #include "ui/display/types/gamma_ramp_rgb_entry.h" |
18 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
19 #include "ui/gfx/geometry/size.h" | 21 #include "ui/gfx/geometry/size.h" |
20 | 22 |
21 namespace display { | 23 namespace display { |
22 namespace { | 24 namespace { |
23 | 25 |
24 constexpr int64_t kDisplayId1 = 123; | 26 constexpr int64_t kDisplayId1 = 123; |
25 constexpr int64_t kDisplayId2 = 456; | 27 constexpr int64_t kDisplayId2 = 456; |
26 constexpr int64_t kDisplayId3 = 789; | 28 constexpr int64_t kDisplayId3 = 789; |
27 | 29 |
28 class DisplayStructTraitsTest : public testing::Test, | |
29 public mojom::DisplayStructTraitsTest { | |
30 public: | |
31 DisplayStructTraitsTest() {} | |
32 | |
33 protected: | |
34 mojom::DisplayStructTraitsTestPtr GetTraitsTestProxy() { | |
35 return traits_test_bindings_.CreateInterfacePtrAndBind(this); | |
36 } | |
37 | |
38 private: | |
39 // mojom::DisplayStructTraitsTest: | |
40 void EchoDisplay(const Display& in, | |
41 const EchoDisplayCallback& callback) override { | |
42 callback.Run(in); | |
43 } | |
44 | |
45 void EchoDisplayMode(std::unique_ptr<DisplayMode> in, | |
46 const EchoDisplayModeCallback& callback) override { | |
47 callback.Run(std::move(in)); | |
48 } | |
49 | |
50 void EchoDisplaySnapshotMojo( | |
51 std::unique_ptr<DisplaySnapshotMojo> in, | |
52 const EchoDisplaySnapshotMojoCallback& callback) override { | |
53 callback.Run(std::move(in)); | |
54 } | |
55 | |
56 void EchoDisplayPlacement( | |
57 const DisplayPlacement& in, | |
58 const EchoDisplayPlacementCallback& callback) override { | |
59 callback.Run(in); | |
60 } | |
61 | |
62 void EchoDisplayLayout(std::unique_ptr<display::DisplayLayout> in, | |
63 const EchoDisplayLayoutCallback& callback) override { | |
64 callback.Run(std::move(in)); | |
65 } | |
66 | |
67 void EchoHDCPState(display::HDCPState in, | |
68 const EchoHDCPStateCallback& callback) override { | |
69 callback.Run(in); | |
70 } | |
71 | |
72 void EchoGammaRampRGBEntry( | |
73 const GammaRampRGBEntry& in, | |
74 const EchoGammaRampRGBEntryCallback& callback) override { | |
75 callback.Run(in); | |
76 } | |
77 | |
78 base::MessageLoop loop_; // A MessageLoop is needed for Mojo IPC to work. | |
79 mojo::BindingSet<mojom::DisplayStructTraitsTest> traits_test_bindings_; | |
80 | |
81 DISALLOW_COPY_AND_ASSIGN(DisplayStructTraitsTest); | |
82 }; | |
83 | |
84 void CheckDisplaysEqual(const Display& input, const Display& output) { | 30 void CheckDisplaysEqual(const Display& input, const Display& output) { |
85 EXPECT_NE(&input, &output); // Make sure they aren't the same object. | 31 EXPECT_NE(&input, &output); // Make sure they aren't the same object. |
86 EXPECT_EQ(input.id(), output.id()); | 32 EXPECT_EQ(input.id(), output.id()); |
87 EXPECT_EQ(input.bounds(), output.bounds()); | 33 EXPECT_EQ(input.bounds(), output.bounds()); |
88 EXPECT_EQ(input.work_area(), output.work_area()); | 34 EXPECT_EQ(input.work_area(), output.work_area()); |
89 EXPECT_EQ(input.device_scale_factor(), output.device_scale_factor()); | 35 EXPECT_EQ(input.device_scale_factor(), output.device_scale_factor()); |
90 EXPECT_EQ(input.rotation(), output.rotation()); | 36 EXPECT_EQ(input.rotation(), output.rotation()); |
91 EXPECT_EQ(input.touch_support(), output.touch_support()); | 37 EXPECT_EQ(input.touch_support(), output.touch_support()); |
92 EXPECT_EQ(input.maximum_cursor_size(), output.maximum_cursor_size()); | 38 EXPECT_EQ(input.maximum_cursor_size(), output.maximum_cursor_size()); |
93 } | 39 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 EXPECT_TRUE(CompareModes(*input.current_mode(), *output.current_mode())); | 83 EXPECT_TRUE(CompareModes(*input.current_mode(), *output.current_mode())); |
138 | 84 |
139 if (!input.native_mode()) | 85 if (!input.native_mode()) |
140 EXPECT_EQ(nullptr, output.native_mode()); | 86 EXPECT_EQ(nullptr, output.native_mode()); |
141 else | 87 else |
142 EXPECT_TRUE(CompareModes(*input.native_mode(), *output.native_mode())); | 88 EXPECT_TRUE(CompareModes(*input.native_mode(), *output.native_mode())); |
143 | 89 |
144 EXPECT_EQ(input.maximum_cursor_size(), output.maximum_cursor_size()); | 90 EXPECT_EQ(input.maximum_cursor_size(), output.maximum_cursor_size()); |
145 } | 91 } |
146 | 92 |
| 93 // Test StructTrait serialization and deserialization for copyable type. |input| |
| 94 // will be serialized and then deserialized into |output|. |
| 95 template <class MojomType, class Type> |
| 96 void SerializeAndDeserialize(const Type& input, Type* output) { |
| 97 MojomType::Deserialize(MojomType::Serialize(&input), output); |
| 98 } |
| 99 |
| 100 // Test StructTrait serialization and deserialization for move only type. |
| 101 // |input| will be serialized and then deserialized into |output|. |
| 102 template <class MojomType, class Type> |
| 103 void SerializeAndDeserialize(Type&& input, Type* output) { |
| 104 MojomType::Deserialize(MojomType::Serialize(&input), output); |
| 105 } |
147 } // namespace | 106 } // namespace |
148 | 107 |
149 TEST_F(DisplayStructTraitsTest, DefaultDisplayValues) { | 108 TEST(DisplayStructTraitsTest, DefaultDisplayValues) { |
150 Display input(5); | 109 Display input(5); |
151 | 110 |
152 Display output; | 111 Display output; |
153 GetTraitsTestProxy()->EchoDisplay(input, &output); | 112 SerializeAndDeserialize<mojom::Display>(input, &output); |
154 | 113 |
155 CheckDisplaysEqual(input, output); | 114 CheckDisplaysEqual(input, output); |
156 } | 115 } |
157 | 116 |
158 TEST_F(DisplayStructTraitsTest, SetAllDisplayValues) { | 117 TEST(DisplayStructTraitsTest, SetAllDisplayValues) { |
159 const gfx::Rect bounds(100, 200, 500, 600); | 118 const gfx::Rect bounds(100, 200, 500, 600); |
160 const gfx::Rect work_area(150, 250, 400, 500); | 119 const gfx::Rect work_area(150, 250, 400, 500); |
161 const gfx::Size maximum_cursor_size(64, 64); | 120 const gfx::Size maximum_cursor_size(64, 64); |
162 | 121 |
163 Display input(246345234, bounds); | 122 Display input(246345234, bounds); |
164 input.set_work_area(work_area); | 123 input.set_work_area(work_area); |
165 input.set_device_scale_factor(2.0f); | 124 input.set_device_scale_factor(2.0f); |
166 input.set_rotation(Display::ROTATE_270); | 125 input.set_rotation(Display::ROTATE_270); |
167 input.set_touch_support(Display::TOUCH_SUPPORT_AVAILABLE); | 126 input.set_touch_support(Display::TOUCH_SUPPORT_AVAILABLE); |
168 input.set_maximum_cursor_size(maximum_cursor_size); | 127 input.set_maximum_cursor_size(maximum_cursor_size); |
169 | 128 |
170 Display output; | 129 Display output; |
171 GetTraitsTestProxy()->EchoDisplay(input, &output); | 130 SerializeAndDeserialize<mojom::Display>(input, &output); |
172 | 131 |
173 CheckDisplaysEqual(input, output); | 132 CheckDisplaysEqual(input, output); |
174 } | 133 } |
175 | 134 |
176 TEST_F(DisplayStructTraitsTest, DefaultDisplayMode) { | 135 TEST(DisplayStructTraitsTest, DefaultDisplayMode) { |
177 std::unique_ptr<DisplayMode> input = | 136 std::unique_ptr<DisplayMode> input = |
178 base::MakeUnique<DisplayMode>(gfx::Size(1024, 768), true, 61.0); | 137 base::MakeUnique<DisplayMode>(gfx::Size(1024, 768), true, 61.0); |
179 | 138 |
180 mojom::DisplayStructTraitsTestPtr proxy = GetTraitsTestProxy(); | |
181 std::unique_ptr<DisplayMode> output; | 139 std::unique_ptr<DisplayMode> output; |
182 | 140 SerializeAndDeserialize<mojom::DisplayMode>(input->Clone(), &output); |
183 proxy->EchoDisplayMode(input->Clone(), &output); | |
184 | 141 |
185 // We want to test each component individually to make sure each data member | 142 // We want to test each component individually to make sure each data member |
186 // was correctly serialized and deserialized. | 143 // was correctly serialized and deserialized. |
187 EXPECT_EQ(input->size(), output->size()); | 144 EXPECT_EQ(input->size(), output->size()); |
188 EXPECT_EQ(input->is_interlaced(), output->is_interlaced()); | 145 EXPECT_EQ(input->is_interlaced(), output->is_interlaced()); |
189 EXPECT_EQ(input->refresh_rate(), output->refresh_rate()); | 146 EXPECT_EQ(input->refresh_rate(), output->refresh_rate()); |
190 } | 147 } |
191 | 148 |
192 TEST_F(DisplayStructTraitsTest, DisplayPlacementFlushAtTop) { | 149 TEST(DisplayStructTraitsTest, DisplayPlacementFlushAtTop) { |
193 DisplayPlacement input; | 150 DisplayPlacement input; |
194 input.display_id = kDisplayId1; | 151 input.display_id = kDisplayId1; |
195 input.parent_display_id = kDisplayId2; | 152 input.parent_display_id = kDisplayId2; |
196 input.position = DisplayPlacement::TOP; | 153 input.position = DisplayPlacement::TOP; |
197 input.offset = 0; | 154 input.offset = 0; |
198 input.offset_reference = DisplayPlacement::TOP_LEFT; | 155 input.offset_reference = DisplayPlacement::TOP_LEFT; |
199 | 156 |
200 DisplayPlacement output; | 157 DisplayPlacement output; |
201 GetTraitsTestProxy()->EchoDisplayPlacement(input, &output); | 158 SerializeAndDeserialize<mojom::DisplayPlacement>(input, &output); |
202 | 159 |
203 EXPECT_EQ(input, output); | 160 EXPECT_EQ(input, output); |
204 } | 161 } |
205 | 162 |
206 TEST_F(DisplayStructTraitsTest, DisplayPlacementWithOffset) { | 163 TEST(DisplayStructTraitsTest, DisplayPlacementWithOffset) { |
207 DisplayPlacement input; | 164 DisplayPlacement input; |
208 input.display_id = kDisplayId1; | 165 input.display_id = kDisplayId1; |
209 input.parent_display_id = kDisplayId2; | 166 input.parent_display_id = kDisplayId2; |
210 input.position = DisplayPlacement::BOTTOM; | 167 input.position = DisplayPlacement::BOTTOM; |
211 input.offset = -100; | 168 input.offset = -100; |
212 input.offset_reference = DisplayPlacement::BOTTOM_RIGHT; | 169 input.offset_reference = DisplayPlacement::BOTTOM_RIGHT; |
213 | 170 |
214 DisplayPlacement output; | 171 DisplayPlacement output; |
215 GetTraitsTestProxy()->EchoDisplayPlacement(input, &output); | 172 SerializeAndDeserialize<mojom::DisplayPlacement>(input, &output); |
216 | 173 |
217 EXPECT_EQ(input, output); | 174 EXPECT_EQ(input, output); |
218 } | 175 } |
219 | 176 |
220 TEST_F(DisplayStructTraitsTest, DisplayLayoutTwoExtended) { | 177 TEST(DisplayStructTraitsTest, DisplayLayoutTwoExtended) { |
221 DisplayPlacement placement; | 178 DisplayPlacement placement; |
222 placement.display_id = kDisplayId1; | 179 placement.display_id = kDisplayId1; |
223 placement.parent_display_id = kDisplayId2; | 180 placement.parent_display_id = kDisplayId2; |
224 placement.position = DisplayPlacement::RIGHT; | 181 placement.position = DisplayPlacement::RIGHT; |
225 placement.offset = 0; | 182 placement.offset = 0; |
226 placement.offset_reference = DisplayPlacement::TOP_LEFT; | 183 placement.offset_reference = DisplayPlacement::TOP_LEFT; |
227 | 184 |
228 auto input = base::MakeUnique<DisplayLayout>(); | 185 auto input = base::MakeUnique<DisplayLayout>(); |
229 input->placement_list.push_back(placement); | 186 input->placement_list.push_back(placement); |
230 input->primary_id = kDisplayId2; | 187 input->primary_id = kDisplayId2; |
231 input->mirrored = false; | 188 input->mirrored = false; |
232 input->default_unified = true; | 189 input->default_unified = true; |
233 | 190 |
234 std::unique_ptr<DisplayLayout> output; | 191 std::unique_ptr<DisplayLayout> output; |
235 GetTraitsTestProxy()->EchoDisplayLayout(input->Copy(), &output); | 192 SerializeAndDeserialize<mojom::DisplayLayout>(input->Copy(), &output); |
236 | 193 |
237 CheckDisplayLayoutsEqual(*input, *output); | 194 CheckDisplayLayoutsEqual(*input, *output); |
238 } | 195 } |
239 | 196 |
240 TEST_F(DisplayStructTraitsTest, DisplayLayoutThreeExtended) { | 197 TEST(DisplayStructTraitsTest, DisplayLayoutThreeExtended) { |
241 DisplayPlacement placement1; | 198 DisplayPlacement placement1; |
242 placement1.display_id = kDisplayId2; | 199 placement1.display_id = kDisplayId2; |
243 placement1.parent_display_id = kDisplayId1; | 200 placement1.parent_display_id = kDisplayId1; |
244 placement1.position = DisplayPlacement::LEFT; | 201 placement1.position = DisplayPlacement::LEFT; |
245 placement1.offset = 0; | 202 placement1.offset = 0; |
246 placement1.offset_reference = DisplayPlacement::TOP_LEFT; | 203 placement1.offset_reference = DisplayPlacement::TOP_LEFT; |
247 | 204 |
248 DisplayPlacement placement2; | 205 DisplayPlacement placement2; |
249 placement2.display_id = kDisplayId3; | 206 placement2.display_id = kDisplayId3; |
250 placement2.parent_display_id = kDisplayId1; | 207 placement2.parent_display_id = kDisplayId1; |
251 placement2.position = DisplayPlacement::RIGHT; | 208 placement2.position = DisplayPlacement::RIGHT; |
252 placement2.offset = -100; | 209 placement2.offset = -100; |
253 placement2.offset_reference = DisplayPlacement::BOTTOM_RIGHT; | 210 placement2.offset_reference = DisplayPlacement::BOTTOM_RIGHT; |
254 | 211 |
255 auto input = base::MakeUnique<DisplayLayout>(); | 212 auto input = base::MakeUnique<DisplayLayout>(); |
256 input->placement_list.push_back(placement1); | 213 input->placement_list.push_back(placement1); |
257 input->placement_list.push_back(placement2); | 214 input->placement_list.push_back(placement2); |
258 input->primary_id = kDisplayId1; | 215 input->primary_id = kDisplayId1; |
259 input->mirrored = false; | 216 input->mirrored = false; |
260 input->default_unified = false; | 217 input->default_unified = false; |
261 | 218 |
262 std::unique_ptr<DisplayLayout> output; | 219 std::unique_ptr<DisplayLayout> output; |
263 GetTraitsTestProxy()->EchoDisplayLayout(input->Copy(), &output); | 220 SerializeAndDeserialize<mojom::DisplayLayout>(input->Copy(), &output); |
264 | 221 |
265 CheckDisplayLayoutsEqual(*input, *output); | 222 CheckDisplayLayoutsEqual(*input, *output); |
266 } | 223 } |
267 | 224 |
268 TEST_F(DisplayStructTraitsTest, DisplayLayoutTwoMirrored) { | 225 TEST(DisplayStructTraitsTest, DisplayLayoutTwoMirrored) { |
269 DisplayPlacement placement; | 226 DisplayPlacement placement; |
270 placement.display_id = kDisplayId1; | 227 placement.display_id = kDisplayId1; |
271 placement.parent_display_id = kDisplayId2; | 228 placement.parent_display_id = kDisplayId2; |
272 placement.position = DisplayPlacement::RIGHT; | 229 placement.position = DisplayPlacement::RIGHT; |
273 placement.offset = 0; | 230 placement.offset = 0; |
274 placement.offset_reference = DisplayPlacement::TOP_LEFT; | 231 placement.offset_reference = DisplayPlacement::TOP_LEFT; |
275 | 232 |
276 auto input = base::MakeUnique<DisplayLayout>(); | 233 auto input = base::MakeUnique<DisplayLayout>(); |
277 input->placement_list.push_back(placement); | 234 input->placement_list.push_back(placement); |
278 input->primary_id = kDisplayId2; | 235 input->primary_id = kDisplayId2; |
279 input->mirrored = true; | 236 input->mirrored = true; |
280 input->default_unified = true; | 237 input->default_unified = true; |
281 | 238 |
282 std::unique_ptr<DisplayLayout> output; | 239 std::unique_ptr<DisplayLayout> output; |
283 GetTraitsTestProxy()->EchoDisplayLayout(input->Copy(), &output); | 240 SerializeAndDeserialize<mojom::DisplayLayout>(input->Copy(), &output); |
284 | 241 |
285 CheckDisplayLayoutsEqual(*input, *output); | 242 CheckDisplayLayoutsEqual(*input, *output); |
286 } | 243 } |
287 | 244 |
288 TEST_F(DisplayStructTraitsTest, BasicGammaRampRGBEntry) { | 245 TEST(DisplayStructTraitsTest, BasicGammaRampRGBEntry) { |
289 const GammaRampRGBEntry input{259, 81, 16}; | 246 const GammaRampRGBEntry input{259, 81, 16}; |
290 | 247 |
291 GammaRampRGBEntry output; | 248 GammaRampRGBEntry output; |
292 GetTraitsTestProxy()->EchoGammaRampRGBEntry(input, &output); | 249 SerializeAndDeserialize<mojom::GammaRampRGBEntry>(input, &output); |
293 | 250 |
294 EXPECT_EQ(input.r, output.r); | 251 EXPECT_EQ(input.r, output.r); |
295 EXPECT_EQ(input.g, output.g); | 252 EXPECT_EQ(input.g, output.g); |
296 EXPECT_EQ(input.b, output.b); | 253 EXPECT_EQ(input.b, output.b); |
297 } | 254 } |
298 | 255 |
299 // One display mode, current and native mode nullptr. | 256 // One display mode, current and native mode nullptr. |
300 TEST_F(DisplayStructTraitsTest, DisplaySnapshotCurrentAndNativeModesNull) { | 257 TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentAndNativeModesNull) { |
301 // Prepare sample input with random values. | 258 // Prepare sample input with random values. |
302 const int64_t display_id = 7; | 259 const int64_t display_id = 7; |
303 const gfx::Point origin(1, 2); | 260 const gfx::Point origin(1, 2); |
304 const gfx::Size physical_size(5, 9); | 261 const gfx::Size physical_size(5, 9); |
305 const gfx::Size maximum_cursor_size(3, 5); | 262 const gfx::Size maximum_cursor_size(3, 5); |
306 const DisplayConnectionType type = | 263 const DisplayConnectionType type = |
307 display::DISPLAY_CONNECTION_TYPE_DISPLAYPORT; | 264 display::DISPLAY_CONNECTION_TYPE_DISPLAYPORT; |
308 const bool is_aspect_preserving_scaling = true; | 265 const bool is_aspect_preserving_scaling = true; |
309 const bool has_overscan = true; | 266 const bool has_overscan = true; |
310 const bool has_color_correction_matrix = true; | 267 const bool has_color_correction_matrix = true; |
(...skipping 11 matching lines...) Expand all Loading... |
322 const std::vector<uint8_t> edid = {1}; | 279 const std::vector<uint8_t> edid = {1}; |
323 | 280 |
324 std::unique_ptr<DisplaySnapshotMojo> input = | 281 std::unique_ptr<DisplaySnapshotMojo> input = |
325 base::MakeUnique<DisplaySnapshotMojo>( | 282 base::MakeUnique<DisplaySnapshotMojo>( |
326 display_id, origin, physical_size, type, is_aspect_preserving_scaling, | 283 display_id, origin, physical_size, type, is_aspect_preserving_scaling, |
327 has_overscan, has_color_correction_matrix, display_name, sys_path, | 284 has_overscan, has_color_correction_matrix, display_name, sys_path, |
328 product_id, std::move(modes), edid, current_mode, native_mode, | 285 product_id, std::move(modes), edid, current_mode, native_mode, |
329 maximum_cursor_size); | 286 maximum_cursor_size); |
330 | 287 |
331 std::unique_ptr<DisplaySnapshotMojo> output; | 288 std::unique_ptr<DisplaySnapshotMojo> output; |
332 GetTraitsTestProxy()->EchoDisplaySnapshotMojo( | 289 SerializeAndDeserialize<mojom::DisplaySnapshotMojo>( |
333 DisplaySnapshotMojo::CreateFrom(*input), &output); | 290 DisplaySnapshotMojo::CreateFrom(*input), &output); |
334 | 291 |
335 CheckDisplaySnapShotMojoEqual(*input, *output); | 292 CheckDisplaySnapShotMojoEqual(*input, *output); |
336 } | 293 } |
337 | 294 |
338 // One display mode that is the native mode and no current mode. | 295 // One display mode that is the native mode and no current mode. |
339 TEST_F(DisplayStructTraitsTest, DisplaySnapshotCurrentModeNull) { | 296 TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentModeNull) { |
340 // Prepare sample input with random values. | 297 // Prepare sample input with random values. |
341 const int64_t display_id = 6; | 298 const int64_t display_id = 6; |
342 const gfx::Point origin(11, 32); | 299 const gfx::Point origin(11, 32); |
343 const gfx::Size physical_size(55, 49); | 300 const gfx::Size physical_size(55, 49); |
344 const gfx::Size maximum_cursor_size(13, 95); | 301 const gfx::Size maximum_cursor_size(13, 95); |
345 const DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_VGA; | 302 const DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_VGA; |
346 const bool is_aspect_preserving_scaling = true; | 303 const bool is_aspect_preserving_scaling = true; |
347 const bool has_overscan = true; | 304 const bool has_overscan = true; |
348 const bool has_color_correction_matrix = true; | 305 const bool has_color_correction_matrix = true; |
349 const std::string display_name("whatever display_name"); | 306 const std::string display_name("whatever display_name"); |
(...skipping 10 matching lines...) Expand all Loading... |
360 const std::vector<uint8_t> edid = {1}; | 317 const std::vector<uint8_t> edid = {1}; |
361 | 318 |
362 std::unique_ptr<DisplaySnapshotMojo> input = | 319 std::unique_ptr<DisplaySnapshotMojo> input = |
363 base::MakeUnique<DisplaySnapshotMojo>( | 320 base::MakeUnique<DisplaySnapshotMojo>( |
364 display_id, origin, physical_size, type, is_aspect_preserving_scaling, | 321 display_id, origin, physical_size, type, is_aspect_preserving_scaling, |
365 has_overscan, has_color_correction_matrix, display_name, sys_path, | 322 has_overscan, has_color_correction_matrix, display_name, sys_path, |
366 product_id, std::move(modes), edid, current_mode, native_mode, | 323 product_id, std::move(modes), edid, current_mode, native_mode, |
367 maximum_cursor_size); | 324 maximum_cursor_size); |
368 | 325 |
369 std::unique_ptr<DisplaySnapshotMojo> output; | 326 std::unique_ptr<DisplaySnapshotMojo> output; |
370 GetTraitsTestProxy()->EchoDisplaySnapshotMojo( | 327 SerializeAndDeserialize<mojom::DisplaySnapshotMojo>( |
371 DisplaySnapshotMojo::CreateFrom(*input), &output); | 328 DisplaySnapshotMojo::CreateFrom(*input), &output); |
372 | 329 |
373 CheckDisplaySnapShotMojoEqual(*input, *output); | 330 CheckDisplaySnapShotMojoEqual(*input, *output); |
374 } | 331 } |
375 | 332 |
376 // Multiple display modes, both native and current mode set. | 333 // Multiple display modes, both native and current mode set. |
377 TEST_F(DisplayStructTraitsTest, DisplaySnapshotExternal) { | 334 TEST(DisplayStructTraitsTest, DisplaySnapshotExternal) { |
378 // Prepare sample input from external display. | 335 // Prepare sample input from external display. |
379 const int64_t display_id = 9834293210466051; | 336 const int64_t display_id = 9834293210466051; |
380 const gfx::Point origin(0, 1760); | 337 const gfx::Point origin(0, 1760); |
381 const gfx::Size physical_size(520, 320); | 338 const gfx::Size physical_size(520, 320); |
382 const gfx::Size maximum_cursor_size(4, 5); | 339 const gfx::Size maximum_cursor_size(4, 5); |
383 const DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_HDMI; | 340 const DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_HDMI; |
384 const bool is_aspect_preserving_scaling = false; | 341 const bool is_aspect_preserving_scaling = false; |
385 const bool has_overscan = false; | 342 const bool has_overscan = false; |
386 const bool has_color_correction_matrix = false; | 343 const bool has_color_correction_matrix = false; |
387 const std::string display_name("HP Z24i"); | 344 const std::string display_name("HP Z24i"); |
(...skipping 14 matching lines...) Expand all Loading... |
402 const std::vector<uint8_t> edid = {2, 3, 4, 5}; | 359 const std::vector<uint8_t> edid = {2, 3, 4, 5}; |
403 | 360 |
404 std::unique_ptr<DisplaySnapshotMojo> input = | 361 std::unique_ptr<DisplaySnapshotMojo> input = |
405 base::MakeUnique<DisplaySnapshotMojo>( | 362 base::MakeUnique<DisplaySnapshotMojo>( |
406 display_id, origin, physical_size, type, is_aspect_preserving_scaling, | 363 display_id, origin, physical_size, type, is_aspect_preserving_scaling, |
407 has_overscan, has_color_correction_matrix, display_name, sys_path, | 364 has_overscan, has_color_correction_matrix, display_name, sys_path, |
408 product_id, std::move(modes), edid, current_mode, native_mode, | 365 product_id, std::move(modes), edid, current_mode, native_mode, |
409 maximum_cursor_size); | 366 maximum_cursor_size); |
410 | 367 |
411 std::unique_ptr<DisplaySnapshotMojo> output; | 368 std::unique_ptr<DisplaySnapshotMojo> output; |
412 GetTraitsTestProxy()->EchoDisplaySnapshotMojo( | 369 SerializeAndDeserialize<mojom::DisplaySnapshotMojo>( |
413 DisplaySnapshotMojo::CreateFrom(*input), &output); | 370 DisplaySnapshotMojo::CreateFrom(*input), &output); |
414 | 371 |
415 CheckDisplaySnapShotMojoEqual(*input, *output); | 372 CheckDisplaySnapShotMojoEqual(*input, *output); |
416 } | 373 } |
417 | 374 |
418 TEST_F(DisplayStructTraitsTest, DisplaySnapshotInternal) { | 375 TEST(DisplayStructTraitsTest, DisplaySnapshotInternal) { |
419 // Prepare sample input from Pixel's internal display. | 376 // Prepare sample input from Pixel's internal display. |
420 const int64_t display_id = 13761487533244416; | 377 const int64_t display_id = 13761487533244416; |
421 const gfx::Point origin(0, 0); | 378 const gfx::Point origin(0, 0); |
422 const gfx::Size physical_size(270, 180); | 379 const gfx::Size physical_size(270, 180); |
423 const gfx::Size maximum_cursor_size(64, 64); | 380 const gfx::Size maximum_cursor_size(64, 64); |
424 const DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_INTERNAL; | 381 const DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_INTERNAL; |
425 const bool is_aspect_preserving_scaling = true; | 382 const bool is_aspect_preserving_scaling = true; |
426 const bool has_overscan = false; | 383 const bool has_overscan = false; |
427 const bool has_color_correction_matrix = false; | 384 const bool has_color_correction_matrix = false; |
428 const std::string display_name(""); | 385 const std::string display_name(""); |
(...skipping 10 matching lines...) Expand all Loading... |
439 const std::vector<uint8_t> edid = {2, 3}; | 396 const std::vector<uint8_t> edid = {2, 3}; |
440 | 397 |
441 std::unique_ptr<DisplaySnapshotMojo> input = | 398 std::unique_ptr<DisplaySnapshotMojo> input = |
442 base::MakeUnique<DisplaySnapshotMojo>( | 399 base::MakeUnique<DisplaySnapshotMojo>( |
443 display_id, origin, physical_size, type, is_aspect_preserving_scaling, | 400 display_id, origin, physical_size, type, is_aspect_preserving_scaling, |
444 has_overscan, has_color_correction_matrix, display_name, sys_path, | 401 has_overscan, has_color_correction_matrix, display_name, sys_path, |
445 product_id, std::move(modes), edid, current_mode, native_mode, | 402 product_id, std::move(modes), edid, current_mode, native_mode, |
446 maximum_cursor_size); | 403 maximum_cursor_size); |
447 | 404 |
448 std::unique_ptr<DisplaySnapshotMojo> output; | 405 std::unique_ptr<DisplaySnapshotMojo> output; |
449 GetTraitsTestProxy()->EchoDisplaySnapshotMojo( | 406 SerializeAndDeserialize<mojom::DisplaySnapshotMojo>( |
450 DisplaySnapshotMojo::CreateFrom(*input), &output); | 407 DisplaySnapshotMojo::CreateFrom(*input), &output); |
451 | 408 |
452 CheckDisplaySnapShotMojoEqual(*input, *output); | 409 CheckDisplaySnapShotMojoEqual(*input, *output); |
453 } | 410 } |
454 | 411 |
455 TEST_F(DisplayStructTraitsTest, HDCPStateBasic) { | |
456 const display::HDCPState input(HDCP_STATE_ENABLED); | |
457 display::HDCPState output; | |
458 GetTraitsTestProxy()->EchoHDCPState(input, &output); | |
459 EXPECT_EQ(input, output); | |
460 } | |
461 | |
462 } // namespace display | 412 } // namespace display |
OLD | NEW |