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

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

Issue 7740055: Set user-visible machine names and devices types for synced sessions. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Set device_type for SessionHeader 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 ASSERT_FALSE(SessionModelAssociator::IsValidSessionTab(tab)); 44 ASSERT_FALSE(SessionModelAssociator::IsValidSessionTab(tab));
45 TabNavigation nav2(0, GURL("about:bubba"), 45 TabNavigation nav2(0, GURL("about:bubba"),
46 GURL("about:referrer"), 46 GURL("about:referrer"),
47 string16(ASCIIToUTF16("title")), 47 string16(ASCIIToUTF16("title")),
48 std::string("state"), 0U); 48 std::string("state"), 0U);
49 tab.navigations.push_back(nav2); 49 tab.navigations.push_back(nav2);
50 // Once there's another navigation, the tab is valid. 50 // Once there's another navigation, the tab is valid.
51 ASSERT_TRUE(SessionModelAssociator::IsValidSessionTab(tab)); 51 ASSERT_TRUE(SessionModelAssociator::IsValidSessionTab(tab));
52 } 52 }
53 53
54 TEST_F(SessionModelAssociatorTest, PopulateSessionHeader) {
55 sync_pb::SessionHeader header_s;
56 header_s.set_client_name("Client 1");
57 header_s.set_device_type(sync_pb::SessionHeader_DeviceType_TYPE_WIN);
58
59 SyncedSession session;
60 SessionModelAssociator::PopulateSessionHeaderFromSpecifics(
61 header_s, &session);
62 ASSERT_EQ("Client 1", session.client_name);
63 ASSERT_EQ(SyncedSession::TYPE_WIN, session.device_type);
64 }
65
54 TEST_F(SessionModelAssociatorTest, PopulateSessionWindow) { 66 TEST_F(SessionModelAssociatorTest, PopulateSessionWindow) {
55 sync_pb::SessionWindow window_s; 67 sync_pb::SessionWindow window_s;
56 window_s.add_tab(0); 68 window_s.add_tab(0);
57 window_s.set_browser_type(sync_pb::SessionWindow_BrowserType_TYPE_TABBED); 69 window_s.set_browser_type(sync_pb::SessionWindow_BrowserType_TYPE_TABBED);
58 window_s.set_selected_tab_index(1); 70 window_s.set_selected_tab_index(1);
59 71
60 std::string tag = "tag"; 72 std::string tag = "tag";
61 SyncedSessionTracker tracker; 73 SyncedSessionTracker tracker;
62 SyncedSession* session = tracker.GetSession(tag); 74 SyncedSession* session = tracker.GetSession(tag);
63 SessionWindow* win = new SessionWindow(); 75 SessionWindow* win = new SessionWindow();
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // The sessions don't have valid windows, lookup should not succeed. 163 // The sessions don't have valid windows, lookup should not succeed.
152 std::vector<const SyncedSession*> sessions; 164 std::vector<const SyncedSession*> sessions;
153 ASSERT_FALSE(tracker.LookupAllForeignSessions(&sessions)); 165 ASSERT_FALSE(tracker.LookupAllForeignSessions(&sessions));
154 166
155 tracker.clear(); 167 tracker.clear();
156 ASSERT_EQ(0U, tracker.num_synced_tabs(tag1)); 168 ASSERT_EQ(0U, tracker.num_synced_tabs(tag1));
157 ASSERT_EQ(0U, tracker.num_synced_tabs(tag2)); 169 ASSERT_EQ(0U, tracker.num_synced_tabs(tag2));
158 ASSERT_EQ(0U, tracker.num_synced_sessions()); 170 ASSERT_EQ(0U, tracker.num_synced_sessions());
159 } 171 }
160 172
173 TEST_F(SessionModelAssociatorTest, InitializeCurrentMachineName) {
174 SessionModelAssociator::InitializeCurrentMachineName();
175 ASSERT_TRUE(SessionModelAssociator::current_machine_name_.length() > 0);
176 }
177
178
161 } // namespace browser_sync 179 } // namespace browser_sync
162
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698