| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 6 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
| 7 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 7 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
| 8 #include "chrome/browser/sync/test/integration/sync_test.h" | 8 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 9 #include "chrome/browser/sync/test/integration/themes_helper.h" | 9 #include "chrome/browser/sync/test/integration/themes_helper.h" |
| 10 | 10 |
| 11 using sync_integration_test_util::AwaitCommitActivityCompletion; | 11 using themes_helper::AwaitThemeIsPendingInstall; |
| 12 using themes_helper::AwaitUsingSystemTheme; |
| 13 using themes_helper::AwaitUsingDefaultTheme; |
| 12 using themes_helper::GetCustomTheme; | 14 using themes_helper::GetCustomTheme; |
| 13 using themes_helper::GetThemeID; | 15 using themes_helper::GetThemeID; |
| 14 using themes_helper::HasOrWillHaveCustomTheme; | |
| 15 using themes_helper::ThemeIsPendingInstall; | |
| 16 using themes_helper::UseCustomTheme; | 16 using themes_helper::UseCustomTheme; |
| 17 using themes_helper::UseDefaultTheme; | 17 using themes_helper::UseDefaultTheme; |
| 18 using themes_helper::UseSystemTheme; | 18 using themes_helper::UseSystemTheme; |
| 19 using themes_helper::UsingCustomTheme; | 19 using themes_helper::UsingCustomTheme; |
| 20 using themes_helper::UsingDefaultTheme; | 20 using themes_helper::UsingDefaultTheme; |
| 21 using themes_helper::UsingSystemTheme; | 21 using themes_helper::UsingSystemTheme; |
| 22 | 22 |
| 23 class TwoClientThemesSyncTest : public SyncTest { | 23 class TwoClientThemesSyncTest : public SyncTest { |
| 24 public: | 24 public: |
| 25 TwoClientThemesSyncTest() : SyncTest(TWO_CLIENT) {} | 25 TwoClientThemesSyncTest() : SyncTest(TWO_CLIENT) {} |
| 26 virtual ~TwoClientThemesSyncTest() {} | 26 virtual ~TwoClientThemesSyncTest() {} |
| 27 | 27 |
| 28 virtual bool TestUsesSelfNotifications() OVERRIDE { |
| 29 return false; |
| 30 } |
| 31 |
| 28 private: | 32 private: |
| 29 DISALLOW_COPY_AND_ASSIGN(TwoClientThemesSyncTest); | 33 DISALLOW_COPY_AND_ASSIGN(TwoClientThemesSyncTest); |
| 30 }; | 34 }; |
| 31 | 35 |
| 32 class LegacyTwoClientThemesSyncTest : public SyncTest { | 36 // Starts with default themes, then sets up sync and uses it to set all |
| 33 public: | 37 // profiles to use a custom theme. Does not actually install any themes, but |
| 34 LegacyTwoClientThemesSyncTest() : SyncTest(TWO_CLIENT_LEGACY) {} | 38 // instead verifies the custom theme is pending for install. |
| 35 virtual ~LegacyTwoClientThemesSyncTest() {} | 39 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DefaultThenSyncCustom) { |
| 36 | 40 ASSERT_TRUE(SetupSync()); |
| 37 private: | |
| 38 DISALLOW_COPY_AND_ASSIGN(LegacyTwoClientThemesSyncTest); | |
| 39 }; | |
| 40 | |
| 41 // TODO(akalin): Add tests for model association (i.e., tests that | |
| 42 // start with SetupClients(), change the theme state, then call | |
| 43 // SetupSync()). | |
| 44 | |
| 45 // TCM ID - 3667311. | |
| 46 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomTheme) { | |
| 47 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 48 | 41 |
| 49 ASSERT_FALSE(UsingCustomTheme(GetProfile(0))); | 42 ASSERT_FALSE(UsingCustomTheme(GetProfile(0))); |
| 50 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | 43 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); |
| 51 ASSERT_FALSE(UsingCustomTheme(verifier())); | 44 ASSERT_FALSE(UsingCustomTheme(verifier())); |
| 52 | 45 |
| 53 UseCustomTheme(GetProfile(0), 0); | 46 UseCustomTheme(GetProfile(0), 0); |
| 54 UseCustomTheme(verifier(), 0); | 47 UseCustomTheme(verifier(), 0); |
| 55 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | 48 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); |
| 56 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | 49 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); |
| 57 | 50 |
| 58 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 51 // TODO(sync): Add functions to simulate when a pending extension |
| 59 | |
| 60 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 61 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 62 // TODO(akalin): Add functions to simulate when a pending extension | |
| 63 // is installed as well as when a pending extension fails to | 52 // is installed as well as when a pending extension fails to |
| 64 // install. | 53 // install. |
| 65 ASSERT_TRUE(ThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0))); | 54 ASSERT_TRUE(AwaitThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0))); |
| 66 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | 55 |
| 56 EXPECT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); |
| 57 EXPECT_FALSE(UsingCustomTheme(GetProfile(1))); |
| 58 EXPECT_EQ(GetCustomTheme(0), GetThemeID(verifier())); |
| 67 } | 59 } |
| 68 | 60 |
| 69 // TCM ID - 3599303. | 61 // Starts with custom themes, then sets up sync and uses it to set all profiles |
| 70 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575. | 62 // to the system theme. |
| 71 #if defined(OS_CHROMEOS) | 63 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomThenSyncNative) { |
| 72 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DISABLED_NativeTheme) { | 64 ASSERT_TRUE(SetupClients()); |
| 73 #else | |
| 74 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, NativeTheme) { | |
| 75 #endif // OS_CHROMEOS | |
| 76 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 77 | 65 |
| 78 UseCustomTheme(GetProfile(0), 0); | 66 UseCustomTheme(GetProfile(0), 0); |
| 79 UseCustomTheme(GetProfile(1), 0); | 67 UseCustomTheme(GetProfile(1), 0); |
| 80 UseCustomTheme(verifier(), 0); | 68 UseCustomTheme(verifier(), 0); |
| 81 | 69 |
| 82 ASSERT_TRUE(AwaitQuiescence()); | 70 ASSERT_TRUE(SetupSync()); |
| 83 | 71 |
| 84 UseSystemTheme(GetProfile(0)); | 72 UseSystemTheme(GetProfile(0)); |
| 85 UseSystemTheme(verifier()); | 73 UseSystemTheme(verifier()); |
| 86 ASSERT_TRUE(UsingSystemTheme(GetProfile(0))); | 74 ASSERT_TRUE(UsingSystemTheme(GetProfile(0))); |
| 87 ASSERT_TRUE(UsingSystemTheme(verifier())); | 75 ASSERT_TRUE(UsingSystemTheme(verifier())); |
| 88 | 76 |
| 89 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 77 ASSERT_TRUE(AwaitUsingSystemTheme(GetProfile(1))); |
| 90 | 78 |
| 91 ASSERT_TRUE(UsingSystemTheme(GetProfile(0))); | 79 EXPECT_TRUE(UsingSystemTheme(GetProfile(0))); |
| 92 ASSERT_TRUE(UsingSystemTheme(GetProfile(1))); | 80 EXPECT_TRUE(UsingSystemTheme(GetProfile(1))); |
| 93 ASSERT_TRUE(UsingSystemTheme(verifier())); | 81 EXPECT_TRUE(UsingSystemTheme(verifier())); |
| 94 } | 82 } |
| 95 | 83 |
| 96 // TCM ID - 7247455. | 84 // Starts with custom themes, then sets up sync and uses it to set all profiles |
| 97 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DefaultTheme) { | 85 // to the default theme. |
| 98 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 86 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomThenSyncDefault) { |
| 87 ASSERT_TRUE(SetupClients()); |
| 99 | 88 |
| 100 UseCustomTheme(GetProfile(0), 0); | 89 UseCustomTheme(GetProfile(0), 0); |
| 101 UseCustomTheme(GetProfile(1), 0); | 90 UseCustomTheme(GetProfile(1), 0); |
| 102 UseCustomTheme(verifier(), 0); | 91 UseCustomTheme(verifier(), 0); |
| 103 | 92 |
| 104 ASSERT_TRUE(AwaitQuiescence()); | 93 ASSERT_TRUE(SetupSync()); |
| 105 | 94 |
| 106 UseDefaultTheme(GetProfile(0)); | 95 UseDefaultTheme(GetProfile(0)); |
| 107 UseDefaultTheme(verifier()); | 96 UseDefaultTheme(verifier()); |
| 108 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); | 97 EXPECT_TRUE(UsingDefaultTheme(GetProfile(0))); |
| 109 ASSERT_TRUE(UsingDefaultTheme(verifier())); | 98 EXPECT_TRUE(UsingDefaultTheme(verifier())); |
| 110 | 99 |
| 111 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 100 ASSERT_TRUE(AwaitUsingDefaultTheme(GetProfile(1))); |
| 112 | 101 EXPECT_TRUE(UsingDefaultTheme(GetProfile(0))); |
| 113 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); | 102 EXPECT_TRUE(UsingDefaultTheme(GetProfile(1))); |
| 114 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); | 103 EXPECT_TRUE(UsingDefaultTheme(verifier())); |
| 115 ASSERT_TRUE(UsingDefaultTheme(verifier())); | |
| 116 } | 104 } |
| 117 | 105 |
| 118 // TCM ID - 7292065. | 106 // Cycles through a set of options. |
| 119 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575. | 107 // |
| 120 // TODO(erg): Fails on linux_aura. See http://crbug.com/304554 | 108 // Most other tests have significant coverage of model association. This test |
| 121 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | 109 // is intended to test steady-state scenarios. |
| 122 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DISABLED_NativeDefaultRace) { | 110 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CycleOptions) { |
| 123 #else | |
| 124 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, NativeDefaultRace) { | |
| 125 #endif // OS_CHROMEOS | |
| 126 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 127 | |
| 128 UseSystemTheme(GetProfile(0)); | |
| 129 UseDefaultTheme(GetProfile(1)); | |
| 130 ASSERT_TRUE(UsingSystemTheme(GetProfile(0))); | |
| 131 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); | |
| 132 | |
| 133 ASSERT_TRUE(AwaitQuiescence()); | |
| 134 | |
| 135 // TODO(akalin): Add function that compares two profiles to see if | |
| 136 // they're at the same state. | |
| 137 | |
| 138 ASSERT_EQ(UsingSystemTheme(GetProfile(0)), | |
| 139 UsingSystemTheme(GetProfile(1))); | |
| 140 ASSERT_EQ(UsingDefaultTheme(GetProfile(0)), | |
| 141 UsingDefaultTheme(GetProfile(1))); | |
| 142 } | |
| 143 | |
| 144 // TCM ID - 7294077. | |
| 145 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575. | |
| 146 #if defined(OS_CHROMEOS) | |
| 147 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DISABLED_CustomNativeRace) { | |
| 148 #else | |
| 149 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomNativeRace) { | |
| 150 #endif // OS_CHROMEOS | |
| 151 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 111 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 152 | 112 |
| 153 UseCustomTheme(GetProfile(0), 0); | 113 UseCustomTheme(GetProfile(0), 0); |
| 154 UseSystemTheme(GetProfile(1)); | 114 UseCustomTheme(verifier(), 0); |
| 155 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 156 ASSERT_TRUE(UsingSystemTheme(GetProfile(1))); | |
| 157 | 115 |
| 158 ASSERT_TRUE(AwaitQuiescence()); | 116 ASSERT_TRUE(AwaitThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0))); |
| 117 EXPECT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); |
| 118 EXPECT_EQ(GetCustomTheme(0), GetThemeID(verifier())); |
| 159 | 119 |
| 160 // TODO(akalin): Add function to wait for pending extensions to be | 120 UseSystemTheme(GetProfile(0)); |
| 161 // installed. | 121 UseSystemTheme(verifier()); |
| 162 | 122 |
| 163 ASSERT_EQ(HasOrWillHaveCustomTheme(GetProfile(0), GetCustomTheme(0)), | 123 ASSERT_TRUE(AwaitUsingSystemTheme(GetProfile(1))); |
| 164 HasOrWillHaveCustomTheme(GetProfile(1), GetCustomTheme(0))); | 124 EXPECT_TRUE(UsingSystemTheme(GetProfile(0))); |
| 125 EXPECT_TRUE(UsingSystemTheme(GetProfile(1))); |
| 126 EXPECT_TRUE(UsingSystemTheme(verifier())); |
| 127 |
| 128 UseDefaultTheme(GetProfile(0)); |
| 129 UseDefaultTheme(verifier()); |
| 130 |
| 131 ASSERT_TRUE(AwaitUsingDefaultTheme(GetProfile(1))); |
| 132 EXPECT_TRUE(UsingDefaultTheme(GetProfile(0))); |
| 133 EXPECT_TRUE(UsingDefaultTheme(GetProfile(1))); |
| 134 EXPECT_TRUE(UsingDefaultTheme(verifier())); |
| 135 |
| 136 UseCustomTheme(GetProfile(0), 1); |
| 137 UseCustomTheme(verifier(), 1); |
| 138 ASSERT_TRUE(AwaitThemeIsPendingInstall(GetProfile(1), GetCustomTheme(1))); |
| 139 EXPECT_EQ(GetCustomTheme(1), GetThemeID(GetProfile(0))); |
| 140 EXPECT_EQ(GetCustomTheme(1), GetThemeID(verifier())); |
| 165 } | 141 } |
| 166 | |
| 167 // TCM ID - 7307225. | |
| 168 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomDefaultRace) { | |
| 169 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 170 | |
| 171 UseCustomTheme(GetProfile(0), 0); | |
| 172 UseDefaultTheme(GetProfile(1)); | |
| 173 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 174 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); | |
| 175 | |
| 176 ASSERT_TRUE(AwaitQuiescence()); | |
| 177 | |
| 178 ASSERT_EQ(HasOrWillHaveCustomTheme(GetProfile(0), GetCustomTheme(0)), | |
| 179 HasOrWillHaveCustomTheme(GetProfile(1), GetCustomTheme(0))); | |
| 180 } | |
| 181 | |
| 182 // TCM ID - 7264758. | |
| 183 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomCustomRace) { | |
| 184 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 185 | |
| 186 // TODO(akalin): Generalize this to n clients. | |
| 187 | |
| 188 UseCustomTheme(GetProfile(0), 0); | |
| 189 UseCustomTheme(GetProfile(1), 1); | |
| 190 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 191 ASSERT_EQ(GetCustomTheme(1), GetThemeID(GetProfile(1))); | |
| 192 | |
| 193 ASSERT_TRUE(AwaitQuiescence()); | |
| 194 | |
| 195 bool using_theme_0 = | |
| 196 (GetThemeID(GetProfile(0)) == GetCustomTheme(0)) && | |
| 197 HasOrWillHaveCustomTheme(GetProfile(1), GetCustomTheme(0)); | |
| 198 bool using_theme_1 = | |
| 199 HasOrWillHaveCustomTheme(GetProfile(0), GetCustomTheme(1)) && | |
| 200 (GetThemeID(GetProfile(1)) == GetCustomTheme(1)); | |
| 201 | |
| 202 // Equivalent to using_theme_0 xor using_theme_1. | |
| 203 ASSERT_NE(using_theme_0, using_theme_1); | |
| 204 } | |
| 205 | |
| 206 // TCM ID - 3723272. | |
| 207 IN_PROC_BROWSER_TEST_F(LegacyTwoClientThemesSyncTest, DisableThemes) { | |
| 208 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 209 | |
| 210 ASSERT_FALSE(UsingCustomTheme(GetProfile(0))); | |
| 211 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 212 ASSERT_FALSE(UsingCustomTheme(verifier())); | |
| 213 | |
| 214 ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::THEMES)); | |
| 215 UseCustomTheme(GetProfile(0), 0); | |
| 216 UseCustomTheme(verifier(), 0); | |
| 217 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | |
| 218 | |
| 219 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 220 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 221 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
| 222 | |
| 223 ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncer::THEMES)); | |
| 224 ASSERT_TRUE(AwaitQuiescence()); | |
| 225 | |
| 226 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 227 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 228 ASSERT_TRUE(ThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0))); | |
| 229 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
| 230 } | |
| 231 | |
| 232 // TCM ID - 3687288. | |
| 233 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DisableSync) { | |
| 234 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 235 | |
| 236 ASSERT_FALSE(UsingCustomTheme(GetProfile(0))); | |
| 237 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 238 ASSERT_FALSE(UsingCustomTheme(verifier())); | |
| 239 | |
| 240 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes()); | |
| 241 UseCustomTheme(GetProfile(0), 0); | |
| 242 UseCustomTheme(verifier(), 0); | |
| 243 ASSERT_TRUE( | |
| 244 AwaitCommitActivityCompletion(GetSyncService((0)))); | |
| 245 | |
| 246 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 247 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 248 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
| 249 | |
| 250 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes()); | |
| 251 ASSERT_TRUE(AwaitQuiescence()); | |
| 252 | |
| 253 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
| 254 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
| 255 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
| 256 ASSERT_TRUE(ThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0))); | |
| 257 } | |
| OLD | NEW |