| 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/sync/abstract_profile_sync_service_test.h" | 5 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 record.id = node_id; | 38 record.id = node_id; |
| 39 record.specifics = specifics; | 39 record.specifics = specifics; |
| 40 syncer::ChangeRecordList records(1, record); | 40 syncer::ChangeRecordList records(1, record); |
| 41 return syncer::ImmutableChangeRecordList(&records); | 41 return syncer::ImmutableChangeRecordList(&records); |
| 42 } | 42 } |
| 43 | 43 |
| 44 AbstractProfileSyncServiceTest::AbstractProfileSyncServiceTest() | 44 AbstractProfileSyncServiceTest::AbstractProfileSyncServiceTest() |
| 45 : thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD | | 45 : thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD | |
| 46 content::TestBrowserThreadBundle::REAL_FILE_THREAD | | 46 content::TestBrowserThreadBundle::REAL_FILE_THREAD | |
| 47 content::TestBrowserThreadBundle::REAL_IO_THREAD), | 47 content::TestBrowserThreadBundle::REAL_IO_THREAD), |
| 48 token_service_(NULL), | |
| 49 sync_service_(NULL) { | 48 sync_service_(NULL) { |
| 50 } | 49 } |
| 51 | 50 |
| 52 AbstractProfileSyncServiceTest::~AbstractProfileSyncServiceTest() {} | 51 AbstractProfileSyncServiceTest::~AbstractProfileSyncServiceTest() {} |
| 53 | 52 |
| 54 void AbstractProfileSyncServiceTest::SetUp() { | 53 void AbstractProfileSyncServiceTest::SetUp() { |
| 55 } | 54 } |
| 56 | 55 |
| 57 void AbstractProfileSyncServiceTest::TearDown() { | 56 void AbstractProfileSyncServiceTest::TearDown() { |
| 58 // Pump messages posted by the sync core thread (which may end up | 57 // Pump messages posted by the sync core thread (which may end up |
| 59 // posting on the IO thread). | 58 // posting on the IO thread). |
| 60 base::RunLoop().RunUntilIdle(); | 59 base::RunLoop().RunUntilIdle(); |
| 61 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); | 60 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); |
| 62 base::RunLoop().RunUntilIdle(); | 61 base::RunLoop().RunUntilIdle(); |
| 63 } | 62 } |
| 64 | 63 |
| 65 bool AbstractProfileSyncServiceTest::CreateRoot(ModelType model_type) { | 64 bool AbstractProfileSyncServiceTest::CreateRoot(ModelType model_type) { |
| 66 return syncer::TestUserShare::CreateRoot(model_type, | 65 return syncer::TestUserShare::CreateRoot(model_type, |
| 67 sync_service_->GetUserShare()); | 66 sync_service_->GetUserShare()); |
| 68 } | 67 } |
| 69 | 68 |
| 70 // static | |
| 71 BrowserContextKeyedService* AbstractProfileSyncServiceTest::BuildTokenService( | |
| 72 content::BrowserContext* profile) { | |
| 73 return new TokenService; | |
| 74 } | |
| 75 | |
| 76 CreateRootHelper::CreateRootHelper(AbstractProfileSyncServiceTest* test, | 69 CreateRootHelper::CreateRootHelper(AbstractProfileSyncServiceTest* test, |
| 77 ModelType model_type) | 70 ModelType model_type) |
| 78 : callback_(base::Bind(&CreateRootHelper::CreateRootCallback, | 71 : callback_(base::Bind(&CreateRootHelper::CreateRootCallback, |
| 79 base::Unretained(this))), | 72 base::Unretained(this))), |
| 80 test_(test), | 73 test_(test), |
| 81 model_type_(model_type), | 74 model_type_(model_type), |
| 82 success_(false) { | 75 success_(false) { |
| 83 } | 76 } |
| 84 | 77 |
| 85 CreateRootHelper::~CreateRootHelper() { | 78 CreateRootHelper::~CreateRootHelper() { |
| 86 } | 79 } |
| 87 | 80 |
| 88 const base::Closure& CreateRootHelper::callback() const { | 81 const base::Closure& CreateRootHelper::callback() const { |
| 89 return callback_; | 82 return callback_; |
| 90 } | 83 } |
| 91 | 84 |
| 92 bool CreateRootHelper::success() { | 85 bool CreateRootHelper::success() { |
| 93 return success_; | 86 return success_; |
| 94 } | 87 } |
| 95 | 88 |
| 96 void CreateRootHelper::CreateRootCallback() { | 89 void CreateRootHelper::CreateRootCallback() { |
| 97 success_ = test_->CreateRoot(model_type_); | 90 success_ = test_->CreateRoot(model_type_); |
| 98 } | 91 } |
| OLD | NEW |