Chromium Code Reviews| 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" | |
| 13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 14 #include "components/browser_sync/profile_sync_service.h" | 15 #include "components/browser_sync/profile_sync_service.h" |
| 15 #include "components/history/core/browser/history_types.h" | 16 #include "components/history/core/browser/history_types.h" |
| 16 #include "components/sessions/core/session_types.h" | 17 #include "components/sessions/core/session_types.h" |
| 17 #include "components/sync/base/time.h" | 18 #include "components/sync/base/time.h" |
| 19 #include "components/sync/driver/sync_driver_switches.h" | |
| 18 #include "components/sync/test/fake_server/fake_server_verifier.h" | 20 #include "components/sync/test/fake_server/fake_server_verifier.h" |
| 19 #include "components/sync/test/fake_server/sessions_hierarchy.h" | 21 #include "components/sync/test/fake_server/sessions_hierarchy.h" |
| 20 | 22 |
| 21 using fake_server::SessionsHierarchy; | 23 using fake_server::SessionsHierarchy; |
| 22 using sessions_helper::CheckInitialState; | 24 using sessions_helper::CheckInitialState; |
| 23 using sessions_helper::GetLocalWindows; | 25 using sessions_helper::GetLocalWindows; |
| 24 using sessions_helper::GetSessionData; | 26 using sessions_helper::GetSessionData; |
| 25 using sessions_helper::ModelAssociatorHasTabWithUrl; | 27 using sessions_helper::ModelAssociatorHasTabWithUrl; |
| 26 using sessions_helper::OpenTabAndGetLocalWindows; | 28 using sessions_helper::OpenTabAndGetLocalWindows; |
| 27 using sessions_helper::ScopedWindowMap; | 29 using sessions_helper::ScopedWindowMap; |
| 28 using sessions_helper::SessionWindowMap; | 30 using sessions_helper::SessionWindowMap; |
| 29 using sessions_helper::SyncedSessionVector; | 31 using sessions_helper::SyncedSessionVector; |
| 30 using sessions_helper::WaitForTabsToLoad; | 32 using sessions_helper::WaitForTabsToLoad; |
| 31 using sessions_helper::WindowsMatch; | 33 using sessions_helper::WindowsMatch; |
| 32 using typed_urls_helper::GetUrlFromClient; | 34 using typed_urls_helper::GetUrlFromClient; |
| 33 | 35 |
| 34 class SingleClientSessionsSyncTest : public SyncTest { | 36 class SingleClientSessionsSyncTest : public SyncTest { |
| 35 public: | 37 public: |
| 36 SingleClientSessionsSyncTest() : SyncTest(SINGLE_CLIENT) {} | 38 SingleClientSessionsSyncTest() : SyncTest(SINGLE_CLIENT) {} |
| 37 ~SingleClientSessionsSyncTest() override {} | 39 ~SingleClientSessionsSyncTest() override {} |
| 38 | 40 |
| 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 | |
|
Nicolas Zea
2016/11/09 00:35:13
Hmm, what's the issue with CookieJarMismatch? Idea
Patrick Noland
2016/11/10 22:13:00
SessionsHelper waits for a title to load before de
| |
| 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 | |
| 39 private: | 53 private: |
| 40 DISALLOW_COPY_AND_ASSIGN(SingleClientSessionsSyncTest); | 54 DISALLOW_COPY_AND_ASSIGN(SingleClientSessionsSyncTest); |
| 41 }; | 55 }; |
| 42 | 56 |
| 43 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, Sanity) { | 57 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, Sanity) { |
| 44 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 58 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 45 | 59 |
| 46 ASSERT_TRUE(CheckInitialState(0)); | 60 ASSERT_TRUE(CheckInitialState(0)); |
| 47 | 61 |
| 48 // Add a new session to client 0 and wait for it to sync. | 62 // 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... | |
| 192 // Verify the cookie jar mismatch bool is set to false. | 206 // Verify the cookie jar mismatch bool is set to false. |
| 193 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 207 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
| 194 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); | 208 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); |
| 195 | 209 |
| 196 // Verify the histograms were recorded properly. | 210 // Verify the histograms were recorded properly. |
| 197 histogram_tester.ExpectTotalCount("Sync.CookieJarMatchOnNavigation", 2); | 211 histogram_tester.ExpectTotalCount("Sync.CookieJarMatchOnNavigation", 2); |
| 198 histogram_tester.ExpectBucketCount("Sync.CookieJarMatchOnNavigation", true, | 212 histogram_tester.ExpectBucketCount("Sync.CookieJarMatchOnNavigation", true, |
| 199 1); | 213 1); |
| 200 histogram_tester.ExpectUniqueSample("Sync.CookieJarEmptyOnMismatch", true, 1); | 214 histogram_tester.ExpectUniqueSample("Sync.CookieJarEmptyOnMismatch", true, 1); |
| 201 } | 215 } |
| OLD | NEW |