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