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

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

Issue 7792102: Revert 99391 (broke CrOS unit_tests) - Set user-visible machine names and devices types for synce... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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"
11 #include "chrome/browser/sync/glue/session_model_associator.h" 11 #include "chrome/browser/sync/glue/session_model_associator.h"
12 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
13 #include "content/common/page_transition_types.h" 13 #include "content/common/page_transition_types.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 using browser_sync::SessionModelAssociator; 16 using browser_sync::SessionModelAssociator;
17 using browser_sync::SyncedSessionTracker; 17 using browser_sync::SyncedSessionTracker;
18
19 namespace browser_sync { 18 namespace browser_sync {
20 19
21 typedef testing::Test SessionModelAssociatorTest; 20 typedef testing::Test SessionModelAssociatorTest;
22 21
23 TEST_F(SessionModelAssociatorTest, SessionWindowHasNoTabsToSync) { 22 TEST_F(SessionModelAssociatorTest, SessionWindowHasNoTabsToSync) {
24 SessionWindow win; 23 SessionWindow win;
25 ASSERT_TRUE(SessionModelAssociator::SessionWindowHasNoTabsToSync(win)); 24 ASSERT_TRUE(SessionModelAssociator::SessionWindowHasNoTabsToSync(win));
26 scoped_ptr<SessionTab> tab(new SessionTab()); 25 scoped_ptr<SessionTab> tab(new SessionTab());
27 win.tabs.push_back(tab.release()); 26 win.tabs.push_back(tab.release());
28 ASSERT_TRUE(SessionModelAssociator::SessionWindowHasNoTabsToSync(win)); 27 ASSERT_TRUE(SessionModelAssociator::SessionWindowHasNoTabsToSync(win));
(...skipping 16 matching lines...) Expand all
45 ASSERT_FALSE(SessionModelAssociator::IsValidSessionTab(tab)); 44 ASSERT_FALSE(SessionModelAssociator::IsValidSessionTab(tab));
46 TabNavigation nav2(0, GURL("about:bubba"), 45 TabNavigation nav2(0, GURL("about:bubba"),
47 GURL("about:referrer"), 46 GURL("about:referrer"),
48 string16(ASCIIToUTF16("title")), 47 string16(ASCIIToUTF16("title")),
49 std::string("state"), 0U); 48 std::string("state"), 0U);
50 tab.navigations.push_back(nav2); 49 tab.navigations.push_back(nav2);
51 // Once there's another navigation, the tab is valid. 50 // Once there's another navigation, the tab is valid.
52 ASSERT_TRUE(SessionModelAssociator::IsValidSessionTab(tab)); 51 ASSERT_TRUE(SessionModelAssociator::IsValidSessionTab(tab));
53 } 52 }
54 53
55 TEST_F(SessionModelAssociatorTest, PopulateSessionHeader) {
56 sync_pb::SessionHeader header_s;
57 header_s.set_client_name("Client 1");
58 header_s.set_device_type(sync_pb::SessionHeader_DeviceType_TYPE_WIN);
59
60 SyncedSession session;
61 SessionModelAssociator::PopulateSessionHeaderFromSpecifics(
62 header_s, &session);
63 ASSERT_EQ("Client 1", session.session_name);
64 ASSERT_EQ(SyncedSession::TYPE_WIN, session.device_type);
65 }
66
67 TEST_F(SessionModelAssociatorTest, PopulateSessionWindow) { 54 TEST_F(SessionModelAssociatorTest, PopulateSessionWindow) {
68 sync_pb::SessionWindow window_s; 55 sync_pb::SessionWindow window_s;
69 window_s.add_tab(0); 56 window_s.add_tab(0);
70 window_s.set_browser_type(sync_pb::SessionWindow_BrowserType_TYPE_TABBED); 57 window_s.set_browser_type(sync_pb::SessionWindow_BrowserType_TYPE_TABBED);
71 window_s.set_selected_tab_index(1); 58 window_s.set_selected_tab_index(1);
72 59
73 std::string tag = "tag"; 60 std::string tag = "tag";
74 SyncedSessionTracker tracker; 61 SyncedSessionTracker tracker;
75 SyncedSession* session = tracker.GetSession(tag); 62 SyncedSession* session = tracker.GetSession(tag);
76 SessionWindow* win = new SessionWindow(); 63 SessionWindow* win = new SessionWindow();
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // The sessions don't have valid windows, lookup should not succeed. 151 // The sessions don't have valid windows, lookup should not succeed.
165 std::vector<const SyncedSession*> sessions; 152 std::vector<const SyncedSession*> sessions;
166 ASSERT_FALSE(tracker.LookupAllForeignSessions(&sessions)); 153 ASSERT_FALSE(tracker.LookupAllForeignSessions(&sessions));
167 154
168 tracker.clear(); 155 tracker.clear();
169 ASSERT_EQ(0U, tracker.num_synced_tabs(tag1)); 156 ASSERT_EQ(0U, tracker.num_synced_tabs(tag1));
170 ASSERT_EQ(0U, tracker.num_synced_tabs(tag2)); 157 ASSERT_EQ(0U, tracker.num_synced_tabs(tag2));
171 ASSERT_EQ(0U, tracker.num_synced_sessions()); 158 ASSERT_EQ(0U, tracker.num_synced_sessions());
172 } 159 }
173 160
174 #if defined(OS_WIN) 161 } // namespace browser_sync
175 // The test is somewhat silly, and just verifies that we return a computer name.
176 TEST(SessionModelAssociatorTest, TestGetComputerName) {
177 std::string computer_name = SessionModelAssociator::GetComputerName();
178 EXPECT_TRUE(!computer_name.empty());
179 }
180 #endif
181 162
182 #if defined(OS_MACOSX)
183 // The test is somewhat silly, and just verifies that we return a hardware
184 // model name.
185 TEST_F(SessionModelAssociatorTest, GetHardwareModelName) {
186 std::string hardware_model = SessionModelAssociator::GetHardwareModelName();
187 EXPECT_TRUE(!hardware_model.empty());
188 }
189 #endif
190
191
192 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/session_model_associator_mac.mm ('k') | chrome/browser/sync/glue/synced_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698