| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/basictypes.h" | |
| 6 #include "chrome/browser/sync/profile_sync_service_harness.h" | |
| 7 #include "chrome/test/live_sync/live_themes_sync_test.h" | |
| 8 | |
| 9 class TwoClientLiveThemesSyncTest : public LiveThemesSyncTest { | |
| 10 public: | |
| 11 TwoClientLiveThemesSyncTest() : LiveThemesSyncTest(TWO_CLIENT) {} | |
| 12 virtual ~TwoClientLiveThemesSyncTest() {} | |
| 13 | |
| 14 private: | |
| 15 DISALLOW_COPY_AND_ASSIGN(TwoClientLiveThemesSyncTest); | |
| 16 }; | |
| 17 | |
| 18 // TODO(akalin): Add tests for model association (i.e., tests that | |
| 19 // start with SetupClients(), change the theme state, then call | |
| 20 // SetupSync()). | |
| 21 | |
| 22 // TCM ID - 3667311. | |
| 23 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, CustomTheme) { | |
| 24 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 25 | |
| 26 ASSERT_FALSE(UsingCustomTheme(GetProfile(0))); | |
| 27 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 28 ASSERT_FALSE(UsingCustomTheme(verifier())); | |
| 29 | |
| 30 UseCustomTheme(GetProfile(0), 0); | |
| 31 UseCustomTheme(verifier(), 0); | |
| 32 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 33 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
| 34 | |
| 35 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
| 36 | |
| 37 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 38 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 39 // TODO(akalin): Add functions to simulate when a pending extension | |
| 40 // is installed as well as when a pending extension fails to | |
| 41 // install. | |
| 42 ASSERT_TRUE(ThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0))); | |
| 43 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
| 44 } | |
| 45 | |
| 46 // TCM ID - 3599303. | |
| 47 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575. | |
| 48 #if defined(OS_CHROMEOS) | |
| 49 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, FAILS_NativeTheme) { | |
| 50 #else | |
| 51 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, NativeTheme) { | |
| 52 #endif // OS_CHROMEOS | |
| 53 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 54 | |
| 55 UseCustomTheme(GetProfile(0), 0); | |
| 56 UseCustomTheme(GetProfile(1), 0); | |
| 57 UseCustomTheme(verifier(), 0); | |
| 58 | |
| 59 ASSERT_TRUE(AwaitQuiescence()); | |
| 60 | |
| 61 UseNativeTheme(GetProfile(0)); | |
| 62 UseNativeTheme(verifier()); | |
| 63 ASSERT_TRUE(UsingNativeTheme(GetProfile(0))); | |
| 64 ASSERT_TRUE(UsingNativeTheme(verifier())); | |
| 65 | |
| 66 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
| 67 | |
| 68 ASSERT_TRUE(UsingNativeTheme(GetProfile(0))); | |
| 69 ASSERT_TRUE(UsingNativeTheme(GetProfile(1))); | |
| 70 ASSERT_TRUE(UsingNativeTheme(verifier())); | |
| 71 } | |
| 72 | |
| 73 // TCM ID - 7247455. | |
| 74 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, DefaultTheme) { | |
| 75 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 76 | |
| 77 UseCustomTheme(GetProfile(0), 0); | |
| 78 UseCustomTheme(GetProfile(1), 0); | |
| 79 UseCustomTheme(verifier(), 0); | |
| 80 | |
| 81 ASSERT_TRUE(AwaitQuiescence()); | |
| 82 | |
| 83 UseDefaultTheme(GetProfile(0)); | |
| 84 UseDefaultTheme(verifier()); | |
| 85 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); | |
| 86 ASSERT_TRUE(UsingDefaultTheme(verifier())); | |
| 87 | |
| 88 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
| 89 | |
| 90 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); | |
| 91 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); | |
| 92 ASSERT_TRUE(UsingDefaultTheme(verifier())); | |
| 93 } | |
| 94 | |
| 95 // TCM ID - 7292065. | |
| 96 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575. | |
| 97 #if defined(OS_CHROMEOS) | |
| 98 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, FAILS_NativeDefaultRace) { | |
| 99 #else | |
| 100 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, NativeDefaultRace) { | |
| 101 #endif // OS_CHROMEOS | |
| 102 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 103 | |
| 104 UseNativeTheme(GetProfile(0)); | |
| 105 UseDefaultTheme(GetProfile(1)); | |
| 106 ASSERT_TRUE(UsingNativeTheme(GetProfile(0))); | |
| 107 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); | |
| 108 | |
| 109 ASSERT_TRUE(AwaitQuiescence()); | |
| 110 | |
| 111 // TODO(akalin): Add function that compares two profiles to see if | |
| 112 // they're at the same state. | |
| 113 | |
| 114 ASSERT_EQ(UsingNativeTheme(GetProfile(0)), | |
| 115 UsingNativeTheme(GetProfile(1))); | |
| 116 ASSERT_EQ(UsingDefaultTheme(GetProfile(0)), | |
| 117 UsingDefaultTheme(GetProfile(1))); | |
| 118 } | |
| 119 | |
| 120 // TCM ID - 7294077. | |
| 121 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575. | |
| 122 #if defined(OS_CHROMEOS) | |
| 123 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, FAILS_CustomNativeRace) { | |
| 124 #else | |
| 125 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, CustomNativeRace) { | |
| 126 #endif // OS_CHROMEOS | |
| 127 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 128 | |
| 129 UseCustomTheme(GetProfile(0), 0); | |
| 130 UseNativeTheme(GetProfile(1)); | |
| 131 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 132 ASSERT_TRUE(UsingNativeTheme(GetProfile(1))); | |
| 133 | |
| 134 ASSERT_TRUE(AwaitQuiescence()); | |
| 135 | |
| 136 // TODO(akalin): Add function to wait for pending extensions to be | |
| 137 // installed. | |
| 138 | |
| 139 ASSERT_EQ(HasOrWillHaveCustomTheme(GetProfile(0), GetCustomTheme(0)), | |
| 140 HasOrWillHaveCustomTheme(GetProfile(1), GetCustomTheme(0))); | |
| 141 } | |
| 142 | |
| 143 // TCM ID - 7307225. | |
| 144 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, CustomDefaultRace) { | |
| 145 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 146 | |
| 147 UseCustomTheme(GetProfile(0), 0); | |
| 148 UseDefaultTheme(GetProfile(1)); | |
| 149 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 150 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); | |
| 151 | |
| 152 ASSERT_TRUE(AwaitQuiescence()); | |
| 153 | |
| 154 ASSERT_EQ(HasOrWillHaveCustomTheme(GetProfile(0), GetCustomTheme(0)), | |
| 155 HasOrWillHaveCustomTheme(GetProfile(1), GetCustomTheme(0))); | |
| 156 } | |
| 157 | |
| 158 // TCM ID - 7264758. | |
| 159 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, CustomCustomRace) { | |
| 160 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 161 | |
| 162 // TODO(akalin): Generalize this to n clients. | |
| 163 | |
| 164 UseCustomTheme(GetProfile(0), 0); | |
| 165 UseCustomTheme(GetProfile(1), 1); | |
| 166 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 167 ASSERT_EQ(GetCustomTheme(1), GetThemeID(GetProfile(1))); | |
| 168 | |
| 169 ASSERT_TRUE(AwaitQuiescence()); | |
| 170 | |
| 171 bool using_theme_0 = | |
| 172 (GetThemeID(GetProfile(0)) == GetCustomTheme(0)) && | |
| 173 HasOrWillHaveCustomTheme(GetProfile(1), GetCustomTheme(0)); | |
| 174 bool using_theme_1 = | |
| 175 HasOrWillHaveCustomTheme(GetProfile(0), GetCustomTheme(1)) && | |
| 176 (GetThemeID(GetProfile(1)) == GetCustomTheme(1)); | |
| 177 | |
| 178 // Equivalent to using_theme_0 xor using_theme_1. | |
| 179 ASSERT_NE(using_theme_0, using_theme_1); | |
| 180 } | |
| 181 | |
| 182 // TCM ID - 3723272. | |
| 183 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, DisableThemes) { | |
| 184 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 185 | |
| 186 ASSERT_FALSE(UsingCustomTheme(GetProfile(0))); | |
| 187 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 188 ASSERT_FALSE(UsingCustomTheme(verifier())); | |
| 189 | |
| 190 ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncable::THEMES)); | |
| 191 UseCustomTheme(GetProfile(0), 0); | |
| 192 UseCustomTheme(verifier(), 0); | |
| 193 ASSERT_TRUE(AwaitQuiescence()); | |
| 194 | |
| 195 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 196 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 197 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
| 198 | |
| 199 ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncable::THEMES)); | |
| 200 ASSERT_TRUE(AwaitQuiescence()); | |
| 201 | |
| 202 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 203 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 204 ASSERT_TRUE(ThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0))); | |
| 205 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
| 206 } | |
| 207 | |
| 208 // TCM ID - 3687288. | |
| 209 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, DisableSync) { | |
| 210 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 211 | |
| 212 ASSERT_FALSE(UsingCustomTheme(GetProfile(0))); | |
| 213 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 214 ASSERT_FALSE(UsingCustomTheme(verifier())); | |
| 215 | |
| 216 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes()); | |
| 217 UseCustomTheme(GetProfile(0), 0); | |
| 218 UseCustomTheme(verifier(), 0); | |
| 219 ASSERT_TRUE( | |
| 220 GetClient(0)->AwaitSyncCycleCompletion("Installed a custom theme.")); | |
| 221 | |
| 222 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 223 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 224 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
| 225 | |
| 226 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes()); | |
| 227 ASSERT_TRUE(AwaitQuiescence()); | |
| 228 | |
| 229 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 230 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
| 231 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 232 ASSERT_TRUE(ThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0))); | |
| 233 } | |
| OLD | NEW |