blob: a023367752234503f4d348136a6eff7f65e99650 [file] [log] [blame]
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -07001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <gmock/gmock.h>
18#include <gtest/gtest.h>
19
20#include "DisplayHardware/DisplayIdentification.h"
21
22namespace android {
23namespace {
24
25const unsigned char kInternalEdid[] =
26 "\x00\xff\xff\xff\xff\xff\xff\x00\x4c\xa3\x42\x31\x00\x00\x00\x00"
27 "\x00\x15\x01\x03\x80\x1a\x10\x78\x0a\xd3\xe5\x95\x5c\x60\x90\x27"
28 "\x19\x50\x54\x00\x00\x00\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
29 "\x01\x01\x01\x01\x01\x01\x9e\x1b\x00\xa0\x50\x20\x12\x30\x10\x30"
30 "\x13\x00\x05\xa3\x10\x00\x00\x19\x00\x00\x00\x0f\x00\x00\x00\x00"
31 "\x00\x00\x00\x00\x00\x23\x87\x02\x64\x00\x00\x00\x00\xfe\x00\x53"
32 "\x41\x4d\x53\x55\x4e\x47\x0a\x20\x20\x20\x20\x20\x00\x00\x00\xfe"
33 "\x00\x31\x32\x31\x41\x54\x31\x31\x2d\x38\x30\x31\x0a\x20\x00\x45";
34
35const unsigned char kExternalEdid[] =
36 "\x00\xff\xff\xff\xff\xff\xff\x00\x22\xf0\x6c\x28\x01\x01\x01\x01"
37 "\x02\x16\x01\x04\xb5\x40\x28\x78\xe2\x8d\x85\xad\x4f\x35\xb1\x25"
38 "\x0e\x50\x54\x00\x00\x00\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
39 "\x01\x01\x01\x01\x01\x01\xe2\x68\x00\xa0\xa0\x40\x2e\x60\x30\x20"
40 "\x36\x00\x81\x90\x21\x00\x00\x1a\xbc\x1b\x00\xa0\x50\x20\x17\x30"
41 "\x30\x20\x36\x00\x81\x90\x21\x00\x00\x1a\x00\x00\x00\xfc\x00\x48"
42 "\x50\x20\x5a\x52\x33\x30\x77\x0a\x20\x20\x20\x20\x00\x00\x00\xff"
43 "\x00\x43\x4e\x34\x32\x30\x32\x31\x33\x37\x51\x0a\x20\x20\x00\x71";
44
45// Extended EDID with timing extension.
46const unsigned char kExternalEedid[] =
47 "\x00\xff\xff\xff\xff\xff\xff\x00\x4c\x2d\xfe\x08\x00\x00\x00\x00"
48 "\x29\x15\x01\x03\x80\x10\x09\x78\x0a\xee\x91\xa3\x54\x4c\x99\x26"
49 "\x0f\x50\x54\xbd\xef\x80\x71\x4f\x81\xc0\x81\x00\x81\x80\x95\x00"
50 "\xa9\xc0\xb3\x00\x01\x01\x02\x3a\x80\x18\x71\x38\x2d\x40\x58\x2c"
51 "\x45\x00\xa0\x5a\x00\x00\x00\x1e\x66\x21\x56\xaa\x51\x00\x1e\x30"
52 "\x46\x8f\x33\x00\xa0\x5a\x00\x00\x00\x1e\x00\x00\x00\xfd\x00\x18"
53 "\x4b\x0f\x51\x17\x00\x0a\x20\x20\x20\x20\x20\x20\x00\x00\x00\xfc"
54 "\x00\x53\x41\x4d\x53\x55\x4e\x47\x0a\x20\x20\x20\x20\x20\x01\x1d"
55 "\x02\x03\x1f\xf1\x47\x90\x04\x05\x03\x20\x22\x07\x23\x09\x07\x07"
56 "\x83\x01\x00\x00\xe2\x00\x0f\x67\x03\x0c\x00\x20\x00\xb8\x2d\x01"
57 "\x1d\x80\x18\x71\x1c\x16\x20\x58\x2c\x25\x00\xa0\x5a\x00\x00\x00"
58 "\x9e\x01\x1d\x00\x72\x51\xd0\x1e\x20\x6e\x28\x55\x00\xa0\x5a\x00"
59 "\x00\x00\x1e\x8c\x0a\xd0\x8a\x20\xe0\x2d\x10\x10\x3e\x96\x00\xa0"
60 "\x5a\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
61 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
62 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc6";
63
Marin Shalamanovf5de90d2019-10-08 10:57:25 +020064const unsigned char kPanasonicTvEdid[] =
65 "\x00\xff\xff\xff\xff\xff\xff\x00\x34\xa9\x96\xa2\x01\x01\x01"
66 "\x01\x00\x1d\x01\x03\x80\x80\x48\x78\x0a\xda\xff\xa3\x58\x4a"
67 "\xa2\x29\x17\x49\x4b\x20\x08\x00\x31\x40\x61\x40\x01\x01\x01"
68 "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x08\xe8\x00\x30\xf2\x70"
69 "\x5a\x80\xb0\x58\x8a\x00\xba\x88\x21\x00\x00\x1e\x02\x3a\x80"
70 "\x18\x71\x38\x2d\x40\x58\x2c\x45\x00\xba\x88\x21\x00\x00\x1e"
71 "\x00\x00\x00\xfc\x00\x50\x61\x6e\x61\x73\x6f\x6e\x69\x63\x2d"
72 "\x54\x56\x0a\x00\x00\x00\xfd\x00\x17\x3d\x0f\x88\x3c\x00\x0a"
73 "\x20\x20\x20\x20\x20\x20\x01\x1d\x02\x03\x6b\xf0\x57\x61\x60"
74 "\x10\x1f\x66\x65\x05\x14\x20\x21\x22\x04\x13\x03\x12\x07\x16"
75 "\x5d\x5e\x5f\x62\x63\x64\x2c\x0d\x07\x01\x15\x07\x50\x57\x07"
76 "\x01\x67\x04\x03\x83\x0f\x00\x00\x6e\x03\x0c\x00\x20\x00\x38"
77 "\x3c\x2f\x08\x80\x01\x02\x03\x04\x67\xd8\x5d\xc4\x01\x78\x80"
78 "\x03\xe2\x00\x4b\xe3\x05\xff\x01\xe2\x0f\x33\xe3\x06\x0f\x01"
79 "\xe5\x01\x8b\x84\x90\x01\xeb\x01\x46\xd0\x00\x44\x03\x70\x80"
80 "\x5e\x75\x94\xe6\x11\x46\xd0\x00\x70\x00\x66\x21\x56\xaa\x51"
81 "\x00\x1e\x30\x46\x8f\x33\x00\xba\x88\x21\x00\x00\x1e\x00\x00"
82 "\xc8";
83
84const unsigned char kHisenseTvEdid[] =
85 "\x00\xff\xff\xff\xff\xff\xff\x00\x20\xa3\x00\x00\x00\x00\x00"
86 "\x00\x12\x1d\x01\x03\x80\x00\x00\x78\x0a\xd7\xa5\xa2\x59\x4a"
87 "\x96\x24\x14\x50\x54\xa3\x08\x00\xd1\xc0\xb3\x00\x81\x00\x81"
88 "\x80\x81\x40\x81\xc0\x01\x01\x01\x01\x02\x3a\x80\x18\x71\x38"
89 "\x2d\x40\x58\x2c\x45\x00\x3f\x43\x21\x00\x00\x1a\x02\x3a\x80"
90 "\x18\x71\x38\x2d\x40\x58\x2c\x45\x00\x3f\x43\x21\x00\x00\x1a"
91 "\x00\x00\x00\xfd\x00\x1e\x4c\x1e\x5a\x1e\x00\x0a\x20\x20\x20"
92 "\x20\x20\x20\x00\x00\x00\xfc\x00\x48\x69\x73\x65\x6e\x73\x65"
93 "\x0a\x20\x20\x20\x20\x20\x01\x47\x02\x03\x2d\x71\x50\x90\x05"
94 "\x04\x03\x07\x02\x06\x01\x1f\x14\x13\x12\x16\x11\x15\x20\x2c"
95 "\x09\x07\x03\x15\x07\x50\x57\x07\x00\x39\x07\xbb\x66\x03\x0c"
96 "\x00\x20\x00\x00\x83\x01\x00\x00\x01\x1d\x00\x72\x51\xd0\x1e"
97 "\x20\x6e\x28\x55\x00\xc4\x8e\x21\x00\x00\x1e\x01\x1d\x80\x18"
98 "\x71\x1c\x16\x20\x58\x2c\x25\x00\xc4\x8e\x21\x00\x00\x9e\x8c"
99 "\x0a\xd0\x8a\x20\xe0\x2d\x10\x10\x3e\x96\x00\x13\x8e\x21\x00"
100 "\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
101 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
102 "\x07";
103
104const unsigned char kCtlDisplayEdid[] =
105 "\x00\xff\xff\xff\xff\xff\xff\x00\x0e\x8c\x9d\x24\x00\x00\x00\x00"
106 "\xff\x17\x01\x04\xa5\x34\x1d\x78\x3a\xa7\x25\xa4\x57\x51\xa0\x26"
107 "\x10\x50\x54\xbf\xef\x80\xb3\x00\xa9\x40\x95\x00\x81\x40\x81\x80"
108 "\x95\x0f\x71\x4f\x90\x40\x02\x3a\x80\x18\x71\x38\x2d\x40\x58\x2c"
109 "\x45\x00\x09\x25\x21\x00\x00\x1e\x66\x21\x50\xb0\x51\x00\x1b\x30"
110 "\x40\x70\x36\x00\x09\x25\x21\x00\x00\x1e\x00\x00\x00\xfd\x00\x31"
111 "\x4c\x1e\x52\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfc"
112 "\x00\x4c\x50\x32\x33\x36\x31\x0a\x20\x20\x20\x20\x20\x20\x01\x3e"
113 "\x02\x03\x22\xf2\x4f\x90\x9f\x05\x14\x04\x13\x03\x02\x12\x11\x07"
114 "\x06\x16\x15\x01\x23\x09\x07\x07\x83\x01\x00\x00\x65\xb9\x14\x00"
115 "\x04\x00\x02\x3a\x80\x18\x71\x38\x2d\x40\x58\x2c\x45\x00\x09\x25"
116 "\x21\x00\x00\x1e\x02\x3a\x80\xd0\x72\x38\x2d\x40\x10\x2c\x45\x80"
117 "\x09\x25\x21\x00\x00\x1e\x01\x1d\x00\x72\x51\xd0\x1e\x20\x6e\x28"
118 "\x55\x00\x09\x25\x21\x00\x00\x1e\x8c\x0a\xd0\x8a\x20\xe0\x2d\x10"
119 "\x10\x3e\x96\x00\x09\x25\x21\x00\x00\x18\x00\x00\x00\x00\x00\x00"
120 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4";
121
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700122template <size_t N>
123DisplayIdentificationData asDisplayIdentificationData(const unsigned char (&bytes)[N]) {
124 return DisplayIdentificationData(bytes, bytes + N - 1);
125}
126
127} // namespace
128
Dominik Laskowski075d3172018-05-24 15:50:06 -0700129const DisplayIdentificationData& getInternalEdid() {
130 static const DisplayIdentificationData data = asDisplayIdentificationData(kInternalEdid);
131 return data;
132}
133
134const DisplayIdentificationData& getExternalEdid() {
135 static const DisplayIdentificationData data = asDisplayIdentificationData(kExternalEdid);
136 return data;
137}
138
139const DisplayIdentificationData& getExternalEedid() {
140 static const DisplayIdentificationData data = asDisplayIdentificationData(kExternalEedid);
141 return data;
142}
143
Marin Shalamanovf5de90d2019-10-08 10:57:25 +0200144const DisplayIdentificationData& getPanasonicTvEdid() {
145 static const DisplayIdentificationData data = asDisplayIdentificationData(kPanasonicTvEdid);
146 return data;
147}
148
149const DisplayIdentificationData& getHisenseTvEdid() {
150 static const DisplayIdentificationData data = asDisplayIdentificationData(kHisenseTvEdid);
151 return data;
152}
153
154const DisplayIdentificationData& getCtlDisplayEdid() {
155 static const DisplayIdentificationData data = asDisplayIdentificationData(kCtlDisplayEdid);
156 return data;
157}
158
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700159TEST(DisplayIdentificationTest, isEdid) {
160 EXPECT_FALSE(isEdid({}));
161
Dominik Laskowski075d3172018-05-24 15:50:06 -0700162 EXPECT_TRUE(isEdid(getInternalEdid()));
163 EXPECT_TRUE(isEdid(getExternalEdid()));
164 EXPECT_TRUE(isEdid(getExternalEedid()));
Marin Shalamanovf5de90d2019-10-08 10:57:25 +0200165 EXPECT_TRUE(isEdid(getPanasonicTvEdid()));
166 EXPECT_TRUE(isEdid(getHisenseTvEdid()));
167 EXPECT_TRUE(isEdid(getCtlDisplayEdid()));
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700168}
169
170TEST(DisplayIdentificationTest, parseEdid) {
Dominik Laskowski075d3172018-05-24 15:50:06 -0700171 auto edid = parseEdid(getInternalEdid());
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700172 ASSERT_TRUE(edid);
173 EXPECT_EQ(0x4ca3u, edid->manufacturerId);
174 EXPECT_STREQ("SEC", edid->pnpId.data());
175 // ASCII text should be used as fallback if display name and serial number are missing.
176 EXPECT_EQ("121AT11-801", edid->displayName);
Marin Shalamanovf5de90d2019-10-08 10:57:25 +0200177 EXPECT_EQ(12610, edid->productId);
178 EXPECT_EQ(21, edid->manufactureOrModelYear);
179 EXPECT_EQ(0, edid->manufactureWeek);
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700180
Dominik Laskowski075d3172018-05-24 15:50:06 -0700181 edid = parseEdid(getExternalEdid());
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700182 ASSERT_TRUE(edid);
183 EXPECT_EQ(0x22f0u, edid->manufacturerId);
184 EXPECT_STREQ("HWP", edid->pnpId.data());
185 EXPECT_EQ("HP ZR30w", edid->displayName);
Marin Shalamanovf5de90d2019-10-08 10:57:25 +0200186 EXPECT_EQ(10348, edid->productId);
187 EXPECT_EQ(22, edid->manufactureOrModelYear);
188 EXPECT_EQ(2, edid->manufactureWeek);
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700189
Dominik Laskowski075d3172018-05-24 15:50:06 -0700190 edid = parseEdid(getExternalEedid());
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700191 ASSERT_TRUE(edid);
192 EXPECT_EQ(0x4c2du, edid->manufacturerId);
193 EXPECT_STREQ("SAM", edid->pnpId.data());
194 EXPECT_EQ("SAMSUNG", edid->displayName);
Marin Shalamanovf5de90d2019-10-08 10:57:25 +0200195 EXPECT_EQ(2302, edid->productId);
196 EXPECT_EQ(21, edid->manufactureOrModelYear);
197 EXPECT_EQ(41, edid->manufactureWeek);
198
199 edid = parseEdid(getPanasonicTvEdid());
200 ASSERT_TRUE(edid);
201 EXPECT_EQ(13481, edid->manufacturerId);
202 EXPECT_STREQ("MEI", edid->pnpId.data());
203 EXPECT_EQ("Panasonic-TV", edid->displayName);
204 EXPECT_EQ(41622, edid->productId);
205 EXPECT_EQ(29, edid->manufactureOrModelYear);
206 EXPECT_EQ(0, edid->manufactureWeek);
207
208 edid = parseEdid(getHisenseTvEdid());
209 ASSERT_TRUE(edid);
210 EXPECT_EQ(8355, edid->manufacturerId);
211 EXPECT_STREQ("HEC", edid->pnpId.data());
212 EXPECT_EQ("Hisense", edid->displayName);
213 EXPECT_EQ(0, edid->productId);
214 EXPECT_EQ(29, edid->manufactureOrModelYear);
215 EXPECT_EQ(18, edid->manufactureWeek);
216
217 edid = parseEdid(getCtlDisplayEdid());
218 ASSERT_TRUE(edid);
219 EXPECT_EQ(3724, edid->manufacturerId);
220 EXPECT_STREQ("CTL", edid->pnpId.data());
221 EXPECT_EQ("LP2361", edid->displayName);
222 EXPECT_EQ(9373, edid->productId);
223 EXPECT_EQ(23, edid->manufactureOrModelYear);
224 EXPECT_EQ(0xff, edid->manufactureWeek);
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700225}
226
227TEST(DisplayIdentificationTest, parseInvalidEdid) {
228 EXPECT_FALSE(isEdid({}));
229 EXPECT_FALSE(parseEdid({}));
230
231 // Display name must be printable.
Dominik Laskowski075d3172018-05-24 15:50:06 -0700232 auto data = getExternalEdid();
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700233 data[97] = '\x1b';
234 auto edid = parseEdid(data);
235 ASSERT_TRUE(edid);
236 // Serial number should be used as fallback if display name is invalid.
237 EXPECT_EQ("CN4202137Q", edid->displayName);
238
239 // Parsing should succeed even if EDID is truncated.
240 data.pop_back();
241 edid = parseEdid(data);
242 ASSERT_TRUE(edid);
243 EXPECT_EQ("CN4202137Q", edid->displayName);
244}
245
246TEST(DisplayIdentificationTest, getPnpId) {
247 EXPECT_FALSE(getPnpId(0));
248 EXPECT_FALSE(getPnpId(static_cast<uint16_t>(-1)));
249
250 EXPECT_STREQ("SEC", getPnpId(0x4ca3u).value_or(PnpId{}).data());
251 EXPECT_STREQ("HWP", getPnpId(0x22f0u).value_or(PnpId{}).data());
252 EXPECT_STREQ("SAM", getPnpId(0x4c2du).value_or(PnpId{}).data());
253}
254
Dominik Laskowski075d3172018-05-24 15:50:06 -0700255TEST(DisplayIdentificationTest, parseDisplayIdentificationData) {
256 const auto primaryInfo = parseDisplayIdentificationData(0, getInternalEdid());
257 ASSERT_TRUE(primaryInfo);
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700258
Dominik Laskowski075d3172018-05-24 15:50:06 -0700259 const auto secondaryInfo = parseDisplayIdentificationData(1, getExternalEdid());
260 ASSERT_TRUE(secondaryInfo);
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700261
Dominik Laskowski075d3172018-05-24 15:50:06 -0700262 const auto tertiaryInfo = parseDisplayIdentificationData(2, getExternalEedid());
263 ASSERT_TRUE(tertiaryInfo);
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700264
265 // Display IDs should be unique.
Dominik Laskowski075d3172018-05-24 15:50:06 -0700266 EXPECT_NE(primaryInfo->id, secondaryInfo->id);
267 EXPECT_NE(primaryInfo->id, tertiaryInfo->id);
268 EXPECT_NE(secondaryInfo->id, tertiaryInfo->id);
269}
270
Marin Shalamanovf5de90d2019-10-08 10:57:25 +0200271TEST(DisplayIdentificationTest, deviceProductInfo) {
272 using ManufactureYear = DeviceProductInfo::ManufactureYear;
273 using ManufactureWeekAndYear = DeviceProductInfo::ManufactureWeekAndYear;
274 using ModelYear = DeviceProductInfo::ModelYear;
275
276 {
277 const auto displayIdInfo = parseDisplayIdentificationData(0, getInternalEdid());
278 ASSERT_TRUE(displayIdInfo);
279 ASSERT_TRUE(displayIdInfo->deviceProductInfo);
280 const auto& info = *displayIdInfo->deviceProductInfo;
281 EXPECT_STREQ("121AT11-801", info.name.data());
282 EXPECT_STREQ("SEC", info.manufacturerPnpId.data());
283 EXPECT_STREQ("12610", info.productId.data());
284 ASSERT_TRUE(std::holds_alternative<ManufactureYear>(info.manufactureOrModelDate));
285 EXPECT_EQ(2011, std::get<ManufactureYear>(info.manufactureOrModelDate).year);
286 }
287 {
288 const auto displayIdInfo = parseDisplayIdentificationData(0, getExternalEdid());
289 ASSERT_TRUE(displayIdInfo);
290 ASSERT_TRUE(displayIdInfo->deviceProductInfo);
291 const auto& info = *displayIdInfo->deviceProductInfo;
292 EXPECT_STREQ("HP ZR30w", info.name.data());
293 EXPECT_STREQ("HWP", info.manufacturerPnpId.data());
294 EXPECT_STREQ("10348", info.productId.data());
295 ASSERT_TRUE(std::holds_alternative<ManufactureWeekAndYear>(info.manufactureOrModelDate));
296 const auto& date = std::get<ManufactureWeekAndYear>(info.manufactureOrModelDate);
297 EXPECT_EQ(2012, date.year);
298 EXPECT_EQ(2, date.week);
299 }
300 {
301 const auto displayIdInfo = parseDisplayIdentificationData(0, getExternalEedid());
302 ASSERT_TRUE(displayIdInfo);
303 ASSERT_TRUE(displayIdInfo->deviceProductInfo);
304 const auto& info = *displayIdInfo->deviceProductInfo;
305 EXPECT_STREQ("SAMSUNG", info.name.data());
306 EXPECT_STREQ("SAM", info.manufacturerPnpId.data());
307 EXPECT_STREQ("2302", info.productId.data());
308 ASSERT_TRUE(std::holds_alternative<ManufactureWeekAndYear>(info.manufactureOrModelDate));
309 const auto& date = std::get<ManufactureWeekAndYear>(info.manufactureOrModelDate);
310 EXPECT_EQ(2011, date.year);
311 EXPECT_EQ(41, date.week);
312 }
313 {
314 const auto displayIdInfo = parseDisplayIdentificationData(0, getPanasonicTvEdid());
315 ASSERT_TRUE(displayIdInfo);
316 ASSERT_TRUE(displayIdInfo->deviceProductInfo);
317 const auto& info = *displayIdInfo->deviceProductInfo;
318 EXPECT_STREQ("Panasonic-TV", info.name.data());
319 EXPECT_STREQ("MEI", info.manufacturerPnpId.data());
320 EXPECT_STREQ("41622", info.productId.data());
321 ASSERT_TRUE(std::holds_alternative<ManufactureYear>(info.manufactureOrModelDate));
322 const auto& date = std::get<ManufactureYear>(info.manufactureOrModelDate);
323 EXPECT_EQ(2019, date.year);
324 }
325 {
326 const auto displayIdInfo = parseDisplayIdentificationData(0, getHisenseTvEdid());
327 ASSERT_TRUE(displayIdInfo);
328 ASSERT_TRUE(displayIdInfo->deviceProductInfo);
329 const auto& info = *displayIdInfo->deviceProductInfo;
330 EXPECT_STREQ("Hisense", info.name.data());
331 EXPECT_STREQ("HEC", info.manufacturerPnpId.data());
332 EXPECT_STREQ("0", info.productId.data());
333 ASSERT_TRUE(std::holds_alternative<ManufactureWeekAndYear>(info.manufactureOrModelDate));
334 const auto& date = std::get<ManufactureWeekAndYear>(info.manufactureOrModelDate);
335 EXPECT_EQ(2019, date.year);
336 EXPECT_EQ(18, date.week);
337 }
338 {
339 const auto displayIdInfo = parseDisplayIdentificationData(0, getCtlDisplayEdid());
340 ASSERT_TRUE(displayIdInfo);
341 ASSERT_TRUE(displayIdInfo->deviceProductInfo);
342 const auto& info = *displayIdInfo->deviceProductInfo;
343 EXPECT_STREQ("LP2361", info.name.data());
344 EXPECT_STREQ("CTL", info.manufacturerPnpId.data());
345 EXPECT_STREQ("9373", info.productId.data());
346 ASSERT_TRUE(std::holds_alternative<ModelYear>(info.manufactureOrModelDate));
347 EXPECT_EQ(2013, std::get<ModelYear>(info.manufactureOrModelDate).year);
348 }
349}
350
Dominik Laskowski075d3172018-05-24 15:50:06 -0700351TEST(DisplayIdentificationTest, getFallbackDisplayId) {
352 // Manufacturer ID should be invalid.
353 ASSERT_FALSE(getPnpId(getFallbackDisplayId(0)));
354 ASSERT_FALSE(getPnpId(getFallbackDisplayId(0xffu)));
355}
356
357TEST(DisplayIdentificationTest, getVirtualDisplayId) {
358 // Manufacturer ID should be invalid.
359 ASSERT_FALSE(getPnpId(getVirtualDisplayId(0)));
360 ASSERT_FALSE(getPnpId(getVirtualDisplayId(0xffff'ffffu)));
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700361}
362
363} // namespace android