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", | |
178 false, 1); | |
maxbogue
2016/05/18 22:14:48
Nit: this line should be moved right one space (an
Nicolas Zea
2016/05/18 22:18:28
Done.
| |
179 histogram_tester.ExpectUniqueSample("Sync.CookieJarEmptyOnMismatch", | |
180 true, 1); | |
175 | 181 |
176 // Trigger a cookie jar change (user signing in to content area). | 182 // Trigger a cookie jar change (user signing in to content area). |
177 gaia::ListedAccount signed_in_account; | 183 gaia::ListedAccount signed_in_account; |
178 signed_in_account.gaia_id = | 184 signed_in_account.gaia_id = |
179 GetClient(0)->service()->signin()->GetAuthenticatedAccountId(); | 185 GetClient(0)->service()->signin()->GetAuthenticatedAccountId(); |
180 std::vector<gaia::ListedAccount> accounts; | 186 std::vector<gaia::ListedAccount> accounts; |
181 accounts.push_back(signed_in_account); | 187 accounts.push_back(signed_in_account); |
182 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); | 188 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); |
183 GetClient(0)->service()->OnGaiaAccountsInCookieUpdated(accounts, error); | 189 GetClient(0)->service()->OnGaiaAccountsInCookieUpdated(accounts, error); |
184 | 190 |
185 // Trigger a sync and wait for it. | 191 // Trigger a sync and wait for it. |
186 url = GURL("http://127.0.0.1/bubba2"); | 192 url = GURL("http://127.0.0.1/bubba2"); |
187 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, old_windows.GetMutable())); | 193 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, old_windows.GetMutable())); |
188 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); | 194 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); |
189 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 195 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
190 | 196 |
191 // Verify the cookie jar mismatch bool is set to false. | 197 // Verify the cookie jar mismatch bool is set to false. |
192 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 198 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
193 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); | 199 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); |
200 | |
201 // Verify the histograms were recorded properly. | |
202 histogram_tester.ExpectTotalCount("Sync.CookieJarMatchOnNavigation", 2); | |
203 histogram_tester.ExpectBucketCount("Sync.CookieJarMatchOnNavigation", | |
204 true, 1); | |
205 histogram_tester.ExpectUniqueSample("Sync.CookieJarEmptyOnMismatch", | |
206 true, 1); | |
194 } | 207 } |
OLD | NEW |