| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/test/live_sync/live_themes_sync_test.h" | 5 #include "chrome/test/live_sync/live_themes_sync_test.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
| 9 | 9 |
| 10 class SingleClientLiveThemesSyncTest : public LiveThemesSyncTest { | 10 class SingleClientLiveThemesSyncTest : public LiveThemesSyncTest { |
| 11 public: | 11 public: |
| 12 SingleClientLiveThemesSyncTest() : LiveThemesSyncTest(SINGLE_CLIENT) {} | 12 SingleClientLiveThemesSyncTest() : LiveThemesSyncTest(SINGLE_CLIENT) {} |
| 13 virtual ~SingleClientLiveThemesSyncTest() {} | 13 virtual ~SingleClientLiveThemesSyncTest() {} |
| 14 | 14 |
| 15 private: | 15 private: |
| 16 DISALLOW_COPY_AND_ASSIGN(SingleClientLiveThemesSyncTest); | 16 DISALLOW_COPY_AND_ASSIGN(SingleClientLiveThemesSyncTest); |
| 17 }; | 17 }; |
| 18 | 18 |
| 19 // TODO(akalin): Add tests for model association (i.e., tests that | 19 // TODO(akalin): Add tests for model association (i.e., tests that |
| 20 // start with SetupClients(), change the theme state, then call | 20 // start with SetupClients(), change the theme state, then call |
| 21 // SetupSync()). | 21 // SetupSync()). |
| 22 | 22 |
| 23 IN_PROC_BROWSER_TEST_F(SingleClientLiveThemesSyncTest, CustomTheme) { | 23 IN_PROC_BROWSER_TEST_F(SingleClientLiveThemesSyncTest, CustomTheme) { |
| 24 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 24 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 25 | 25 |
| 26 scoped_refptr<Extension> theme = GetTheme(0); | |
| 27 ASSERT_EQ(NULL, GetCustomTheme(GetProfile(0))); | 26 ASSERT_EQ(NULL, GetCustomTheme(GetProfile(0))); |
| 28 ASSERT_EQ(NULL, GetCustomTheme(verifier())); | 27 ASSERT_EQ(NULL, GetCustomTheme(verifier())); |
| 29 | 28 |
| 30 SetTheme(GetProfile(0), theme); | 29 SetTheme(GetProfile(0), GetTheme(0)); |
| 31 SetTheme(verifier(), theme); | 30 SetTheme(verifier(), GetTheme(0)); |
| 32 ASSERT_EQ(theme, GetCustomTheme(GetProfile(0))); | 31 ASSERT_EQ(GetTheme(0), GetCustomTheme(GetProfile(0))); |
| 33 ASSERT_EQ(theme, GetCustomTheme(verifier())); | 32 ASSERT_EQ(GetTheme(0), GetCustomTheme(verifier())); |
| 34 | 33 |
| 35 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( | 34 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( |
| 36 "Waiting for themes change.")); | 35 "Waiting for custom themes change.")); |
| 37 | 36 |
| 38 ASSERT_EQ(theme, GetCustomTheme(GetProfile(0))); | 37 ASSERT_EQ(GetTheme(0), GetCustomTheme(GetProfile(0))); |
| 39 ASSERT_EQ(theme, GetCustomTheme(verifier())); | 38 ASSERT_EQ(GetTheme(0), GetCustomTheme(verifier())); |
| 40 } | 39 } |
| 41 | 40 |
| 42 IN_PROC_BROWSER_TEST_F(SingleClientLiveThemesSyncTest, NativeTheme) { | 41 IN_PROC_BROWSER_TEST_F(SingleClientLiveThemesSyncTest, NativeTheme) { |
| 43 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 42 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 44 | 43 |
| 45 scoped_refptr<Extension> theme = GetTheme(0); | 44 SetTheme(GetProfile(0), GetTheme(0)); |
| 46 SetTheme(GetProfile(0), theme); | 45 SetTheme(verifier(), GetTheme(0)); |
| 47 SetTheme(verifier(), theme); | |
| 48 ASSERT_FALSE(UsingNativeTheme(GetProfile(0))); | 46 ASSERT_FALSE(UsingNativeTheme(GetProfile(0))); |
| 49 ASSERT_FALSE(UsingNativeTheme(verifier())); | 47 ASSERT_FALSE(UsingNativeTheme(verifier())); |
| 50 | 48 |
| 51 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( | 49 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( |
| 52 "Waiting for themes change.")); | 50 "Waiting for custom themes change.")); |
| 53 | 51 |
| 54 GetProfile(0)->SetNativeTheme(); | 52 GetProfile(0)->SetNativeTheme(); |
| 55 verifier()->SetNativeTheme(); | 53 verifier()->SetNativeTheme(); |
| 56 ASSERT_TRUE(UsingNativeTheme(GetProfile(0))); | 54 ASSERT_TRUE(UsingNativeTheme(GetProfile(0))); |
| 57 ASSERT_TRUE(UsingNativeTheme(verifier())); | 55 ASSERT_TRUE(UsingNativeTheme(verifier())); |
| 58 | 56 |
| 59 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( | 57 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( |
| 60 "Waiting for native theme change.")); | 58 "Waiting for native themes change.")); |
| 61 | 59 |
| 62 ASSERT_TRUE(UsingNativeTheme(GetProfile(0))); | 60 ASSERT_TRUE(UsingNativeTheme(GetProfile(0))); |
| 63 ASSERT_TRUE(UsingNativeTheme(verifier())); | 61 ASSERT_TRUE(UsingNativeTheme(verifier())); |
| 64 } | 62 } |
| 65 | 63 |
| 66 IN_PROC_BROWSER_TEST_F(SingleClientLiveThemesSyncTest, DefaultTheme) { | 64 IN_PROC_BROWSER_TEST_F(SingleClientLiveThemesSyncTest, DefaultTheme) { |
| 67 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 65 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 68 | 66 |
| 69 scoped_refptr<Extension> theme = GetTheme(0); | 67 SetTheme(GetProfile(0), GetTheme(0)); |
| 70 SetTheme(GetProfile(0), theme); | 68 SetTheme(verifier(), GetTheme(0)); |
| 71 SetTheme(verifier(), theme); | |
| 72 ASSERT_FALSE(UsingDefaultTheme(GetProfile(0))); | 69 ASSERT_FALSE(UsingDefaultTheme(GetProfile(0))); |
| 73 ASSERT_FALSE(UsingDefaultTheme(verifier())); | 70 ASSERT_FALSE(UsingDefaultTheme(verifier())); |
| 74 | 71 |
| 75 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( | 72 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( |
| 76 "Waiting for themes change.")); | 73 "Waiting for custom themes change.")); |
| 77 | 74 |
| 78 GetProfile(0)->ClearTheme(); | 75 GetProfile(0)->ClearTheme(); |
| 79 verifier()->ClearTheme(); | 76 verifier()->ClearTheme(); |
| 80 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); | 77 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); |
| 81 ASSERT_TRUE(UsingDefaultTheme(verifier())); | 78 ASSERT_TRUE(UsingDefaultTheme(verifier())); |
| 82 | 79 |
| 83 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( | 80 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion( |
| 84 "Waiting for cleared theme change.")); | 81 "Waiting for native themes change.")); |
| 85 | 82 |
| 86 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); | 83 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); |
| 87 ASSERT_TRUE(UsingDefaultTheme(verifier())); | 84 ASSERT_TRUE(UsingDefaultTheme(verifier())); |
| 88 } | 85 } |
| OLD | NEW |