| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 entry. | 3 // found in the LICENSE entry. |
| 4 | 4 |
| 5 #include <string> |
| 6 |
| 5 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 6 #include "base/test/test_file_util.h" | 8 #include "base/test/test_file_util.h" |
| 7 #include "chrome/browser/sync/syncable/directory_manager.h" | 9 #include "chrome/browser/sync/syncable/directory_manager.h" |
| 10 #include "chrome/browser/sync/util/character_set_converters.h" |
| 8 #include "chrome/browser/sync/util/user_settings.h" | 11 #include "chrome/browser/sync/util/user_settings.h" |
| 9 #include "chrome/browser/sync/util/query_helpers.h" | 12 #include "chrome/browser/sync/util/query_helpers.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 14 |
| 12 using browser_sync::UserSettings; | 15 using browser_sync::UserSettings; |
| 13 | 16 |
| 14 static const PathChar* kV10UserSettingsDB = PSTR("Version10Settings.sqlite3"); | 17 static const PathChar* kV10UserSettingsDB = PSTR("Version10Settings.sqlite3"); |
| 15 static const PathChar* kOldStyleSyncDataDB = PSTR("OldStyleSyncData.sqlite3"); | 18 static const PathChar* kOldStyleSyncDataDB = PSTR("OldStyleSyncData.sqlite3"); |
| 16 | 19 |
| 17 class UserSettingsTest : public testing::Test { | 20 class UserSettingsTest : public testing::Test { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 33 " (email, key, value, " | 36 " (email, key, value, " |
| 34 " PRIMARY KEY(email, key) ON CONFLICT REPLACE)"); | 37 " PRIMARY KEY(email, key) ON CONFLICT REPLACE)"); |
| 35 | 38 |
| 36 // Create and populate version table. | 39 // Create and populate version table. |
| 37 ExecOrDie(primer_handle, "CREATE TABLE db_version ( version )"); | 40 ExecOrDie(primer_handle, "CREATE TABLE db_version ( version )"); |
| 38 ExecOrDie(primer_handle, "INSERT INTO db_version values ( ? )", 10); | 41 ExecOrDie(primer_handle, "INSERT INTO db_version values ( ? )", 10); |
| 39 // Create shares table. | 42 // Create shares table. |
| 40 ExecOrDie(primer_handle, "CREATE TABLE shares" | 43 ExecOrDie(primer_handle, "CREATE TABLE shares" |
| 41 " (email, share_name, file_name," | 44 " (email, share_name, file_name," |
| 42 " PRIMARY KEY(email, share_name) ON CONFLICT REPLACE)"); | 45 " PRIMARY KEY(email, share_name) ON CONFLICT REPLACE)"); |
| 43 #if OS_WIN | |
| 44 // Populate a share. | 46 // Populate a share. |
| 45 ExecOrDie(primer_handle, "INSERT INTO shares values ( ?, ?, ?)", | 47 ExecOrDie(primer_handle, "INSERT INTO shares values ( ?, ?, ?)", |
| 46 "foo@foo.com", "foo@foo.com", WideToUTF8(kOldStyleSyncDataDB)); | 48 "foo@foo.com", "foo@foo.com", |
| 47 #elif OS_LINUX | 49 browser_sync::PathStringToUTF8Quick(kOldStyleSyncDataDB)); |
| 48 // Populate a share. | |
| 49 ExecOrDie(primer_handle, "INSERT INTO shares values ( ?, ?, ?)", | |
| 50 "foo@foo.com", "foo@foo.com", kOldStyleSyncDataDB); | |
| 51 #endif | |
| 52 sqlite3_close(primer_handle); | 50 sqlite3_close(primer_handle); |
| 53 } | 51 } |
| 54 | 52 |
| 55 void CleanUpVersion10Databases() { | 53 void CleanUpVersion10Databases() { |
| 56 ASSERT_TRUE(file_util::DieFileDie(FilePath(kV10UserSettingsDB), false)); | 54 ASSERT_TRUE(file_util::DieFileDie(FilePath(kV10UserSettingsDB), false)); |
| 57 ASSERT_TRUE(file_util::DieFileDie(FilePath(kOldStyleSyncDataDB), false)); | 55 ASSERT_TRUE(file_util::DieFileDie(FilePath(kOldStyleSyncDataDB), false)); |
| 58 ASSERT_TRUE(file_util::DieFileDie(FilePath(PSTR("SyncData.sqlite3")), | 56 ASSERT_TRUE(file_util::DieFileDie(FilePath(PSTR("SyncData.sqlite3")), |
| 59 false)); | 57 false)); |
| 60 } | 58 } |
| 61 | 59 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 85 const int version = sqlite3_column_int(version_query.get(), 0); | 83 const int version = sqlite3_column_int(version_query.get(), 0); |
| 86 EXPECT_TRUE(11 == version); | 84 EXPECT_TRUE(11 == version); |
| 87 EXPECT_FALSE(file_util::PathExists(FilePath(kOldStyleSyncDataDB))); | 85 EXPECT_FALSE(file_util::PathExists(FilePath(kOldStyleSyncDataDB))); |
| 88 | 86 |
| 89 PathString path(syncable::DirectoryManager::GetSyncDataDatabaseFilename()); | 87 PathString path(syncable::DirectoryManager::GetSyncDataDatabaseFilename()); |
| 90 | 88 |
| 91 std::string contents; | 89 std::string contents; |
| 92 ASSERT_TRUE(file_util::ReadFileToString(FilePath(path), &contents)); | 90 ASSERT_TRUE(file_util::ReadFileToString(FilePath(path), &contents)); |
| 93 EXPECT_TRUE(sync_data() == contents); | 91 EXPECT_TRUE(sync_data() == contents); |
| 94 } | 92 } |
| OLD | NEW |