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

Side by Side Diff: chromeos/display/output_util_unittest.cc

Issue 15368003: Changes how to compute the id of a display. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chromeos/display/output_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chromeos/display/output_util.h" 5 #include "chromeos/display/output_util.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace chromeos { 10 namespace chromeos {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 "\x15\x13\x14\x1f\x20\x23\x0d\x7f\x07\x83\x0f\x00\x00\x67\x03\x0c" 68 "\x15\x13\x14\x1f\x20\x23\x0d\x7f\x07\x83\x0f\x00\x00\x67\x03\x0c"
69 "\x00\x10\x00\x38\x2d\xe3\x05\x03\x01\x02\x3a\x80\x18\x71\x38\x2d" 69 "\x00\x10\x00\x38\x2d\xe3\x05\x03\x01\x02\x3a\x80\x18\x71\x38\x2d"
70 "\x40\x58\x2c\x45\x00\x81\x91\x21\x00\x00\x1e\x01\x1d\x80\x18\x71" 70 "\x40\x58\x2c\x45\x00\x81\x91\x21\x00\x00\x1e\x01\x1d\x80\x18\x71"
71 "\x1c\x16\x20\x58\x2c\x25\x00\x81\x91\x21\x00\x00\x9e\x01\x1d\x00" 71 "\x1c\x16\x20\x58\x2c\x25\x00\x81\x91\x21\x00\x00\x9e\x01\x1d\x00"
72 "\x72\x51\xd0\x1e\x20\x6e\x28\x55\x00\x81\x91\x21\x00\x00\x1e\x8c" 72 "\x72\x51\xd0\x1e\x20\x6e\x28\x55\x00\x81\x91\x21\x00\x00\x1e\x8c"
73 "\x0a\xd0\x8a\x20\xe0\x2d\x10\x10\x3e\x96\x00\x81\x91\x21\x00\x00" 73 "\x0a\xd0\x8a\x20\xe0\x2d\x10\x10\x3e\x96\x00\x81\x91\x21\x00\x00"
74 "\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x94"; 74 "\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x94";
75 75
76 } 76 }
77 77
78 const unsigned char kLP2565A[] =
79 "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00\x22\xF0\x76\x26\x01\x01\x01\x01"
80 "\x02\x12\x01\x03\x80\x34\x21\x78\xEE\xEF\x95\xA3\x54\x4C\x9B\x26"
81 "\x0F\x50\x54\xA5\x6B\x80\x81\x40\x81\x80\x81\x99\x71\x00\xA9\x00"
82 "\xA9\x40\xB3\x00\xD1\x00\x28\x3C\x80\xA0\x70\xB0\x23\x40\x30\x20"
83 "\x36\x00\x07\x44\x21\x00\x00\x1A\x00\x00\x00\xFD\x00\x30\x55\x1E"
84 "\x5E\x11\x00\x0A\x20\x20\x20\x20\x20\x20\x00\x00\x00\xFC\x00\x48"
85 "\x50\x20\x4C\x50\x32\x34\x36\x35\x0A\x20\x20\x20\x00\x00\x00\xFF"
86 "\x00\x43\x4E\x4B\x38\x30\x32\x30\x34\x48\x4D\x0A\x20\x20\x00\xA4";
87
88 const unsigned char kLP2565B[] =
89 "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00\x22\xF0\x75\x26\x01\x01\x01\x01"
90 "\x02\x12\x01\x03\x6E\x34\x21\x78\xEE\xEF\x95\xA3\x54\x4C\x9B\x26"
91 "\x0F\x50\x54\xA5\x6B\x80\x81\x40\x71\x00\xA9\x00\xA9\x40\xA9\x4F"
92 "\xB3\x00\xD1\xC0\xD1\x00\x28\x3C\x80\xA0\x70\xB0\x23\x40\x30\x20"
93 "\x36\x00\x07\x44\x21\x00\x00\x1A\x00\x00\x00\xFD\x00\x30\x55\x1E"
94 "\x5E\x15\x00\x0A\x20\x20\x20\x20\x20\x20\x00\x00\x00\xFC\x00\x48"
95 "\x50\x20\x4C\x50\x32\x34\x36\x35\x0A\x20\x20\x20\x00\x00\x00\xFF"
96 "\x00\x43\x4E\x4B\x38\x30\x32\x30\x34\x48\x4D\x0A\x20\x20\x00\x45";
97
78 TEST(OutputUtilTest, ParseEDID) { 98 TEST(OutputUtilTest, ParseEDID) {
79 uint16 manufacturer_id = 0; 99 uint16 manufacturer_id = 0;
80 uint16 product_code = 0;
81 std::string human_readable_name; 100 std::string human_readable_name;
82 EXPECT_TRUE(ParseOutputDeviceData( 101 EXPECT_TRUE(ParseOutputDeviceData(
83 kNormalDisplay, charsize(kNormalDisplay), 102 kNormalDisplay, charsize(kNormalDisplay),
84 &manufacturer_id, &product_code, &human_readable_name)); 103 &manufacturer_id, &human_readable_name));
85 EXPECT_EQ(0x22f0u, manufacturer_id); 104 EXPECT_EQ(0x22f0u, manufacturer_id);
86 EXPECT_EQ(0x286cu, product_code);
87 EXPECT_EQ("HP ZR30w", human_readable_name); 105 EXPECT_EQ("HP ZR30w", human_readable_name);
88 106
89 manufacturer_id = 0; 107 manufacturer_id = 0;
90 product_code = 0;
91 human_readable_name.clear(); 108 human_readable_name.clear();
92 EXPECT_TRUE(ParseOutputDeviceData( 109 EXPECT_TRUE(ParseOutputDeviceData(
93 kInternalDisplay, charsize(kInternalDisplay), 110 kInternalDisplay, charsize(kInternalDisplay),
94 &manufacturer_id, &product_code, NULL)); 111 &manufacturer_id, NULL));
95 EXPECT_EQ(0x4ca3u, manufacturer_id); 112 EXPECT_EQ(0x4ca3u, manufacturer_id);
96 EXPECT_EQ(0x3142u, product_code);
97 EXPECT_EQ("", human_readable_name); 113 EXPECT_EQ("", human_readable_name);
98 114
99 // Internal display doesn't have name. 115 // Internal display doesn't have name.
100 EXPECT_FALSE(ParseOutputDeviceData( 116 EXPECT_FALSE(ParseOutputDeviceData(
101 kInternalDisplay, charsize(kInternalDisplay), 117 kInternalDisplay, charsize(kInternalDisplay),
102 NULL, NULL, &human_readable_name)); 118 NULL, &human_readable_name));
103 119
104 manufacturer_id = 0; 120 manufacturer_id = 0;
105 product_code = 0;
106 human_readable_name.clear(); 121 human_readable_name.clear();
107 EXPECT_TRUE(ParseOutputDeviceData( 122 EXPECT_TRUE(ParseOutputDeviceData(
108 kOverscanDisplay, charsize(kOverscanDisplay), 123 kOverscanDisplay, charsize(kOverscanDisplay),
109 &manufacturer_id, &product_code, &human_readable_name)); 124 &manufacturer_id, &human_readable_name));
110 EXPECT_EQ(0x4c2du, manufacturer_id); 125 EXPECT_EQ(0x4c2du, manufacturer_id);
111 EXPECT_EQ(0x08feu, product_code);
112 EXPECT_EQ("SAMSUNG", human_readable_name); 126 EXPECT_EQ("SAMSUNG", human_readable_name);
113 } 127 }
114 128
115 TEST(OutputUtilTest, ParseBrokenEDID) { 129 TEST(OutputUtilTest, ParseBrokenEDID) {
116 uint16 manufacturer_id = 0; 130 uint16 manufacturer_id = 0;
117 uint16 product_code = 0;
118 std::string human_readable_name; 131 std::string human_readable_name;
119 132
120 // length == 0 133 // length == 0
121 EXPECT_FALSE(ParseOutputDeviceData( 134 EXPECT_FALSE(ParseOutputDeviceData(
122 kNormalDisplay, 0, 135 kNormalDisplay, 0,
123 &manufacturer_id, &product_code, &human_readable_name)); 136 &manufacturer_id, &human_readable_name));
124 137
125 // name is broken. Copying kNormalDisplay and substitute its name data by 138 // name is broken. Copying kNormalDisplay and substitute its name data by
126 // some control code. 139 // some control code.
127 std::string display_data( 140 std::string display_data(
128 reinterpret_cast<const char*>(kNormalDisplay), charsize(kNormalDisplay)); 141 reinterpret_cast<const char*>(kNormalDisplay), charsize(kNormalDisplay));
129 142
130 // display's name data is embedded in byte 95-107 in this specific example. 143 // display's name data is embedded in byte 95-107 in this specific example.
131 // Fix here too when the contents of kNormalDisplay is altered. 144 // Fix here too when the contents of kNormalDisplay is altered.
132 display_data[97] = '\x1b'; 145 display_data[97] = '\x1b';
133 EXPECT_FALSE(ParseOutputDeviceData( 146 EXPECT_FALSE(ParseOutputDeviceData(
134 reinterpret_cast<const unsigned char*>(display_data.data()), 147 reinterpret_cast<const unsigned char*>(display_data.data()),
135 display_data.size(), 148 display_data.size(),
136 &manufacturer_id, &product_code, &human_readable_name)); 149 &manufacturer_id, &human_readable_name));
137 150
138 // If |human_readable_name| isn't specified, it skips parsing the name. 151 // If |human_readable_name| isn't specified, it skips parsing the name.
139 manufacturer_id = 0; 152 manufacturer_id = 0;
140 product_code = 0;
141 EXPECT_TRUE(ParseOutputDeviceData( 153 EXPECT_TRUE(ParseOutputDeviceData(
142 reinterpret_cast<const unsigned char*>(display_data.data()), 154 reinterpret_cast<const unsigned char*>(display_data.data()),
143 display_data.size(), 155 display_data.size(),
144 &manufacturer_id, &product_code, NULL)); 156 &manufacturer_id, NULL));
145 EXPECT_EQ(0x22f0u, manufacturer_id); 157 EXPECT_EQ(0x22f0u, manufacturer_id);
146 EXPECT_EQ(0x286cu, product_code);
147 } 158 }
148 159
149 TEST(OutputUtilTest, ParseOverscanFlag) { 160 TEST(OutputUtilTest, ParseOverscanFlag) {
150 bool flag = false; 161 bool flag = false;
151 EXPECT_FALSE(ParseOutputOverscanFlag( 162 EXPECT_FALSE(ParseOutputOverscanFlag(
152 kNormalDisplay, charsize(kNormalDisplay), &flag)); 163 kNormalDisplay, charsize(kNormalDisplay), &flag));
153 164
154 flag = false; 165 flag = false;
155 EXPECT_FALSE(ParseOutputOverscanFlag( 166 EXPECT_FALSE(ParseOutputOverscanFlag(
156 kInternalDisplay, charsize(kInternalDisplay), &flag)); 167 kInternalDisplay, charsize(kInternalDisplay), &flag));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 EXPECT_TRUE(IsInternalOutputName("LVDSxx")); 209 EXPECT_TRUE(IsInternalOutputName("LVDSxx"));
199 EXPECT_TRUE(IsInternalOutputName("eDPzz")); 210 EXPECT_TRUE(IsInternalOutputName("eDPzz"));
200 211
201 EXPECT_FALSE(IsInternalOutputName("xyz")); 212 EXPECT_FALSE(IsInternalOutputName("xyz"));
202 EXPECT_FALSE(IsInternalOutputName("abcLVDS")); 213 EXPECT_FALSE(IsInternalOutputName("abcLVDS"));
203 EXPECT_FALSE(IsInternalOutputName("cdeeDP")); 214 EXPECT_FALSE(IsInternalOutputName("cdeeDP"));
204 EXPECT_FALSE(IsInternalOutputName("LVD")); 215 EXPECT_FALSE(IsInternalOutputName("LVD"));
205 EXPECT_FALSE(IsInternalOutputName("eD")); 216 EXPECT_FALSE(IsInternalOutputName("eD"));
206 } 217 }
207 218
219 TEST(OutputUtilTest, GetDisplayId) {
220 // EDID of kLP2565A and B are slightly different but actually the same device.
221 int64 id1 = -1;
222 int64 id2 = -1;
223 EXPECT_TRUE(GetDisplayIdFromEDID(kLP2565A, charsize(kLP2565A), 0, &id1));
224 EXPECT_TRUE(GetDisplayIdFromEDID(kLP2565B, charsize(kLP2565B), 0, &id2));
225 EXPECT_EQ(id1, id2);
226 EXPECT_NE(-1, id1);
227 }
228
229 TEST(OutputUtilTest, GetDisplayIdFromInternal) {
230 int64 id = -1;
231 EXPECT_TRUE(GetDisplayIdFromEDID(
232 kInternalDisplay, charsize(kInternalDisplay), 0, &id));
233 EXPECT_NE(-1, id);
234 }
235
236 TEST(OutputUtilTest, GetDisplayIdFailure) {
237 int64 id = -1;
238 EXPECT_FALSE(GetDisplayIdFromEDID(NULL, 0, 0, &id));
239 EXPECT_EQ(-1, id);
240 }
241
208 } // namespace chromeos 242 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/display/output_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698