| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/utility/importer/edge_database_reader_win.h" | 5 #include "chrome/utility/importer/edge_database_reader_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 reader.OpenTableEnumerator(L"TestTable"); | 187 reader.OpenTableEnumerator(L"TestTable"); |
| 188 EXPECT_NE(table_enum, nullptr); | 188 EXPECT_NE(table_enum, nullptr); |
| 189 int row_count = 0; | 189 int row_count = 0; |
| 190 do { | 190 do { |
| 191 int32_t int_col_value = 0; | 191 int32_t int_col_value = 0; |
| 192 EXPECT_TRUE(table_enum->RetrieveColumn(L"IntCol", &int_col_value)); | 192 EXPECT_TRUE(table_enum->RetrieveColumn(L"IntCol", &int_col_value)); |
| 193 EXPECT_EQ(int_col_value, -row_count); | 193 EXPECT_EQ(int_col_value, -row_count); |
| 194 | 194 |
| 195 uint32_t uint_col_value = 0; | 195 uint32_t uint_col_value = 0; |
| 196 EXPECT_TRUE(table_enum->RetrieveColumn(L"UIntCol", &uint_col_value)); | 196 EXPECT_TRUE(table_enum->RetrieveColumn(L"UIntCol", &uint_col_value)); |
| 197 EXPECT_EQ(uint_col_value, row_count); | 197 EXPECT_EQ(uint_col_value, static_cast<uint32_t>(row_count)); |
| 198 | 198 |
| 199 int64_t longlong_col_value = 0; | 199 int64_t longlong_col_value = 0; |
| 200 EXPECT_TRUE( | 200 EXPECT_TRUE( |
| 201 table_enum->RetrieveColumn(L"LongLongCol", &longlong_col_value)); | 201 table_enum->RetrieveColumn(L"LongLongCol", &longlong_col_value)); |
| 202 EXPECT_EQ(longlong_col_value, row_count); | 202 EXPECT_EQ(longlong_col_value, row_count); |
| 203 | 203 |
| 204 GUID guid_col_value = {}; | 204 GUID guid_col_value = {}; |
| 205 GUID expected_guid_col_value = {}; | 205 GUID expected_guid_col_value = {}; |
| 206 EXPECT_TRUE(table_enum->RetrieveColumn(L"GuidCol", &guid_col_value)); | 206 EXPECT_TRUE(table_enum->RetrieveColumn(L"GuidCol", &guid_col_value)); |
| 207 memset(&expected_guid_col_value, row_count, | 207 memset(&expected_guid_col_value, row_count, |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 EdgeDatabaseReader reader; | 374 EdgeDatabaseReader reader; |
| 375 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); | 375 EXPECT_TRUE(reader.OpenDatabase(database_path.value())); |
| 376 scoped_ptr<EdgeDatabaseTableEnumerator> table_enum = | 376 scoped_ptr<EdgeDatabaseTableEnumerator> table_enum = |
| 377 reader.OpenTableEnumerator(L"NullTable"); | 377 reader.OpenTableEnumerator(L"NullTable"); |
| 378 EXPECT_NE(table_enum, nullptr); | 378 EXPECT_NE(table_enum, nullptr); |
| 379 | 379 |
| 380 // We expect to successfully open a column value but get the default value | 380 // We expect to successfully open a column value but get the default value |
| 381 // back. | 381 // back. |
| 382 int32_t int_col_value = 1; | 382 int32_t int_col_value = 1; |
| 383 EXPECT_TRUE(table_enum->RetrieveColumn(L"IntCol", &int_col_value)); | 383 EXPECT_TRUE(table_enum->RetrieveColumn(L"IntCol", &int_col_value)); |
| 384 EXPECT_EQ(int_col_value, 0); | 384 EXPECT_EQ(0, int_col_value); |
| 385 | 385 |
| 386 uint32_t uint_col_value = 1; | 386 uint32_t uint_col_value = 1; |
| 387 EXPECT_TRUE(table_enum->RetrieveColumn(L"UIntCol", &uint_col_value)); | 387 EXPECT_TRUE(table_enum->RetrieveColumn(L"UIntCol", &uint_col_value)); |
| 388 EXPECT_EQ(uint_col_value, 0); | 388 EXPECT_EQ(0u, uint_col_value); |
| 389 | 389 |
| 390 int64_t longlong_col_value = 1; | 390 int64_t longlong_col_value = 1; |
| 391 EXPECT_TRUE(table_enum->RetrieveColumn(L"LongLongCol", &longlong_col_value)); | 391 EXPECT_TRUE(table_enum->RetrieveColumn(L"LongLongCol", &longlong_col_value)); |
| 392 EXPECT_EQ(longlong_col_value, 0); | 392 EXPECT_EQ(0, longlong_col_value); |
| 393 | 393 |
| 394 GUID guid_col_value = {}; | 394 GUID guid_col_value = {}; |
| 395 GUID expected_guid_col_value = {}; | 395 GUID expected_guid_col_value = {}; |
| 396 memset(&guid_col_value, 0x1, sizeof(guid_col_value)); | 396 memset(&guid_col_value, 0x1, sizeof(guid_col_value)); |
| 397 EXPECT_TRUE(table_enum->RetrieveColumn(L"GuidCol", &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)); | 398 memset(&expected_guid_col_value, 0, sizeof(expected_guid_col_value)); |
| 399 EXPECT_EQ(guid_col_value, expected_guid_col_value); | 399 EXPECT_EQ(guid_col_value, expected_guid_col_value); |
| 400 | 400 |
| 401 FILETIME filetime_col_value = {1, 1}; | 401 FILETIME filetime_col_value = {1, 1}; |
| 402 FILETIME expected_filetime_col_value = {}; | 402 FILETIME expected_filetime_col_value = {}; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); | 439 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); |
| 440 EXPECT_FALSE(table_enum->RetrieveColumn(L"GuidCol", &uint_col_value)); | 440 EXPECT_FALSE(table_enum->RetrieveColumn(L"GuidCol", &uint_col_value)); |
| 441 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); | 441 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); |
| 442 EXPECT_FALSE(table_enum->RetrieveColumn(L"DateCol", &uint_col_value)); | 442 EXPECT_FALSE(table_enum->RetrieveColumn(L"DateCol", &uint_col_value)); |
| 443 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); | 443 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); |
| 444 EXPECT_FALSE(table_enum->RetrieveColumn(L"StrCol", &uint_col_value)); | 444 EXPECT_FALSE(table_enum->RetrieveColumn(L"StrCol", &uint_col_value)); |
| 445 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); | 445 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); |
| 446 EXPECT_FALSE(table_enum->RetrieveColumn(L"BoolCol", &uint_col_value)); | 446 EXPECT_FALSE(table_enum->RetrieveColumn(L"BoolCol", &uint_col_value)); |
| 447 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); | 447 EXPECT_EQ(table_enum->last_error(), JET_errInvalidColumnType); |
| 448 } | 448 } |
| OLD | NEW |