| 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_test.h" | 10 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 11 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" | 11 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" |
| 12 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" | 12 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" |
| 13 #include "chrome/common/chrome_switches.h" | |
| 14 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 15 #include "components/browser_sync/profile_sync_service.h" | 14 #include "components/browser_sync/profile_sync_service.h" |
| 16 #include "components/history/core/browser/history_types.h" | 15 #include "components/history/core/browser/history_types.h" |
| 17 #include "components/sessions/core/session_types.h" | 16 #include "components/sessions/core/session_types.h" |
| 18 #include "components/sync/base/time.h" | 17 #include "components/sync/base/time.h" |
| 19 #include "components/sync/driver/sync_driver_switches.h" | |
| 20 #include "components/sync/test/fake_server/fake_server_verifier.h" | 18 #include "components/sync/test/fake_server/fake_server_verifier.h" |
| 21 #include "components/sync/test/fake_server/sessions_hierarchy.h" | 19 #include "components/sync/test/fake_server/sessions_hierarchy.h" |
| 22 | 20 |
| 23 using fake_server::SessionsHierarchy; | 21 using fake_server::SessionsHierarchy; |
| 24 using sessions_helper::CheckInitialState; | 22 using sessions_helper::CheckInitialState; |
| 25 using sessions_helper::GetLocalWindows; | 23 using sessions_helper::GetLocalWindows; |
| 26 using sessions_helper::GetSessionData; | 24 using sessions_helper::GetSessionData; |
| 27 using sessions_helper::ModelAssociatorHasTabWithUrl; | 25 using sessions_helper::ModelAssociatorHasTabWithUrl; |
| 28 using sessions_helper::OpenTabAndGetLocalWindows; | 26 using sessions_helper::OpenTabAndGetLocalWindows; |
| 29 using sessions_helper::ScopedWindowMap; | 27 using sessions_helper::ScopedWindowMap; |
| 30 using sessions_helper::SessionWindowMap; | 28 using sessions_helper::SessionWindowMap; |
| 31 using sessions_helper::SyncedSessionVector; | 29 using sessions_helper::SyncedSessionVector; |
| 32 using sessions_helper::WaitForTabsToLoad; | 30 using sessions_helper::WaitForTabsToLoad; |
| 33 using sessions_helper::WindowsMatch; | 31 using sessions_helper::WindowsMatch; |
| 34 using typed_urls_helper::GetUrlFromClient; | 32 using typed_urls_helper::GetUrlFromClient; |
| 35 | 33 |
| 36 class SingleClientSessionsSyncTest : public SyncTest { | 34 class SingleClientSessionsSyncTest : public SyncTest { |
| 37 public: | 35 public: |
| 38 SingleClientSessionsSyncTest() : SyncTest(SINGLE_CLIENT) {} | 36 SingleClientSessionsSyncTest() : SyncTest(SINGLE_CLIENT) {} |
| 39 ~SingleClientSessionsSyncTest() override {} | 37 ~SingleClientSessionsSyncTest() override {} |
| 40 | 38 |
| 41 void SetUpCommandLine(base::CommandLine* cl) override { | |
| 42 // This is a hacky override of the switches set in | |
| 43 // SyncTest::SetUpCommandLine() to avoid the switch that speeds up nudge | |
| 44 // delays. CookieJarMismatch asserts exact histogram counts assuming that | |
| 45 // sync is relatively slow, so we preserve that assumption. | |
| 46 if (!cl->HasSwitch(switches::kDisableBackgroundNetworking)) | |
| 47 cl->AppendSwitch(switches::kDisableBackgroundNetworking); | |
| 48 | |
| 49 if (!cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) | |
| 50 cl->AppendSwitch(switches::kSyncShortInitialRetryOverride); | |
| 51 } | |
| 52 | |
| 53 private: | 39 private: |
| 54 DISALLOW_COPY_AND_ASSIGN(SingleClientSessionsSyncTest); | 40 DISALLOW_COPY_AND_ASSIGN(SingleClientSessionsSyncTest); |
| 55 }; | 41 }; |
| 56 | 42 |
| 57 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, Sanity) { | 43 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, Sanity) { |
| 58 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 44 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 59 | 45 |
| 60 ASSERT_TRUE(CheckInitialState(0)); | 46 ASSERT_TRUE(CheckInitialState(0)); |
| 61 | 47 |
| 62 // Add a new session to client 0 and wait for it to sync. | 48 // Add a new session to client 0 and wait for it to sync. |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // Verify the cookie jar mismatch bool is set to false. | 192 // Verify the cookie jar mismatch bool is set to false. |
| 207 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 193 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
| 208 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); | 194 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); |
| 209 | 195 |
| 210 // Verify the histograms were recorded properly. | 196 // Verify the histograms were recorded properly. |
| 211 histogram_tester.ExpectTotalCount("Sync.CookieJarMatchOnNavigation", 2); | 197 histogram_tester.ExpectTotalCount("Sync.CookieJarMatchOnNavigation", 2); |
| 212 histogram_tester.ExpectBucketCount("Sync.CookieJarMatchOnNavigation", true, | 198 histogram_tester.ExpectBucketCount("Sync.CookieJarMatchOnNavigation", true, |
| 213 1); | 199 1); |
| 214 histogram_tester.ExpectUniqueSample("Sync.CookieJarEmptyOnMismatch", true, 1); | 200 histogram_tester.ExpectUniqueSample("Sync.CookieJarEmptyOnMismatch", true, 1); |
| 215 } | 201 } |
| OLD | NEW |