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 "chrome/browser/sync/sync_setup_wizard.h" | 5 #include "chrome/browser/sync/sync_setup_wizard.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // In real life, this is owned by the view that is opened by the browser. We | 157 // In real life, this is owned by the view that is opened by the browser. We |
158 // mock all that out, so we need to take ownership so the flow doesn't leak. | 158 // mock all that out, so we need to take ownership so the flow doesn't leak. |
159 scoped_ptr<SyncSetupFlow> flow_; | 159 scoped_ptr<SyncSetupFlow> flow_; |
160 | 160 |
161 bool was_show_html_dialog_called_; | 161 bool was_show_html_dialog_called_; |
162 }; | 162 }; |
163 | 163 |
164 class SyncSetupWizardTest : public BrowserWithTestWindowTest { | 164 class SyncSetupWizardTest : public BrowserWithTestWindowTest { |
165 public: | 165 public: |
166 SyncSetupWizardTest() | 166 SyncSetupWizardTest() |
167 : ui_thread_(ChromeThread::UI, MessageLoop::current()), | 167 : file_thread_(ChromeThread::FILE, MessageLoop::current()), |
168 file_thread_(ChromeThread::FILE, MessageLoop::current()), | |
169 test_window_(NULL), | 168 test_window_(NULL), |
170 wizard_(NULL) { } | 169 wizard_(NULL) { } |
171 virtual ~SyncSetupWizardTest() { } | 170 virtual ~SyncSetupWizardTest() { } |
172 virtual void SetUp() { | 171 virtual void SetUp() { |
173 set_profile(new TestingProfileWithSyncService()); | 172 set_profile(new TestingProfileWithSyncService()); |
174 profile()->CreateBookmarkModel(false); | 173 profile()->CreateBookmarkModel(false); |
175 // Wait for the bookmarks model to load. | 174 // Wait for the bookmarks model to load. |
176 profile()->BlockUntilBookmarkModelLoaded(); | 175 profile()->BlockUntilBookmarkModelLoaded(); |
177 set_browser(new Browser(Browser::TYPE_NORMAL, profile())); | 176 set_browser(new Browser(Browser::TYPE_NORMAL, profile())); |
178 test_window_ = new TestBrowserWindowForWizardTest(browser()); | 177 test_window_ = new TestBrowserWindowForWizardTest(browser()); |
179 set_window(test_window_); | 178 set_window(test_window_); |
180 browser()->set_window(window()); | 179 browser()->set_window(window()); |
181 BrowserList::SetLastActive(browser()); | 180 BrowserList::SetLastActive(browser()); |
182 service_ = static_cast<ProfileSyncServiceForWizardTest*>( | 181 service_ = static_cast<ProfileSyncServiceForWizardTest*>( |
183 profile()->GetProfileSyncService()); | 182 profile()->GetProfileSyncService()); |
184 wizard_.reset(new SyncSetupWizard(service_)); | 183 wizard_.reset(new SyncSetupWizard(service_)); |
185 } | 184 } |
186 | 185 |
187 virtual void TearDown() { | 186 virtual void TearDown() { |
188 test_window_ = NULL; | 187 test_window_ = NULL; |
189 service_ = NULL; | 188 service_ = NULL; |
190 wizard_.reset(); | 189 wizard_.reset(); |
191 } | 190 } |
192 | 191 |
193 ChromeThread ui_thread_; | |
194 ChromeThread file_thread_; | 192 ChromeThread file_thread_; |
195 TestBrowserWindowForWizardTest* test_window_; | 193 TestBrowserWindowForWizardTest* test_window_; |
196 scoped_ptr<SyncSetupWizard> wizard_; | 194 scoped_ptr<SyncSetupWizard> wizard_; |
197 ProfileSyncServiceForWizardTest* service_; | 195 ProfileSyncServiceForWizardTest* service_; |
198 }; | 196 }; |
199 | 197 |
200 // See http://code.google.com/p/chromium/issues/detail?id=40715 for | 198 // See http://code.google.com/p/chromium/issues/detail?id=40715 for |
201 // why we skip the below tests on OS X. We don't use DISABLED_ as we | 199 // why we skip the below tests on OS X. We don't use DISABLED_ as we |
202 // would have to change the corresponding FRIEND_TEST() declarations. | 200 // would have to change the corresponding FRIEND_TEST() declarations. |
203 | 201 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 TEST_F(SyncSetupWizardTest, ChooseDataTypesSetsPrefs) { | 297 TEST_F(SyncSetupWizardTest, ChooseDataTypesSetsPrefs) { |
300 SKIP_TEST_ON_MACOSX(); | 298 SKIP_TEST_ON_MACOSX(); |
301 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); | 299 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); |
302 wizard_->Step(SyncSetupWizard::CHOOSE_DATA_TYPES); | 300 wizard_->Step(SyncSetupWizard::CHOOSE_DATA_TYPES); |
303 | 301 |
304 ListValue data_type_choices_value; | 302 ListValue data_type_choices_value; |
305 std::string data_type_choices = "{\"keepEverythingSynced\":false,"; | 303 std::string data_type_choices = "{\"keepEverythingSynced\":false,"; |
306 data_type_choices += "\"syncBookmarks\":true,\"syncPreferences\":true,"; | 304 data_type_choices += "\"syncBookmarks\":true,\"syncPreferences\":true,"; |
307 data_type_choices += "\"syncThemes\":false,\"syncPasswords\":false,"; | 305 data_type_choices += "\"syncThemes\":false,\"syncPasswords\":false,"; |
308 data_type_choices += "\"syncAutofill\":false,\"syncExtensions\":false,"; | 306 data_type_choices += "\"syncAutofill\":false,\"syncExtensions\":false,"; |
309 data_type_choices += "\"syncTypedUrls\":true,\"syncApps\":true}"; | 307 data_type_choices += "\"syncTypedUrls\":true,\"syncApps\":true,"; |
| 308 data_type_choices += "\"syncSessions\":false}"; |
310 data_type_choices_value.Append(new StringValue(data_type_choices)); | 309 data_type_choices_value.Append(new StringValue(data_type_choices)); |
311 | 310 |
312 // Simulate the user choosing data types; bookmarks, prefs, typed | 311 // Simulate the user choosing data types; bookmarks, prefs, typed |
313 // URLS, and apps are on, the rest are off. | 312 // URLS, and apps are on, the rest are off. |
314 test_window_->flow()->flow_handler_->HandleChooseDataTypes( | 313 test_window_->flow()->flow_handler_->HandleChooseDataTypes( |
315 &data_type_choices_value); | 314 &data_type_choices_value); |
316 EXPECT_TRUE(wizard_->IsVisible()); | 315 EXPECT_TRUE(wizard_->IsVisible()); |
317 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 316 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
318 EXPECT_FALSE(service_->keep_everything_synced_); | 317 EXPECT_FALSE(service_->keep_everything_synced_); |
319 EXPECT_EQ(service_->chosen_data_types_.count(syncable::BOOKMARKS), 1U); | 318 EXPECT_EQ(service_->chosen_data_types_.count(syncable::BOOKMARKS), 1U); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 int error = -1; | 482 int error = -1; |
484 dialog_args.GetInteger("error", &error); | 483 dialog_args.GetInteger("error", &error); |
485 EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error); | 484 EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error); |
486 service_->set_auth_state(kTestUser, AuthError::None()); | 485 service_->set_auth_state(kTestUser, AuthError::None()); |
487 | 486 |
488 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); | 487 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); |
489 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 488 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
490 } | 489 } |
491 | 490 |
492 #undef SKIP_TEST_ON_MACOSX | 491 #undef SKIP_TEST_ON_MACOSX |
OLD | NEW |