OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/base/x/x11_util.h" | 8 #include "ui/base/x/x11_util.h" |
9 | 9 |
10 namespace ui { | 10 namespace ui { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 "\x00\x53\x41\x4d\x53\x55\x4e\x47\x0a\x20\x20\x20\x20\x20\x01\x1d" | 47 "\x00\x53\x41\x4d\x53\x55\x4e\x47\x0a\x20\x20\x20\x20\x20\x01\x1d" |
48 "\x02\x03\x1f\xf1\x47\x90\x04\x05\x03\x20\x22\x07\x23\x09\x07\x07" | 48 "\x02\x03\x1f\xf1\x47\x90\x04\x05\x03\x20\x22\x07\x23\x09\x07\x07" |
49 "\x83\x01\x00\x00\xe2\x00\x0f\x67\x03\x0c\x00\x20\x00\xb8\x2d\x01" | 49 "\x83\x01\x00\x00\xe2\x00\x0f\x67\x03\x0c\x00\x20\x00\xb8\x2d\x01" |
50 "\x1d\x80\x18\x71\x1c\x16\x20\x58\x2c\x25\x00\xa0\x5a\x00\x00\x00" | 50 "\x1d\x80\x18\x71\x1c\x16\x20\x58\x2c\x25\x00\xa0\x5a\x00\x00\x00" |
51 "\x9e\x01\x1d\x00\x72\x51\xd0\x1e\x20\x6e\x28\x55\x00\xa0\x5a\x00" | 51 "\x9e\x01\x1d\x00\x72\x51\xd0\x1e\x20\x6e\x28\x55\x00\xa0\x5a\x00" |
52 "\x00\x00\x1e\x8c\x0a\xd0\x8a\x20\xe0\x2d\x10\x10\x3e\x96\x00\xa0" | 52 "\x00\x00\x1e\x8c\x0a\xd0\x8a\x20\xe0\x2d\x10\x10\x3e\x96\x00\xa0" |
53 "\x5a\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" | 53 "\x5a\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
54 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" | 54 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
55 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc6"; | 55 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc6"; |
56 | 56 |
| 57 // The EDID info misdetecting overscan once. see crbug.com/226318 |
| 58 const unsigned char kMisdetecedDisplay[] = |
| 59 "\x00\xff\xff\xff\xff\xff\xff\x00\x10\xac\x64\x40\x4c\x30\x30\x32" |
| 60 "\x0c\x15\x01\x03\x80\x40\x28\x78\xea\x8d\x85\xad\x4f\x35\xb1\x25" |
| 61 "\x0e\x50\x54\xa5\x4b\x00\x71\x4f\x81\x00\x81\x80\xd1\x00\xa9\x40" |
| 62 "\x01\x01\x01\x01\x01\x01\x28\x3c\x80\xa0\x70\xb0\x23\x40\x30\x20" |
| 63 "\x36\x00\x81\x91\x21\x00\x00\x1a\x00\x00\x00\xff\x00\x50\x48\x35" |
| 64 "\x4e\x59\x31\x33\x4e\x32\x30\x30\x4c\x0a\x00\x00\x00\xfc\x00\x44" |
| 65 "\x45\x4c\x4c\x20\x55\x33\x30\x31\x31\x0a\x20\x20\x00\x00\x00\xfd" |
| 66 "\x00\x31\x56\x1d\x5e\x12\x00\x0a\x20\x20\x20\x20\x20\x20\x01\x38" |
| 67 "\x02\x03\x29\xf1\x50\x90\x05\x04\x03\x02\x07\x16\x01\x06\x11\x12" |
| 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" |
| 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" |
| 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" |
| 74 "\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x94"; |
| 75 |
57 } | 76 } |
58 | 77 |
59 TEST(X11UtilTest, ParseEDID) { | 78 TEST(X11UtilTest, ParseEDID) { |
60 uint16 manufacturer_id = 0; | 79 uint16 manufacturer_id = 0; |
61 uint16 product_code = 0; | 80 uint16 product_code = 0; |
62 std::string human_readable_name; | 81 std::string human_readable_name; |
63 EXPECT_TRUE(ParseOutputDeviceData( | 82 EXPECT_TRUE(ParseOutputDeviceData( |
64 kNormalDisplay, charsize(kNormalDisplay), | 83 kNormalDisplay, charsize(kNormalDisplay), |
65 &manufacturer_id, &product_code, &human_readable_name)); | 84 &manufacturer_id, &product_code, &human_readable_name)); |
66 EXPECT_EQ(0x22f0u, manufacturer_id); | 85 EXPECT_EQ(0x22f0u, manufacturer_id); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 flag = false; | 154 flag = false; |
136 EXPECT_FALSE(ParseOutputOverscanFlag( | 155 EXPECT_FALSE(ParseOutputOverscanFlag( |
137 kInternalDisplay, charsize(kInternalDisplay), &flag)); | 156 kInternalDisplay, charsize(kInternalDisplay), &flag)); |
138 | 157 |
139 flag = false; | 158 flag = false; |
140 EXPECT_TRUE(ParseOutputOverscanFlag( | 159 EXPECT_TRUE(ParseOutputOverscanFlag( |
141 kOverscanDisplay, charsize(kOverscanDisplay), &flag)); | 160 kOverscanDisplay, charsize(kOverscanDisplay), &flag)); |
142 EXPECT_TRUE(flag); | 161 EXPECT_TRUE(flag); |
143 | 162 |
144 flag = false; | 163 flag = false; |
| 164 EXPECT_FALSE(ParseOutputOverscanFlag( |
| 165 kMisdetecedDisplay, charsize(kMisdetecedDisplay), &flag)); |
| 166 |
| 167 flag = false; |
145 // Copy |kOverscanDisplay| and set flags to false in it. The overscan flags | 168 // Copy |kOverscanDisplay| and set flags to false in it. The overscan flags |
146 // are embedded at byte 150 in this specific example. Fix here too when the | 169 // are embedded at byte 150 in this specific example. Fix here too when the |
147 // contents of kOverscanDisplay is altered. | 170 // contents of kOverscanDisplay is altered. |
148 std::string display_data(reinterpret_cast<const char*>(kOverscanDisplay), | 171 std::string display_data(reinterpret_cast<const char*>(kOverscanDisplay), |
149 charsize(kOverscanDisplay)); | 172 charsize(kOverscanDisplay)); |
150 display_data[150] = '\0'; | 173 display_data[150] = '\0'; |
151 EXPECT_TRUE(ParseOutputOverscanFlag( | 174 EXPECT_TRUE(ParseOutputOverscanFlag( |
152 reinterpret_cast<const unsigned char*>(display_data.data()), | 175 reinterpret_cast<const unsigned char*>(display_data.data()), |
153 display_data.size(), &flag)); | 176 display_data.size(), &flag)); |
154 EXPECT_FALSE(flag); | 177 EXPECT_FALSE(flag); |
155 } | 178 } |
156 | 179 |
157 TEST(X11UtilTest, ParseBrokenOverscanData) { | 180 TEST(X11UtilTest, ParseBrokenOverscanData) { |
158 // Do not fill valid data here because it anyway fails to parse the data. | 181 // Do not fill valid data here because it anyway fails to parse the data. |
159 scoped_ptr<unsigned char[]> data(new unsigned char[126]); | 182 scoped_ptr<unsigned char[]> data(new unsigned char[126]); |
160 bool flag = false; | 183 bool flag = false; |
161 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 0, &flag)); | 184 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 0, &flag)); |
162 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 126, &flag)); | 185 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 126, &flag)); |
163 | 186 |
164 // extending data because ParseOutputOverscanFlag() will access the data. | 187 // extending data because ParseOutputOverscanFlag() will access the data. |
165 data.reset(new unsigned char[150]); | 188 data.reset(new unsigned char[150]); |
166 // The number of CEA extensions is stored at byte 126. | 189 // The number of CEA extensions is stored at byte 126. |
167 data[126] = '\x01'; | 190 data[126] = '\x01'; |
168 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 128, &flag)); | 191 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 128, &flag)); |
169 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 150, &flag)); | 192 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 150, &flag)); |
170 } | 193 } |
171 | 194 |
172 } | 195 } |
OLD | NEW |