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

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

Issue 1062013003: [Sync] Sync the chrome://history page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self review Created 5 years, 8 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/memory/scoped_vector.h" 5 #include "base/memory/scoped_vector.h"
6 #include "chrome/browser/sessions/session_service.h" 6 #include "chrome/browser/sessions/session_service.h"
7 #include "chrome/browser/sync/profile_sync_service.h" 7 #include "chrome/browser/sync/profile_sync_service.h"
8 #include "chrome/browser/sync/test/integration/sessions_helper.h" 8 #include "chrome/browser/sync/test/integration/sessions_helper.h"
9 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" 9 #include "chrome/browser/sync/test/integration/sync_integration_test_util.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/common/url_constants.h"
12 #include "components/history/core/browser/history_types.h" 13 #include "components/history/core/browser/history_types.h"
13 #include "components/sessions/session_types.h" 14 #include "components/sessions/session_types.h"
14 #include "sync/util/time.h" 15 #include "sync/util/time.h"
15 16
16 using sessions_helper::CheckInitialState; 17 using sessions_helper::CheckInitialState;
17 using sessions_helper::GetLocalWindows; 18 using sessions_helper::GetLocalWindows;
18 using sessions_helper::GetSessionData; 19 using sessions_helper::GetSessionData;
20 using sessions_helper::ModelAssociatorHasTabWithUrl;
19 using sessions_helper::OpenTabAndGetLocalWindows; 21 using sessions_helper::OpenTabAndGetLocalWindows;
20 using sessions_helper::ScopedWindowMap; 22 using sessions_helper::ScopedWindowMap;
21 using sessions_helper::SessionWindowMap; 23 using sessions_helper::SessionWindowMap;
22 using sessions_helper::SyncedSessionVector; 24 using sessions_helper::SyncedSessionVector;
25 using sessions_helper::WaitForTabsToLoad;
23 using sessions_helper::WindowsMatch; 26 using sessions_helper::WindowsMatch;
24 using sync_integration_test_util::AwaitCommitActivityCompletion; 27 using sync_integration_test_util::AwaitCommitActivityCompletion;
25 using typed_urls_helper::GetUrlFromClient; 28 using typed_urls_helper::GetUrlFromClient;
26 29
27 class SingleClientSessionsSyncTest : public SyncTest { 30 class SingleClientSessionsSyncTest : public SyncTest {
28 public: 31 public:
29 SingleClientSessionsSyncTest() : SyncTest(SINGLE_CLIENT) {} 32 SingleClientSessionsSyncTest() : SyncTest(SINGLE_CLIENT) {}
30 ~SingleClientSessionsSyncTest() override {} 33 ~SingleClientSessionsSyncTest() override {}
31 34
32 private: 35 private:
33 DISALLOW_COPY_AND_ASSIGN(SingleClientSessionsSyncTest); 36 DISALLOW_COPY_AND_ASSIGN(SingleClientSessionsSyncTest);
34 }; 37 };
35 38
36 // Timeout on Windows, see http://crbug.com/99819 39 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, Sanity) {
37 #if defined(OS_WIN)
38 #define MAYBE_Sanity DISABLED_Sanity
39 #else
40 #define MAYBE_Sanity Sanity
41 #endif
42
43 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, MAYBE_Sanity) {
44 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 40 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
45 41
46 ASSERT_TRUE(CheckInitialState(0)); 42 ASSERT_TRUE(CheckInitialState(0));
47 43
48 // Add a new session to client 0 and wait for it to sync. 44 // Add a new session to client 0 and wait for it to sync.
49 ScopedWindowMap old_windows; 45 ScopedWindowMap old_windows;
50 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, 46 ASSERT_TRUE(OpenTabAndGetLocalWindows(0,
51 GURL("http://127.0.0.1/bubba"), 47 GURL("http://127.0.0.1/bubba"),
52 old_windows.GetMutable())); 48 old_windows.GetMutable()));
53 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); 49 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
54 50
55 // Get foreign session data from client 0. 51 // Get foreign session data from client 0.
56 SyncedSessionVector sessions; 52 SyncedSessionVector sessions;
57 ASSERT_FALSE(GetSessionData(0, &sessions)); 53 ASSERT_FALSE(GetSessionData(0, &sessions));
58 ASSERT_EQ(0U, sessions.size()); 54 ASSERT_EQ(0U, sessions.size());
59 55
60 // Verify client didn't change. 56 // Verify client didn't change.
61 ScopedWindowMap new_windows; 57 ScopedWindowMap new_windows;
62 ASSERT_TRUE(GetLocalWindows(0, new_windows.GetMutable())); 58 ASSERT_TRUE(GetLocalWindows(0, new_windows.GetMutable()));
63 ASSERT_TRUE(WindowsMatch(*old_windows.Get(), *new_windows.Get())); 59 ASSERT_TRUE(WindowsMatch(*old_windows.Get(), *new_windows.Get()));
64 } 60 }
65 61
62 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ChromeHistory) {
63 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
64
65 ASSERT_TRUE(CheckInitialState(0));
66
67 // Add a new session to client 0 and wait for it to sync.
68 ScopedWindowMap old_windows;
69 ASSERT_TRUE(OpenTabAndGetLocalWindows(0,
70 GURL(chrome::kChromeUIHistoryURL),
71 old_windows.GetMutable()));
72 std::vector<GURL> urls;
73 urls.push_back(GURL(chrome::kChromeUIHistoryURL));
74 ASSERT_TRUE(WaitForTabsToLoad(0, urls));
75
76 // Verify the chrome history page synced.
77 ASSERT_TRUE(ModelAssociatorHasTabWithUrl(0,
78 GURL(chrome::kChromeUIHistoryURL)));
79 }
80
66 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, TimestampMatchesHistory) { 81 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, TimestampMatchesHistory) {
67 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 82 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
68 83
69 ASSERT_TRUE(CheckInitialState(0)); 84 ASSERT_TRUE(CheckInitialState(0));
70 85
71 // We want a URL that doesn't 404 and has a non-empty title. 86 // We want a URL that doesn't 404 and has a non-empty title.
72 const GURL url("data:text/html,<html><title>Test</title></html>"); 87 const GURL url("data:text/html,<html><title>Test</title></html>");
73 88
74 ScopedWindowMap windows; 89 ScopedWindowMap windows;
75 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, windows.GetMutable())); 90 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, windows.GetMutable()));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 for (std::vector<sessions::SerializedNavigationEntry>::const_iterator 130 for (std::vector<sessions::SerializedNavigationEntry>::const_iterator
116 it3 = (*it2)->navigations.begin(); 131 it3 = (*it2)->navigations.begin();
117 it3 != (*it2)->navigations.end(); ++it3) { 132 it3 != (*it2)->navigations.end(); ++it3) {
118 EXPECT_EQ(200, it3->http_status_code()); 133 EXPECT_EQ(200, it3->http_status_code());
119 ++found_navigations; 134 ++found_navigations;
120 } 135 }
121 } 136 }
122 } 137 }
123 ASSERT_EQ(1, found_navigations); 138 ASSERT_EQ(1, found_navigations);
124 } 139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698