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

Side by Side Diff: chrome/browser/sync/glue/session_model_associator_unittest.cc

Issue 8806011: Make NavigationEntry and friends use content::Referrer instead of plain URLs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/sessions/session_types.h" 9 #include "chrome/browser/sessions/session_types.h"
10 #include "chrome/browser/sync/glue/session_model_associator.h" 10 #include "chrome/browser/sync/glue/session_model_associator.h"
11 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "content/public/common/page_transition_types.h" 12 #include "content/public/common/page_transition_types.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace browser_sync { 15 namespace browser_sync {
16 16
17 typedef testing::Test SessionModelAssociatorTest; 17 typedef testing::Test SessionModelAssociatorTest;
18 18
19 TEST_F(SessionModelAssociatorTest, SessionWindowHasNoTabsToSync) { 19 TEST_F(SessionModelAssociatorTest, SessionWindowHasNoTabsToSync) {
20 SessionWindow win; 20 SessionWindow win;
21 ASSERT_TRUE(SessionWindowHasNoTabsToSync(win)); 21 ASSERT_TRUE(SessionWindowHasNoTabsToSync(win));
22 scoped_ptr<SessionTab> tab(new SessionTab()); 22 scoped_ptr<SessionTab> tab(new SessionTab());
23 win.tabs.push_back(tab.release()); 23 win.tabs.push_back(tab.release());
24 ASSERT_TRUE(SessionWindowHasNoTabsToSync(win)); 24 ASSERT_TRUE(SessionWindowHasNoTabsToSync(win));
25 TabNavigation nav(0, GURL("about:bubba"), GURL("about:referrer"), 25 TabNavigation nav(0, GURL("about:bubba"),
26 content::Referrer(GURL("about:referrer"),
27 WebKit::WebReferrerPolicyDefault),
26 string16(ASCIIToUTF16("title")), 28 string16(ASCIIToUTF16("title")),
27 std::string("state"), content::PageTransitionFromInt(0)); 29 std::string("state"), content::PageTransitionFromInt(0));
28 win.tabs[0]->navigations.push_back(nav); 30 win.tabs[0]->navigations.push_back(nav);
29 ASSERT_FALSE(SessionWindowHasNoTabsToSync(win)); 31 ASSERT_FALSE(SessionWindowHasNoTabsToSync(win));
30 } 32 }
31 33
32 TEST_F(SessionModelAssociatorTest, IsValidSessionTab) { 34 TEST_F(SessionModelAssociatorTest, IsValidSessionTab) {
33 SessionTab tab; 35 SessionTab tab;
34 ASSERT_FALSE(IsValidSessionTab(tab)); 36 ASSERT_FALSE(IsValidSessionTab(tab));
35 TabNavigation nav(0, GURL(chrome::kChromeUINewTabURL), 37 TabNavigation nav(0, GURL(chrome::kChromeUINewTabURL),
36 GURL("about:referrer"), 38 content::Referrer(GURL("about:referrer"),
39 WebKit::WebReferrerPolicyDefault),
37 string16(ASCIIToUTF16("title")), 40 string16(ASCIIToUTF16("title")),
38 std::string("state"), content::PageTransitionFromInt(0)); 41 std::string("state"), content::PageTransitionFromInt(0));
39 tab.navigations.push_back(nav); 42 tab.navigations.push_back(nav);
40 // NewTab does not count as valid if it's the only navigation. 43 // NewTab does not count as valid if it's the only navigation.
41 ASSERT_FALSE(IsValidSessionTab(tab)); 44 ASSERT_FALSE(IsValidSessionTab(tab));
42 TabNavigation nav2(0, GURL("about:bubba"), 45 TabNavigation nav2(0, GURL("about:bubba"),
43 GURL("about:referrer"), 46 content::Referrer(GURL("about:referrer"),
47 WebKit::WebReferrerPolicyDefault),
44 string16(ASCIIToUTF16("title")), 48 string16(ASCIIToUTF16("title")),
45 std::string("state"), content::PageTransitionFromInt(0)); 49 std::string("state"), content::PageTransitionFromInt(0));
46 tab.navigations.push_back(nav2); 50 tab.navigations.push_back(nav2);
47 // Once there's another navigation, the tab is valid. 51 // Once there's another navigation, the tab is valid.
48 ASSERT_TRUE(IsValidSessionTab(tab)); 52 ASSERT_TRUE(IsValidSessionTab(tab));
49 } 53 }
50 54
51 TEST_F(SessionModelAssociatorTest, IsValidSessionTabIgnoresFragmentForNtp) { 55 TEST_F(SessionModelAssociatorTest, IsValidSessionTabIgnoresFragmentForNtp) {
52 SessionTab tab; 56 SessionTab tab;
53 ASSERT_FALSE(IsValidSessionTab(tab)); 57 ASSERT_FALSE(IsValidSessionTab(tab));
54 TabNavigation nav(0, GURL(std::string(chrome::kChromeUINewTabURL) + 58 TabNavigation nav(0, GURL(std::string(chrome::kChromeUINewTabURL) +
55 "#bookmarks"), 59 "#bookmarks"),
56 GURL("about:referrer"), 60 content::Referrer(GURL("about:referrer"),
61 WebKit::WebReferrerPolicyDefault),
57 string16(ASCIIToUTF16("title")), 62 string16(ASCIIToUTF16("title")),
58 std::string("state"), content::PageTransitionFromInt(0)); 63 std::string("state"), content::PageTransitionFromInt(0));
59 tab.navigations.push_back(nav); 64 tab.navigations.push_back(nav);
60 // NewTab does not count as valid if it's the only navigation. 65 // NewTab does not count as valid if it's the only navigation.
61 ASSERT_FALSE(IsValidSessionTab(tab)); 66 ASSERT_FALSE(IsValidSessionTab(tab));
62 } 67 }
63 68
64 TEST_F(SessionModelAssociatorTest, PopulateSessionHeader) { 69 TEST_F(SessionModelAssociatorTest, PopulateSessionHeader) {
65 sync_pb::SessionHeader header_s; 70 sync_pb::SessionHeader header_s;
66 header_s.set_client_name("Client 1"); 71 header_s.set_client_name("Client 1");
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 SessionTab tab; 116 SessionTab tab;
112 tab.tab_id.set_id(5); // Expected to be set by the SyncedSessionTracker. 117 tab.tab_id.set_id(5); // Expected to be set by the SyncedSessionTracker.
113 SessionModelAssociator::PopulateSessionTabFromSpecifics( 118 SessionModelAssociator::PopulateSessionTabFromSpecifics(
114 tab_s, base::Time(), &tab); 119 tab_s, base::Time(), &tab);
115 ASSERT_EQ(5, tab.tab_id.id()); 120 ASSERT_EQ(5, tab.tab_id.id());
116 ASSERT_EQ(13, tab.tab_visual_index); 121 ASSERT_EQ(13, tab.tab_visual_index);
117 ASSERT_EQ(3, tab.current_navigation_index); 122 ASSERT_EQ(3, tab.current_navigation_index);
118 ASSERT_TRUE(tab.pinned); 123 ASSERT_TRUE(tab.pinned);
119 ASSERT_EQ("app_id", tab.extension_app_id); 124 ASSERT_EQ("app_id", tab.extension_app_id);
120 ASSERT_EQ(12, tab.navigations[0].index()); 125 ASSERT_EQ(12, tab.navigations[0].index());
121 ASSERT_EQ(GURL("referrer"), tab.navigations[0].referrer()); 126 ASSERT_EQ(GURL("referrer"), tab.navigations[0].referrer().url);
122 ASSERT_EQ(string16(ASCIIToUTF16("title")), tab.navigations[0].title()); 127 ASSERT_EQ(string16(ASCIIToUTF16("title")), tab.navigations[0].title());
123 ASSERT_EQ(content::PAGE_TRANSITION_TYPED, tab.navigations[0].transition()); 128 ASSERT_EQ(content::PAGE_TRANSITION_TYPED, tab.navigations[0].transition());
124 ASSERT_EQ(GURL("http://foo/1"), tab.navigations[0].virtual_url()); 129 ASSERT_EQ(GURL("http://foo/1"), tab.navigations[0].virtual_url());
125 } 130 }
126 131
127 TEST_F(SessionModelAssociatorTest, TabNodePool) { 132 TEST_F(SessionModelAssociatorTest, TabNodePool) {
128 SessionModelAssociator::TabNodePool pool(NULL); 133 SessionModelAssociator::TabNodePool pool(NULL);
129 pool.set_machine_tag("tag"); 134 pool.set_machine_tag("tag");
130 ASSERT_TRUE(pool.empty()); 135 ASSERT_TRUE(pool.empty());
131 ASSERT_TRUE(pool.full()); 136 ASSERT_TRUE(pool.full());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 ASSERT_FALSE(pool.empty()); 171 ASSERT_FALSE(pool.empty());
167 ASSERT_TRUE(pool.full()); 172 ASSERT_TRUE(pool.full());
168 ASSERT_EQ(2U, pool.capacity()); 173 ASSERT_EQ(2U, pool.capacity());
169 pool.clear(); 174 pool.clear();
170 ASSERT_TRUE(pool.empty()); 175 ASSERT_TRUE(pool.empty());
171 ASSERT_TRUE(pool.full()); 176 ASSERT_TRUE(pool.full());
172 ASSERT_EQ(0U, pool.capacity()); 177 ASSERT_EQ(0U, pool.capacity());
173 } 178 }
174 179
175 } // namespace browser_sync 180 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/session_model_associator.cc ('k') | chrome/browser/sync/glue/synced_session_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698