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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 arraysize(kOverscanDisplay)); | 145 arraysize(kOverscanDisplay)); |
146 display_data[150] = '\0'; | 146 display_data[150] = '\0'; |
147 EXPECT_TRUE(ParseOutputOverscanFlag( | 147 EXPECT_TRUE(ParseOutputOverscanFlag( |
148 reinterpret_cast<const unsigned char*>(display_data.data()), | 148 reinterpret_cast<const unsigned char*>(display_data.data()), |
149 display_data.size(), &flag)); | 149 display_data.size(), &flag)); |
150 EXPECT_FALSE(flag); | 150 EXPECT_FALSE(flag); |
151 } | 151 } |
152 | 152 |
153 TEST(X11UtilTest, ParseBrokenOverscanData) { | 153 TEST(X11UtilTest, ParseBrokenOverscanData) { |
154 // Do not fill valid data here because it anyway fails to parse the data. | 154 // Do not fill valid data here because it anyway fails to parse the data. |
155 scoped_array<unsigned char> data(new unsigned char[126]); | 155 scoped_ptr<unsigned char[]> data(new unsigned char[126]); |
156 bool flag = false; | 156 bool flag = false; |
157 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 0, &flag)); | 157 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 0, &flag)); |
158 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 126, &flag)); | 158 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 126, &flag)); |
159 | 159 |
160 // extending data because ParseOutputOverscanFlag() will access the data. | 160 // extending data because ParseOutputOverscanFlag() will access the data. |
161 data.reset(new unsigned char[150]); | 161 data.reset(new unsigned char[150]); |
162 // The number of CEA extensions is stored at byte 126. | 162 // The number of CEA extensions is stored at byte 126. |
163 data[126] = '\x01'; | 163 data[126] = '\x01'; |
164 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 128, &flag)); | 164 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 128, &flag)); |
165 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 150, &flag)); | 165 EXPECT_FALSE(ParseOutputOverscanFlag(data.get(), 150, &flag)); |
166 } | 166 } |
167 | 167 |
168 } | 168 } |
OLD | NEW |