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/path_service.h" | |
| 6 #include "base/test/histogram_tester.h" | 7 #include "base/test/histogram_tester.h" |
| 7 #include "chrome/browser/sessions/session_service.h" | 8 #include "chrome/browser/sessions/session_service.h" |
| 8 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 9 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
| 10 #include "chrome/browser/sync/test/integration/session_hierarchy_match_checker.h " | |
| 9 #include "chrome/browser/sync/test/integration/sessions_helper.h" | 11 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
| 10 #include "chrome/browser/sync/test/integration/sync_test.h" | 12 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 11 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" | 13 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" |
| 12 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h " | 14 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h " |
| 13 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 15 #include "components/browser_sync/profile_sync_service.h" | 17 #include "components/browser_sync/profile_sync_service.h" |
| 16 #include "components/history/core/browser/history_types.h" | 18 #include "components/history/core/browser/history_types.h" |
| 17 #include "components/sessions/core/session_types.h" | 19 #include "components/sessions/core/session_types.h" |
| 18 #include "components/sync/base/time.h" | 20 #include "components/sync/base/time.h" |
| 19 #include "components/sync/driver/sync_driver_switches.h" | 21 #include "components/sync/driver/sync_driver_switches.h" |
| 20 #include "components/sync/test/fake_server/fake_server_verifier.h" | |
| 21 #include "components/sync/test/fake_server/sessions_hierarchy.h" | 22 #include "components/sync/test/fake_server/sessions_hierarchy.h" |
| 22 | 23 |
| 23 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
| 24 #include "chromeos/chromeos_switches.h" | 25 #include "chromeos/chromeos_switches.h" |
| 25 #endif | 26 #endif |
| 26 | 27 |
| 27 using base::HistogramBase; | 28 using base::HistogramBase; |
| 28 using base::HistogramSamples; | 29 using base::HistogramSamples; |
| 29 using base::HistogramTester; | 30 using base::HistogramTester; |
| 30 using fake_server::SessionsHierarchy; | 31 using fake_server::SessionsHierarchy; |
| 31 using sessions_helper::CheckInitialState; | 32 using sessions_helper::CheckInitialState; |
| 32 using sessions_helper::GetLocalWindows; | 33 using sessions_helper::GetLocalWindows; |
| 33 using sessions_helper::GetSessionData; | 34 using sessions_helper::GetSessionData; |
| 34 using sessions_helper::ModelAssociatorHasTabWithUrl; | 35 using sessions_helper::ModelAssociatorHasTabWithUrl; |
| 35 using sessions_helper::OpenTabAndGetLocalWindows; | 36 using sessions_helper::MoveTab; |
| 37 using sessions_helper::NavigateTab; | |
| 38 using sessions_helper::NavigateTabBack; | |
| 39 using sessions_helper::NavigateTabForward; | |
| 40 using sessions_helper::OpenTab; | |
| 41 using sessions_helper::OpenTabAtIndex; | |
| 36 using sessions_helper::ScopedWindowMap; | 42 using sessions_helper::ScopedWindowMap; |
| 37 using sessions_helper::SessionWindowMap; | 43 using sessions_helper::SessionWindowMap; |
| 38 using sessions_helper::SyncedSessionVector; | 44 using sessions_helper::SyncedSessionVector; |
| 39 using sessions_helper::WaitForTabsToLoad; | 45 using sessions_helper::WaitForTabsToLoad; |
| 40 using sessions_helper::WindowsMatch; | 46 using sessions_helper::WindowsMatch; |
| 41 using typed_urls_helper::GetUrlFromClient; | 47 using typed_urls_helper::GetUrlFromClient; |
| 42 | 48 |
| 43 namespace { | 49 namespace { |
| 44 | 50 |
| 45 void ExpectUniqueSampleGE(const HistogramTester& histogram_tester, | 51 void ExpectUniqueSampleGE(const HistogramTester& histogram_tester, |
| 46 const std::string& name, | 52 const std::string& name, |
| 47 HistogramBase::Sample sample, | 53 HistogramBase::Sample sample, |
| 48 HistogramBase::Count expected_inclusive_lower_bound) { | 54 HistogramBase::Count expected_inclusive_lower_bound) { |
| 49 std::unique_ptr<HistogramSamples> samples = | 55 std::unique_ptr<HistogramSamples> samples = |
| 50 histogram_tester.GetHistogramSamplesSinceCreation(name); | 56 histogram_tester.GetHistogramSamplesSinceCreation(name); |
| 51 int sample_count = samples->GetCount(sample); | 57 int sample_count = samples->GetCount(sample); |
| 52 EXPECT_GE(expected_inclusive_lower_bound, sample_count); | 58 EXPECT_GE(sample_count, expected_inclusive_lower_bound); |
|
skym
2017/03/02 19:56:11
When trying to always put the expected value on th
Patrick Noland
2017/03/02 21:57:44
Acknowledged.
| |
| 53 EXPECT_EQ(sample_count, samples->TotalCount()); | 59 EXPECT_EQ(sample_count, samples->TotalCount()); |
| 54 } | 60 } |
| 55 | 61 |
| 56 } // namespace | 62 } // namespace |
| 57 | 63 |
| 58 class SingleClientSessionsSyncTest : public SyncTest { | 64 class SingleClientSessionsSyncTest : public SyncTest { |
| 59 public: | 65 public: |
| 60 SingleClientSessionsSyncTest() : SyncTest(SINGLE_CLIENT) {} | 66 SingleClientSessionsSyncTest() : SyncTest(SINGLE_CLIENT) {} |
| 61 ~SingleClientSessionsSyncTest() override {} | 67 ~SingleClientSessionsSyncTest() override {} |
| 62 | 68 |
| 63 void SetUpCommandLine(base::CommandLine* cl) override { | 69 void SetUpOnMainThread() override { |
| 64 // This is a hacky override of the switches set in | 70 base::FilePath test_data_dir; |
| 65 // SyncTest::SetUpCommandLine() to avoid the switch that speeds up nudge | 71 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); |
| 66 // delays. CookieJarMismatch asserts exact histogram counts assuming that | 72 embedded_test_server()->ServeFilesFromDirectory(test_data_dir); |
| 67 // sync is relatively slow, so we preserve that assumption. | 73 ASSERT_TRUE(embedded_test_server()->Start()); |
| 68 if (!cl->HasSwitch(switches::kDisableBackgroundNetworking)) | 74 } |
| 69 cl->AppendSwitch(switches::kDisableBackgroundNetworking); | |
| 70 | 75 |
| 71 if (!cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) | 76 void ExpectNavigationChain(const std::vector<GURL>& urls) { |
| 72 cl->AppendSwitch(switches::kSyncShortInitialRetryOverride); | 77 ScopedWindowMap windows; |
| 78 ASSERT_TRUE(GetLocalWindows(0, &windows)); | |
| 79 ASSERT_EQ(windows.begin()->second->tabs.size(), 1u); | |
| 80 sessions::SessionTab* tab = windows.begin()->second->tabs[0].get(); | |
| 73 | 81 |
| 74 #if defined(OS_CHROMEOS) | 82 int index = 0; |
| 75 // kIgnoreUserProfileMappingForTests will let UserManager always return | 83 EXPECT_EQ(urls.size(), tab->navigations.size()); |
| 76 // active user. If this switch is not set, sync test's profile will not | 84 for (auto it = tab->navigations.begin(); it != tab->navigations.end(); |
| 77 // match UserManager's active user, then UserManager won't return active | 85 ++it, ++index) { |
| 78 // user to our tests. | 86 EXPECT_EQ(urls[index], it->virtual_url()); |
| 79 if (!cl->HasSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests)) | 87 } |
| 80 cl->AppendSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests); | 88 } |
| 81 #endif | 89 |
| 90 // Block until the expected hierarchy is recorded on the FakeServer for | |
| 91 // profile 0. This will time out if the hierarchy is never | |
| 92 // recorded. | |
| 93 void WaitForHierarchyOnServer( | |
| 94 const fake_server::SessionsHierarchy& hierarchy) { | |
| 95 SessionHierarchyMatchChecker checker(hierarchy, GetSyncService(0), | |
| 96 GetFakeServer()); | |
| 97 EXPECT_TRUE(checker.Wait()); | |
| 98 } | |
| 99 | |
| 100 // Shortcut to call WaitForHierarchyOnServer for only |url| in a single | |
| 101 // window. | |
| 102 void WaitForURLOnServer(const GURL& url) { | |
| 103 WaitForHierarchyOnServer({{url.spec()}}); | |
| 82 } | 104 } |
| 83 | 105 |
| 84 private: | 106 private: |
| 85 DISALLOW_COPY_AND_ASSIGN(SingleClientSessionsSyncTest); | 107 DISALLOW_COPY_AND_ASSIGN(SingleClientSessionsSyncTest); |
| 86 }; | 108 }; |
| 87 | 109 |
| 88 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, Sanity) { | 110 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, Sanity) { |
| 89 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 111 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 90 | 112 |
| 91 ASSERT_TRUE(CheckInitialState(0)); | 113 ASSERT_TRUE(CheckInitialState(0)); |
| 92 | 114 |
| 93 // Add a new session to client 0 and wait for it to sync. | 115 // Add a new session to client 0 and wait for it to sync. |
| 94 ScopedWindowMap old_windows; | 116 ScopedWindowMap old_windows; |
| 95 GURL url = GURL("http://127.0.0.1/bubba"); | 117 GURL url = GURL("http://127.0.0.1/bubba"); |
| 96 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows)); | 118 ASSERT_TRUE(OpenTab(0, url)); |
| 119 ASSERT_TRUE(GetLocalWindows(0, &old_windows)); | |
| 97 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | 120 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
| 98 | 121 |
| 99 // Get foreign session data from client 0. | 122 // Get foreign session data from client 0. |
| 100 SyncedSessionVector sessions; | 123 SyncedSessionVector sessions; |
| 101 ASSERT_FALSE(GetSessionData(0, &sessions)); | 124 ASSERT_FALSE(GetSessionData(0, &sessions)); |
| 102 ASSERT_EQ(0U, sessions.size()); | 125 ASSERT_EQ(0U, sessions.size()); |
| 103 | 126 |
| 104 // Verify client didn't change. | 127 // Verify client didn't change. |
| 105 ScopedWindowMap new_windows; | 128 ScopedWindowMap new_windows; |
| 106 ASSERT_TRUE(GetLocalWindows(0, &new_windows)); | 129 ASSERT_TRUE(GetLocalWindows(0, &new_windows)); |
| 107 ASSERT_TRUE(WindowsMatch(old_windows, new_windows)); | 130 ASSERT_TRUE(WindowsMatch(old_windows, new_windows)); |
| 108 | 131 |
| 109 fake_server::FakeServerVerifier fake_server_verifier(GetFakeServer()); | 132 WaitForURLOnServer(url); |
| 110 SessionsHierarchy expected_sessions; | |
| 111 expected_sessions.AddWindow(url.spec()); | |
| 112 ASSERT_TRUE(fake_server_verifier.VerifySessions(expected_sessions)); | |
| 113 } | 133 } |
| 114 | 134 |
| 115 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, NoSessions) { | 135 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, NoSessions) { |
| 116 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 136 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 117 | 137 |
| 118 fake_server::FakeServerVerifier fake_server_verifier(GetFakeServer()); | 138 WaitForHierarchyOnServer(SessionsHierarchy()); |
| 119 SessionsHierarchy expected_sessions; | |
| 120 ASSERT_TRUE(fake_server_verifier.VerifySessions(expected_sessions)); | |
| 121 } | 139 } |
| 122 | 140 |
| 123 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ChromeHistory) { | 141 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ChromeHistory) { |
| 124 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 142 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 125 | 143 |
| 126 ASSERT_TRUE(CheckInitialState(0)); | 144 ASSERT_TRUE(CheckInitialState(0)); |
| 127 | 145 |
| 128 // Add a new session to client 0 and wait for it to sync. | 146 ASSERT_TRUE(OpenTab(0, GURL(chrome::kChromeUIHistoryURL))); |
| 129 ScopedWindowMap old_windows; | 147 WaitForURLOnServer(GURL(chrome::kChromeUIHistoryURL)); |
| 130 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(chrome::kChromeUIHistoryURL), | |
| 131 &old_windows)); | |
| 132 std::vector<GURL> urls; | |
| 133 urls.push_back(GURL(chrome::kChromeUIHistoryURL)); | |
| 134 ASSERT_TRUE(WaitForTabsToLoad(0, urls)); | |
| 135 | |
| 136 // Verify the chrome history page synced. | |
| 137 ASSERT_TRUE(ModelAssociatorHasTabWithUrl(0, | |
| 138 GURL(chrome::kChromeUIHistoryURL))); | |
| 139 } | 148 } |
| 140 | 149 |
| 141 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, TimestampMatchesHistory) { | 150 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, TimestampMatchesHistory) { |
| 142 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 151 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 143 | 152 |
| 144 ASSERT_TRUE(CheckInitialState(0)); | 153 ASSERT_TRUE(CheckInitialState(0)); |
| 145 | 154 |
| 146 // We want a URL that doesn't 404 and has a non-empty title. | 155 // We want a URL that doesn't 404 and has a non-empty title. |
| 147 const GURL url("data:text/html,<html><title>Test</title></html>"); | 156 const GURL url("data:text/html,<html><title>Test</title></html>"); |
| 148 | 157 |
| 149 ScopedWindowMap windows; | 158 ScopedWindowMap windows; |
| 150 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &windows)); | 159 ASSERT_TRUE(OpenTab(0, url)); |
| 160 ASSERT_TRUE(GetLocalWindows(0, &windows)); | |
| 151 | 161 |
| 152 int found_navigations = 0; | 162 int found_navigations = 0; |
| 153 for (auto it = windows.begin(); it != windows.end(); ++it) { | 163 for (auto it = windows.begin(); it != windows.end(); ++it) { |
| 154 for (auto it2 = it->second->tabs.begin(); it2 != it->second->tabs.end(); | 164 for (auto it2 = it->second->tabs.begin(); it2 != it->second->tabs.end(); |
| 155 ++it2) { | 165 ++it2) { |
| 156 for (auto it3 = (*it2)->navigations.begin(); | 166 for (auto it3 = (*it2)->navigations.begin(); |
| 157 it3 != (*it2)->navigations.end(); ++it3) { | 167 it3 != (*it2)->navigations.end(); ++it3) { |
| 158 const base::Time timestamp = it3->timestamp(); | 168 const base::Time timestamp = it3->timestamp(); |
| 159 | 169 |
| 160 history::URLRow virtual_row; | 170 history::URLRow virtual_row; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 171 | 181 |
| 172 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ResponseCodeIsPreserved) { | 182 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ResponseCodeIsPreserved) { |
| 173 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 183 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 174 | 184 |
| 175 ASSERT_TRUE(CheckInitialState(0)); | 185 ASSERT_TRUE(CheckInitialState(0)); |
| 176 | 186 |
| 177 // We want a URL that doesn't 404 and has a non-empty title. | 187 // We want a URL that doesn't 404 and has a non-empty title. |
| 178 const GURL url("data:text/html,<html><title>Test</title></html>"); | 188 const GURL url("data:text/html,<html><title>Test</title></html>"); |
| 179 | 189 |
| 180 ScopedWindowMap windows; | 190 ScopedWindowMap windows; |
| 181 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &windows)); | 191 ASSERT_TRUE(OpenTab(0, url)); |
| 192 ASSERT_TRUE(GetLocalWindows(0, &windows)); | |
| 182 | 193 |
| 183 int found_navigations = 0; | 194 int found_navigations = 0; |
| 184 for (auto it = windows.begin(); it != windows.end(); ++it) { | 195 for (auto it = windows.begin(); it != windows.end(); ++it) { |
| 185 for (auto it2 = it->second->tabs.begin(); it2 != it->second->tabs.end(); | 196 for (auto it2 = it->second->tabs.begin(); it2 != it->second->tabs.end(); |
| 186 ++it2) { | 197 ++it2) { |
| 187 for (auto it3 = (*it2)->navigations.begin(); | 198 for (auto it3 = (*it2)->navigations.begin(); |
| 188 it3 != (*it2)->navigations.end(); ++it3) { | 199 it3 != (*it2)->navigations.end(); ++it3) { |
| 189 EXPECT_EQ(200, it3->http_status_code()); | 200 EXPECT_EQ(200, it3->http_status_code()); |
| 190 ++found_navigations; | 201 ++found_navigations; |
| 191 } | 202 } |
| 192 } | 203 } |
| 193 } | 204 } |
| 194 ASSERT_EQ(1, found_navigations); | 205 ASSERT_EQ(1, found_navigations); |
| 195 } | 206 } |
| 196 | 207 |
| 208 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, FragmentURLNavigation) { | |
| 209 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 210 ASSERT_TRUE(CheckInitialState(0)); | |
| 211 | |
| 212 GURL url = embedded_test_server()->GetURL("/fragment.html"); | |
|
skym
2017/03/02 19:56:11
Per our discussion offline, lets use the data: URI
Patrick Noland
2017/03/02 21:57:45
Done.
| |
| 213 ASSERT_TRUE(OpenTab(0, url)); | |
| 214 WaitForURLOnServer(url); | |
| 215 | |
| 216 embedded_test_server(); | |
|
skym
2017/03/02 19:56:11
Should this line be removed?
Patrick Noland
2017/03/02 21:57:44
Done.
| |
| 217 GURL fragment_url = embedded_test_server()->GetURL("/fragment.html#fragment"); | |
| 218 NavigateTab(0, fragment_url); | |
| 219 WaitForURLOnServer(fragment_url); | |
| 220 } | |
| 221 | |
| 222 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, | |
| 223 NavigationChainForwardBack) { | |
| 224 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 225 ASSERT_TRUE(CheckInitialState(0)); | |
| 226 | |
| 227 GURL first_url = GURL("http://127.0.0.1/foobar"); | |
| 228 ASSERT_TRUE(OpenTab(0, first_url)); | |
|
skym
2017/03/02 19:56:11
Since this is apparently flaky, can we completely
Patrick Noland
2017/03/02 21:57:45
Done.
| |
| 229 WaitForURLOnServer(first_url); | |
| 230 | |
| 231 GURL second_url = GURL("http://127.0.0.1/barbaz"); | |
| 232 NavigateTab(0, second_url); | |
| 233 WaitForURLOnServer(second_url); | |
| 234 | |
| 235 NavigateTabBack(0); | |
| 236 WaitForURLOnServer(first_url); | |
| 237 | |
| 238 ExpectNavigationChain({first_url, second_url}); | |
| 239 | |
| 240 NavigateTabForward(0); | |
| 241 WaitForURLOnServer(second_url); | |
| 242 | |
| 243 ExpectNavigationChain({first_url, second_url}); | |
| 244 } | |
| 245 | |
| 246 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, | |
| 247 NavigationChainAlteredDestructively) { | |
| 248 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 249 ASSERT_TRUE(CheckInitialState(0)); | |
| 250 | |
| 251 GURL base_url = GURL("http://127.0.0.1/bubba"); | |
| 252 ASSERT_TRUE(OpenTab(0, base_url)); | |
| 253 WaitForURLOnServer(base_url); | |
| 254 | |
| 255 GURL first_url = GURL("http://127.0.0.1/foobar"); | |
| 256 ASSERT_TRUE(NavigateTab(0, first_url)); | |
| 257 WaitForURLOnServer(first_url); | |
| 258 | |
| 259 // Check that the navigation chain matches the above sequence of {base_url, | |
| 260 // first_url}. | |
| 261 ExpectNavigationChain({base_url, first_url}); | |
| 262 | |
| 263 NavigateTabBack(0); | |
| 264 WaitForURLOnServer(base_url); | |
| 265 | |
| 266 GURL second_url = GURL("http://127.0.0.1/barbaz"); | |
| 267 NavigateTab(0, second_url); | |
| 268 WaitForURLOnServer(second_url); | |
| 269 | |
| 270 NavigateTabBack(0); | |
| 271 WaitForURLOnServer(base_url); | |
| 272 | |
| 273 // Check that the navigation chain contains second_url where first_url was | |
| 274 // before. | |
| 275 ExpectNavigationChain({base_url, second_url}); | |
| 276 } | |
| 277 | |
| 278 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, OpenNewTab) { | |
| 279 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 280 ASSERT_TRUE(CheckInitialState(0)); | |
| 281 | |
| 282 GURL base_url = GURL("http://127.0.0.1/bubba"); | |
| 283 ASSERT_TRUE(OpenTabAtIndex(0, 0, base_url)); | |
| 284 | |
| 285 WaitForURLOnServer(base_url); | |
| 286 | |
| 287 GURL new_tab_url = GURL("http://127.0.0.1/foobar"); | |
| 288 ASSERT_TRUE(OpenTabAtIndex(0, 1, new_tab_url)); | |
| 289 | |
| 290 WaitForHierarchyOnServer( | |
| 291 SessionsHierarchy({{base_url.spec(), new_tab_url.spec()}})); | |
| 292 } | |
| 293 | |
| 294 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, OpenNewWindow) { | |
| 295 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 296 ASSERT_TRUE(CheckInitialState(0)); | |
| 297 | |
| 298 GURL base_url = GURL("http://127.0.0.1/bubba"); | |
| 299 ASSERT_TRUE(OpenTab(0, base_url)); | |
| 300 | |
| 301 WaitForURLOnServer(base_url); | |
| 302 | |
| 303 GURL new_window_url = GURL("http://127.0.0.1/foobar"); | |
| 304 AddBrowser(0); | |
| 305 ASSERT_TRUE(OpenTab(1, new_window_url)); | |
| 306 | |
| 307 WaitForHierarchyOnServer( | |
| 308 SessionsHierarchy({{base_url.spec()}, {new_window_url.spec()}})); | |
| 309 } | |
| 310 | |
| 311 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, TabMovedToOtherWindow) { | |
| 312 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 313 ASSERT_TRUE(CheckInitialState(0)); | |
| 314 | |
| 315 GURL base_url = GURL("http://127.0.0.1/bubba"); | |
| 316 GURL moved_tab_url = GURL("http://127.0.0.1/foobar"); | |
| 317 | |
| 318 ASSERT_TRUE(OpenTab(0, base_url)); | |
| 319 ASSERT_TRUE(OpenTabAtIndex(0, 1, moved_tab_url)); | |
| 320 | |
| 321 GURL new_window_url = GURL("http://127.0.0.1/barbaz"); | |
| 322 AddBrowser(0); | |
| 323 ASSERT_TRUE(OpenTab(1, new_window_url)); | |
| 324 | |
| 325 WaitForHierarchyOnServer(SessionsHierarchy( | |
| 326 {{base_url.spec(), moved_tab_url.spec()}, {new_window_url.spec()}})); | |
| 327 | |
| 328 // Move tab 1 in browser 0 to browser 1. | |
| 329 MoveTab(0, 1, 1); | |
| 330 | |
| 331 WaitForHierarchyOnServer(SessionsHierarchy( | |
| 332 {{base_url.spec()}, {new_window_url.spec(), moved_tab_url.spec()}})); | |
| 333 } | |
| 334 | |
| 197 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, CookieJarMismatch) { | 335 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, CookieJarMismatch) { |
| 198 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 336 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 199 | 337 |
| 200 ASSERT_TRUE(CheckInitialState(0)); | 338 ASSERT_TRUE(CheckInitialState(0)); |
| 201 | 339 |
| 202 ScopedWindowMap old_windows; | 340 ScopedWindowMap old_windows; |
| 203 sync_pb::ClientToServerMessage message; | 341 sync_pb::ClientToServerMessage message; |
| 204 | 342 |
| 205 // The HistogramTester objects are scoped to allow more precise verification. | 343 // The HistogramTester objects are scoped to allow more precise verification. |
| 206 { | 344 { |
| 207 HistogramTester histogram_tester; | 345 HistogramTester histogram_tester; |
| 208 | 346 |
| 209 // Add a new session to client 0 and wait for it to sync. | 347 // Add a new session to client 0 and wait for it to sync. |
| 210 GURL url = GURL("http://127.0.0.1/bubba"); | 348 GURL url = GURL("http://127.0.0.1/bubba"); |
| 211 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows)); | 349 ASSERT_TRUE(OpenTab(0, url)); |
| 212 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); | 350 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); |
|
skym
2017/03/02 19:56:11
Why the change? Reading this code, it isn't clear
Patrick Noland
2017/03/02 21:57:45
WaitForURLOnServer, which was used here previously
skym
2017/03/02 22:59:43
Discussed this offline, I would still prefer the W
Patrick Noland
2017/03/02 23:32:48
Done.
| |
| 213 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | 351 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
| 214 | 352 |
| 215 // The cookie jar mismatch value will be true by default due to | 353 // The cookie jar mismatch value will be true by default due to |
| 216 // the way integration tests trigger signin (which does not involve a normal | 354 // the way integration tests trigger signin (which does not involve a normal |
| 217 // web content signin flow). | 355 // web content signin flow). |
| 218 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 356 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
| 219 ASSERT_TRUE(message.commit().config_params().cookie_jar_mismatch()); | 357 ASSERT_TRUE(message.commit().config_params().cookie_jar_mismatch()); |
| 220 | 358 |
| 221 // It is possible that multiple sync cycles occured during the call to | 359 // It is possible that multiple sync cycles occured during the call to |
| 222 // OpenTabAndGetLocalWindows, which would cause multiple identical samples. | 360 // OpenTab, which would cause multiple identical samples. |
| 223 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", | 361 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", |
| 224 false, 1); | 362 false, 1); |
| 225 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarEmptyOnMismatch", | 363 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarEmptyOnMismatch", |
| 226 true, 1); | 364 true, 1); |
| 227 | 365 |
| 228 // Trigger a cookie jar change (user signing in to content area). | 366 // Trigger a cookie jar change (user signing in to content area). |
| 229 gaia::ListedAccount signed_in_account; | 367 gaia::ListedAccount signed_in_account; |
| 230 signed_in_account.id = | 368 signed_in_account.id = |
| 231 GetClient(0)->service()->signin()->GetAuthenticatedAccountId(); | 369 GetClient(0)->service()->signin()->GetAuthenticatedAccountId(); |
| 232 std::vector<gaia::ListedAccount> accounts; | 370 std::vector<gaia::ListedAccount> accounts; |
| 233 std::vector<gaia::ListedAccount> signed_out_accounts; | 371 std::vector<gaia::ListedAccount> signed_out_accounts; |
| 234 accounts.push_back(signed_in_account); | 372 accounts.push_back(signed_in_account); |
| 235 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); | 373 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); |
| 236 GetClient(0)->service()->OnGaiaAccountsInCookieUpdated( | 374 GetClient(0)->service()->OnGaiaAccountsInCookieUpdated( |
| 237 accounts, signed_out_accounts, error); | 375 accounts, signed_out_accounts, error); |
| 238 } | 376 } |
| 239 | 377 |
| 240 { | 378 { |
| 241 HistogramTester histogram_tester; | 379 HistogramTester histogram_tester; |
| 242 | 380 |
| 243 // Trigger a sync and wait for it. | 381 // Trigger a sync and wait for it. |
| 244 GURL url = GURL("http://127.0.0.1/bubba2"); | 382 GURL url = GURL("http://127.0.0.1/bubba2"); |
| 245 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows)); | 383 ASSERT_TRUE(OpenTab(0, url)); |
| 384 ASSERT_TRUE(GetLocalWindows(0, &old_windows)); | |
| 246 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); | 385 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); |
| 247 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | 386 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
| 248 | 387 |
| 249 // Verify the cookie jar mismatch bool is set to false. | 388 // Verify the cookie jar mismatch bool is set to false. |
| 250 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 389 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
| 251 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); | 390 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); |
| 252 | 391 |
| 253 // Verify the histograms were recorded properly. | 392 // Verify the histograms were recorded properly. |
| 254 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", | 393 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", |
| 255 true, 1); | 394 true, 1); |
| 256 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0); | 395 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0); |
| 257 } | 396 } |
| 258 } | 397 } |
| OLD | NEW |