Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/utility/importer/edge_database_reader_win.h" | |
| 6 | |
| 7 #include <windows.h> | |
| 8 | |
| 9 #include "base/files/file_util.h" | |
| 10 #include "base/files/scoped_temp_dir.h" | |
| 11 #include "base/path_service.h" | |
| 12 #include "base/strings/string_util.h" | |
| 13 #include "base/strings/stringprintf.h" | |
| 14 #include "base/strings/utf_string_conversions.h" | |
| 15 #include "base/win/windows_version.h" | |
| 16 #include "chrome/common/chrome_paths.h" | |
| 17 #include "components/compression/compression_utils.h" | |
| 18 #include "testing/gtest/include/gtest/gtest.h" | |
| 19 | |
| 20 namespace { | |
| 21 | |
|
ananta
2015/12/02 21:33:11
Thanks for adding these tests.
| |
| 22 class EdgeDatabaseReaderTest : public ::testing::Test { | |
| 23 protected: | |
| 24 bool CopyTestDatabase(const base::string16& database_name, | |
| 25 base::FilePath* copied_path) { | |
| 26 base::FilePath input_path; | |
| 27 input_path = test_data_path_.AppendASCII("edge_database_reader") | |
| 28 .Append(database_name) | |
| 29 .AddExtension(L".gz"); | |
| 30 base::FilePath output_path = temp_dir_.path().Append(database_name); | |
| 31 | |
| 32 if (DecompressDatabase(input_path, output_path)) { | |
| 33 *copied_path = output_path; | |
| 34 return true; | |
| 35 } | |
| 36 return false; | |
| 37 } | |
| 38 | |
| 39 bool WriteFile(const base::string16& name, | |
| 40 const std::string& contents, | |
| 41 base::FilePath* output_path) { | |
| 42 *output_path = temp_dir_.path().Append(name); | |
| 43 return base::WriteFile(*output_path, contents.c_str(), contents.size()) >= | |
| 44 0; | |
| 45 } | |
| 46 | |
| 47 void SetUp() override { | |
| 48 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | |
| 49 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_path_)); | |
| 50 } | |
| 51 | |
| 52 private: | |
| 53 bool DecompressDatabase(const base::FilePath& gzip_file, | |
| 54 const base::FilePath& output_file) { | |
| 55 std::string gzip_data; | |
| 56 if (!base::ReadFileToString(gzip_file, &gzip_data)) | |
| 57 return false; | |
| 58 if (!compression::GzipUncompress(gzip_data, &gzip_data)) | |
| 59 return false; | |
| 60 return base::WriteFile(output_file, gzip_data.c_str(), gzip_data.size()) >= | |
| 61 0; | |
| 62 } | |
| 63 | |
| 64 base::ScopedTempDir temp_dir_; | |
| 65 base::FilePath test_data_path_; | |
| 66 }; | |
| 67 | |
| 68 } // namespace | |
| 69 | |
| 70 TEST_F(EdgeDatabaseReaderTest, OpenFileTest) { | |
| 71 // Only verified to work with ESE library on Windows 7 and above. | |
| 72 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 73 return; | |
| 74 | |
| 75 base::FilePath database_path; | |
| 76 ASSERT_TRUE(CopyTestDatabase(L"testdata.edb", &database_path)); | |
| 77 EdgeDatabaseReader reader; | |
| 78 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); | |
| 79 } | |
| 80 | |
| 81 TEST_F(EdgeDatabaseReaderTest, NoFileTest) { | |
| 82 // Only verified to work with ESE library on Windows 7 and above. | |
| 83 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 84 return; | |
| 85 | |
| 86 EdgeDatabaseReader reader; | |
| 87 EXPECT_FALSE(reader.OpenDatabase(L"ThisIsntARealFileName.edb")); | |
| 88 } | |
| 89 | |
| 90 TEST_F(EdgeDatabaseReaderTest, RandomGarbageDatabaseTest) { | |
| 91 // Only verified to work with ESE library on Windows 7 and above. | |
| 92 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 93 return; | |
| 94 | |
| 95 base::FilePath database_path; | |
| 96 ASSERT_TRUE(CopyTestDatabase(L"random.edb", &database_path)); | |
| 97 EdgeDatabaseReader reader; | |
| 98 EXPECT_FALSE(reader.OpenDatabase(database_path.value())); | |
| 99 } | |
| 100 | |
| 101 TEST_F(EdgeDatabaseReaderTest, ZerosDatabaseTest) { | |
| 102 // Only verified to work with ESE library on Windows 7 and above. | |
| 103 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 104 return; | |
| 105 | |
| 106 base::FilePath database_path; | |
| 107 std::string zeros(0x10000, '\0'); | |
| 108 ASSERT_TRUE(WriteFile(L"zeros.edb", zeros, &database_path)); | |
| 109 EdgeDatabaseReader reader; | |
| 110 EXPECT_FALSE(reader.OpenDatabase(database_path.value())); | |
| 111 } | |
| 112 | |
| 113 TEST_F(EdgeDatabaseReaderTest, EmptyDatabaseTest) { | |
| 114 // Only verified to work with ESE library on Windows 7 and above. | |
| 115 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 116 return; | |
| 117 | |
| 118 base::FilePath database_path; | |
| 119 ASSERT_TRUE(WriteFile(L"empty.edb", "", &database_path)); | |
| 120 EdgeDatabaseReader reader; | |
| 121 EXPECT_FALSE(reader.OpenDatabase(database_path.value())); | |
| 122 } | |
| 123 | |
| 124 TEST_F(EdgeDatabaseReaderTest, OpenTableDatabaseTest) { | |
| 125 // Only verified to work with ESE library on Windows 7 and above. | |
| 126 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 127 return; | |
| 128 | |
| 129 base::FilePath database_path; | |
| 130 ASSERT_TRUE(CopyTestDatabase(L"testdata.edb", &database_path)); | |
| 131 EdgeDatabaseReader reader; | |
| 132 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); | |
| 133 scoped_ptr<EdgeDatabaseTableEnumerator> table_enum = | |
| 134 reader.OpenTableEnumerator(L"TestTable"); | |
| 135 EXPECT_NE(table_enum, nullptr); | |
| 136 } | |
| 137 | |
| 138 TEST_F(EdgeDatabaseReaderTest, InvalidTableDatabaseTest) { | |
| 139 // Only verified to work with ESE library on Windows 7 and above. | |
| 140 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 141 return; | |
| 142 | |
| 143 base::FilePath database_path; | |
| 144 ASSERT_TRUE(CopyTestDatabase(L"testdata.edb", &database_path)); | |
| 145 EdgeDatabaseReader reader; | |
| 146 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); | |
| 147 scoped_ptr<EdgeDatabaseTableEnumerator> table_enum = | |
| 148 reader.OpenTableEnumerator(L"NotARealTableName"); | |
| 149 EXPECT_EQ(table_enum, nullptr); | |
| 150 } | |
| 151 | |
| 152 TEST_F(EdgeDatabaseReaderTest, NotOpenDatabaseTest) { | |
| 153 // Only verified to work with ESE library on Windows 7 and above. | |
| 154 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 155 return; | |
| 156 | |
| 157 EdgeDatabaseReader reader; | |
| 158 scoped_ptr<EdgeDatabaseTableEnumerator> table_enum = | |
| 159 reader.OpenTableEnumerator(L"TestTable"); | |
| 160 EXPECT_EQ(table_enum, nullptr); | |
| 161 EXPECT_EQ(reader.last_error(), JET_errDatabaseNotFound); | |
| 162 } | |
| 163 | |
| 164 TEST_F(EdgeDatabaseReaderTest, AlreadyOpenDatabaseTest) { | |
| 165 // Only verified to work with ESE library on Windows 7 and above. | |
| 166 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 167 return; | |
| 168 | |
| 169 base::FilePath database_path; | |
| 170 ASSERT_TRUE(CopyTestDatabase(L"testdata.edb", &database_path)); | |
| 171 EdgeDatabaseReader reader; | |
| 172 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); | |
| 173 EXPECT_FALSE(reader.OpenDatabase(database_path.value())); | |
| 174 EXPECT_EQ(reader.last_error(), JET_errOneDatabasePerSession); | |
| 175 } | |
| 176 | |
| 177 TEST_F(EdgeDatabaseReaderTest, OpenTableAndReadDataDatabaseTest) { | |
| 178 // Only verified to work with ESE library on Windows 7 and above. | |
| 179 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 180 return; | |
| 181 | |
| 182 base::FilePath database_path; | |
| 183 ASSERT_TRUE(CopyTestDatabase(L"testdata.edb", &database_path)); | |
| 184 EdgeDatabaseReader reader; | |
| 185 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); | |
| 186 scoped_ptr<EdgeDatabaseTableEnumerator> table_enum = | |
| 187 reader.OpenTableEnumerator(L"TestTable"); | |
| 188 EXPECT_NE(table_enum, nullptr); | |
| 189 int row_count = 0; | |
| 190 do { | |
| 191 int32_t int_col_value = 0; | |
| 192 EXPECT_TRUE(table_enum->RetrieveColumn(L"IntCol", &int_col_value)); | |
| 193 EXPECT_EQ(int_col_value, -row_count); | |
| 194 | |
| 195 uint32_t uint_col_value = 0; | |
| 196 EXPECT_TRUE(table_enum->RetrieveColumn(L"UIntCol", &uint_col_value)); | |
| 197 EXPECT_EQ(uint_col_value, row_count); | |
| 198 | |
| 199 int64_t longlong_col_value = 0; | |
| 200 EXPECT_TRUE( | |
| 201 table_enum->RetrieveColumn(L"LongLongCol", &longlong_col_value)); | |
| 202 EXPECT_EQ(longlong_col_value, row_count); | |
| 203 | |
| 204 GUID guid_col_value = {}; | |
| 205 GUID expected_guid_col_value = {}; | |
| 206 EXPECT_TRUE(table_enum->RetrieveColumn(L"GuidCol", &guid_col_value)); | |
| 207 memset(&expected_guid_col_value, row_count, | |
| 208 sizeof(expected_guid_col_value)); | |
| 209 EXPECT_EQ(guid_col_value, expected_guid_col_value); | |
| 210 | |
| 211 FILETIME filetime_col_value = {}; | |
| 212 FILETIME expected_filetime_col_value = {}; | |
| 213 SYSTEMTIME system_time = {}; | |
| 214 // Expected time value is row_count+1/January/1970. | |
| 215 system_time.wYear = 1970; | |
| 216 system_time.wMonth = 1; | |
| 217 system_time.wDay = row_count + 1; | |
| 218 EXPECT_TRUE( | |
| 219 SystemTimeToFileTime(&system_time, &expected_filetime_col_value)); | |
| 220 EXPECT_TRUE(table_enum->RetrieveColumn(L"DateCol", &filetime_col_value)); | |
| 221 EXPECT_EQ(filetime_col_value.dwLowDateTime, | |
| 222 expected_filetime_col_value.dwLowDateTime); | |
| 223 EXPECT_EQ(filetime_col_value.dwHighDateTime, | |
| 224 expected_filetime_col_value.dwHighDateTime); | |
| 225 | |
| 226 std::wstring row_string = base::StringPrintf(L"String: %d", row_count); | |
| 227 base::string16 str_col_value; | |
| 228 EXPECT_TRUE(table_enum->RetrieveColumn(L"StrCol", &str_col_value)); | |
| 229 EXPECT_EQ(str_col_value, row_string); | |
| 230 | |
| 231 bool bool_col_value; | |
| 232 EXPECT_TRUE(table_enum->RetrieveColumn(L"BoolCol", &bool_col_value)); | |
| 233 EXPECT_EQ(bool_col_value, (row_count % 2) == 0); | |
| 234 | |
| 235 row_count++; | |
| 236 } while (table_enum->Next()); | |
| 237 EXPECT_EQ(row_count, 16); | |
|
Nico
2015/12/09 18:23:06
FYI: It's EXPECT_EQ(expected, actual), not EXPECT_
| |
| 238 } | |
| 239 | |
| 240 TEST_F(EdgeDatabaseReaderTest, CheckEnumResetDatabaseTest) { | |
| 241 // Only verified to work with ESE library on Windows 7 and above. | |
| 242 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 243 return; | |
| 244 | |
| 245 base::FilePath database_path; | |
| 246 ASSERT_TRUE(CopyTestDatabase(L"testdata.edb", &database_path)); | |
| 247 EdgeDatabaseReader reader; | |
| 248 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); | |
| 249 scoped_ptr<EdgeDatabaseTableEnumerator> table_enum = | |
| 250 reader.OpenTableEnumerator(L"TestTable"); | |
| 251 EXPECT_NE(table_enum, nullptr); | |
| 252 int row_count = 0; | |
| 253 do { | |
| 254 row_count++; | |
| 255 } while (table_enum->Next()); | |
| 256 EXPECT_NE(row_count, 0); | |
| 257 EXPECT_TRUE(table_enum->Reset()); | |
| 258 do { | |
| 259 row_count--; | |
| 260 } while (table_enum->Next()); | |
| 261 EXPECT_EQ(row_count, 0); | |
| 262 } | |
| 263 | |
| 264 TEST_F(EdgeDatabaseReaderTest, InvalidColumnDatabaseTest) { | |
| 265 // Only verified to work with ESE library on Windows 7 and above. | |
| 266 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 267 return; | |
| 268 | |
| 269 base::FilePath database_path; | |
| 270 ASSERT_TRUE(CopyTestDatabase(L"testdata.edb", &database_path)); | |
| 271 EdgeDatabaseReader reader; | |
| 272 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); | |
| 273 scoped_ptr<EdgeDatabaseTableEnumerator> table_enum = | |
| 274 reader.OpenTableEnumerator(L"TestTable"); | |
| 275 EXPECT_NE(table_enum, nullptr); | |
| 276 int32_t int_col_value = 0; | |
| 277 EXPECT_FALSE(table_enum->RetrieveColumn(L"NotARealNameCol", &int_col_value)); | |
| 278 EXPECT_EQ(table_enum->last_error(), JET_errColumnNotFound); | |
| 279 } | |
| 280 | |
| 281 TEST_F(EdgeDatabaseReaderTest, NoColumnDatabaseTest) { | |
| 282 // Only verified to work with ESE library on Windows 7 and above. | |
| 283 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 284 return; | |
| 285 | |
| 286 base::FilePath database_path; | |
| 287 ASSERT_TRUE(CopyTestDatabase(L"testdata.edb", &database_path)); | |
| 288 EdgeDatabaseReader reader; | |
| 289 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); | |
| 290 scoped_ptr<EdgeDatabaseTableEnumerator> table_enum = | |
| 291 reader.OpenTableEnumerator(L"NoColsTable"); | |
| 292 EXPECT_NE(table_enum, nullptr); | |
| 293 int32_t int_col_value = 0; | |
| 294 EXPECT_FALSE(table_enum->RetrieveColumn(L"IntCol", &int_col_value)); | |
| 295 EXPECT_EQ(table_enum->last_error(), JET_errColumnNotFound); | |
| 296 } | |
| 297 | |
| 298 TEST_F(EdgeDatabaseReaderTest, EmptyTableDatabaseTest) { | |
| 299 // Only verified to work with ESE library on Windows 7 and above. | |
| 300 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 301 return; | |
| 302 | |
| 303 base::FilePath database_path; | |
| 304 ASSERT_TRUE(CopyTestDatabase(L"testdata.edb", &database_path)); | |
| 305 EdgeDatabaseReader reader; | |
| 306 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); | |
| 307 scoped_ptr<EdgeDatabaseTableEnumerator> table_enum = | |
| 308 reader.OpenTableEnumerator(L"EmptyTable"); | |
| 309 EXPECT_NE(table_enum, nullptr); | |
| 310 int32_t int_col_value = 0; | |
| 311 EXPECT_FALSE(table_enum->RetrieveColumn(L"IntCol", &int_col_value)); | |
| 312 EXPECT_NE(table_enum->last_error(), JET_errColumnNotFound); | |
| 313 EXPECT_FALSE(table_enum->Reset()); | |
| 314 EXPECT_FALSE(table_enum->Next()); | |
| 315 } | |
| 316 | |
| 317 TEST_F(EdgeDatabaseReaderTest, UnicodeStringsDatabaseTest) { | |
| 318 const char* utf8_strings[] = { | |
| 319 "\xE3\x81\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF", | |
| 320 "\xE4\xBD\xA0\xE5\xA5\xBD", | |
| 321 "\xD0\x97\xD0\xB4\xD1\x80\xD0\xB0\xD0\xB2\xD1\x81\xD1\x82\xD0\xB2\xD1\x83" | |
| 322 "\xD0\xB9\xD1\x82\xD0\xB5", | |
| 323 "\x48\x65\x6C\x6C\x6F", | |
| 324 "\xEC\x95\x88\xEB\x85\x95\xED\x95\x98\xEC\x84\xB8\xEC\x9A\x94", | |
| 325 }; | |
| 326 // Only verified to work with ESE library on Windows 7 and above. | |
| 327 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 328 return; | |
| 329 | |
| 330 base::FilePath database_path; | |
| 331 ASSERT_TRUE(CopyTestDatabase(L"testdata.edb", &database_path)); | |
| 332 EdgeDatabaseReader reader; | |
| 333 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); | |
| 334 scoped_ptr<EdgeDatabaseTableEnumerator> table_enum = | |
| 335 reader.OpenTableEnumerator(L"UnicodeTable"); | |
| 336 EXPECT_NE(table_enum, nullptr); | |
| 337 size_t utf8_strings_count = arraysize(utf8_strings); | |
| 338 for (size_t row_count = 0; row_count < utf8_strings_count; ++row_count) { | |
| 339 std::wstring row_string = base::UTF8ToWide(utf8_strings[row_count]); | |
| 340 base::string16 str_col_value; | |
| 341 EXPECT_TRUE(table_enum->RetrieveColumn(L"StrCol", &str_col_value)); | |
| 342 EXPECT_EQ(str_col_value, row_string); | |
| 343 if (row_count < utf8_strings_count - 1) | |
| 344 EXPECT_TRUE(table_enum->Next()); | |
| 345 else | |
| 346 EXPECT_FALSE(table_enum->Next()); | |
| 347 } | |
| 348 } | |
| 349 | |
| 350 TEST_F(EdgeDatabaseReaderTest, NonUnicodeStringsDatabaseTest) { | |
| 351 // Only verified to work with ESE library on Windows 7 and above. | |
| 352 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 353 return; | |
| 354 | |
| 355 base::FilePath database_path; | |
| 356 ASSERT_TRUE(CopyTestDatabase(L"testdata.edb", &database_path)); | |
| 357 EdgeDatabaseReader reader; | |
| 358 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); | |
| 359 scoped_ptr<EdgeDatabaseTableEnumerator> table_enum = | |
| 360 reader.OpenTableEnumerator(L"NonUnicodeTable"); | |
| 361 EXPECT_NE(table_enum, nullptr); | |
| 362 base::string16 str_col_value; | |
| 363 EXPECT_FALSE(table_enum->RetrieveColumn(L"StrCol", &str_col_value)); | |
| 364 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); | |
| 365 } | |
| 366 | |
| 367 TEST_F(EdgeDatabaseReaderTest, CheckNullColumnDatabaseTest) { | |
| 368 // Only verified to work with ESE library on Windows 7 and above. | |
| 369 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 370 return; | |
| 371 | |
| 372 base::FilePath database_path; | |
| 373 ASSERT_TRUE(CopyTestDatabase(L"testdata.edb", &database_path)); | |
| 374 EdgeDatabaseReader reader; | |
| 375 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); | |
| 376 scoped_ptr<EdgeDatabaseTableEnumerator> table_enum = | |
| 377 reader.OpenTableEnumerator(L"NullTable"); | |
| 378 EXPECT_NE(table_enum, nullptr); | |
| 379 | |
| 380 // We expect to successfully open a column value but get the default value | |
| 381 // back. | |
| 382 int32_t int_col_value = 1; | |
| 383 EXPECT_TRUE(table_enum->RetrieveColumn(L"IntCol", &int_col_value)); | |
| 384 EXPECT_EQ(int_col_value, 0); | |
| 385 | |
| 386 uint32_t uint_col_value = 1; | |
| 387 EXPECT_TRUE(table_enum->RetrieveColumn(L"UIntCol", &uint_col_value)); | |
| 388 EXPECT_EQ(uint_col_value, 0); | |
| 389 | |
| 390 int64_t longlong_col_value = 1; | |
| 391 EXPECT_TRUE(table_enum->RetrieveColumn(L"LongLongCol", &longlong_col_value)); | |
| 392 EXPECT_EQ(longlong_col_value, 0); | |
| 393 | |
| 394 GUID guid_col_value = {}; | |
| 395 GUID expected_guid_col_value = {}; | |
| 396 memset(&guid_col_value, 0x1, sizeof(guid_col_value)); | |
| 397 EXPECT_TRUE(table_enum->RetrieveColumn(L"GuidCol", &guid_col_value)); | |
| 398 memset(&expected_guid_col_value, 0, sizeof(expected_guid_col_value)); | |
| 399 EXPECT_EQ(guid_col_value, expected_guid_col_value); | |
| 400 | |
| 401 FILETIME filetime_col_value = {1, 1}; | |
| 402 FILETIME expected_filetime_col_value = {}; | |
| 403 EXPECT_TRUE(table_enum->RetrieveColumn(L"DateCol", &filetime_col_value)); | |
| 404 EXPECT_EQ(filetime_col_value.dwLowDateTime, | |
| 405 expected_filetime_col_value.dwLowDateTime); | |
| 406 EXPECT_EQ(filetime_col_value.dwHighDateTime, | |
| 407 expected_filetime_col_value.dwHighDateTime); | |
| 408 | |
| 409 base::string16 str_col_value; | |
| 410 EXPECT_TRUE(table_enum->RetrieveColumn(L"StrCol", &str_col_value)); | |
| 411 EXPECT_TRUE(str_col_value.empty()); | |
| 412 | |
| 413 bool bool_col_value; | |
| 414 EXPECT_TRUE(table_enum->RetrieveColumn(L"BoolCol", &bool_col_value)); | |
| 415 EXPECT_EQ(bool_col_value, false); | |
| 416 } | |
| 417 | |
| 418 TEST_F(EdgeDatabaseReaderTest, CheckInvalidColumnTypeDatabaseTest) { | |
| 419 // Only verified to work with ESE library on Windows 7 and above. | |
| 420 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 421 return; | |
| 422 | |
| 423 base::FilePath database_path; | |
| 424 ASSERT_TRUE(CopyTestDatabase(L"testdata.edb", &database_path)); | |
| 425 EdgeDatabaseReader reader; | |
| 426 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); | |
| 427 scoped_ptr<EdgeDatabaseTableEnumerator> table_enum = | |
| 428 reader.OpenTableEnumerator(L"TestTable"); | |
| 429 EXPECT_NE(table_enum, nullptr); | |
| 430 | |
| 431 uint32_t uint_col_value = 0; | |
| 432 EXPECT_FALSE(table_enum->RetrieveColumn(L"IntCol", &uint_col_value)); | |
| 433 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); | |
| 434 // Check unsigned int with a signed int. | |
| 435 int32_t int_col_value = 0; | |
| 436 EXPECT_FALSE(table_enum->RetrieveColumn(L"UIntCol", &int_col_value)); | |
| 437 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); | |
| 438 EXPECT_FALSE(table_enum->RetrieveColumn(L"LongLongCol", &uint_col_value)); | |
| 439 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); | |
| 440 EXPECT_FALSE(table_enum->RetrieveColumn(L"GuidCol", &uint_col_value)); | |
| 441 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); | |
| 442 EXPECT_FALSE(table_enum->RetrieveColumn(L"DateCol", &uint_col_value)); | |
| 443 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); | |
| 444 EXPECT_FALSE(table_enum->RetrieveColumn(L"StrCol", &uint_col_value)); | |
| 445 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); | |
| 446 EXPECT_FALSE(table_enum->RetrieveColumn(L"BoolCol", &uint_col_value)); | |
| 447 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); | |
| 448 } | |
| OLD | NEW |