OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // TODO(akalin): Rename this file to migration_test.cc. | 5 // TODO(akalin): Rename this file to migration_test.cc. |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 8 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/sync/profile_sync_service_harness.h" | 10 #include "chrome/browser/sync/profile_sync_service_harness.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 class MigrationTest : public SyncTest { | 67 class MigrationTest : public SyncTest { |
68 public: | 68 public: |
69 explicit MigrationTest(TestType test_type) : SyncTest(test_type) {} | 69 explicit MigrationTest(TestType test_type) : SyncTest(test_type) {} |
70 virtual ~MigrationTest() {} | 70 virtual ~MigrationTest() {} |
71 | 71 |
72 // TODO(akalin): Add more MODIFY_(data type) trigger methods, as | 72 // TODO(akalin): Add more MODIFY_(data type) trigger methods, as |
73 // well as a poll-based trigger method. | 73 // well as a poll-based trigger method. |
74 enum TriggerMethod { MODIFY_PREF, MODIFY_BOOKMARK, TRIGGER_NOTIFICATION }; | 74 enum TriggerMethod { MODIFY_PREF, MODIFY_BOOKMARK, TRIGGER_NOTIFICATION }; |
75 | 75 |
76 syncable::ModelEnumSet GetPreferredDataTypes() { | 76 syncable::ModelEnumSet GetPreferredDataTypes() { |
77 syncable::ModelTypeSet preferred_data_types; | 77 const syncable::ModelEnumSet preferred_data_types = |
78 GetClient(0)->service()->GetPreferredDataTypes(&preferred_data_types); | 78 GetClient(0)->service()->GetPreferredDataTypes(); |
79 // Make sure all clients have the same preferred data types. | 79 // Make sure all clients have the same preferred data types. |
80 for (int i = 1; i < num_clients(); ++i) { | 80 for (int i = 1; i < num_clients(); ++i) { |
81 syncable::ModelTypeSet other_preferred_data_types; | 81 const syncable::ModelEnumSet other_preferred_data_types = |
82 GetClient(i)->service()->GetPreferredDataTypes( | 82 GetClient(i)->service()->GetPreferredDataTypes(); |
83 &other_preferred_data_types); | 83 EXPECT_TRUE(preferred_data_types.Equals(other_preferred_data_types)); |
84 EXPECT_EQ(preferred_data_types, other_preferred_data_types); | |
85 } | 84 } |
86 return syncable::ModelTypeSetToEnumSet(preferred_data_types); | 85 return preferred_data_types; |
87 } | 86 } |
88 | 87 |
89 // Returns a MigrationList with every enabled data type in its own | 88 // Returns a MigrationList with every enabled data type in its own |
90 // set. | 89 // set. |
91 MigrationList GetPreferredDataTypesList() { | 90 MigrationList GetPreferredDataTypesList() { |
92 MigrationList migration_list; | 91 MigrationList migration_list; |
93 const syncable::ModelEnumSet preferred_data_types = | 92 const syncable::ModelEnumSet preferred_data_types = |
94 GetPreferredDataTypes(); | 93 GetPreferredDataTypes(); |
95 for (syncable::ModelEnumSet::Iterator it = | 94 for (syncable::ModelEnumSet::Iterator it = |
96 preferred_data_types.First(); it.Good(); it.Inc()) { | 95 preferred_data_types.First(); it.Good(); it.Inc()) { |
(...skipping 22 matching lines...) Expand all Loading... |
119 TriggerNotification(model_types); | 118 TriggerNotification(model_types); |
120 break; | 119 break; |
121 default: | 120 default: |
122 ADD_FAILURE(); | 121 ADD_FAILURE(); |
123 } | 122 } |
124 } | 123 } |
125 | 124 |
126 // Block until all clients have completed migration for the given | 125 // Block until all clients have completed migration for the given |
127 // types. | 126 // types. |
128 void AwaitMigration(syncable::ModelEnumSet migrate_types) { | 127 void AwaitMigration(syncable::ModelEnumSet migrate_types) { |
129 const syncable::ModelTypeSet& migrate_types_set = | |
130 syncable::ModelEnumSetToSet(migrate_types); | |
131 for (int i = 0; i < num_clients(); ++i) { | 128 for (int i = 0; i < num_clients(); ++i) { |
132 ASSERT_TRUE(GetClient(i)->AwaitMigration(migrate_types_set)); | 129 ASSERT_TRUE(GetClient(i)->AwaitMigration(migrate_types)); |
133 } | 130 } |
134 } | 131 } |
135 | 132 |
136 bool ShouldRunMigrationTest() const { | 133 bool ShouldRunMigrationTest() const { |
137 if (!ServerSupportsNotificationControl() || | 134 if (!ServerSupportsNotificationControl() || |
138 !ServerSupportsErrorTriggering()) { | 135 !ServerSupportsErrorTriggering()) { |
139 LOG(WARNING) << "Test skipped in this server environment."; | 136 LOG(WARNING) << "Test skipped in this server environment."; |
140 return false; | 137 return false; |
141 } | 138 } |
142 return true; | 139 return true; |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 | 441 |
445 // Phase 5: Verify that preferences can still be synchronized. | 442 // Phase 5: Verify that preferences can still be synchronized. |
446 VerifyPrefSync(); | 443 VerifyPrefSync(); |
447 | 444 |
448 // Phase 6: Verify that sessions are registered and enabled. | 445 // Phase 6: Verify that sessions are registered and enabled. |
449 ASSERT_TRUE(GetClient(0)->IsTypeRunning(syncable::SESSIONS)); | 446 ASSERT_TRUE(GetClient(0)->IsTypeRunning(syncable::SESSIONS)); |
450 ASSERT_TRUE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); | 447 ASSERT_TRUE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); |
451 } | 448 } |
452 | 449 |
453 } // namespace | 450 } // namespace |
OLD | NEW |