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

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

Issue 14497003: Moves TabNavigation into components/sessions and renames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Really remove webkit_support Created 7 years, 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <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/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/sessions/session_types.h" 12 #include "chrome/browser/sessions/session_types.h"
13 #include "chrome/browser/sessions/session_types_test_helper.h"
14 #include "chrome/browser/sync/glue/synced_session_tracker.h" 13 #include "chrome/browser/sync/glue/synced_session_tracker.h"
14 #include "components/sessions/serialized_navigation_entry_test_helper.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace browser_sync { 17 namespace browser_sync {
18 18
19 typedef testing::Test SyncedSessionTrackerTest; 19 typedef testing::Test SyncedSessionTrackerTest;
20 20
21 TEST_F(SyncedSessionTrackerTest, GetSession) { 21 TEST_F(SyncedSessionTrackerTest, GetSession) {
22 SyncedSessionTracker tracker; 22 SyncedSessionTracker tracker;
23 SyncedSession* session1 = tracker.GetSession("tag"); 23 SyncedSession* session1 = tracker.GetSession("tag");
24 SyncedSession* session2 = tracker.GetSession("tag2"); 24 SyncedSession* session2 = tracker.GetSession("tag2");
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 TEST_F(SyncedSessionTrackerTest, LookupAllForeignSessions) { 56 TEST_F(SyncedSessionTrackerTest, LookupAllForeignSessions) {
57 SyncedSessionTracker tracker; 57 SyncedSessionTracker tracker;
58 std::vector<const SyncedSession*> sessions; 58 std::vector<const SyncedSession*> sessions;
59 ASSERT_FALSE(tracker.LookupAllForeignSessions(&sessions)); 59 ASSERT_FALSE(tracker.LookupAllForeignSessions(&sessions));
60 tracker.GetSession("tag1"); 60 tracker.GetSession("tag1");
61 tracker.GetSession("tag2"); 61 tracker.GetSession("tag2");
62 tracker.PutWindowInSession("tag1", 0); 62 tracker.PutWindowInSession("tag1", 0);
63 tracker.PutTabInWindow("tag1", 0, 15, 0); 63 tracker.PutTabInWindow("tag1", 0, 15, 0);
64 SessionTab* tab = tracker.GetTab("tag1", 15); 64 SessionTab* tab = tracker.GetTab("tag1", 15);
65 ASSERT_TRUE(tab); 65 ASSERT_TRUE(tab);
66 tab->navigations.push_back(SessionTypesTestHelper::CreateNavigation( 66 tab->navigations.push_back(
67 sessions::SerializedNavigationEntryTestHelper::CreateNavigation(
67 "bla://valid_url", "title")); 68 "bla://valid_url", "title"));
68 ASSERT_TRUE(tracker.LookupAllForeignSessions(&sessions)); 69 ASSERT_TRUE(tracker.LookupAllForeignSessions(&sessions));
69 // Only the session with a valid window and tab gets returned. 70 // Only the session with a valid window and tab gets returned.
70 ASSERT_EQ(1U, sessions.size()); 71 ASSERT_EQ(1U, sessions.size());
71 ASSERT_EQ("tag1", sessions[0]->session_tag); 72 ASSERT_EQ("tag1", sessions[0]->session_tag);
72 } 73 }
73 74
74 TEST_F(SyncedSessionTrackerTest, LookupSessionWindows) { 75 TEST_F(SyncedSessionTrackerTest, LookupSessionWindows) {
75 SyncedSessionTracker tracker; 76 SyncedSessionTracker tracker;
76 std::vector<const SessionWindow*> windows; 77 std::vector<const SessionWindow*> windows;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 ASSERT_EQ(1U, session2->windows[2]->tabs.size()); 236 ASSERT_EQ(1U, session2->windows[2]->tabs.size());
236 ASSERT_EQ(2U, tracker.num_synced_sessions()); 237 ASSERT_EQ(2U, tracker.num_synced_sessions());
237 ASSERT_EQ(4U, tracker.num_synced_tabs(tag1)); 238 ASSERT_EQ(4U, tracker.num_synced_tabs(tag1));
238 ASSERT_EQ(1U, tracker.num_synced_tabs(tag2)); 239 ASSERT_EQ(1U, tracker.num_synced_tabs(tag2));
239 240
240 // All memory should be properly deallocated by destructor for the 241 // All memory should be properly deallocated by destructor for the
241 // SyncedSessionTracker. 242 // SyncedSessionTracker.
242 } 243 }
243 244
244 } // namespace browser_sync 245 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698