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 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 5 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
6 #include "chrome/browser/profiles/profile.h" | 6 #include "chrome/browser/profiles/profile.h" |
7 #include "chrome/browser/sync/profile_sync_service_harness.h" | 7 #include "chrome/browser/sync/profile_sync_service_harness.h" |
8 #include "chrome/browser/translate/translate_prefs.h" | 8 #include "chrome/browser/translate/translate_prefs.h" |
9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
| 11 #include "chrome/test/live_sync/bookmarks_helper.h" |
11 #include "chrome/test/live_sync/live_sync_test.h" | 12 #include "chrome/test/live_sync/live_sync_test.h" |
12 #include "chrome/test/live_sync/bookmarks_helper.h" | |
13 #include "chrome/test/live_sync/preferences_helper.h" | 13 #include "chrome/test/live_sync/preferences_helper.h" |
14 | 14 |
15 using bookmarks_helper::AddURL; | 15 using bookmarks_helper::AddURL; |
16 using bookmarks_helper::IndexedURL; | 16 using bookmarks_helper::IndexedURL; |
17 using bookmarks_helper::IndexedURLTitle; | 17 using bookmarks_helper::IndexedURLTitle; |
18 | 18 |
19 using preferences_helper::BooleanPrefMatches; | 19 using preferences_helper::BooleanPrefMatches; |
20 using preferences_helper::ChangeBooleanPref; | 20 using preferences_helper::ChangeBooleanPref; |
21 | 21 |
22 // Tests to make sure that the migration cycle works properly, | 22 // Tests to make sure that the migration cycle works properly, |
23 // i.e. doesn't stall. | 23 // i.e. doesn't stall. |
24 | 24 |
25 class MigrationCycleTest : public LiveSyncTest { | 25 class MigrationCycleTest : public LiveSyncTest { |
26 public: | 26 public: |
27 MigrationCycleTest() : LiveSyncTest(SINGLE_CLIENT) {} | 27 MigrationCycleTest() : LiveSyncTest(SINGLE_CLIENT) {} |
28 virtual ~MigrationCycleTest() {} | 28 virtual ~MigrationCycleTest() {} |
29 | 29 |
30 private: | 30 private: |
31 DISALLOW_COPY_AND_ASSIGN(MigrationCycleTest); | 31 DISALLOW_COPY_AND_ASSIGN(MigrationCycleTest); |
32 }; | 32 }; |
33 | 33 |
34 IN_PROC_BROWSER_TEST_F(MigrationCycleTest, PrefsOnly) { | 34 IN_PROC_BROWSER_TEST_F(MigrationCycleTest, PrefsOnly) { |
35 if (!ServerSupportsErrorTriggering()) { | 35 if (!ServerSupportsNotificationControl() || |
| 36 !ServerSupportsErrorTriggering()) { |
36 LOG(WARNING) << "Test skipped in this server environment."; | 37 LOG(WARNING) << "Test skipped in this server environment."; |
37 return; | 38 return; |
38 } | 39 } |
39 | 40 |
| 41 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 42 |
40 DisableNotifications(); | 43 DisableNotifications(); |
41 | 44 |
42 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
43 | |
44 // Phase 1: Trigger a preference migration on the server. | 45 // Phase 1: Trigger a preference migration on the server. |
45 syncable::ModelTypeSet migrate_types; | 46 syncable::ModelTypeSet migrate_types; |
46 migrate_types.insert(syncable::PREFERENCES); | 47 migrate_types.insert(syncable::PREFERENCES); |
47 TriggerMigrationDoneError(migrate_types); | 48 TriggerMigrationDoneError(migrate_types); |
48 | 49 |
49 // Phase 2: Modify a pref (to trigger migration) and wait for a sync | 50 // Phase 2: Modify a pref (to trigger migration) and wait for a sync |
50 // cycle. | 51 // cycle. |
51 // TODO(akalin): Shouldn't need to wait for full sync cycle; see | 52 // TODO(akalin): Shouldn't need to wait for full sync cycle; see |
52 // 93167. | 53 // 93167. |
53 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); | 54 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); |
54 ChangeBooleanPref(0, prefs::kShowHomeButton); | 55 ChangeBooleanPref(0, prefs::kShowHomeButton); |
55 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Migration")); | 56 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Migration")); |
56 } | 57 } |
57 | 58 |
58 // TODO(akalin): Fails (times out) due to http://crbug.com/92928. | 59 // TODO(akalin): Fails (times out) due to http://crbug.com/92928. |
| 60 IN_PROC_BROWSER_TEST_F(MigrationCycleTest, |
| 61 DISABLED_PrefsOnlyTriggerNotification) { |
| 62 if (!ServerSupportsNotificationControl() || |
| 63 !ServerSupportsErrorTriggering()) { |
| 64 LOG(WARNING) << "Test skipped in this server environment."; |
| 65 return; |
| 66 } |
| 67 |
| 68 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 69 |
| 70 // Phase 1: Trigger a preference migration on the server. |
| 71 syncable::ModelTypeSet migrate_types; |
| 72 migrate_types.insert(syncable::PREFERENCES); |
| 73 TriggerMigrationDoneError(migrate_types); |
| 74 |
| 75 // Phase 2: Synthesize a notification (to trigger migration) and |
| 76 // wait for a sync cycle. |
| 77 // TODO(akalin): Shouldn't need to wait for full sync cycle; see |
| 78 // 93167. |
| 79 TriggerNotification(migrate_types); |
| 80 ASSERT_TRUE(GetClient(0)->AwaitNextSyncCycleCompletion("Migration")); |
| 81 } |
| 82 |
| 83 // TODO(akalin): Fails (times out) due to http://crbug.com/92928. |
59 IN_PROC_BROWSER_TEST_F(MigrationCycleTest, DISABLED_PrefsNigori) { | 84 IN_PROC_BROWSER_TEST_F(MigrationCycleTest, DISABLED_PrefsNigori) { |
60 if (!ServerSupportsErrorTriggering()) { | 85 if (!ServerSupportsNotificationControl() || |
| 86 !ServerSupportsErrorTriggering()) { |
61 LOG(WARNING) << "Test skipped in this server environment."; | 87 LOG(WARNING) << "Test skipped in this server environment."; |
62 return; | 88 return; |
63 } | 89 } |
64 | 90 |
| 91 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 92 |
65 DisableNotifications(); | 93 DisableNotifications(); |
66 | 94 |
67 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
68 | |
69 // Phase 1: Trigger a preference and nigori migration on the server. | 95 // Phase 1: Trigger a preference and nigori migration on the server. |
70 { | 96 { |
71 syncable::ModelTypeSet migrate_types; | 97 syncable::ModelTypeSet migrate_types; |
72 migrate_types.insert(syncable::PREFERENCES); | 98 migrate_types.insert(syncable::PREFERENCES); |
73 TriggerMigrationDoneError(migrate_types); | 99 TriggerMigrationDoneError(migrate_types); |
74 } | 100 } |
75 { | 101 { |
76 syncable::ModelTypeSet migrate_types; | 102 syncable::ModelTypeSet migrate_types; |
77 migrate_types.insert(syncable::NIGORI); | 103 migrate_types.insert(syncable::NIGORI); |
78 TriggerMigrationDoneError(migrate_types); | 104 TriggerMigrationDoneError(migrate_types); |
79 } | 105 } |
80 | 106 |
81 // Phase 2: Modify a pref (to trigger migration) and wait for a sync | 107 // Phase 2: Modify a pref (to trigger migration) and wait for a sync |
82 // cycle. | 108 // cycle. |
83 // TODO(akalin): Shouldn't need to wait for full sync cycle; see | 109 // TODO(akalin): Shouldn't need to wait for full sync cycle; see |
84 // 93167. | 110 // 93167. |
85 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); | 111 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); |
86 ChangeBooleanPref(0, prefs::kShowHomeButton); | 112 ChangeBooleanPref(0, prefs::kShowHomeButton); |
87 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Migration")); | 113 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Migration")); |
88 } | 114 } |
89 | 115 |
90 // TODO(akalin): Fails (times out) due to http://crbug.com/92928. | 116 // TODO(akalin): Fails (times out) due to http://crbug.com/92928. |
91 IN_PROC_BROWSER_TEST_F(MigrationCycleTest, DISABLED_BookmarksPrefs) { | 117 IN_PROC_BROWSER_TEST_F(MigrationCycleTest, DISABLED_BookmarksPrefs) { |
92 if (!ServerSupportsErrorTriggering()) { | 118 if (!ServerSupportsNotificationControl() || |
| 119 !ServerSupportsErrorTriggering()) { |
93 LOG(WARNING) << "Test skipped in this server environment."; | 120 LOG(WARNING) << "Test skipped in this server environment."; |
94 return; | 121 return; |
95 } | 122 } |
96 | 123 |
| 124 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 125 |
97 DisableNotifications(); | 126 DisableNotifications(); |
98 | 127 |
99 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
100 | |
101 // Phase 1: Trigger a bookmark and preference migration on the | 128 // Phase 1: Trigger a bookmark and preference migration on the |
102 // server. | 129 // server. |
103 { | 130 { |
104 syncable::ModelTypeSet migrate_types; | 131 syncable::ModelTypeSet migrate_types; |
105 migrate_types.insert(syncable::BOOKMARKS); | 132 migrate_types.insert(syncable::BOOKMARKS); |
106 TriggerMigrationDoneError(migrate_types); | 133 TriggerMigrationDoneError(migrate_types); |
107 } | 134 } |
108 { | 135 { |
109 syncable::ModelTypeSet migrate_types; | 136 syncable::ModelTypeSet migrate_types; |
110 migrate_types.insert(syncable::PREFERENCES); | 137 migrate_types.insert(syncable::PREFERENCES); |
111 TriggerMigrationDoneError(migrate_types); | 138 TriggerMigrationDoneError(migrate_types); |
112 } | 139 } |
113 | 140 |
114 // Phase 2: Modify a bookmark (to trigger migration) and wait for a | 141 // Phase 2: Modify a bookmark (to trigger migration) and wait for a |
115 // sync cycle. | 142 // sync cycle. |
116 // TODO(akalin): Shouldn't need to wait for full sync cycle; see | 143 // TODO(akalin): Shouldn't need to wait for full sync cycle; see |
117 // 93167. | 144 // 93167. |
118 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); | 145 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); |
119 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Migration")); | 146 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Migration")); |
120 } | 147 } |
121 | 148 |
122 // TODO(akalin): Add tests where the migration trigger is a poll or a | 149 // TODO(akalin): Add tests where the migration trigger is a poll. |
123 // nudge from notifications. | |
124 | 150 |
125 class MigrationErrorsTest : public LiveSyncTest { | 151 class MigrationErrorsTest : public LiveSyncTest { |
126 public: | 152 public: |
127 MigrationErrorsTest() : LiveSyncTest(TWO_CLIENT) {} | 153 MigrationErrorsTest() : LiveSyncTest(TWO_CLIENT) {} |
128 virtual ~MigrationErrorsTest() {} | 154 virtual ~MigrationErrorsTest() {} |
129 | 155 |
130 private: | 156 private: |
131 DISALLOW_COPY_AND_ASSIGN(MigrationErrorsTest); | 157 DISALLOW_COPY_AND_ASSIGN(MigrationErrorsTest); |
132 }; | 158 }; |
133 | 159 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 // Phase 5: Verify that preferences can still be synchronized. | 395 // Phase 5: Verify that preferences can still be synchronized. |
370 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); | 396 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); |
371 ChangeBooleanPref(0, prefs::kShowHomeButton); | 397 ChangeBooleanPref(0, prefs::kShowHomeButton); |
372 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 398 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
373 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); | 399 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); |
374 | 400 |
375 // Phase 6: Verify that sessions are registered and enabled. | 401 // Phase 6: Verify that sessions are registered and enabled. |
376 ASSERT_TRUE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS)); | 402 ASSERT_TRUE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS)); |
377 ASSERT_TRUE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); | 403 ASSERT_TRUE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); |
378 } | 404 } |
OLD | NEW |