OLD | NEW |
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 #include <X11/extensions/Xrandr.h> | 10 #include <X11/extensions/Xrandr.h> |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 "\x00\x31\x56\x1d\x5e\x12\x00\x0a\x20\x20\x20\x20\x20\x20\x01\x38" | 68 "\x00\x31\x56\x1d\x5e\x12\x00\x0a\x20\x20\x20\x20\x20\x20\x01\x38" |
69 "\x02\x03\x29\xf1\x50\x90\x05\x04\x03\x02\x07\x16\x01\x06\x11\x12" | 69 "\x02\x03\x29\xf1\x50\x90\x05\x04\x03\x02\x07\x16\x01\x06\x11\x12" |
70 "\x15\x13\x14\x1f\x20\x23\x0d\x7f\x07\x83\x0f\x00\x00\x67\x03\x0c" | 70 "\x15\x13\x14\x1f\x20\x23\x0d\x7f\x07\x83\x0f\x00\x00\x67\x03\x0c" |
71 "\x00\x10\x00\x38\x2d\xe3\x05\x03\x01\x02\x3a\x80\x18\x71\x38\x2d" | 71 "\x00\x10\x00\x38\x2d\xe3\x05\x03\x01\x02\x3a\x80\x18\x71\x38\x2d" |
72 "\x40\x58\x2c\x45\x00\x81\x91\x21\x00\x00\x1e\x01\x1d\x80\x18\x71" | 72 "\x40\x58\x2c\x45\x00\x81\x91\x21\x00\x00\x1e\x01\x1d\x80\x18\x71" |
73 "\x1c\x16\x20\x58\x2c\x25\x00\x81\x91\x21\x00\x00\x9e\x01\x1d\x00" | 73 "\x1c\x16\x20\x58\x2c\x25\x00\x81\x91\x21\x00\x00\x9e\x01\x1d\x00" |
74 "\x72\x51\xd0\x1e\x20\x6e\x28\x55\x00\x81\x91\x21\x00\x00\x1e\x8c" | 74 "\x72\x51\xd0\x1e\x20\x6e\x28\x55\x00\x81\x91\x21\x00\x00\x1e\x8c" |
75 "\x0a\xd0\x8a\x20\xe0\x2d\x10\x10\x3e\x96\x00\x81\x91\x21\x00\x00" | 75 "\x0a\xd0\x8a\x20\xe0\x2d\x10\x10\x3e\x96\x00\x81\x91\x21\x00\x00" |
76 "\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x94"; | 76 "\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x94"; |
77 | 77 |
78 } // namespace | 78 } |
| 79 |
| 80 const unsigned char kLP2565A[] = |
| 81 "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00\x22\xF0\x76\x26\x01\x01\x01\x01" |
| 82 "\x02\x12\x01\x03\x80\x34\x21\x78\xEE\xEF\x95\xA3\x54\x4C\x9B\x26" |
| 83 "\x0F\x50\x54\xA5\x6B\x80\x81\x40\x81\x80\x81\x99\x71\x00\xA9\x00" |
| 84 "\xA9\x40\xB3\x00\xD1\x00\x28\x3C\x80\xA0\x70\xB0\x23\x40\x30\x20" |
| 85 "\x36\x00\x07\x44\x21\x00\x00\x1A\x00\x00\x00\xFD\x00\x30\x55\x1E" |
| 86 "\x5E\x11\x00\x0A\x20\x20\x20\x20\x20\x20\x00\x00\x00\xFC\x00\x48" |
| 87 "\x50\x20\x4C\x50\x32\x34\x36\x35\x0A\x20\x20\x20\x00\x00\x00\xFF" |
| 88 "\x00\x43\x4E\x4B\x38\x30\x32\x30\x34\x48\x4D\x0A\x20\x20\x00\xA4"; |
| 89 |
| 90 const unsigned char kLP2565B[] = |
| 91 "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00\x22\xF0\x75\x26\x01\x01\x01\x01" |
| 92 "\x02\x12\x01\x03\x6E\x34\x21\x78\xEE\xEF\x95\xA3\x54\x4C\x9B\x26" |
| 93 "\x0F\x50\x54\xA5\x6B\x80\x81\x40\x71\x00\xA9\x00\xA9\x40\xA9\x4F" |
| 94 "\xB3\x00\xD1\xC0\xD1\x00\x28\x3C\x80\xA0\x70\xB0\x23\x40\x30\x20" |
| 95 "\x36\x00\x07\x44\x21\x00\x00\x1A\x00\x00\x00\xFD\x00\x30\x55\x1E" |
| 96 "\x5E\x15\x00\x0A\x20\x20\x20\x20\x20\x20\x00\x00\x00\xFC\x00\x48" |
| 97 "\x50\x20\x4C\x50\x32\x34\x36\x35\x0A\x20\x20\x20\x00\x00\x00\xFF" |
| 98 "\x00\x43\x4E\x4B\x38\x30\x32\x30\x34\x48\x4D\x0A\x20\x20\x00\x45"; |
| 99 |
| 100 TEST(OutputUtilTest, ParseEDID) { |
| 101 uint16 manufacturer_id = 0; |
| 102 std::string human_readable_name; |
| 103 EXPECT_TRUE(ParseOutputDeviceData( |
| 104 kNormalDisplay, charsize(kNormalDisplay), |
| 105 &manufacturer_id, &human_readable_name)); |
| 106 EXPECT_EQ(0x22f0u, manufacturer_id); |
| 107 EXPECT_EQ("HP ZR30w", human_readable_name); |
| 108 |
| 109 manufacturer_id = 0; |
| 110 human_readable_name.clear(); |
| 111 EXPECT_TRUE(ParseOutputDeviceData( |
| 112 kInternalDisplay, charsize(kInternalDisplay), |
| 113 &manufacturer_id, NULL)); |
| 114 EXPECT_EQ(0x4ca3u, manufacturer_id); |
| 115 EXPECT_EQ("", human_readable_name); |
| 116 |
| 117 // Internal display doesn't have name. |
| 118 EXPECT_TRUE(ParseOutputDeviceData( |
| 119 kInternalDisplay, charsize(kInternalDisplay), |
| 120 NULL, &human_readable_name)); |
| 121 EXPECT_TRUE(human_readable_name.empty()); |
| 122 |
| 123 manufacturer_id = 0; |
| 124 human_readable_name.clear(); |
| 125 EXPECT_TRUE(ParseOutputDeviceData( |
| 126 kOverscanDisplay, charsize(kOverscanDisplay), |
| 127 &manufacturer_id, &human_readable_name)); |
| 128 EXPECT_EQ(0x4c2du, manufacturer_id); |
| 129 EXPECT_EQ("SAMSUNG", human_readable_name); |
| 130 } |
| 131 |
| 132 TEST(OutputUtilTest, ParseBrokenEDID) { |
| 133 uint16 manufacturer_id = 0; |
| 134 std::string human_readable_name; |
| 135 |
| 136 // length == 0 |
| 137 EXPECT_FALSE(ParseOutputDeviceData( |
| 138 kNormalDisplay, 0, |
| 139 &manufacturer_id, &human_readable_name)); |
| 140 |
| 141 // name is broken. Copying kNormalDisplay and substitute its name data by |
| 142 // some control code. |
| 143 std::string display_data( |
| 144 reinterpret_cast<const char*>(kNormalDisplay), charsize(kNormalDisplay)); |
| 145 |
| 146 // display's name data is embedded in byte 95-107 in this specific example. |
| 147 // Fix here too when the contents of kNormalDisplay is altered. |
| 148 display_data[97] = '\x1b'; |
| 149 EXPECT_FALSE(ParseOutputDeviceData( |
| 150 reinterpret_cast<const unsigned char*>(display_data.data()), |
| 151 display_data.size(), |
| 152 &manufacturer_id, &human_readable_name)); |
| 153 |
| 154 // If |human_readable_name| isn't specified, it skips parsing the name. |
| 155 manufacturer_id = 0; |
| 156 EXPECT_TRUE(ParseOutputDeviceData( |
| 157 reinterpret_cast<const unsigned char*>(display_data.data()), |
| 158 display_data.size(), |
| 159 &manufacturer_id, NULL)); |
| 160 EXPECT_EQ(0x22f0u, manufacturer_id); |
| 161 } |
79 | 162 |
80 TEST(OutputUtilTest, ParseOverscanFlag) { | 163 TEST(OutputUtilTest, ParseOverscanFlag) { |
81 bool flag = false; | 164 bool flag = false; |
82 EXPECT_FALSE(ParseOutputOverscanFlag( | 165 EXPECT_FALSE(ParseOutputOverscanFlag( |
83 kNormalDisplay, charsize(kNormalDisplay), &flag)); | 166 kNormalDisplay, charsize(kNormalDisplay), &flag)); |
84 | 167 |
85 flag = false; | 168 flag = false; |
86 EXPECT_FALSE(ParseOutputOverscanFlag( | 169 EXPECT_FALSE(ParseOutputOverscanFlag( |
87 kInternalDisplay, charsize(kInternalDisplay), &flag)); | 170 kInternalDisplay, charsize(kInternalDisplay), &flag)); |
88 | 171 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 216 |
134 EXPECT_FALSE(IsInternalOutputName("xyz")); | 217 EXPECT_FALSE(IsInternalOutputName("xyz")); |
135 EXPECT_FALSE(IsInternalOutputName("abcLVDS")); | 218 EXPECT_FALSE(IsInternalOutputName("abcLVDS")); |
136 EXPECT_FALSE(IsInternalOutputName("cdeeDP")); | 219 EXPECT_FALSE(IsInternalOutputName("cdeeDP")); |
137 EXPECT_FALSE(IsInternalOutputName("abcDSI")); | 220 EXPECT_FALSE(IsInternalOutputName("abcDSI")); |
138 EXPECT_FALSE(IsInternalOutputName("LVD")); | 221 EXPECT_FALSE(IsInternalOutputName("LVD")); |
139 EXPECT_FALSE(IsInternalOutputName("eD")); | 222 EXPECT_FALSE(IsInternalOutputName("eD")); |
140 EXPECT_FALSE(IsInternalOutputName("DS")); | 223 EXPECT_FALSE(IsInternalOutputName("DS")); |
141 } | 224 } |
142 | 225 |
| 226 TEST(OutputUtilTest, GetDisplayId) { |
| 227 // EDID of kLP2565A and B are slightly different but actually the same device. |
| 228 int64 id1 = -1; |
| 229 int64 id2 = -1; |
| 230 EXPECT_TRUE(GetDisplayIdFromEDID(kLP2565A, charsize(kLP2565A), 0, &id1)); |
| 231 EXPECT_TRUE(GetDisplayIdFromEDID(kLP2565B, charsize(kLP2565B), 0, &id2)); |
| 232 EXPECT_EQ(id1, id2); |
| 233 EXPECT_NE(-1, id1); |
| 234 } |
| 235 |
| 236 TEST(OutputUtilTest, GetDisplayIdFromInternal) { |
| 237 int64 id = -1; |
| 238 EXPECT_TRUE(GetDisplayIdFromEDID( |
| 239 kInternalDisplay, charsize(kInternalDisplay), 0, &id)); |
| 240 EXPECT_NE(-1, id); |
| 241 } |
| 242 |
| 243 TEST(OutputUtilTest, GetDisplayIdFailure) { |
| 244 int64 id = -1; |
| 245 EXPECT_FALSE(GetDisplayIdFromEDID(NULL, 0, 0, &id)); |
| 246 EXPECT_EQ(-1, id); |
| 247 } |
| 248 |
143 } // namespace chromeos | 249 } // namespace chromeos |
OLD | NEW |