OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/macros.h" | 5 #include "base/macros.h" |
6 #include "base/test/histogram_tester.h" | 6 #include "base/test/histogram_tester.h" |
7 #include "chrome/browser/sessions/session_service.h" | 7 #include "chrome/browser/sessions/session_service.h" |
8 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 8 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
9 #include "chrome/browser/sync/test/integration/sessions_helper.h" | 9 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
10 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 10 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, Sanity) { | 44 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, Sanity) { |
45 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 45 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
46 | 46 |
47 ASSERT_TRUE(CheckInitialState(0)); | 47 ASSERT_TRUE(CheckInitialState(0)); |
48 | 48 |
49 // Add a new session to client 0 and wait for it to sync. | 49 // Add a new session to client 0 and wait for it to sync. |
50 ScopedWindowMap old_windows; | 50 ScopedWindowMap old_windows; |
51 GURL url = GURL("http://127.0.0.1/bubba"); | 51 GURL url = GURL("http://127.0.0.1/bubba"); |
52 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows)); | 52 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows)); |
53 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 53 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); |
54 | 54 |
55 // Get foreign session data from client 0. | 55 // Get foreign session data from client 0. |
56 SyncedSessionVector sessions; | 56 SyncedSessionVector sessions; |
57 ASSERT_FALSE(GetSessionData(0, &sessions)); | 57 ASSERT_FALSE(GetSessionData(0, &sessions)); |
58 ASSERT_EQ(0U, sessions.size()); | 58 ASSERT_EQ(0U, sessions.size()); |
59 | 59 |
60 // Verify client didn't change. | 60 // Verify client didn't change. |
61 ScopedWindowMap new_windows; | 61 ScopedWindowMap new_windows; |
62 ASSERT_TRUE(GetLocalWindows(0, &new_windows)); | 62 ASSERT_TRUE(GetLocalWindows(0, &new_windows)); |
63 ASSERT_TRUE(WindowsMatch(old_windows, new_windows)); | 63 ASSERT_TRUE(WindowsMatch(old_windows, new_windows)); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 154 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
155 | 155 |
156 ASSERT_TRUE(CheckInitialState(0)); | 156 ASSERT_TRUE(CheckInitialState(0)); |
157 | 157 |
158 // Add a new session to client 0 and wait for it to sync. | 158 // Add a new session to client 0 and wait for it to sync. |
159 base::HistogramTester histogram_tester; | 159 base::HistogramTester histogram_tester; |
160 ScopedWindowMap old_windows; | 160 ScopedWindowMap old_windows; |
161 GURL url = GURL("http://127.0.0.1/bubba"); | 161 GURL url = GURL("http://127.0.0.1/bubba"); |
162 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows)); | 162 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows)); |
163 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); | 163 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); |
164 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 164 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); |
165 | 165 |
166 // The cookie jar mismatch value will be true by default due to | 166 // The cookie jar mismatch value will be true by default due to |
167 // the way integration tests trigger signin (which does not involve a normal | 167 // the way integration tests trigger signin (which does not involve a normal |
168 // web content signin flow). | 168 // web content signin flow). |
169 sync_pb::ClientToServerMessage message; | 169 sync_pb::ClientToServerMessage message; |
170 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 170 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
171 ASSERT_TRUE(message.commit().config_params().cookie_jar_mismatch()); | 171 ASSERT_TRUE(message.commit().config_params().cookie_jar_mismatch()); |
172 histogram_tester.ExpectUniqueSample("Sync.CookieJarMatchOnNavigation", false, | 172 histogram_tester.ExpectUniqueSample("Sync.CookieJarMatchOnNavigation", false, |
173 1); | 173 1); |
174 histogram_tester.ExpectUniqueSample("Sync.CookieJarEmptyOnMismatch", true, 1); | 174 histogram_tester.ExpectUniqueSample("Sync.CookieJarEmptyOnMismatch", true, 1); |
175 | 175 |
176 // Trigger a cookie jar change (user signing in to content area). | 176 // Trigger a cookie jar change (user signing in to content area). |
177 gaia::ListedAccount signed_in_account; | 177 gaia::ListedAccount signed_in_account; |
178 signed_in_account.id = | 178 signed_in_account.id = |
179 GetClient(0)->service()->signin()->GetAuthenticatedAccountId(); | 179 GetClient(0)->service()->signin()->GetAuthenticatedAccountId(); |
180 std::vector<gaia::ListedAccount> accounts; | 180 std::vector<gaia::ListedAccount> accounts; |
181 std::vector<gaia::ListedAccount> signed_out_accounts; | 181 std::vector<gaia::ListedAccount> signed_out_accounts; |
182 accounts.push_back(signed_in_account); | 182 accounts.push_back(signed_in_account); |
183 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); | 183 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); |
184 GetClient(0)->service()->OnGaiaAccountsInCookieUpdated( | 184 GetClient(0)->service()->OnGaiaAccountsInCookieUpdated( |
185 accounts, signed_out_accounts, error); | 185 accounts, signed_out_accounts, error); |
186 | 186 |
187 // Trigger a sync and wait for it. | 187 // Trigger a sync and wait for it. |
188 url = GURL("http://127.0.0.1/bubba2"); | 188 url = GURL("http://127.0.0.1/bubba2"); |
189 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows)); | 189 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows)); |
190 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); | 190 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); |
191 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 191 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); |
192 | 192 |
193 // Verify the cookie jar mismatch bool is set to false. | 193 // Verify the cookie jar mismatch bool is set to false. |
194 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 194 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
195 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); | 195 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); |
196 | 196 |
197 // Verify the histograms were recorded properly. | 197 // Verify the histograms were recorded properly. |
198 histogram_tester.ExpectTotalCount("Sync.CookieJarMatchOnNavigation", 2); | 198 histogram_tester.ExpectTotalCount("Sync.CookieJarMatchOnNavigation", 2); |
199 histogram_tester.ExpectBucketCount("Sync.CookieJarMatchOnNavigation", true, | 199 histogram_tester.ExpectBucketCount("Sync.CookieJarMatchOnNavigation", true, |
200 1); | 200 1); |
201 histogram_tester.ExpectUniqueSample("Sync.CookieJarEmptyOnMismatch", true, 1); | 201 histogram_tester.ExpectUniqueSample("Sync.CookieJarEmptyOnMismatch", true, 1); |
202 } | 202 } |
OLD | NEW |