| 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "chrome/browser/browser.h" | 6 #include "chrome/browser/browser.h" |
| 7 #include "chrome/browser/pref_service.h" | 7 #include "chrome/browser/pref_service.h" |
| 8 #include "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
| 9 #include "chrome/browser/sync/glue/sync_backend_host.h" | 9 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 10 #include "chrome/browser/sync/sessions/session_state.h" | 10 #include "chrome/browser/sync/sessions/session_state.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 NewRunnableMethod(timeout_signal.get(), | 252 NewRunnableMethod(timeout_signal.get(), |
| 253 &StateChangeTimeoutEvent::Callback), | 253 &StateChangeTimeoutEvent::Callback), |
| 254 1000 * timeout_seconds); | 254 1000 * timeout_seconds); |
| 255 ui_test_utils::RunMessageLoop(); | 255 ui_test_utils::RunMessageLoop(); |
| 256 return timeout_signal->Abort(); | 256 return timeout_signal->Abort(); |
| 257 } | 257 } |
| 258 | 258 |
| 259 bool ProfileSyncServiceTestHarness::WaitForServiceInit() { | 259 bool ProfileSyncServiceTestHarness::WaitForServiceInit() { |
| 260 // Wait for the OnAuthError() callback. | 260 // Wait for the OnAuthError() callback. |
| 261 EXPECT_EQ(wait_state_, WAITING_FOR_ON_AUTH_ERROR); | 261 EXPECT_EQ(wait_state_, WAITING_FOR_ON_AUTH_ERROR); |
| 262 if (!AwaitStatusChangeWithTimeout(30, | 262 EXPECT_TRUE(AwaitStatusChangeWithTimeout(30, |
| 263 "Waiting for the OnAuthError() callback.")) { | 263 "Waiting for the OnAuthError() callback.")) << |
| 264 return false; | 264 "OnAuthError() not seen after 30 seconds."; |
| 265 } | |
| 266 | 265 |
| 267 // Enter GAIA credentials and wait for the OnBackendInitialized() callback. | 266 // Enter GAIA credentials and wait for the OnBackendInitialized() callback. |
| 268 service_->backend()->Authenticate(username_, password_, std::string()); | 267 service_->backend()->Authenticate(username_, password_, std::string()); |
| 269 EXPECT_EQ(wait_state_, WAITING_FOR_ON_BACKEND_INITIALIZED); | 268 EXPECT_EQ(wait_state_, WAITING_FOR_ON_BACKEND_INITIALIZED); |
| 270 if (!AwaitStatusChangeWithTimeout(30, | 269 EXPECT_TRUE(AwaitStatusChangeWithTimeout(30, |
| 271 "Waiting for OnBackendInitialized().")) { | 270 "Waiting for OnBackendInitialized().")) << |
| 272 return false; | 271 "OnBackendInitialized() not seen after 30 seconds."; |
| 273 } | |
| 274 | 272 |
| 275 // Choose datatypes to be synced and wait for notifications_enabled to be set | 273 // Choose datatypes to be synced and wait for notifications_enabled to be set |
| 276 // to true. | 274 // to true. |
| 277 syncable::ModelTypeSet set; | 275 syncable::ModelTypeSet set; |
| 278 for (int i = syncable::FIRST_REAL_MODEL_TYPE; | 276 for (int i = syncable::FIRST_REAL_MODEL_TYPE; |
| 279 i < syncable::MODEL_TYPE_COUNT; ++i) { | 277 i < syncable::MODEL_TYPE_COUNT; ++i) { |
| 280 set.insert(syncable::ModelTypeFromInt(i)); | 278 set.insert(syncable::ModelTypeFromInt(i)); |
| 281 } | 279 } |
| 282 service_->OnUserChoseDatatypes(true, set); | 280 service_->OnUserChoseDatatypes(true, set); |
| 283 EXPECT_EQ(wait_state_, WAITING_FOR_NOTIFICATIONS_ENABLED); | 281 EXPECT_EQ(wait_state_, WAITING_FOR_NOTIFICATIONS_ENABLED); |
| 284 if (!AwaitStatusChangeWithTimeout(30, | 282 EXPECT_TRUE(AwaitStatusChangeWithTimeout(30, |
| 285 "Waiting for notifications_enabled to be set to true.")) { | 283 "Waiting for notifications_enabled to be set to true.")) << |
| 286 return false; | 284 "notifications_enabled not set to true after 30 seconds."; |
| 287 } | |
| 288 | 285 |
| 289 return true; | 286 return true; |
| 290 } | 287 } |
| 291 | 288 |
| 292 const SyncSessionSnapshot* | 289 const SyncSessionSnapshot* |
| 293 ProfileSyncServiceTestHarness::GetLastSessionSnapshot() const { | 290 ProfileSyncServiceTestHarness::GetLastSessionSnapshot() const { |
| 294 EXPECT_FALSE(service_ == NULL) << "Sync service has not yet been set up."; | 291 EXPECT_FALSE(service_ == NULL) << "Sync service has not yet been set up."; |
| 295 return service_->backend()->GetLastSessionSnapshot(); | 292 return service_->backend()->GetLastSessionSnapshot(); |
| 296 } | 293 } |
| OLD | NEW |