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 "chrome/browser/sessions/session_service.h" | 7 #include "chrome/browser/sessions/session_service.h" |
7 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 8 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
8 #include "chrome/browser/sync/test/integration/sessions_helper.h" | 9 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
9 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 10 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
10 #include "chrome/browser/sync/test/integration/sync_test.h" | 11 #include "chrome/browser/sync/test/integration/sync_test.h" |
11 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" | 12 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" |
12 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
13 #include "components/browser_sync/browser/profile_sync_service.h" | 14 #include "components/browser_sync/browser/profile_sync_service.h" |
14 #include "components/history/core/browser/history_types.h" | 15 #include "components/history/core/browser/history_types.h" |
15 #include "components/sessions/core/session_types.h" | 16 #include "components/sessions/core/session_types.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 } | 154 } |
154 ASSERT_EQ(1, found_navigations); | 155 ASSERT_EQ(1, found_navigations); |
155 } | 156 } |
156 | 157 |
157 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, CookieJarMismatch) { | 158 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, CookieJarMismatch) { |
158 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 159 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
159 | 160 |
160 ASSERT_TRUE(CheckInitialState(0)); | 161 ASSERT_TRUE(CheckInitialState(0)); |
161 | 162 |
162 // Add a new session to client 0 and wait for it to sync. | 163 // Add a new session to client 0 and wait for it to sync. |
| 164 base::HistogramTester histogram_tester; |
163 ScopedWindowMap old_windows; | 165 ScopedWindowMap old_windows; |
164 GURL url = GURL("http://127.0.0.1/bubba"); | 166 GURL url = GURL("http://127.0.0.1/bubba"); |
165 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, old_windows.GetMutable())); | 167 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, old_windows.GetMutable())); |
166 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); | 168 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); |
167 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 169 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
168 | 170 |
169 // The cookie jar mismatch value will be true by default due to | 171 // The cookie jar mismatch value will be true by default due to |
170 // the way integration tests trigger signin (which does not involve a normal | 172 // the way integration tests trigger signin (which does not involve a normal |
171 // web content signin flow). | 173 // web content signin flow). |
172 sync_pb::ClientToServerMessage message; | 174 sync_pb::ClientToServerMessage message; |
173 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 175 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
174 ASSERT_TRUE(message.commit().config_params().cookie_jar_mismatch()); | 176 ASSERT_TRUE(message.commit().config_params().cookie_jar_mismatch()); |
| 177 histogram_tester.ExpectUniqueSample("Sync.CookieJarMatchOnNavigation", false, |
| 178 1); |
| 179 histogram_tester.ExpectUniqueSample("Sync.CookieJarEmptyOnMismatch", true, 1); |
175 | 180 |
176 // Trigger a cookie jar change (user signing in to content area). | 181 // Trigger a cookie jar change (user signing in to content area). |
177 gaia::ListedAccount signed_in_account; | 182 gaia::ListedAccount signed_in_account; |
178 signed_in_account.gaia_id = | 183 signed_in_account.gaia_id = |
179 GetClient(0)->service()->signin()->GetAuthenticatedAccountId(); | 184 GetClient(0)->service()->signin()->GetAuthenticatedAccountId(); |
180 std::vector<gaia::ListedAccount> accounts; | 185 std::vector<gaia::ListedAccount> accounts; |
181 accounts.push_back(signed_in_account); | 186 accounts.push_back(signed_in_account); |
182 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); | 187 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); |
183 GetClient(0)->service()->OnGaiaAccountsInCookieUpdated(accounts, error); | 188 GetClient(0)->service()->OnGaiaAccountsInCookieUpdated(accounts, error); |
184 | 189 |
185 // Trigger a sync and wait for it. | 190 // Trigger a sync and wait for it. |
186 url = GURL("http://127.0.0.1/bubba2"); | 191 url = GURL("http://127.0.0.1/bubba2"); |
187 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, old_windows.GetMutable())); | 192 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, old_windows.GetMutable())); |
188 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); | 193 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); |
189 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 194 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
190 | 195 |
191 // Verify the cookie jar mismatch bool is set to false. | 196 // Verify the cookie jar mismatch bool is set to false. |
192 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 197 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
193 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); | 198 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); |
| 199 |
| 200 // Verify the histograms were recorded properly. |
| 201 histogram_tester.ExpectTotalCount("Sync.CookieJarMatchOnNavigation", 2); |
| 202 histogram_tester.ExpectBucketCount("Sync.CookieJarMatchOnNavigation", true, |
| 203 1); |
| 204 histogram_tester.ExpectUniqueSample("Sync.CookieJarEmptyOnMismatch", true, 1); |
194 } | 205 } |
OLD | NEW |