Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc

Issue 2753753005: [sync] WebContentsObserver based sessions notifications (Closed)
Patch Set: use base:MakeUnique, alphabetize Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/test/histogram_tester.h" 7 #include "base/test/histogram_tester.h"
8 #include "chrome/browser/sessions/session_service.h" 8 #include "chrome/browser/sessions/session_service.h"
9 #include "chrome/browser/sessions/session_tab_helper.h"
10 #include "chrome/browser/sync/sessions/sync_sessions_router_tab_helper.h"
9 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 11 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
10 #include "chrome/browser/sync/test/integration/session_hierarchy_match_checker.h " 12 #include "chrome/browser/sync/test/integration/session_hierarchy_match_checker.h "
11 #include "chrome/browser/sync/test/integration/sessions_helper.h" 13 #include "chrome/browser/sync/test/integration/sessions_helper.h"
12 #include "chrome/browser/sync/test/integration/sync_test.h" 14 #include "chrome/browser/sync/test/integration/sync_test.h"
13 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" 15 #include "chrome/browser/sync/test/integration/typed_urls_helper.h"
14 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h " 16 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h "
17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
16 #include "components/browser_sync/profile_sync_service.h" 20 #include "components/browser_sync/profile_sync_service.h"
17 #include "components/history/core/browser/history_types.h" 21 #include "components/history/core/browser/history_types.h"
18 #include "components/sessions/core/session_types.h" 22 #include "components/sessions/core/session_types.h"
19 #include "components/sync/base/time.h" 23 #include "components/sync/base/time.h"
20 #include "components/sync/driver/sync_driver_switches.h" 24 #include "components/sync/driver/sync_driver_switches.h"
21 #include "components/sync/test/fake_server/sessions_hierarchy.h" 25 #include "components/sync/test/fake_server/sessions_hierarchy.h"
26 #include "ui/base/mojo/window_open_disposition.mojom.h"
22 27
23 using base::HistogramBase; 28 using base::HistogramBase;
24 using base::HistogramSamples; 29 using base::HistogramSamples;
25 using base::HistogramTester; 30 using base::HistogramTester;
26 using fake_server::SessionsHierarchy; 31 using fake_server::SessionsHierarchy;
27 using sessions_helper::CheckInitialState; 32 using sessions_helper::CheckInitialState;
28 using sessions_helper::GetLocalWindows; 33 using sessions_helper::GetLocalWindows;
29 using sessions_helper::GetSessionData; 34 using sessions_helper::GetSessionData;
30 using sessions_helper::ModelAssociatorHasTabWithUrl; 35 using sessions_helper::SessionsSyncManagerHasTabWithURL;
31 using sessions_helper::MoveTab; 36 using sessions_helper::MoveTab;
32 using sessions_helper::NavigateTab; 37 using sessions_helper::NavigateTab;
33 using sessions_helper::NavigateTabBack; 38 using sessions_helper::NavigateTabBack;
34 using sessions_helper::NavigateTabForward; 39 using sessions_helper::NavigateTabForward;
35 using sessions_helper::OpenTab; 40 using sessions_helper::OpenTab;
36 using sessions_helper::OpenTabAtIndex; 41 using sessions_helper::OpenTabAtIndex;
42 using sessions_helper::OpenTabFromSourceIndex;
37 using sessions_helper::ScopedWindowMap; 43 using sessions_helper::ScopedWindowMap;
38 using sessions_helper::SessionWindowMap; 44 using sessions_helper::SessionWindowMap;
39 using sessions_helper::SyncedSessionVector; 45 using sessions_helper::SyncedSessionVector;
40 using sessions_helper::WaitForTabsToLoad;
41 using sessions_helper::WindowsMatch; 46 using sessions_helper::WindowsMatch;
42 using typed_urls_helper::GetUrlFromClient; 47 using typed_urls_helper::GetUrlFromClient;
43 48
44 namespace { 49 namespace {
45 50
46 static const char* kURL1 = "data:text/html,<html><title>Test</title></html>"; 51 static const char* kURL1 = "data:text/html,<html><title>Test</title></html>";
47 static const char* kURL2 = "data:text/html,<html><title>Test2</title></html>"; 52 static const char* kURL2 = "data:text/html,<html><title>Test2</title></html>";
48 static const char* kURL3 = "data:text/html,<html><title>Test3</title></html>"; 53 static const char* kURL3 = "data:text/html,<html><title>Test3</title></html>";
49 static const char* kBaseFragmentURL = 54 static const char* kBaseFragmentURL =
50 "data:text/html,<html><title>Fragment</title><body></body></html>"; 55 "data:text/html,<html><title>Fragment</title><body></body></html>";
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 WaitForHierarchyOnServer(SessionsHierarchy( 322 WaitForHierarchyOnServer(SessionsHierarchy(
318 {{base_url.spec(), moved_tab_url.spec()}, {new_window_url.spec()}})); 323 {{base_url.spec(), moved_tab_url.spec()}, {new_window_url.spec()}}));
319 324
320 // Move tab 1 in browser 0 to browser 1. 325 // Move tab 1 in browser 0 to browser 1.
321 MoveTab(0, 1, 1); 326 MoveTab(0, 1, 1);
322 327
323 WaitForHierarchyOnServer(SessionsHierarchy( 328 WaitForHierarchyOnServer(SessionsHierarchy(
324 {{base_url.spec()}, {new_window_url.spec(), moved_tab_url.spec()}})); 329 {{base_url.spec()}, {new_window_url.spec(), moved_tab_url.spec()}}));
325 } 330 }
326 331
332 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, SourceTabIDSet) {
333 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
334 ASSERT_TRUE(CheckInitialState(0));
335
336 GURL base_url = GURL(kURL1);
337 ASSERT_TRUE(OpenTab(0, base_url));
338
339 WaitForURLOnServer(base_url);
340
341 GURL new_tab_url = GURL(kURL2);
342 ASSERT_TRUE(OpenTabFromSourceIndex(
343 0, 0, new_tab_url, WindowOpenDisposition::NEW_FOREGROUND_TAB));
344 WaitForHierarchyOnServer(
345 SessionsHierarchy({{base_url.spec(), new_tab_url.spec()}}));
346
347 content::WebContents* original_tab_contents =
348 GetBrowser(0)->tab_strip_model()->GetWebContentsAt(0);
349 content::WebContents* new_tab_contents =
350 GetBrowser(0)->tab_strip_model()->GetWebContentsAt(1);
351
352 SessionID::id_type source_tab_id =
353 SessionTabHelper::IdForTab(original_tab_contents);
354 sync_sessions::SyncSessionsRouterTabHelper* new_tab_helper =
355 sync_sessions::SyncSessionsRouterTabHelper::FromWebContents(
356 new_tab_contents);
357 EXPECT_EQ(new_tab_helper->source_tab_id(), source_tab_id);
358 }
359
327 // crbug.com/689662 360 // crbug.com/689662
328 #if defined(OS_CHROMEOS) 361 #if defined(OS_CHROMEOS)
329 #define MAYBE_CookieJarMismatch DISABLED_CookieJarMismatch 362 #define MAYBE_CookieJarMismatch DISABLED_CookieJarMismatch
330 #else 363 #else
331 #define MAYBE_CookieJarMismatch CookieJarMismatch 364 #define MAYBE_CookieJarMismatch CookieJarMismatch
332 #endif 365 #endif
333 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, MAYBE_CookieJarMismatch) { 366 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, MAYBE_CookieJarMismatch) {
334 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 367 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
335 368
336 ASSERT_TRUE(CheckInitialState(0)); 369 ASSERT_TRUE(CheckInitialState(0));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 // Verify the cookie jar mismatch bool is set to false. 422 // Verify the cookie jar mismatch bool is set to false.
390 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); 423 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message));
391 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); 424 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch());
392 425
393 // Verify the histograms were recorded properly. 426 // Verify the histograms were recorded properly.
394 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", 427 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation",
395 true, 1); 428 true, 1);
396 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0); 429 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0);
397 } 430 }
398 } 431 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698