| 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 #include "chrome/browser/chrome_notification_types.h" | |
| 8 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | |
| 9 #include "chrome/browser/sync/test/integration/sync_test.h" | 7 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 10 #include "chrome/browser/sync/test/integration/themes_helper.h" | 8 #include "chrome/browser/sync/test/integration/themes_helper.h" |
| 11 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" | 9 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" |
| 12 #include "chrome/browser/themes/theme_service_factory.h" | |
| 13 #include "components/browser_sync/profile_sync_service.h" | 10 #include "components/browser_sync/profile_sync_service.h" |
| 14 #include "content/public/test/test_utils.h" | |
| 15 | 11 |
| 16 using themes_helper::GetCustomTheme; | 12 using themes_helper::GetCustomTheme; |
| 17 using themes_helper::GetThemeID; | 13 using themes_helper::GetThemeID; |
| 14 using themes_helper::UseCustomTheme; |
| 18 using themes_helper::UseDefaultTheme; | 15 using themes_helper::UseDefaultTheme; |
| 19 using themes_helper::UseSystemTheme; | 16 using themes_helper::UseSystemTheme; |
| 20 using themes_helper::UsingCustomTheme; | 17 using themes_helper::UsingCustomTheme; |
| 21 using themes_helper::UsingDefaultTheme; | 18 using themes_helper::UsingDefaultTheme; |
| 22 using themes_helper::UsingSystemTheme; | 19 using themes_helper::UsingSystemTheme; |
| 23 | 20 |
| 24 namespace { | |
| 25 | |
| 26 class SingleClientThemesSyncTest : public SyncTest { | 21 class SingleClientThemesSyncTest : public SyncTest { |
| 27 public: | 22 public: |
| 28 SingleClientThemesSyncTest() : SyncTest(SINGLE_CLIENT) {} | 23 SingleClientThemesSyncTest() : SyncTest(SINGLE_CLIENT) {} |
| 29 ~SingleClientThemesSyncTest() override {} | 24 ~SingleClientThemesSyncTest() override {} |
| 30 | 25 |
| 31 private: | 26 private: |
| 32 DISALLOW_COPY_AND_ASSIGN(SingleClientThemesSyncTest); | 27 DISALLOW_COPY_AND_ASSIGN(SingleClientThemesSyncTest); |
| 33 }; | 28 }; |
| 34 | 29 |
| 35 // TODO(akalin): Add tests for model association (i.e., tests that | 30 // TODO(akalin): Add tests for model association (i.e., tests that |
| 36 // start with SetupClients(), change the theme state, then call | 31 // start with SetupClients(), change the theme state, then call |
| 37 // SetupSync()). | 32 // SetupSync()). |
| 38 | 33 |
| 39 IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, CustomTheme) { | 34 IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, CustomTheme) { |
| 40 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 35 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 41 | 36 |
| 42 EXPECT_FALSE(UsingCustomTheme(GetProfile(0))); | 37 ASSERT_FALSE(UsingCustomTheme(GetProfile(0))); |
| 43 EXPECT_FALSE(UsingCustomTheme(verifier())); | 38 ASSERT_FALSE(UsingCustomTheme(verifier())); |
| 44 | 39 |
| 45 SetCustomTheme(GetProfile(0)); | 40 UseCustomTheme(GetProfile(0), 0); |
| 46 SetCustomTheme(verifier()); | 41 UseCustomTheme(verifier(), 0); |
| 47 EXPECT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | 42 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); |
| 48 EXPECT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | 43 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); |
| 49 | 44 |
| 50 EXPECT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | 45 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
| 51 | 46 |
| 52 EXPECT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | 47 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); |
| 53 EXPECT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | 48 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); |
| 54 } | 49 } |
| 55 | 50 |
| 56 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575. | 51 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575. |
| 57 #if defined(OS_CHROMEOS) | 52 #if defined(OS_CHROMEOS) |
| 58 IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, DISABLED_NativeTheme) { | 53 IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, DISABLED_NativeTheme) { |
| 59 #else | 54 #else |
| 60 IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, NativeTheme) { | 55 IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, NativeTheme) { |
| 61 #endif // OS_CHROMEOS | 56 #endif // OS_CHROMEOS |
| 62 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 57 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 63 | 58 |
| 64 SetCustomTheme(GetProfile(0)); | 59 UseCustomTheme(GetProfile(0), 0); |
| 65 SetCustomTheme(verifier()); | 60 UseCustomTheme(verifier(), 0); |
| 66 EXPECT_FALSE(UsingSystemTheme(GetProfile(0))); | 61 ASSERT_FALSE(UsingSystemTheme(GetProfile(0))); |
| 67 EXPECT_FALSE(UsingSystemTheme(verifier())); | 62 ASSERT_FALSE(UsingSystemTheme(verifier())); |
| 68 | 63 |
| 69 EXPECT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | 64 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
| 70 | 65 |
| 71 UseSystemTheme(GetProfile(0)); | 66 UseSystemTheme(GetProfile(0)); |
| 72 UseSystemTheme(verifier()); | 67 UseSystemTheme(verifier()); |
| 73 EXPECT_TRUE(UsingSystemTheme(GetProfile(0))); | 68 ASSERT_TRUE(UsingSystemTheme(GetProfile(0))); |
| 74 EXPECT_TRUE(UsingSystemTheme(verifier())); | 69 ASSERT_TRUE(UsingSystemTheme(verifier())); |
| 75 | 70 |
| 76 EXPECT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | 71 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
| 77 | 72 |
| 78 EXPECT_TRUE(UsingSystemTheme(GetProfile(0))); | 73 ASSERT_TRUE(UsingSystemTheme(GetProfile(0))); |
| 79 EXPECT_TRUE(UsingSystemTheme(verifier())); | 74 ASSERT_TRUE(UsingSystemTheme(verifier())); |
| 80 } | 75 } |
| 81 | 76 |
| 82 IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, DefaultTheme) { | 77 IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, DefaultTheme) { |
| 83 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 78 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 84 | 79 |
| 85 SetCustomTheme(GetProfile(0)); | 80 UseCustomTheme(GetProfile(0), 0); |
| 86 EXPECT_FALSE(UsingDefaultTheme(GetProfile(0))); | 81 UseCustomTheme(verifier(), 0); |
| 82 ASSERT_FALSE(UsingDefaultTheme(GetProfile(0))); |
| 83 ASSERT_FALSE(UsingDefaultTheme(verifier())); |
| 87 | 84 |
| 88 SetCustomTheme(verifier()); | 85 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
| 89 EXPECT_FALSE(UsingDefaultTheme(verifier())); | |
| 90 | 86 |
| 91 EXPECT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | |
| 92 UseDefaultTheme(GetProfile(0)); | 87 UseDefaultTheme(GetProfile(0)); |
| 93 EXPECT_TRUE(UsingDefaultTheme(GetProfile(0))); | |
| 94 UseDefaultTheme(verifier()); | 88 UseDefaultTheme(verifier()); |
| 95 EXPECT_TRUE(UsingDefaultTheme(verifier())); | 89 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); |
| 90 ASSERT_TRUE(UsingDefaultTheme(verifier())); |
| 96 | 91 |
| 97 EXPECT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | 92 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
| 98 | 93 |
| 99 EXPECT_TRUE(UsingDefaultTheme(GetProfile(0))); | 94 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); |
| 100 EXPECT_TRUE(UsingDefaultTheme(verifier())); | 95 ASSERT_TRUE(UsingDefaultTheme(verifier())); |
| 101 } | 96 } |
| 102 | |
| 103 } // namespace | |
| OLD | NEW |