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/sessions/session_tab_helper.h" |
| 9 #include "chrome/browser/sync/sessions/sync_sessions_router_tab_helper.h" |
8 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
9 #include "chrome/browser/sync/test/integration/session_hierarchy_match_checker.h
" | 11 #include "chrome/browser/sync/test/integration/session_hierarchy_match_checker.h
" |
10 #include "chrome/browser/sync/test/integration/sessions_helper.h" | 12 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
11 #include "chrome/browser/sync/test/integration/sync_test.h" | 13 #include "chrome/browser/sync/test/integration/sync_test.h" |
12 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" | 14 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" |
13 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" | 15 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" |
| 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
14 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
15 #include "components/browser_sync/profile_sync_service.h" | 19 #include "components/browser_sync/profile_sync_service.h" |
16 #include "components/history/core/browser/history_types.h" | 20 #include "components/history/core/browser/history_types.h" |
17 #include "components/sessions/core/session_types.h" | 21 #include "components/sessions/core/session_types.h" |
18 #include "components/sync/base/time.h" | 22 #include "components/sync/base/time.h" |
19 #include "components/sync/driver/sync_driver_switches.h" | 23 #include "components/sync/driver/sync_driver_switches.h" |
20 #include "components/sync/test/fake_server/sessions_hierarchy.h" | 24 #include "components/sync/test/fake_server/sessions_hierarchy.h" |
| 25 #include "ui/base/mojo/window_open_disposition.mojom.h" |
21 | 26 |
22 using base::HistogramBase; | 27 using base::HistogramBase; |
23 using base::HistogramSamples; | 28 using base::HistogramSamples; |
24 using base::HistogramTester; | 29 using base::HistogramTester; |
25 using fake_server::SessionsHierarchy; | 30 using fake_server::SessionsHierarchy; |
26 using sessions_helper::CheckInitialState; | 31 using sessions_helper::CheckInitialState; |
27 using sessions_helper::GetLocalWindows; | 32 using sessions_helper::GetLocalWindows; |
28 using sessions_helper::GetSessionData; | 33 using sessions_helper::GetSessionData; |
29 using sessions_helper::ModelAssociatorHasTabWithUrl; | 34 using sessions_helper::ModelAssociatorHasTabWithUrl; |
30 using sessions_helper::MoveTab; | 35 using sessions_helper::MoveTab; |
31 using sessions_helper::NavigateTab; | 36 using sessions_helper::NavigateTab; |
32 using sessions_helper::NavigateTabBack; | 37 using sessions_helper::NavigateTabBack; |
33 using sessions_helper::NavigateTabForward; | 38 using sessions_helper::NavigateTabForward; |
34 using sessions_helper::OpenTab; | 39 using sessions_helper::OpenTab; |
35 using sessions_helper::OpenTabAtIndex; | 40 using sessions_helper::OpenTabAtIndex; |
| 41 using sessions_helper::OpenTabFromSourceIndex; |
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; | |
40 using sessions_helper::WindowsMatch; | 45 using sessions_helper::WindowsMatch; |
41 using typed_urls_helper::GetUrlFromClient; | 46 using typed_urls_helper::GetUrlFromClient; |
42 | 47 |
43 namespace { | 48 namespace { |
44 | 49 |
45 static const char* kURL1 = "data:text/html,<html><title>Test</title></html>"; | 50 static const char* kURL1 = "data:text/html,<html><title>Test</title></html>"; |
46 static const char* kURL2 = "data:text/html,<html><title>Test2</title></html>"; | 51 static const char* kURL2 = "data:text/html,<html><title>Test2</title></html>"; |
47 static const char* kURL3 = "data:text/html,<html><title>Test3</title></html>"; | 52 static const char* kURL3 = "data:text/html,<html><title>Test3</title></html>"; |
48 static const char* kBaseFragmentURL = | 53 static const char* kBaseFragmentURL = |
49 "data:text/html,<html><title>Fragment</title><body></body></html>"; | 54 "data:text/html,<html><title>Fragment</title><body></body></html>"; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 WaitForHierarchyOnServer(SessionsHierarchy( | 321 WaitForHierarchyOnServer(SessionsHierarchy( |
317 {{base_url.spec(), moved_tab_url.spec()}, {new_window_url.spec()}})); | 322 {{base_url.spec(), moved_tab_url.spec()}, {new_window_url.spec()}})); |
318 | 323 |
319 // Move tab 1 in browser 0 to browser 1. | 324 // Move tab 1 in browser 0 to browser 1. |
320 MoveTab(0, 1, 1); | 325 MoveTab(0, 1, 1); |
321 | 326 |
322 WaitForHierarchyOnServer(SessionsHierarchy( | 327 WaitForHierarchyOnServer(SessionsHierarchy( |
323 {{base_url.spec()}, {new_window_url.spec(), moved_tab_url.spec()}})); | 328 {{base_url.spec()}, {new_window_url.spec(), moved_tab_url.spec()}})); |
324 } | 329 } |
325 | 330 |
| 331 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, SourceTabIDSet) { |
| 332 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 333 ASSERT_TRUE(CheckInitialState(0)); |
| 334 |
| 335 GURL base_url = GURL(kURL1); |
| 336 ASSERT_TRUE(OpenTab(0, base_url)); |
| 337 |
| 338 WaitForURLOnServer(base_url); |
| 339 |
| 340 GURL new_tab_url = GURL(kURL2); |
| 341 ASSERT_TRUE(OpenTabFromSourceIndex( |
| 342 0, 0, new_tab_url, WindowOpenDisposition::NEW_FOREGROUND_TAB)); |
| 343 WaitForHierarchyOnServer( |
| 344 SessionsHierarchy({{base_url.spec(), new_tab_url.spec()}})); |
| 345 |
| 346 content::WebContents* original_tab_contents = |
| 347 GetBrowser(0)->tab_strip_model()->GetWebContentsAt(0); |
| 348 content::WebContents* new_tab_contents = |
| 349 GetBrowser(0)->tab_strip_model()->GetWebContentsAt(1); |
| 350 |
| 351 SessionID::id_type source_tab_id = |
| 352 SessionTabHelper::IdForTab(original_tab_contents); |
| 353 sync_sessions::SyncSessionsRouterTabHelper* new_tab_helper = |
| 354 sync_sessions::SyncSessionsRouterTabHelper::FromWebContents( |
| 355 new_tab_contents); |
| 356 EXPECT_EQ(new_tab_helper->source_tab_id(), source_tab_id); |
| 357 } |
| 358 |
326 // crbug.com/689662 | 359 // crbug.com/689662 |
327 #if defined(OS_CHROMEOS) | 360 #if defined(OS_CHROMEOS) |
328 #define MAYBE_CookieJarMismatch DISABLED_CookieJarMismatch | 361 #define MAYBE_CookieJarMismatch DISABLED_CookieJarMismatch |
329 #else | 362 #else |
330 #define MAYBE_CookieJarMismatch CookieJarMismatch | 363 #define MAYBE_CookieJarMismatch CookieJarMismatch |
331 #endif | 364 #endif |
332 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, MAYBE_CookieJarMismatch) { | 365 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, MAYBE_CookieJarMismatch) { |
333 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 366 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
334 | 367 |
335 ASSERT_TRUE(CheckInitialState(0)); | 368 ASSERT_TRUE(CheckInitialState(0)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // Verify the cookie jar mismatch bool is set to false. | 414 // Verify the cookie jar mismatch bool is set to false. |
382 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 415 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
383 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); | 416 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); |
384 | 417 |
385 // Verify the histograms were recorded properly. | 418 // Verify the histograms were recorded properly. |
386 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", | 419 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", |
387 true, 1); | 420 true, 1); |
388 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0); | 421 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0); |
389 } | 422 } |
390 } | 423 } |
OLD | NEW |