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 Type, class MojomType> | |
96 void TestStructTraits(const Type& input, Type* output) { | |
Daniel Erat
2017/05/04 14:56:13
this doesn't actually test anything. would Seriali
kylechar
2017/05/04 16:20:04
Done.
| |
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 Type, class MojomType> | |
103 void TestStructTraits(Type&& input, Type* output) { | |
104 MojomType::Deserialize(MojomType::Serialize(&input), output); | |
105 } | |
106 | |
147 } // namespace | 107 } // namespace |
148 | 108 |
149 TEST_F(DisplayStructTraitsTest, DefaultDisplayValues) { | 109 TEST(DisplayStructTraitsTest, DefaultDisplayValues) { |
150 Display input(5); | 110 Display input(5); |
151 | 111 |
152 Display output; | 112 Display output; |
153 GetTraitsTestProxy()->EchoDisplay(input, &output); | 113 TestStructTraits<Display, mojom::Display>(input, &output); |
154 | 114 |
155 CheckDisplaysEqual(input, output); | 115 CheckDisplaysEqual(input, output); |
156 } | 116 } |
157 | 117 |
158 TEST_F(DisplayStructTraitsTest, SetAllDisplayValues) { | 118 TEST(DisplayStructTraitsTest, SetAllDisplayValues) { |
159 const gfx::Rect bounds(100, 200, 500, 600); | 119 const gfx::Rect bounds(100, 200, 500, 600); |
160 const gfx::Rect work_area(150, 250, 400, 500); | 120 const gfx::Rect work_area(150, 250, 400, 500); |
161 const gfx::Size maximum_cursor_size(64, 64); | 121 const gfx::Size maximum_cursor_size(64, 64); |
162 | 122 |
163 Display input(246345234, bounds); | 123 Display input(246345234, bounds); |
164 input.set_work_area(work_area); | 124 input.set_work_area(work_area); |
165 input.set_device_scale_factor(2.0f); | 125 input.set_device_scale_factor(2.0f); |
166 input.set_rotation(Display::ROTATE_270); | 126 input.set_rotation(Display::ROTATE_270); |
167 input.set_touch_support(Display::TOUCH_SUPPORT_AVAILABLE); | 127 input.set_touch_support(Display::TOUCH_SUPPORT_AVAILABLE); |
168 input.set_maximum_cursor_size(maximum_cursor_size); | 128 input.set_maximum_cursor_size(maximum_cursor_size); |
169 | 129 |
170 Display output; | 130 Display output; |
171 GetTraitsTestProxy()->EchoDisplay(input, &output); | 131 TestStructTraits<Display, mojom::Display>(input, &output); |
172 | 132 |
173 CheckDisplaysEqual(input, output); | 133 CheckDisplaysEqual(input, output); |
174 } | 134 } |
175 | 135 |
176 TEST_F(DisplayStructTraitsTest, DefaultDisplayMode) { | 136 TEST(DisplayStructTraitsTest, DefaultDisplayMode) { |
177 std::unique_ptr<DisplayMode> input = | 137 std::unique_ptr<DisplayMode> input = |
178 base::MakeUnique<DisplayMode>(gfx::Size(1024, 768), true, 61.0); | 138 base::MakeUnique<DisplayMode>(gfx::Size(1024, 768), true, 61.0); |
179 | 139 |
180 mojom::DisplayStructTraitsTestPtr proxy = GetTraitsTestProxy(); | |
181 std::unique_ptr<DisplayMode> output; | 140 std::unique_ptr<DisplayMode> output; |
182 | 141 TestStructTraits<std::unique_ptr<DisplayMode>, mojom::DisplayMode>( |
183 proxy->EchoDisplayMode(input->Clone(), &output); | 142 input->Clone(), &output); |
184 | 143 |
185 // We want to test each component individually to make sure each data member | 144 // We want to test each component individually to make sure each data member |
186 // was correctly serialized and deserialized. | 145 // was correctly serialized and deserialized. |
187 EXPECT_EQ(input->size(), output->size()); | 146 EXPECT_EQ(input->size(), output->size()); |
188 EXPECT_EQ(input->is_interlaced(), output->is_interlaced()); | 147 EXPECT_EQ(input->is_interlaced(), output->is_interlaced()); |
189 EXPECT_EQ(input->refresh_rate(), output->refresh_rate()); | 148 EXPECT_EQ(input->refresh_rate(), output->refresh_rate()); |
190 } | 149 } |
191 | 150 |
192 TEST_F(DisplayStructTraitsTest, DisplayPlacementFlushAtTop) { | 151 TEST(DisplayStructTraitsTest, DisplayPlacementFlushAtTop) { |
193 DisplayPlacement input; | 152 DisplayPlacement input; |
194 input.display_id = kDisplayId1; | 153 input.display_id = kDisplayId1; |
195 input.parent_display_id = kDisplayId2; | 154 input.parent_display_id = kDisplayId2; |
196 input.position = DisplayPlacement::TOP; | 155 input.position = DisplayPlacement::TOP; |
197 input.offset = 0; | 156 input.offset = 0; |
198 input.offset_reference = DisplayPlacement::TOP_LEFT; | 157 input.offset_reference = DisplayPlacement::TOP_LEFT; |
199 | 158 |
200 DisplayPlacement output; | 159 DisplayPlacement output; |
201 GetTraitsTestProxy()->EchoDisplayPlacement(input, &output); | 160 TestStructTraits<DisplayPlacement, mojom::DisplayPlacement>(input, &output); |
202 | 161 |
203 EXPECT_EQ(input, output); | 162 EXPECT_EQ(input, output); |
204 } | 163 } |
205 | 164 |
206 TEST_F(DisplayStructTraitsTest, DisplayPlacementWithOffset) { | 165 TEST(DisplayStructTraitsTest, DisplayPlacementWithOffset) { |
207 DisplayPlacement input; | 166 DisplayPlacement input; |
208 input.display_id = kDisplayId1; | 167 input.display_id = kDisplayId1; |
209 input.parent_display_id = kDisplayId2; | 168 input.parent_display_id = kDisplayId2; |
210 input.position = DisplayPlacement::BOTTOM; | 169 input.position = DisplayPlacement::BOTTOM; |
211 input.offset = -100; | 170 input.offset = -100; |
212 input.offset_reference = DisplayPlacement::BOTTOM_RIGHT; | 171 input.offset_reference = DisplayPlacement::BOTTOM_RIGHT; |
213 | 172 |
214 DisplayPlacement output; | 173 DisplayPlacement output; |
215 GetTraitsTestProxy()->EchoDisplayPlacement(input, &output); | 174 TestStructTraits<DisplayPlacement, mojom::DisplayPlacement>(input, &output); |
216 | 175 |
217 EXPECT_EQ(input, output); | 176 EXPECT_EQ(input, output); |
218 } | 177 } |
219 | 178 |
220 TEST_F(DisplayStructTraitsTest, DisplayLayoutTwoExtended) { | 179 TEST(DisplayStructTraitsTest, DisplayLayoutTwoExtended) { |
221 DisplayPlacement placement; | 180 DisplayPlacement placement; |
222 placement.display_id = kDisplayId1; | 181 placement.display_id = kDisplayId1; |
223 placement.parent_display_id = kDisplayId2; | 182 placement.parent_display_id = kDisplayId2; |
224 placement.position = DisplayPlacement::RIGHT; | 183 placement.position = DisplayPlacement::RIGHT; |
225 placement.offset = 0; | 184 placement.offset = 0; |
226 placement.offset_reference = DisplayPlacement::TOP_LEFT; | 185 placement.offset_reference = DisplayPlacement::TOP_LEFT; |
227 | 186 |
228 auto input = base::MakeUnique<DisplayLayout>(); | 187 auto input = base::MakeUnique<DisplayLayout>(); |
229 input->placement_list.push_back(placement); | 188 input->placement_list.push_back(placement); |
230 input->primary_id = kDisplayId2; | 189 input->primary_id = kDisplayId2; |
231 input->mirrored = false; | 190 input->mirrored = false; |
232 input->default_unified = true; | 191 input->default_unified = true; |
233 | 192 |
234 std::unique_ptr<DisplayLayout> output; | 193 std::unique_ptr<DisplayLayout> output; |
235 GetTraitsTestProxy()->EchoDisplayLayout(input->Copy(), &output); | 194 TestStructTraits<std::unique_ptr<DisplayLayout>, mojom::DisplayLayout>( |
195 input->Copy(), &output); | |
236 | 196 |
237 CheckDisplayLayoutsEqual(*input, *output); | 197 CheckDisplayLayoutsEqual(*input, *output); |
238 } | 198 } |
239 | 199 |
240 TEST_F(DisplayStructTraitsTest, DisplayLayoutThreeExtended) { | 200 TEST(DisplayStructTraitsTest, DisplayLayoutThreeExtended) { |
241 DisplayPlacement placement1; | 201 DisplayPlacement placement1; |
242 placement1.display_id = kDisplayId2; | 202 placement1.display_id = kDisplayId2; |
243 placement1.parent_display_id = kDisplayId1; | 203 placement1.parent_display_id = kDisplayId1; |
244 placement1.position = DisplayPlacement::LEFT; | 204 placement1.position = DisplayPlacement::LEFT; |
245 placement1.offset = 0; | 205 placement1.offset = 0; |
246 placement1.offset_reference = DisplayPlacement::TOP_LEFT; | 206 placement1.offset_reference = DisplayPlacement::TOP_LEFT; |
247 | 207 |
248 DisplayPlacement placement2; | 208 DisplayPlacement placement2; |
249 placement2.display_id = kDisplayId3; | 209 placement2.display_id = kDisplayId3; |
250 placement2.parent_display_id = kDisplayId1; | 210 placement2.parent_display_id = kDisplayId1; |
251 placement2.position = DisplayPlacement::RIGHT; | 211 placement2.position = DisplayPlacement::RIGHT; |
252 placement2.offset = -100; | 212 placement2.offset = -100; |
253 placement2.offset_reference = DisplayPlacement::BOTTOM_RIGHT; | 213 placement2.offset_reference = DisplayPlacement::BOTTOM_RIGHT; |
254 | 214 |
255 auto input = base::MakeUnique<DisplayLayout>(); | 215 auto input = base::MakeUnique<DisplayLayout>(); |
256 input->placement_list.push_back(placement1); | 216 input->placement_list.push_back(placement1); |
257 input->placement_list.push_back(placement2); | 217 input->placement_list.push_back(placement2); |
258 input->primary_id = kDisplayId1; | 218 input->primary_id = kDisplayId1; |
259 input->mirrored = false; | 219 input->mirrored = false; |
260 input->default_unified = false; | 220 input->default_unified = false; |
261 | 221 |
262 std::unique_ptr<DisplayLayout> output; | 222 std::unique_ptr<DisplayLayout> output; |
263 GetTraitsTestProxy()->EchoDisplayLayout(input->Copy(), &output); | 223 TestStructTraits<std::unique_ptr<DisplayLayout>, mojom::DisplayLayout>( |
224 input->Copy(), &output); | |
264 | 225 |
265 CheckDisplayLayoutsEqual(*input, *output); | 226 CheckDisplayLayoutsEqual(*input, *output); |
266 } | 227 } |
267 | 228 |
268 TEST_F(DisplayStructTraitsTest, DisplayLayoutTwoMirrored) { | 229 TEST(DisplayStructTraitsTest, DisplayLayoutTwoMirrored) { |
269 DisplayPlacement placement; | 230 DisplayPlacement placement; |
270 placement.display_id = kDisplayId1; | 231 placement.display_id = kDisplayId1; |
271 placement.parent_display_id = kDisplayId2; | 232 placement.parent_display_id = kDisplayId2; |
272 placement.position = DisplayPlacement::RIGHT; | 233 placement.position = DisplayPlacement::RIGHT; |
273 placement.offset = 0; | 234 placement.offset = 0; |
274 placement.offset_reference = DisplayPlacement::TOP_LEFT; | 235 placement.offset_reference = DisplayPlacement::TOP_LEFT; |
275 | 236 |
276 auto input = base::MakeUnique<DisplayLayout>(); | 237 auto input = base::MakeUnique<DisplayLayout>(); |
277 input->placement_list.push_back(placement); | 238 input->placement_list.push_back(placement); |
278 input->primary_id = kDisplayId2; | 239 input->primary_id = kDisplayId2; |
279 input->mirrored = true; | 240 input->mirrored = true; |
280 input->default_unified = true; | 241 input->default_unified = true; |
281 | 242 |
282 std::unique_ptr<DisplayLayout> output; | 243 std::unique_ptr<DisplayLayout> output; |
283 GetTraitsTestProxy()->EchoDisplayLayout(input->Copy(), &output); | 244 TestStructTraits<std::unique_ptr<DisplayLayout>, mojom::DisplayLayout>( |
245 input->Copy(), &output); | |
284 | 246 |
285 CheckDisplayLayoutsEqual(*input, *output); | 247 CheckDisplayLayoutsEqual(*input, *output); |
286 } | 248 } |
287 | 249 |
288 TEST_F(DisplayStructTraitsTest, BasicGammaRampRGBEntry) { | 250 TEST(DisplayStructTraitsTest, BasicGammaRampRGBEntry) { |
289 const GammaRampRGBEntry input{259, 81, 16}; | 251 const GammaRampRGBEntry input{259, 81, 16}; |
290 | 252 |
291 GammaRampRGBEntry output; | 253 GammaRampRGBEntry output; |
292 GetTraitsTestProxy()->EchoGammaRampRGBEntry(input, &output); | 254 TestStructTraits<GammaRampRGBEntry, mojom::GammaRampRGBEntry>(input, &output); |
293 | 255 |
294 EXPECT_EQ(input.r, output.r); | 256 EXPECT_EQ(input.r, output.r); |
295 EXPECT_EQ(input.g, output.g); | 257 EXPECT_EQ(input.g, output.g); |
296 EXPECT_EQ(input.b, output.b); | 258 EXPECT_EQ(input.b, output.b); |
297 } | 259 } |
298 | 260 |
299 // One display mode, current and native mode nullptr. | 261 // One display mode, current and native mode nullptr. |
300 TEST_F(DisplayStructTraitsTest, DisplaySnapshotCurrentAndNativeModesNull) { | 262 TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentAndNativeModesNull) { |
301 // Prepare sample input with random values. | 263 // Prepare sample input with random values. |
302 const int64_t display_id = 7; | 264 const int64_t display_id = 7; |
303 const gfx::Point origin(1, 2); | 265 const gfx::Point origin(1, 2); |
304 const gfx::Size physical_size(5, 9); | 266 const gfx::Size physical_size(5, 9); |
305 const gfx::Size maximum_cursor_size(3, 5); | 267 const gfx::Size maximum_cursor_size(3, 5); |
306 const DisplayConnectionType type = | 268 const DisplayConnectionType type = |
307 display::DISPLAY_CONNECTION_TYPE_DISPLAYPORT; | 269 display::DISPLAY_CONNECTION_TYPE_DISPLAYPORT; |
308 const bool is_aspect_preserving_scaling = true; | 270 const bool is_aspect_preserving_scaling = true; |
309 const bool has_overscan = true; | 271 const bool has_overscan = true; |
310 const bool has_color_correction_matrix = true; | 272 const bool has_color_correction_matrix = true; |
(...skipping 11 matching lines...) Expand all Loading... | |
322 const std::vector<uint8_t> edid = {1}; | 284 const std::vector<uint8_t> edid = {1}; |
323 | 285 |
324 std::unique_ptr<DisplaySnapshotMojo> input = | 286 std::unique_ptr<DisplaySnapshotMojo> input = |
325 base::MakeUnique<DisplaySnapshotMojo>( | 287 base::MakeUnique<DisplaySnapshotMojo>( |
326 display_id, origin, physical_size, type, is_aspect_preserving_scaling, | 288 display_id, origin, physical_size, type, is_aspect_preserving_scaling, |
327 has_overscan, has_color_correction_matrix, display_name, sys_path, | 289 has_overscan, has_color_correction_matrix, display_name, sys_path, |
328 product_id, std::move(modes), edid, current_mode, native_mode, | 290 product_id, std::move(modes), edid, current_mode, native_mode, |
329 maximum_cursor_size); | 291 maximum_cursor_size); |
330 | 292 |
331 std::unique_ptr<DisplaySnapshotMojo> output; | 293 std::unique_ptr<DisplaySnapshotMojo> output; |
332 GetTraitsTestProxy()->EchoDisplaySnapshotMojo( | 294 TestStructTraits<std::unique_ptr<DisplaySnapshotMojo>, |
295 mojom::DisplaySnapshotMojo>( | |
333 DisplaySnapshotMojo::CreateFrom(*input), &output); | 296 DisplaySnapshotMojo::CreateFrom(*input), &output); |
334 | 297 |
335 CheckDisplaySnapShotMojoEqual(*input, *output); | 298 CheckDisplaySnapShotMojoEqual(*input, *output); |
336 } | 299 } |
337 | 300 |
338 // One display mode that is the native mode and no current mode. | 301 // One display mode that is the native mode and no current mode. |
339 TEST_F(DisplayStructTraitsTest, DisplaySnapshotCurrentModeNull) { | 302 TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentModeNull) { |
340 // Prepare sample input with random values. | 303 // Prepare sample input with random values. |
341 const int64_t display_id = 6; | 304 const int64_t display_id = 6; |
342 const gfx::Point origin(11, 32); | 305 const gfx::Point origin(11, 32); |
343 const gfx::Size physical_size(55, 49); | 306 const gfx::Size physical_size(55, 49); |
344 const gfx::Size maximum_cursor_size(13, 95); | 307 const gfx::Size maximum_cursor_size(13, 95); |
345 const DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_VGA; | 308 const DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_VGA; |
346 const bool is_aspect_preserving_scaling = true; | 309 const bool is_aspect_preserving_scaling = true; |
347 const bool has_overscan = true; | 310 const bool has_overscan = true; |
348 const bool has_color_correction_matrix = true; | 311 const bool has_color_correction_matrix = true; |
349 const std::string display_name("whatever display_name"); | 312 const std::string display_name("whatever display_name"); |
(...skipping 10 matching lines...) Expand all Loading... | |
360 const std::vector<uint8_t> edid = {1}; | 323 const std::vector<uint8_t> edid = {1}; |
361 | 324 |
362 std::unique_ptr<DisplaySnapshotMojo> input = | 325 std::unique_ptr<DisplaySnapshotMojo> input = |
363 base::MakeUnique<DisplaySnapshotMojo>( | 326 base::MakeUnique<DisplaySnapshotMojo>( |
364 display_id, origin, physical_size, type, is_aspect_preserving_scaling, | 327 display_id, origin, physical_size, type, is_aspect_preserving_scaling, |
365 has_overscan, has_color_correction_matrix, display_name, sys_path, | 328 has_overscan, has_color_correction_matrix, display_name, sys_path, |
366 product_id, std::move(modes), edid, current_mode, native_mode, | 329 product_id, std::move(modes), edid, current_mode, native_mode, |
367 maximum_cursor_size); | 330 maximum_cursor_size); |
368 | 331 |
369 std::unique_ptr<DisplaySnapshotMojo> output; | 332 std::unique_ptr<DisplaySnapshotMojo> output; |
370 GetTraitsTestProxy()->EchoDisplaySnapshotMojo( | 333 TestStructTraits<std::unique_ptr<DisplaySnapshotMojo>, |
334 mojom::DisplaySnapshotMojo>( | |
371 DisplaySnapshotMojo::CreateFrom(*input), &output); | 335 DisplaySnapshotMojo::CreateFrom(*input), &output); |
372 | 336 |
373 CheckDisplaySnapShotMojoEqual(*input, *output); | 337 CheckDisplaySnapShotMojoEqual(*input, *output); |
374 } | 338 } |
375 | 339 |
376 // Multiple display modes, both native and current mode set. | 340 // Multiple display modes, both native and current mode set. |
377 TEST_F(DisplayStructTraitsTest, DisplaySnapshotExternal) { | 341 TEST(DisplayStructTraitsTest, DisplaySnapshotExternal) { |
378 // Prepare sample input from external display. | 342 // Prepare sample input from external display. |
379 const int64_t display_id = 9834293210466051; | 343 const int64_t display_id = 9834293210466051; |
380 const gfx::Point origin(0, 1760); | 344 const gfx::Point origin(0, 1760); |
381 const gfx::Size physical_size(520, 320); | 345 const gfx::Size physical_size(520, 320); |
382 const gfx::Size maximum_cursor_size(4, 5); | 346 const gfx::Size maximum_cursor_size(4, 5); |
383 const DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_HDMI; | 347 const DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_HDMI; |
384 const bool is_aspect_preserving_scaling = false; | 348 const bool is_aspect_preserving_scaling = false; |
385 const bool has_overscan = false; | 349 const bool has_overscan = false; |
386 const bool has_color_correction_matrix = false; | 350 const bool has_color_correction_matrix = false; |
387 const std::string display_name("HP Z24i"); | 351 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}; | 366 const std::vector<uint8_t> edid = {2, 3, 4, 5}; |
403 | 367 |
404 std::unique_ptr<DisplaySnapshotMojo> input = | 368 std::unique_ptr<DisplaySnapshotMojo> input = |
405 base::MakeUnique<DisplaySnapshotMojo>( | 369 base::MakeUnique<DisplaySnapshotMojo>( |
406 display_id, origin, physical_size, type, is_aspect_preserving_scaling, | 370 display_id, origin, physical_size, type, is_aspect_preserving_scaling, |
407 has_overscan, has_color_correction_matrix, display_name, sys_path, | 371 has_overscan, has_color_correction_matrix, display_name, sys_path, |
408 product_id, std::move(modes), edid, current_mode, native_mode, | 372 product_id, std::move(modes), edid, current_mode, native_mode, |
409 maximum_cursor_size); | 373 maximum_cursor_size); |
410 | 374 |
411 std::unique_ptr<DisplaySnapshotMojo> output; | 375 std::unique_ptr<DisplaySnapshotMojo> output; |
412 GetTraitsTestProxy()->EchoDisplaySnapshotMojo( | 376 TestStructTraits<std::unique_ptr<DisplaySnapshotMojo>, |
377 mojom::DisplaySnapshotMojo>( | |
413 DisplaySnapshotMojo::CreateFrom(*input), &output); | 378 DisplaySnapshotMojo::CreateFrom(*input), &output); |
414 | 379 |
415 CheckDisplaySnapShotMojoEqual(*input, *output); | 380 CheckDisplaySnapShotMojoEqual(*input, *output); |
416 } | 381 } |
417 | 382 |
418 TEST_F(DisplayStructTraitsTest, DisplaySnapshotInternal) { | 383 TEST(DisplayStructTraitsTest, DisplaySnapshotInternal) { |
419 // Prepare sample input from Pixel's internal display. | 384 // Prepare sample input from Pixel's internal display. |
420 const int64_t display_id = 13761487533244416; | 385 const int64_t display_id = 13761487533244416; |
421 const gfx::Point origin(0, 0); | 386 const gfx::Point origin(0, 0); |
422 const gfx::Size physical_size(270, 180); | 387 const gfx::Size physical_size(270, 180); |
423 const gfx::Size maximum_cursor_size(64, 64); | 388 const gfx::Size maximum_cursor_size(64, 64); |
424 const DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_INTERNAL; | 389 const DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_INTERNAL; |
425 const bool is_aspect_preserving_scaling = true; | 390 const bool is_aspect_preserving_scaling = true; |
426 const bool has_overscan = false; | 391 const bool has_overscan = false; |
427 const bool has_color_correction_matrix = false; | 392 const bool has_color_correction_matrix = false; |
428 const std::string display_name(""); | 393 const std::string display_name(""); |
(...skipping 10 matching lines...) Expand all Loading... | |
439 const std::vector<uint8_t> edid = {2, 3}; | 404 const std::vector<uint8_t> edid = {2, 3}; |
440 | 405 |
441 std::unique_ptr<DisplaySnapshotMojo> input = | 406 std::unique_ptr<DisplaySnapshotMojo> input = |
442 base::MakeUnique<DisplaySnapshotMojo>( | 407 base::MakeUnique<DisplaySnapshotMojo>( |
443 display_id, origin, physical_size, type, is_aspect_preserving_scaling, | 408 display_id, origin, physical_size, type, is_aspect_preserving_scaling, |
444 has_overscan, has_color_correction_matrix, display_name, sys_path, | 409 has_overscan, has_color_correction_matrix, display_name, sys_path, |
445 product_id, std::move(modes), edid, current_mode, native_mode, | 410 product_id, std::move(modes), edid, current_mode, native_mode, |
446 maximum_cursor_size); | 411 maximum_cursor_size); |
447 | 412 |
448 std::unique_ptr<DisplaySnapshotMojo> output; | 413 std::unique_ptr<DisplaySnapshotMojo> output; |
449 GetTraitsTestProxy()->EchoDisplaySnapshotMojo( | 414 TestStructTraits<std::unique_ptr<DisplaySnapshotMojo>, |
415 mojom::DisplaySnapshotMojo>( | |
450 DisplaySnapshotMojo::CreateFrom(*input), &output); | 416 DisplaySnapshotMojo::CreateFrom(*input), &output); |
451 | 417 |
452 CheckDisplaySnapShotMojoEqual(*input, *output); | 418 CheckDisplaySnapShotMojoEqual(*input, *output); |
453 } | 419 } |
454 | 420 |
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 | 421 } // namespace display |
OLD | NEW |