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 TwoClientLiveThemesSyncTest : public LiveThemesSyncTest { | 10 class TwoClientLiveThemesSyncTest : public LiveThemesSyncTest { |
11 public: | 11 public: |
12 TwoClientLiveThemesSyncTest() : LiveThemesSyncTest(TWO_CLIENT) {} | 12 TwoClientLiveThemesSyncTest() : LiveThemesSyncTest(TWO_CLIENT) {} |
13 virtual ~TwoClientLiveThemesSyncTest() {} | 13 virtual ~TwoClientLiveThemesSyncTest() {} |
14 | 14 |
15 private: | 15 private: |
16 DISALLOW_COPY_AND_ASSIGN(TwoClientLiveThemesSyncTest); | 16 DISALLOW_COPY_AND_ASSIGN(TwoClientLiveThemesSyncTest); |
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(TwoClientLiveThemesSyncTest, CustomTheme) { | 23 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, 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(GetProfile(1))); | 27 ASSERT_EQ(NULL, GetCustomTheme(GetProfile(1))); |
29 ASSERT_EQ(NULL, GetCustomTheme(verifier())); | 28 ASSERT_EQ(NULL, GetCustomTheme(verifier())); |
30 | 29 |
31 SetTheme(GetProfile(0), theme); | 30 SetTheme(GetProfile(0), GetTheme(0)); |
32 SetTheme(verifier(), theme); | 31 SetTheme(verifier(), GetTheme(0)); |
33 ASSERT_EQ(theme, GetCustomTheme(GetProfile(0))); | 32 ASSERT_EQ(GetTheme(0), GetCustomTheme(GetProfile(0))); |
34 ASSERT_EQ(NULL, GetCustomTheme(GetProfile(1))); | 33 ASSERT_EQ(NULL, GetCustomTheme(GetProfile(1))); |
35 ASSERT_EQ(theme, GetCustomTheme(verifier())); | 34 ASSERT_EQ(GetTheme(0), GetCustomTheme(verifier())); |
36 | 35 |
37 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 36 ASSERT_TRUE(AwaitQuiescence()); |
38 | 37 |
39 ASSERT_EQ(theme, GetCustomTheme(GetProfile(0))); | 38 ASSERT_EQ(GetTheme(0), GetCustomTheme(GetProfile(0))); |
40 // TODO(akalin): Add functions to simulate when a pending extension | 39 // TODO(akalin): Add functions to simulate when a pending extension |
41 // is installed as well as when a pending extension fails to | 40 // is installed as well as when a pending extension fails to |
42 // install. | 41 // install. |
43 ASSERT_TRUE(ExtensionIsPendingInstall(GetProfile(1), theme)); | 42 ASSERT_TRUE(ExtensionIsPendingInstall(GetProfile(1), GetTheme(0))); |
44 ASSERT_EQ(theme, GetCustomTheme(verifier())); | 43 ASSERT_EQ(GetTheme(0), GetCustomTheme(verifier())); |
45 } | 44 } |
46 | 45 |
47 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, NativeTheme) { | 46 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, NativeTheme) { |
48 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 47 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
49 | 48 |
50 scoped_refptr<Extension> theme = GetTheme(0); | 49 SetTheme(GetProfile(0), GetTheme(0)); |
51 SetTheme(GetProfile(0), theme); | 50 SetTheme(GetProfile(1), GetTheme(0)); |
52 SetTheme(GetProfile(1), theme); | 51 SetTheme(verifier(), GetTheme(0)); |
53 SetTheme(verifier(), theme); | |
54 | 52 |
55 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 53 ASSERT_TRUE(AwaitQuiescence()); |
56 | 54 |
57 GetProfile(0)->SetNativeTheme(); | 55 GetProfile(0)->SetNativeTheme(); |
58 verifier()->SetNativeTheme(); | 56 verifier()->SetNativeTheme(); |
59 ASSERT_TRUE(UsingNativeTheme(GetProfile(0))); | 57 ASSERT_TRUE(UsingNativeTheme(GetProfile(0))); |
60 ASSERT_FALSE(UsingNativeTheme(GetProfile(1))); | 58 ASSERT_FALSE(UsingNativeTheme(GetProfile(1))); |
61 ASSERT_TRUE(UsingNativeTheme(verifier())); | 59 ASSERT_TRUE(UsingNativeTheme(verifier())); |
62 | 60 |
63 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 61 ASSERT_TRUE(AwaitQuiescence()); |
64 | 62 |
65 ASSERT_TRUE(UsingNativeTheme(GetProfile(0))); | 63 ASSERT_TRUE(UsingNativeTheme(GetProfile(0))); |
66 ASSERT_TRUE(UsingNativeTheme(GetProfile(1))); | 64 ASSERT_TRUE(UsingNativeTheme(GetProfile(1))); |
67 ASSERT_TRUE(UsingNativeTheme(verifier())); | 65 ASSERT_TRUE(UsingNativeTheme(verifier())); |
68 } | 66 } |
69 | 67 |
70 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, DefaultTheme) { | 68 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, DefaultTheme) { |
71 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 69 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
72 | 70 |
73 scoped_refptr<Extension> theme = GetTheme(0); | 71 SetTheme(GetProfile(0), GetTheme(0)); |
74 SetTheme(GetProfile(0), theme); | 72 SetTheme(GetProfile(1), GetTheme(0)); |
75 SetTheme(GetProfile(1), theme); | 73 SetTheme(verifier(), GetTheme(0)); |
76 SetTheme(verifier(), theme); | |
77 | 74 |
78 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 75 ASSERT_TRUE(AwaitQuiescence()); |
79 | 76 |
80 GetProfile(0)->ClearTheme(); | 77 GetProfile(0)->ClearTheme(); |
81 verifier()->ClearTheme(); | 78 verifier()->ClearTheme(); |
82 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); | 79 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); |
83 ASSERT_FALSE(UsingDefaultTheme(GetProfile(1))); | 80 ASSERT_FALSE(UsingDefaultTheme(GetProfile(1))); |
84 ASSERT_TRUE(UsingDefaultTheme(verifier())); | 81 ASSERT_TRUE(UsingDefaultTheme(verifier())); |
85 | 82 |
86 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 83 ASSERT_TRUE(AwaitQuiescence()); |
Raghu Simha
2010/11/12 01:40:50
This can stay as AwaitMutualSyncCycleCompletion fo
akalin
2010/11/12 02:19:03
Done, also fixed other places in here
| |
87 | 84 |
88 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); | 85 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); |
89 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); | 86 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); |
90 ASSERT_TRUE(UsingDefaultTheme(verifier())); | 87 ASSERT_TRUE(UsingDefaultTheme(verifier())); |
91 } | 88 } |
92 | 89 |
93 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, NativeDefaultRace) { | 90 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, NativeDefaultRace) { |
94 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 91 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
95 | 92 |
96 GetProfile(0)->SetNativeTheme(); | 93 GetProfile(0)->SetNativeTheme(); |
97 GetProfile(1)->ClearTheme(); | 94 GetProfile(1)->ClearTheme(); |
98 ASSERT_TRUE(UsingNativeTheme(GetProfile(0))); | 95 ASSERT_TRUE(UsingNativeTheme(GetProfile(0))); |
99 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); | 96 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); |
100 | 97 |
101 ASSERT_TRUE(AwaitQuiescence()); | 98 ASSERT_TRUE(AwaitQuiescence()); |
102 | 99 |
103 // TODO(akalin): Add function that compares two profiles to see if | 100 // TODO(akalin): Add function that compares two profiles to see if |
104 // they're at the same state. | 101 // they're at the same state. |
105 | 102 |
106 ASSERT_EQ(UsingNativeTheme(GetProfile(0)), | 103 ASSERT_EQ(UsingNativeTheme(GetProfile(0)), |
107 UsingNativeTheme(GetProfile(1))); | 104 UsingNativeTheme(GetProfile(1))); |
108 ASSERT_EQ(UsingDefaultTheme(GetProfile(0)), | 105 ASSERT_EQ(UsingDefaultTheme(GetProfile(0)), |
109 UsingDefaultTheme(GetProfile(1))); | 106 UsingDefaultTheme(GetProfile(1))); |
110 } | 107 } |
111 | 108 |
112 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, CustomNativeRace) { | 109 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, CustomNativeRace) { |
113 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 110 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
114 | 111 |
115 scoped_refptr<Extension> theme = GetTheme(0); | 112 SetTheme(GetProfile(0), GetTheme(0)); |
116 SetTheme(GetProfile(0), theme); | |
117 GetProfile(1)->SetNativeTheme(); | 113 GetProfile(1)->SetNativeTheme(); |
118 ASSERT_EQ(theme, GetCustomTheme(GetProfile(0))); | 114 ASSERT_EQ(GetTheme(0), GetCustomTheme(GetProfile(0))); |
119 ASSERT_TRUE(UsingNativeTheme(GetProfile(1))); | 115 ASSERT_TRUE(UsingNativeTheme(GetProfile(1))); |
120 | 116 |
121 ASSERT_TRUE(AwaitQuiescence()); | 117 ASSERT_TRUE(AwaitQuiescence()); |
122 | 118 |
123 // TODO(akalin): Add function to wait for pending extensions to be | 119 // TODO(akalin): Add function to wait for pending extensions to be |
124 // installed. | 120 // installed. |
125 | 121 |
126 ASSERT_EQ(HasOrWillHaveCustomTheme(GetProfile(0), theme), | 122 ASSERT_EQ(HasOrWillHaveCustomTheme(GetProfile(0), GetTheme(0)), |
127 HasOrWillHaveCustomTheme(GetProfile(1), theme)); | 123 HasOrWillHaveCustomTheme(GetProfile(1), GetTheme(0))); |
128 } | 124 } |
129 | 125 |
130 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, CustomDefaultRace) { | 126 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, CustomDefaultRace) { |
131 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 127 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
132 | 128 |
133 scoped_refptr<Extension> theme = GetTheme(0); | 129 SetTheme(GetProfile(0), GetTheme(0)); |
134 SetTheme(GetProfile(0), theme); | |
135 GetProfile(1)->ClearTheme(); | 130 GetProfile(1)->ClearTheme(); |
136 ASSERT_EQ(theme, GetCustomTheme(GetProfile(0))); | 131 ASSERT_EQ(GetTheme(0), GetCustomTheme(GetProfile(0))); |
137 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); | 132 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); |
138 | 133 |
139 ASSERT_TRUE(AwaitQuiescence()); | 134 ASSERT_TRUE(AwaitQuiescence()); |
140 | 135 |
141 ASSERT_EQ(HasOrWillHaveCustomTheme(GetProfile(0), theme), | 136 ASSERT_EQ(HasOrWillHaveCustomTheme(GetProfile(0), GetTheme(0)), |
142 HasOrWillHaveCustomTheme(GetProfile(1), theme)); | 137 HasOrWillHaveCustomTheme(GetProfile(1), GetTheme(0))); |
143 } | 138 } |
144 | 139 |
145 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, CustomCustomRace) { | 140 IN_PROC_BROWSER_TEST_F(TwoClientLiveThemesSyncTest, CustomCustomRace) { |
146 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 141 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
147 | 142 |
143 // TODO(akalin): Generalize this to n clients. | |
144 | |
148 SetTheme(GetProfile(0), GetTheme(0)); | 145 SetTheme(GetProfile(0), GetTheme(0)); |
149 SetTheme(GetProfile(1), GetTheme(1)); | 146 SetTheme(GetProfile(1), GetTheme(1)); |
150 ASSERT_EQ(GetTheme(0), GetCustomTheme(GetProfile(0))); | 147 ASSERT_EQ(GetTheme(0), GetCustomTheme(GetProfile(0))); |
151 ASSERT_EQ(GetTheme(1), GetCustomTheme(GetProfile(1))); | 148 ASSERT_EQ(GetTheme(1), GetCustomTheme(GetProfile(1))); |
152 | 149 |
153 ASSERT_TRUE(AwaitQuiescence()); | 150 ASSERT_TRUE(AwaitQuiescence()); |
154 | 151 |
155 bool using_theme_0 = | 152 bool using_theme_0 = |
156 (GetCustomTheme(GetProfile(0)) == GetTheme(0)) && | 153 (GetCustomTheme(GetProfile(0)) == GetTheme(0)) && |
157 HasOrWillHaveCustomTheme(GetProfile(1), GetTheme(0)); | 154 HasOrWillHaveCustomTheme(GetProfile(1), GetTheme(0)); |
158 bool using_theme_1 = | 155 bool using_theme_1 = |
159 HasOrWillHaveCustomTheme(GetProfile(0), GetTheme(1)) && | 156 HasOrWillHaveCustomTheme(GetProfile(0), GetTheme(1)) && |
160 (GetCustomTheme(GetProfile(1)) == GetTheme(1)); | 157 (GetCustomTheme(GetProfile(1)) == GetTheme(1)); |
161 | 158 |
162 // Equivalent to using_theme_0 xor using_theme_1. | 159 // Equivalent to using_theme_0 xor using_theme_1. |
163 ASSERT_NE(using_theme_0, using_theme_1); | 160 ASSERT_NE(using_theme_0, using_theme_1); |
164 } | 161 } |
OLD | NEW |