OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <limits> | 5 #include <limits> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
10 #include "chrome/browser/sync/syncable/directory_manager.h" | 10 #include "chrome/browser/sync/syncable/directory_manager.h" |
11 #include "chrome/browser/sync/util/character_set_converters.h" | |
12 #include "chrome/browser/sync/util/user_settings.h" | 11 #include "chrome/browser/sync/util/user_settings.h" |
13 #include "chrome/common/sqlite_utils.h" | 12 #include "chrome/common/sqlite_utils.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
15 | 14 |
16 using browser_sync::APEncode; | 15 using browser_sync::APEncode; |
17 using browser_sync::APDecode; | 16 using browser_sync::APDecode; |
18 using browser_sync::ExecOrDie; | 17 using browser_sync::ExecOrDie; |
19 using browser_sync::FilePathToUTF8; | |
20 using browser_sync::UserSettings; | 18 using browser_sync::UserSettings; |
21 | 19 |
22 using std::numeric_limits; | 20 using std::numeric_limits; |
23 | 21 |
24 static const FilePath::CharType kV10UserSettingsDB[] = | 22 static const FilePath::CharType kV10UserSettingsDB[] = |
25 FILE_PATH_LITERAL("Version10Settings.sqlite3"); | 23 FILE_PATH_LITERAL("Version10Settings.sqlite3"); |
26 static const FilePath::CharType kV11UserSettingsDB[] = | 24 static const FilePath::CharType kV11UserSettingsDB[] = |
27 FILE_PATH_LITERAL("Version11Settings.sqlite3"); | 25 FILE_PATH_LITERAL("Version11Settings.sqlite3"); |
28 static const FilePath::CharType kOldStyleSyncDataDB[] = | 26 static const FilePath::CharType kOldStyleSyncDataDB[] = |
29 FILE_PATH_LITERAL("OldStyleSyncData.sqlite3"); | 27 FILE_PATH_LITERAL("OldStyleSyncData.sqlite3"); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 ExecOrDie(primer_handle, "CREATE TABLE shares" | 70 ExecOrDie(primer_handle, "CREATE TABLE shares" |
73 " (email, share_name, file_name," | 71 " (email, share_name, file_name," |
74 " PRIMARY KEY(email, share_name) ON CONFLICT REPLACE)"); | 72 " PRIMARY KEY(email, share_name) ON CONFLICT REPLACE)"); |
75 // Populate a share. | 73 // Populate a share. |
76 { | 74 { |
77 SQLStatement statement; | 75 SQLStatement statement; |
78 const char query[] = "INSERT INTO shares values ( ?, ?, ? )"; | 76 const char query[] = "INSERT INTO shares values ( ?, ?, ? )"; |
79 statement.prepare(primer_handle, query); | 77 statement.prepare(primer_handle, query); |
80 statement.bind_string(0, "foo@foo.com"); | 78 statement.bind_string(0, "foo@foo.com"); |
81 statement.bind_string(1, "foo@foo.com"); | 79 statement.bind_string(1, "foo@foo.com"); |
82 statement.bind_string(2, FilePathToUTF8(old_style_sync_data_path_)); | 80 #if defined(OS_WIN) |
| 81 statement.bind_string(2, WideToUTF8(old_style_sync_data_path_.value())); |
| 82 #elif defined(OS_POSIX) |
| 83 statement.bind_string(2, old_style_sync_data_path_.value()); |
| 84 #endif |
83 if (SQLITE_DONE != statement.step()) { | 85 if (SQLITE_DONE != statement.step()) { |
84 LOG(FATAL) << query << "\n" << sqlite3_errmsg(primer_handle); | 86 LOG(FATAL) << query << "\n" << sqlite3_errmsg(primer_handle); |
85 } | 87 } |
86 } | 88 } |
87 } | 89 } |
88 | 90 |
89 // Creates and populates the V11 database file within | 91 // Creates and populates the V11 database file within |
90 // |destination_directory|. | 92 // |destination_directory|. |
91 void SetUpVersion11Database(const FilePath& destination_directory) { | 93 void SetUpVersion11Database(const FilePath& destination_directory) { |
92 sqlite3* primer_handle = NULL; | 94 sqlite3* primer_handle = NULL; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 UserSettings settings; | 246 UserSettings settings; |
245 settings.Init(temp_dir.path().AppendASCII("UserSettings.sqlite3")); | 247 settings.Init(temp_dir.path().AppendASCII("UserSettings.sqlite3")); |
246 settings.SetAuthTokenForService("username", "service", "012345beefbeef"); | 248 settings.SetAuthTokenForService("username", "service", "012345beefbeef"); |
247 std::string username; | 249 std::string username; |
248 std::string token; | 250 std::string token; |
249 ASSERT_TRUE(settings.GetLastUserAndServiceToken("service", &username, | 251 ASSERT_TRUE(settings.GetLastUserAndServiceToken("service", &username, |
250 &token)); | 252 &token)); |
251 EXPECT_EQ("012345beefbeef", token); | 253 EXPECT_EQ("012345beefbeef", token); |
252 EXPECT_EQ("username", username); | 254 EXPECT_EQ("username", username); |
253 } | 255 } |
OLD | NEW |