| OLD | NEW |
| 1 // Use of this source code is governed by a BSD-style license that can be | 1 // Use of this source code is governed by a BSD-style license that can be |
| 2 // found in the LICENSE file. | 2 // found in the LICENSE file. |
| 3 | 3 |
| 4 // TODO(timsteele): Re-enable ASAP. http://crbug.com/19002 | |
| 5 #if 0 | |
| 6 #ifdef CHROME_PERSONALIZATION | 4 #ifdef CHROME_PERSONALIZATION |
| 7 | 5 |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 7 |
| 10 #include "base/json_writer.h" | 8 #include "base/json_writer.h" |
| 11 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 12 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| 13 #include "chrome/browser/browser.h" | 11 #include "chrome/browser/browser.h" |
| 14 #include "chrome/browser/browser_list.h" | 12 #include "chrome/browser/browser_list.h" |
| 15 #include "chrome/browser/sync/personalization.h" | 13 #include "chrome/browser/sync/personalization.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 was_show_html_dialog_called_(false) { | 98 was_show_html_dialog_called_(false) { |
| 101 } | 99 } |
| 102 | 100 |
| 103 virtual ~TestBrowserWindowForWizardTest() { | 101 virtual ~TestBrowserWindowForWizardTest() { |
| 104 if (flow_.get()) { | 102 if (flow_.get()) { |
| 105 // In real life, the handlers are destroyed by the DOMUI infrastructure, | 103 // In real life, the handlers are destroyed by the DOMUI infrastructure, |
| 106 // which calls GetDOMMessageHandlers to take ownership. This does not | 104 // which calls GetDOMMessageHandlers to take ownership. This does not |
| 107 // exist in our test, so we perform cleanup manually. | 105 // exist in our test, so we perform cleanup manually. |
| 108 std::vector<DOMMessageHandler*> handlers; | 106 std::vector<DOMMessageHandler*> handlers; |
| 109 flow_->GetDOMMessageHandlers(&handlers); | 107 flow_->GetDOMMessageHandlers(&handlers); |
| 108 // The handler contract is that they are valid for the lifetime of the |
| 109 // HTMLDialogUIDelegate, but are cleaned up after the dialog is closed |
| 110 // and/or deleted. |
| 111 flow_.reset(); |
| 110 STLDeleteElements(&handlers); | 112 STLDeleteElements(&handlers); |
| 111 } | 113 } |
| 112 } | 114 } |
| 113 | 115 |
| 114 // We intercept this call to hijack the flow created and then use it to | 116 // We intercept this call to hijack the flow created and then use it to |
| 115 // drive the wizard as if we were the HTML page. | 117 // drive the wizard as if we were the HTML page. |
| 116 virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, | 118 virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, |
| 117 gfx::NativeWindow parent_window) { | 119 gfx::NativeWindow parent_window) { |
| 118 flow_.reset(static_cast<SyncSetupFlow*>(delegate)); | 120 flow_.reset(static_cast<SyncSetupFlow*>(delegate)); |
| 119 was_show_html_dialog_called_ = true; | 121 was_show_html_dialog_called_ = true; |
| 120 } | 122 } |
| 121 | 123 |
| 122 bool TestAndResetWasShowHTMLDialogCalled() { | 124 bool TestAndResetWasShowHTMLDialogCalled() { |
| 123 bool ret = was_show_html_dialog_called_; | 125 bool ret = was_show_html_dialog_called_; |
| 124 was_show_html_dialog_called_ = false; | 126 was_show_html_dialog_called_ = false; |
| 125 return ret; | 127 return ret; |
| 126 } | 128 } |
| 127 | 129 |
| 130 // Simulates the user (or browser view hierarchy) closing the html dialog. |
| 131 // Handles cleaning up the delegate and associated handlers. |
| 132 void CloseDialog() { |
| 133 if (flow_.get()) { |
| 134 std::vector<DOMMessageHandler*> handlers; |
| 135 flow_->GetDOMMessageHandlers(&handlers); |
| 136 // The flow deletes itself here. Don't use reset(). |
| 137 flow_.release()->OnDialogClosed(""); |
| 138 STLDeleteElements(&handlers); |
| 139 } |
| 140 } |
| 141 |
| 142 SyncSetupFlow* flow() { return flow_.get(); } |
| 143 |
| 144 private: |
| 128 // In real life, this is owned by the view that is opened by the browser. We | 145 // In real life, this is owned by the view that is opened by the browser. We |
| 129 // mock all that out, so we need to take ownership so the flow doesn't leak. | 146 // mock all that out, so we need to take ownership so the flow doesn't leak. |
| 130 scoped_ptr<SyncSetupFlow> flow_; | 147 scoped_ptr<SyncSetupFlow> flow_; |
| 131 private: | 148 |
| 132 bool was_show_html_dialog_called_; | 149 bool was_show_html_dialog_called_; |
| 133 }; | 150 }; |
| 134 | 151 |
| 135 class SyncSetupWizardTest : public BrowserWithTestWindowTest { | 152 class SyncSetupWizardTest : public BrowserWithTestWindowTest { |
| 136 public: | 153 public: |
| 137 SyncSetupWizardTest() : test_window_(NULL), wizard_(NULL) { } | 154 SyncSetupWizardTest() : test_window_(NULL), wizard_(NULL) { } |
| 138 virtual ~SyncSetupWizardTest() { } | 155 virtual ~SyncSetupWizardTest() { } |
| 139 virtual void SetUp() { | 156 virtual void SetUp() { |
| 140 set_profile(new TestingProfileWithPersonalization()); | 157 set_profile(new TestingProfileWithPersonalization()); |
| 141 profile()->CreateBookmarkModel(false); | 158 profile()->CreateBookmarkModel(false); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 169 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); | 186 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); |
| 170 std::string json_start_args; | 187 std::string json_start_args; |
| 171 JSONWriter::Write(&dialog_args, false, &json_start_args); | 188 JSONWriter::Write(&dialog_args, false, &json_start_args); |
| 172 ListValue credentials; | 189 ListValue credentials; |
| 173 std::string auth = "{\"user\":\""; | 190 std::string auth = "{\"user\":\""; |
| 174 auth += std::string(kTestUser) + "\",\"pass\":\""; | 191 auth += std::string(kTestUser) + "\",\"pass\":\""; |
| 175 auth += std::string(kTestPassword) + "\"}"; | 192 auth += std::string(kTestPassword) + "\"}"; |
| 176 credentials.Append(new StringValue(auth)); | 193 credentials.Append(new StringValue(auth)); |
| 177 | 194 |
| 178 EXPECT_FALSE(wizard_->IsVisible()); | 195 EXPECT_FALSE(wizard_->IsVisible()); |
| 179 EXPECT_FALSE(test_window_->flow_.get()); | 196 EXPECT_FALSE(test_window_->flow()); |
| 180 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); | 197 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); |
| 181 | 198 |
| 182 EXPECT_TRUE(wizard_->IsVisible()); | 199 EXPECT_TRUE(wizard_->IsVisible()); |
| 183 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 200 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
| 184 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow_->current_state_); | 201 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_); |
| 185 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow_->end_state_); | 202 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->end_state_); |
| 186 EXPECT_EQ(json_start_args, test_window_->flow_->dialog_start_args_); | 203 EXPECT_EQ(json_start_args, test_window_->flow()->dialog_start_args_); |
| 187 | 204 |
| 188 // Simulate the user submitting credentials. | 205 // Simulate the user submitting credentials. |
| 189 test_window_->flow_->flow_handler_->HandleSubmitAuth(&credentials); | 206 test_window_->flow()->flow_handler_->HandleSubmitAuth(&credentials); |
| 190 EXPECT_TRUE(wizard_->IsVisible()); | 207 EXPECT_TRUE(wizard_->IsVisible()); |
| 191 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow_->current_state_); | 208 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_); |
| 192 EXPECT_EQ(kTestUser, service_->username_); | 209 EXPECT_EQ(kTestUser, service_->username_); |
| 193 EXPECT_EQ(kTestPassword, service_->password_); | 210 EXPECT_EQ(kTestPassword, service_->password_); |
| 194 EXPECT_FALSE(service_->user_accepted_merge_and_sync_); | 211 EXPECT_FALSE(service_->user_accepted_merge_and_sync_); |
| 195 EXPECT_FALSE(service_->user_cancelled_dialog_); | 212 EXPECT_FALSE(service_->user_cancelled_dialog_); |
| 196 service_->ResetTestStats(); | 213 service_->ResetTestStats(); |
| 197 | 214 |
| 198 // Simulate failed credentials. | 215 // Simulate failed credentials. |
| 199 service_->set_auth_state(kTestUser, AUTH_ERROR_INVALID_GAIA_CREDENTIALS); | 216 service_->set_auth_state(kTestUser, AUTH_ERROR_INVALID_GAIA_CREDENTIALS); |
| 200 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); | 217 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); |
| 201 EXPECT_TRUE(wizard_->IsVisible()); | 218 EXPECT_TRUE(wizard_->IsVisible()); |
| 202 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 219 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
| 203 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow_->current_state_); | 220 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_); |
| 204 dialog_args.Clear(); | 221 dialog_args.Clear(); |
| 205 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); | 222 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); |
| 206 EXPECT_EQ(2, dialog_args.GetSize()); | 223 EXPECT_EQ(2, dialog_args.GetSize()); |
| 207 std::string actual_user; | 224 std::string actual_user; |
| 208 dialog_args.GetString(L"user", &actual_user); | 225 dialog_args.GetString(L"user", &actual_user); |
| 209 EXPECT_EQ(kTestUser, actual_user); | 226 EXPECT_EQ(kTestUser, actual_user); |
| 210 int error = -1; | 227 int error = -1; |
| 211 dialog_args.GetInteger(L"error", &error); | 228 dialog_args.GetInteger(L"error", &error); |
| 212 EXPECT_EQ(static_cast<int>(AUTH_ERROR_INVALID_GAIA_CREDENTIALS), error); | 229 EXPECT_EQ(static_cast<int>(AUTH_ERROR_INVALID_GAIA_CREDENTIALS), error); |
| 213 service_->set_auth_state(kTestUser, AUTH_ERROR_NONE); | 230 service_->set_auth_state(kTestUser, AUTH_ERROR_NONE); |
| 214 | 231 |
| 215 // Simulate success. | 232 // Simulate success. |
| 216 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); | 233 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); |
| 217 EXPECT_TRUE(wizard_->IsVisible()); | 234 EXPECT_TRUE(wizard_->IsVisible()); |
| 218 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 235 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
| 219 EXPECT_EQ(SyncSetupWizard::GAIA_SUCCESS, test_window_->flow_->current_state_); | 236 EXPECT_EQ(SyncSetupWizard::GAIA_SUCCESS, |
| 237 test_window_->flow()->current_state_); |
| 220 | 238 |
| 221 wizard_->Step(SyncSetupWizard::DONE); // No merge and sync. | 239 wizard_->Step(SyncSetupWizard::DONE); // No merge and sync. |
| 222 EXPECT_TRUE(wizard_->IsVisible()); | 240 EXPECT_TRUE(wizard_->IsVisible()); |
| 223 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 241 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
| 224 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow_->current_state_); | 242 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->current_state_); |
| 225 } | 243 } |
| 226 | 244 |
| 227 TEST_F(SyncSetupWizardTest, InitialStepMergeAndSync) { | 245 TEST_F(SyncSetupWizardTest, InitialStepMergeAndSync) { |
| 228 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); | 246 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); |
| 229 EXPECT_TRUE(wizard_->IsVisible()); | 247 EXPECT_TRUE(wizard_->IsVisible()); |
| 230 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 248 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
| 231 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow_->end_state_); | 249 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->end_state_); |
| 232 | 250 |
| 233 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); | 251 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); |
| 234 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); | 252 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); |
| 235 EXPECT_TRUE(wizard_->IsVisible()); | 253 EXPECT_TRUE(wizard_->IsVisible()); |
| 236 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 254 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
| 237 EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC, | 255 EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC, |
| 238 test_window_->flow_->current_state_); | 256 test_window_->flow()->current_state_); |
| 239 | 257 |
| 240 test_window_->flow_->flow_handler_->HandleSubmitMergeAndSync(NULL); | 258 test_window_->flow()->flow_handler_->HandleSubmitMergeAndSync(NULL); |
| 241 EXPECT_TRUE(wizard_->IsVisible()); | 259 EXPECT_TRUE(wizard_->IsVisible()); |
| 242 EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC, | 260 EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC, |
| 243 test_window_->flow_->current_state_); | 261 test_window_->flow()->current_state_); |
| 244 EXPECT_EQ(std::string(), service_->username_); | 262 EXPECT_EQ(std::string(), service_->username_); |
| 245 EXPECT_EQ(std::string(), service_->password_); | 263 EXPECT_EQ(std::string(), service_->password_); |
| 246 EXPECT_TRUE(service_->user_accepted_merge_and_sync_); | 264 EXPECT_TRUE(service_->user_accepted_merge_and_sync_); |
| 247 EXPECT_FALSE(service_->user_cancelled_dialog_); | 265 EXPECT_FALSE(service_->user_cancelled_dialog_); |
| 248 service_->ResetTestStats(); | 266 service_->ResetTestStats(); |
| 249 wizard_->Step(SyncSetupWizard::DONE); // No merge and sync. | 267 wizard_->Step(SyncSetupWizard::DONE); // No merge and sync. |
| 250 EXPECT_TRUE(wizard_->IsVisible()); | 268 EXPECT_TRUE(wizard_->IsVisible()); |
| 251 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 269 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
| 252 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow_->current_state_); | 270 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->current_state_); |
| 253 } | 271 } |
| 254 | 272 |
| 255 TEST_F(SyncSetupWizardTest, DialogCancelled) { | 273 TEST_F(SyncSetupWizardTest, DialogCancelled) { |
| 256 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); | 274 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); |
| 257 test_window_->flow_->OnDialogClosed(""); | 275 // Simulate the user closing the dialog. |
| 276 test_window_->CloseDialog(); |
| 258 EXPECT_FALSE(wizard_->IsVisible()); | 277 EXPECT_FALSE(wizard_->IsVisible()); |
| 259 EXPECT_TRUE(service_->user_cancelled_dialog_); | 278 EXPECT_TRUE(service_->user_cancelled_dialog_); |
| 260 EXPECT_EQ(std::string(), service_->username_); | 279 EXPECT_EQ(std::string(), service_->username_); |
| 261 EXPECT_EQ(std::string(), service_->password_); | 280 EXPECT_EQ(std::string(), service_->password_); |
| 262 EXPECT_FALSE(service_->user_accepted_merge_and_sync_); | 281 EXPECT_FALSE(service_->user_accepted_merge_and_sync_); |
| 263 | 282 |
| 264 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); | 283 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); |
| 265 EXPECT_TRUE(wizard_->IsVisible()); | 284 EXPECT_TRUE(wizard_->IsVisible()); |
| 266 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 285 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
| 267 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); | 286 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); |
| 268 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 287 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
| 269 | 288 |
| 270 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); | 289 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); |
| 271 test_window_->flow_->OnDialogClosed(""); | 290 test_window_->CloseDialog(); |
| 272 EXPECT_FALSE(wizard_->IsVisible()); | 291 EXPECT_FALSE(wizard_->IsVisible()); |
| 273 EXPECT_TRUE(service_->user_cancelled_dialog_); | 292 EXPECT_TRUE(service_->user_cancelled_dialog_); |
| 274 EXPECT_EQ(std::string(), service_->username_); | 293 EXPECT_EQ(std::string(), service_->username_); |
| 275 EXPECT_EQ(std::string(), service_->password_); | 294 EXPECT_EQ(std::string(), service_->password_); |
| 276 EXPECT_FALSE(service_->user_accepted_merge_and_sync_); | 295 EXPECT_FALSE(service_->user_accepted_merge_and_sync_); |
| 277 } | 296 } |
| 278 | 297 |
| 279 TEST_F(SyncSetupWizardTest, InvalidTransitions) { | 298 TEST_F(SyncSetupWizardTest, InvalidTransitions) { |
| 280 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); | 299 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); |
| 281 EXPECT_FALSE(wizard_->IsVisible()); | 300 EXPECT_FALSE(wizard_->IsVisible()); |
| 282 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 301 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
| 283 | 302 |
| 284 wizard_->Step(SyncSetupWizard::DONE); | 303 wizard_->Step(SyncSetupWizard::DONE); |
| 285 EXPECT_FALSE(wizard_->IsVisible()); | 304 EXPECT_FALSE(wizard_->IsVisible()); |
| 286 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 305 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
| 287 | 306 |
| 288 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); | 307 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); |
| 289 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); | 308 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); |
| 290 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow_->current_state_); | 309 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_); |
| 291 | 310 |
| 292 wizard_->Step(SyncSetupWizard::DONE); | 311 wizard_->Step(SyncSetupWizard::DONE); |
| 293 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow_->current_state_); | 312 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_); |
| 294 | 313 |
| 295 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); | 314 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); |
| 296 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); | 315 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); |
| 297 EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC, | 316 EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC, |
| 298 test_window_->flow_->current_state_); | 317 test_window_->flow()->current_state_); |
| 299 | 318 |
| 300 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); | 319 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); |
| 301 EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC, | 320 EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC, |
| 302 test_window_->flow_->current_state_); | 321 test_window_->flow()->current_state_); |
| 303 } | 322 } |
| 304 | 323 |
| 305 TEST_F(SyncSetupWizardTest, FullSuccessfulRunSetsPref) { | 324 TEST_F(SyncSetupWizardTest, FullSuccessfulRunSetsPref) { |
| 306 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); | 325 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); |
| 307 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); | 326 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); |
| 308 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); | 327 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); |
| 309 wizard_->Step(SyncSetupWizard::DONE); | 328 wizard_->Step(SyncSetupWizard::DONE); |
| 310 test_window_->flow_->OnDialogClosed(""); | 329 test_window_->CloseDialog(); |
| 311 EXPECT_FALSE(wizard_->IsVisible()); | 330 EXPECT_FALSE(wizard_->IsVisible()); |
| 312 EXPECT_TRUE(service_->profile()->GetPrefs()->GetBoolean( | 331 EXPECT_TRUE(service_->profile()->GetPrefs()->GetBoolean( |
| 313 prefs::kSyncHasSetupCompleted)); | 332 prefs::kSyncHasSetupCompleted)); |
| 314 } | 333 } |
| 315 | 334 |
| 316 TEST_F(SyncSetupWizardTest, DiscreteRun) { | 335 TEST_F(SyncSetupWizardTest, DiscreteRun) { |
| 317 DictionaryValue dialog_args; | 336 DictionaryValue dialog_args; |
| 318 // For a discrete run, we need to have ran through setup once. | 337 // For a discrete run, we need to have ran through setup once. |
| 319 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); | 338 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); |
| 320 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); | 339 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); |
| 321 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); | 340 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); |
| 322 wizard_->Step(SyncSetupWizard::DONE); | 341 wizard_->Step(SyncSetupWizard::DONE); |
| 323 test_window_->flow_->OnDialogClosed(""); | 342 test_window_->CloseDialog(); |
| 324 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 343 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
| 325 | 344 |
| 326 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); | 345 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); |
| 327 EXPECT_EQ(SyncSetupWizard::GAIA_SUCCESS, test_window_->flow_->end_state_); | 346 EXPECT_EQ(SyncSetupWizard::GAIA_SUCCESS, test_window_->flow()->end_state_); |
| 328 | 347 |
| 329 service_->set_auth_state(kTestUser, AUTH_ERROR_INVALID_GAIA_CREDENTIALS); | 348 service_->set_auth_state(kTestUser, AUTH_ERROR_INVALID_GAIA_CREDENTIALS); |
| 330 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); | 349 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); |
| 331 EXPECT_TRUE(wizard_->IsVisible()); | 350 EXPECT_TRUE(wizard_->IsVisible()); |
| 332 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); | 351 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); |
| 333 EXPECT_EQ(2, dialog_args.GetSize()); | 352 EXPECT_EQ(2, dialog_args.GetSize()); |
| 334 std::string actual_user; | 353 std::string actual_user; |
| 335 dialog_args.GetString(L"user", &actual_user); | 354 dialog_args.GetString(L"user", &actual_user); |
| 336 EXPECT_EQ(kTestUser, actual_user); | 355 EXPECT_EQ(kTestUser, actual_user); |
| 337 int error = -1; | 356 int error = -1; |
| 338 dialog_args.GetInteger(L"error", &error); | 357 dialog_args.GetInteger(L"error", &error); |
| 339 EXPECT_EQ(static_cast<int>(AUTH_ERROR_INVALID_GAIA_CREDENTIALS), error); | 358 EXPECT_EQ(static_cast<int>(AUTH_ERROR_INVALID_GAIA_CREDENTIALS), error); |
| 340 service_->set_auth_state(kTestUser, AUTH_ERROR_NONE); | 359 service_->set_auth_state(kTestUser, AUTH_ERROR_NONE); |
| 341 | 360 |
| 342 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); | 361 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); |
| 343 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 362 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
| 344 } | 363 } |
| 345 | 364 |
| 346 #endif // CHROME_PERSONALIZATION | 365 #endif // CHROME_PERSONALIZATION |
| 347 #endif | 366 |
| OLD | NEW |