OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
10 #include "chrome/browser/sync/test/integration/migration_waiter.h" | 10 #include "chrome/browser/sync/test/integration/migration_waiter.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 MigrationList MakeList(syncer::ModelType type) { | 60 MigrationList MakeList(syncer::ModelType type) { |
61 return MakeList(MakeSet(type)); | 61 return MakeList(MakeSet(type)); |
62 } | 62 } |
63 | 63 |
64 MigrationList MakeList(syncer::ModelType type1, | 64 MigrationList MakeList(syncer::ModelType type1, |
65 syncer::ModelType type2) { | 65 syncer::ModelType type2) { |
66 return MakeList(MakeSet(type1), MakeSet(type2)); | 66 return MakeList(MakeSet(type1), MakeSet(type2)); |
67 } | 67 } |
68 | 68 |
69 | |
70 class MigrationTest : public SyncTest { | 69 class MigrationTest : public SyncTest { |
71 public: | 70 public: |
72 explicit MigrationTest(TestType test_type) : SyncTest(test_type) {} | 71 explicit MigrationTest(TestType test_type) : SyncTest(test_type) {} |
73 ~MigrationTest() override {} | 72 ~MigrationTest() override {} |
74 | 73 |
75 enum TriggerMethod { MODIFY_PREF, MODIFY_BOOKMARK, TRIGGER_NOTIFICATION }; | 74 enum TriggerMethod { MODIFY_PREF, MODIFY_BOOKMARK, TRIGGER_NOTIFICATION }; |
76 | 75 |
77 // Set up sync for all profiles and initialize all MigrationWatchers. This | 76 // Set up sync for all profiles and initialize all MigrationWatchers. This |
78 // helps ensure that all migration events are captured, even if they were to | 77 // helps ensure that all migration events are captured, even if they were to |
79 // occur before a test calls AwaitMigration for a specific profile. | 78 // occur before a test calls AwaitMigration for a specific profile. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 break; | 152 break; |
154 default: | 153 default: |
155 ADD_FAILURE(); | 154 ADD_FAILURE(); |
156 } | 155 } |
157 } | 156 } |
158 | 157 |
159 // Block until all clients have completed migration for the given | 158 // Block until all clients have completed migration for the given |
160 // types. | 159 // types. |
161 void AwaitMigration(syncer::ModelTypeSet migrate_types) { | 160 void AwaitMigration(syncer::ModelTypeSet migrate_types) { |
162 for (int i = 0; i < num_clients(); ++i) { | 161 for (int i = 0; i < num_clients(); ++i) { |
163 MigrationWaiter waiter(migrate_types, migration_watchers_[i]); | 162 ASSERT_TRUE( |
164 waiter.Wait(); | 163 MigrationWaiter(migrate_types, migration_watchers_[i]).Wait()); |
165 ASSERT_FALSE(waiter.TimedOut()); | |
166 } | 164 } |
167 } | 165 } |
168 | 166 |
169 // Makes sure migration works with the given migration list and | 167 // Makes sure migration works with the given migration list and |
170 // trigger method. | 168 // trigger method. |
171 void RunMigrationTest(const MigrationList& migration_list, | 169 void RunMigrationTest(const MigrationList& migration_list, |
172 TriggerMethod trigger_method) { | 170 TriggerMethod trigger_method) { |
173 // If we have only one client, turn off notifications to avoid the | 171 // If we have only one client, turn off notifications to avoid the |
174 // possibility of spurious sync cycles. | 172 // possibility of spurious sync cycles. |
175 bool do_test_without_notifications = | 173 bool do_test_without_notifications = |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 // Do not add optional datatypes. | 425 // Do not add optional datatypes. |
428 } | 426 } |
429 | 427 |
430 ~MigrationReconfigureTest() override {} | 428 ~MigrationReconfigureTest() override {} |
431 | 429 |
432 private: | 430 private: |
433 DISALLOW_COPY_AND_ASSIGN(MigrationReconfigureTest); | 431 DISALLOW_COPY_AND_ASSIGN(MigrationReconfigureTest); |
434 }; | 432 }; |
435 | 433 |
436 } // namespace | 434 } // namespace |
OLD | NEW |