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