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 "chrome/browser/ui/webui/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/sync_setup_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 const char kTestCaptchaUnlockUrl[] = "http://pizzamyheart/unlock"; | 49 const char kTestCaptchaUnlockUrl[] = "http://pizzamyheart/unlock"; |
50 | 50 |
51 // List of all the types a user can select in the sync config dialog. | 51 // List of all the types a user can select in the sync config dialog. |
52 const syncer::ModelType kUserSelectableTypes[] = { | 52 const syncer::ModelType kUserSelectableTypes[] = { |
53 syncer::APPS, | 53 syncer::APPS, |
54 syncer::AUTOFILL, | 54 syncer::AUTOFILL, |
55 syncer::BOOKMARKS, | 55 syncer::BOOKMARKS, |
56 syncer::EXTENSIONS, | 56 syncer::EXTENSIONS, |
57 syncer::PASSWORDS, | 57 syncer::PASSWORDS, |
58 syncer::PREFERENCES, | 58 syncer::PREFERENCES, |
59 syncer::SESSIONS, | 59 syncer::TABS, |
60 syncer::THEMES, | 60 syncer::THEMES, |
61 syncer::TYPED_URLS | 61 syncer::TYPED_URLS |
62 }; | 62 }; |
63 | 63 |
64 // Returns a ModelTypeSet with all user selectable types set. | 64 // Returns a ModelTypeSet with all user selectable types set. |
65 syncer::ModelTypeSet GetAllTypes() { | 65 syncer::ModelTypeSet GetAllTypes() { |
66 syncer::ModelTypeSet types; | 66 syncer::ModelTypeSet types; |
67 for (size_t i = 0; i < arraysize(kUserSelectableTypes); ++i) | 67 for (size_t i = 0; i < arraysize(kUserSelectableTypes); ++i) |
68 types.Put(kUserSelectableTypes[i]); | 68 types.Put(kUserSelectableTypes[i]); |
69 return types; | 69 return types; |
(...skipping 25 matching lines...) Expand all Loading... |
95 result.SetBoolean("usePassphrase", !passphrase.empty()); | 95 result.SetBoolean("usePassphrase", !passphrase.empty()); |
96 if (!passphrase.empty()) | 96 if (!passphrase.empty()) |
97 result.SetString("passphrase", passphrase); | 97 result.SetString("passphrase", passphrase); |
98 // Add all of our data types. | 98 // Add all of our data types. |
99 result.SetBoolean("appsSynced", types.Has(syncer::APPS)); | 99 result.SetBoolean("appsSynced", types.Has(syncer::APPS)); |
100 result.SetBoolean("autofillSynced", types.Has(syncer::AUTOFILL)); | 100 result.SetBoolean("autofillSynced", types.Has(syncer::AUTOFILL)); |
101 result.SetBoolean("bookmarksSynced", types.Has(syncer::BOOKMARKS)); | 101 result.SetBoolean("bookmarksSynced", types.Has(syncer::BOOKMARKS)); |
102 result.SetBoolean("extensionsSynced", types.Has(syncer::EXTENSIONS)); | 102 result.SetBoolean("extensionsSynced", types.Has(syncer::EXTENSIONS)); |
103 result.SetBoolean("passwordsSynced", types.Has(syncer::PASSWORDS)); | 103 result.SetBoolean("passwordsSynced", types.Has(syncer::PASSWORDS)); |
104 result.SetBoolean("preferencesSynced", types.Has(syncer::PREFERENCES)); | 104 result.SetBoolean("preferencesSynced", types.Has(syncer::PREFERENCES)); |
105 result.SetBoolean("sessionsSynced", types.Has(syncer::SESSIONS)); | 105 result.SetBoolean("tabsSynced", types.Has(syncer::TABS)); |
106 result.SetBoolean("themesSynced", types.Has(syncer::THEMES)); | 106 result.SetBoolean("themesSynced", types.Has(syncer::THEMES)); |
107 result.SetBoolean("typedUrlsSynced", types.Has(syncer::TYPED_URLS)); | 107 result.SetBoolean("typedUrlsSynced", types.Has(syncer::TYPED_URLS)); |
108 std::string args; | 108 std::string args; |
109 base::JSONWriter::Write(&result, &args); | 109 base::JSONWriter::Write(&result, &args); |
110 return args; | 110 return args; |
111 } | 111 } |
112 | 112 |
113 void CheckInt(const DictionaryValue* dictionary, | 113 void CheckInt(const DictionaryValue* dictionary, |
114 const std::string& key, | 114 const std::string& key, |
115 int expected_value) { | 115 int expected_value) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 void CheckConfigDataTypeArguments(DictionaryValue* dictionary, | 194 void CheckConfigDataTypeArguments(DictionaryValue* dictionary, |
195 SyncAllDataConfig config, | 195 SyncAllDataConfig config, |
196 syncer::ModelTypeSet types) { | 196 syncer::ModelTypeSet types) { |
197 CheckBool(dictionary, "syncAllDataTypes", config == SYNC_ALL_DATA); | 197 CheckBool(dictionary, "syncAllDataTypes", config == SYNC_ALL_DATA); |
198 CheckBool(dictionary, "appsSynced", types.Has(syncer::APPS)); | 198 CheckBool(dictionary, "appsSynced", types.Has(syncer::APPS)); |
199 CheckBool(dictionary, "autofillSynced", types.Has(syncer::AUTOFILL)); | 199 CheckBool(dictionary, "autofillSynced", types.Has(syncer::AUTOFILL)); |
200 CheckBool(dictionary, "bookmarksSynced", types.Has(syncer::BOOKMARKS)); | 200 CheckBool(dictionary, "bookmarksSynced", types.Has(syncer::BOOKMARKS)); |
201 CheckBool(dictionary, "extensionsSynced", types.Has(syncer::EXTENSIONS)); | 201 CheckBool(dictionary, "extensionsSynced", types.Has(syncer::EXTENSIONS)); |
202 CheckBool(dictionary, "passwordsSynced", types.Has(syncer::PASSWORDS)); | 202 CheckBool(dictionary, "passwordsSynced", types.Has(syncer::PASSWORDS)); |
203 CheckBool(dictionary, "preferencesSynced", types.Has(syncer::PREFERENCES)); | 203 CheckBool(dictionary, "preferencesSynced", types.Has(syncer::PREFERENCES)); |
204 CheckBool(dictionary, "sessionsSynced", types.Has(syncer::SESSIONS)); | 204 CheckBool(dictionary, "tabsSynced", types.Has(syncer::TABS)); |
205 CheckBool(dictionary, "themesSynced", types.Has(syncer::THEMES)); | 205 CheckBool(dictionary, "themesSynced", types.Has(syncer::THEMES)); |
206 CheckBool(dictionary, "typedUrlsSynced", types.Has(syncer::TYPED_URLS)); | 206 CheckBool(dictionary, "typedUrlsSynced", types.Has(syncer::TYPED_URLS)); |
207 } | 207 } |
208 | 208 |
209 | 209 |
210 } // namespace | 210 } // namespace |
211 | 211 |
212 // Test instance of WebUI that tracks the data passed to | 212 // Test instance of WebUI that tracks the data passed to |
213 // CallJavascriptFunction(). | 213 // CallJavascriptFunction(). |
214 class TestWebUI : public content::WebUI { | 214 class TestWebUI : public content::WebUI { |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 DictionaryValue* dictionary; | 1113 DictionaryValue* dictionary; |
1114 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 1114 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
1115 CheckBool(dictionary, "showSyncEverythingPage", false); | 1115 CheckBool(dictionary, "showSyncEverythingPage", false); |
1116 CheckBool(dictionary, "syncAllDataTypes", true); | 1116 CheckBool(dictionary, "syncAllDataTypes", true); |
1117 CheckBool(dictionary, "appsRegistered", true); | 1117 CheckBool(dictionary, "appsRegistered", true); |
1118 CheckBool(dictionary, "autofillRegistered", true); | 1118 CheckBool(dictionary, "autofillRegistered", true); |
1119 CheckBool(dictionary, "bookmarksRegistered", true); | 1119 CheckBool(dictionary, "bookmarksRegistered", true); |
1120 CheckBool(dictionary, "extensionsRegistered", true); | 1120 CheckBool(dictionary, "extensionsRegistered", true); |
1121 CheckBool(dictionary, "passwordsRegistered", true); | 1121 CheckBool(dictionary, "passwordsRegistered", true); |
1122 CheckBool(dictionary, "preferencesRegistered", true); | 1122 CheckBool(dictionary, "preferencesRegistered", true); |
1123 CheckBool(dictionary, "sessionsRegistered", true); | 1123 CheckBool(dictionary, "tabsRegistered", true); |
1124 CheckBool(dictionary, "themesRegistered", true); | 1124 CheckBool(dictionary, "themesRegistered", true); |
1125 CheckBool(dictionary, "typedUrlsRegistered", true); | 1125 CheckBool(dictionary, "typedUrlsRegistered", true); |
1126 CheckBool(dictionary, "showPassphrase", false); | 1126 CheckBool(dictionary, "showPassphrase", false); |
1127 CheckBool(dictionary, "usePassphrase", false); | 1127 CheckBool(dictionary, "usePassphrase", false); |
1128 CheckBool(dictionary, "passphraseFailed", false); | 1128 CheckBool(dictionary, "passphraseFailed", false); |
1129 CheckBool(dictionary, "encryptAllData", false); | 1129 CheckBool(dictionary, "encryptAllData", false); |
1130 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); | 1130 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); |
1131 } | 1131 } |
1132 | 1132 |
1133 TEST_P(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { | 1133 TEST_P(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 dictionary, err, false, GoogleServiceAuthError::NONE, "", true, ""); | 1281 dictionary, err, false, GoogleServiceAuthError::NONE, "", true, ""); |
1282 handler_->CloseSyncSetup(); | 1282 handler_->CloseSyncSetup(); |
1283 EXPECT_EQ(NULL, | 1283 EXPECT_EQ(NULL, |
1284 LoginUIServiceFactory::GetForProfile( | 1284 LoginUIServiceFactory::GetForProfile( |
1285 profile_.get())->current_login_ui()); | 1285 profile_.get())->current_login_ui()); |
1286 } | 1286 } |
1287 | 1287 |
1288 INSTANTIATE_TEST_CASE_P(SyncSetupHandlerTestWithParam, | 1288 INSTANTIATE_TEST_CASE_P(SyncSetupHandlerTestWithParam, |
1289 SyncSetupHandlerTest, | 1289 SyncSetupHandlerTest, |
1290 Values(true, false)); | 1290 Values(true, false)); |
OLD | NEW |