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

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

Issue 7981006: [Sync] use base::Time in sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linux compile errors Created 9 years, 3 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 | 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 "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/sessions/session_types.h" 10 #include "chrome/browser/sessions/session_types.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 window_s.add_tab(0); 82 window_s.add_tab(0);
83 window_s.set_browser_type(sync_pb::SessionWindow_BrowserType_TYPE_TABBED); 83 window_s.set_browser_type(sync_pb::SessionWindow_BrowserType_TYPE_TABBED);
84 window_s.set_selected_tab_index(1); 84 window_s.set_selected_tab_index(1);
85 85
86 std::string tag = "tag"; 86 std::string tag = "tag";
87 SyncedSessionTracker tracker; 87 SyncedSessionTracker tracker;
88 SyncedSession* session = tracker.GetSession(tag); 88 SyncedSession* session = tracker.GetSession(tag);
89 SessionWindow* win = new SessionWindow(); 89 SessionWindow* win = new SessionWindow();
90 session->windows.push_back(win); 90 session->windows.push_back(win);
91 SessionModelAssociator::PopulateSessionWindowFromSpecifics( 91 SessionModelAssociator::PopulateSessionWindowFromSpecifics(
92 tag, window_s, 0, win, &tracker); 92 tag, window_s, base::Time(), win, &tracker);
93 ASSERT_EQ(1U, win->tabs.size()); 93 ASSERT_EQ(1U, win->tabs.size());
94 ASSERT_EQ(1, win->selected_tab_index); 94 ASSERT_EQ(1, win->selected_tab_index);
95 ASSERT_EQ(1, win->type); 95 ASSERT_EQ(1, win->type);
96 ASSERT_EQ(1U, tracker.num_synced_sessions()); 96 ASSERT_EQ(1U, tracker.num_synced_sessions());
97 ASSERT_EQ(1U, tracker.num_synced_tabs(std::string("tag"))); 97 ASSERT_EQ(1U, tracker.num_synced_tabs(std::string("tag")));
98 98
99 // We do this so that when the destructor for the tracker is called, it will 99 // We do this so that when the destructor for the tracker is called, it will
100 // be able to delete the session, window, and tab. We can't delete these 100 // be able to delete the session, window, and tab. We can't delete these
101 // ourselves, otherwise we would run into double free errors when the 101 // ourselves, otherwise we would run into double free errors when the
102 // destructor was invoked (the true argument tells the tracker the tab 102 // destructor was invoked (the true argument tells the tracker the tab
103 // is now associated with a window). 103 // is now associated with a window).
104 ASSERT_TRUE(tracker.GetSessionTab(tag, 0, true)); 104 ASSERT_TRUE(tracker.GetSessionTab(tag, 0, true));
105 } 105 }
106 106
107 TEST_F(SessionModelAssociatorTest, PopulateSessionTab) { 107 TEST_F(SessionModelAssociatorTest, PopulateSessionTab) {
108 sync_pb::SessionTab tab_s; 108 sync_pb::SessionTab tab_s;
109 tab_s.set_tab_visual_index(13); 109 tab_s.set_tab_visual_index(13);
110 tab_s.set_current_navigation_index(3); 110 tab_s.set_current_navigation_index(3);
111 tab_s.set_pinned(true); 111 tab_s.set_pinned(true);
112 tab_s.set_extension_app_id("app_id"); 112 tab_s.set_extension_app_id("app_id");
113 sync_pb::TabNavigation* navigation = tab_s.add_navigation(); 113 sync_pb::TabNavigation* navigation = tab_s.add_navigation();
114 navigation->set_index(12); 114 navigation->set_index(12);
115 navigation->set_virtual_url("http://foo/1"); 115 navigation->set_virtual_url("http://foo/1");
116 navigation->set_referrer("referrer"); 116 navigation->set_referrer("referrer");
117 navigation->set_title("title"); 117 navigation->set_title("title");
118 navigation->set_page_transition(sync_pb::TabNavigation_PageTransition_TYPED); 118 navigation->set_page_transition(sync_pb::TabNavigation_PageTransition_TYPED);
119 119
120 SessionTab tab; 120 SessionTab tab;
121 SessionModelAssociator::PopulateSessionTabFromSpecifics(tab_s, 0, &tab); 121 SessionModelAssociator::PopulateSessionTabFromSpecifics(
122 tab_s, base::Time(), &tab);
122 ASSERT_EQ(13, tab.tab_visual_index); 123 ASSERT_EQ(13, tab.tab_visual_index);
123 ASSERT_EQ(3, tab.current_navigation_index); 124 ASSERT_EQ(3, tab.current_navigation_index);
124 ASSERT_TRUE(tab.pinned); 125 ASSERT_TRUE(tab.pinned);
125 ASSERT_EQ("app_id", tab.extension_app_id); 126 ASSERT_EQ("app_id", tab.extension_app_id);
126 ASSERT_EQ(12, tab.navigations[0].index()); 127 ASSERT_EQ(12, tab.navigations[0].index());
127 ASSERT_EQ(GURL("referrer"), tab.navigations[0].referrer()); 128 ASSERT_EQ(GURL("referrer"), tab.navigations[0].referrer());
128 ASSERT_EQ(string16(ASCIIToUTF16("title")), tab.navigations[0].title()); 129 ASSERT_EQ(string16(ASCIIToUTF16("title")), tab.navigations[0].title());
129 ASSERT_EQ(PageTransition::TYPED, tab.navigations[0].transition()); 130 ASSERT_EQ(PageTransition::TYPED, tab.navigations[0].transition());
130 ASSERT_EQ(GURL("http://foo/1"), tab.navigations[0].virtual_url()); 131 ASSERT_EQ(GURL("http://foo/1"), tab.navigations[0].virtual_url());
131 } 132 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // The test is somewhat silly, and just verifies that we return a hardware 197 // The test is somewhat silly, and just verifies that we return a hardware
197 // model name. 198 // model name.
198 TEST_F(SessionModelAssociatorTest, GetHardwareModelName) { 199 TEST_F(SessionModelAssociatorTest, GetHardwareModelName) {
199 std::string hardware_model = SessionModelAssociator::GetHardwareModelName(); 200 std::string hardware_model = SessionModelAssociator::GetHardwareModelName();
200 EXPECT_TRUE(!hardware_model.empty()); 201 EXPECT_TRUE(!hardware_model.empty());
201 } 202 }
202 #endif 203 #endif
203 204
204 205
205 } // namespace browser_sync 206 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/session_model_associator.cc ('k') | chrome/browser/sync/internal_api/base_node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698