OLD | NEW |
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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
22 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
23 #include "chrome/test/base/browser_with_test_window_test.h" | 23 #include "chrome/test/base/browser_with_test_window_test.h" |
24 #include "chrome/test/base/testing_profile.h" | 24 #include "chrome/test/base/testing_profile.h" |
25 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
26 #include "content/public/browser/notification_observer.h" | 26 #include "content/public/browser/notification_observer.h" |
27 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
30 | 30 |
| 31 using content::NavigationEntry; |
| 32 |
31 class SessionServiceTest : public BrowserWithTestWindowTest, | 33 class SessionServiceTest : public BrowserWithTestWindowTest, |
32 public content::NotificationObserver { | 34 public content::NotificationObserver { |
33 public: | 35 public: |
34 SessionServiceTest() : window_bounds(0, 1, 2, 3), sync_save_count_(0){} | 36 SessionServiceTest() : window_bounds(0, 1, 2, 3), sync_save_count_(0){} |
35 | 37 |
36 protected: | 38 protected: |
37 virtual void SetUp() { | 39 virtual void SetUp() { |
38 BrowserWithTestWindowTest::SetUp(); | 40 BrowserWithTestWindowTest::SetUp(); |
39 std::string b = base::Int64ToString(base::Time::Now().ToInternalValue()); | 41 std::string b = base::Int64ToString(base::Time::Now().ToInternalValue()); |
40 | 42 |
(...skipping 21 matching lines...) Expand all Loading... |
62 | 64 |
63 virtual void TearDown() { | 65 virtual void TearDown() { |
64 helper_.set_service(NULL); | 66 helper_.set_service(NULL); |
65 } | 67 } |
66 | 68 |
67 void UpdateNavigation(const SessionID& window_id, | 69 void UpdateNavigation(const SessionID& window_id, |
68 const SessionID& tab_id, | 70 const SessionID& tab_id, |
69 const TabNavigation& navigation, | 71 const TabNavigation& navigation, |
70 int index, | 72 int index, |
71 bool select) { | 73 bool select) { |
72 scoped_ptr<content::NavigationEntry> entry( | 74 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
73 content::NavigationEntry::Create()); | |
74 entry->SetURL(navigation.virtual_url()); | 75 entry->SetURL(navigation.virtual_url()); |
75 entry->SetReferrer(navigation.referrer()); | 76 entry->SetReferrer(navigation.referrer()); |
76 entry->SetTitle(navigation.title()); | 77 entry->SetTitle(navigation.title()); |
77 entry->SetContentState(navigation.state()); | 78 entry->SetContentState(navigation.state()); |
78 entry->SetTransitionType(navigation.transition()); | 79 entry->SetTransitionType(navigation.transition()); |
79 entry->SetHasPostData( | 80 entry->SetHasPostData( |
80 navigation.type_mask() & TabNavigation::HAS_POST_DATA); | 81 navigation.type_mask() & TabNavigation::HAS_POST_DATA); |
81 service()->UpdateTabNavigation(window_id, tab_id, index, *entry.get()); | 82 service()->UpdateTabNavigation(window_id, tab_id, index, *entry.get()); |
82 if (select) | 83 if (select) |
83 service()->SetSelectedNavigationIndex(window_id, tab_id, index); | 84 service()->SetSelectedNavigationIndex(window_id, tab_id, index); |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 | 646 |
646 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 647 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
647 UpdateNavigation(window_id, tab_id, nav1, 0, true); | 648 UpdateNavigation(window_id, tab_id, nav1, 0, true); |
648 service()->TabClosed(window_id, tab_id, true); | 649 service()->TabClosed(window_id, tab_id, true); |
649 | 650 |
650 ScopedVector<SessionWindow> windows; | 651 ScopedVector<SessionWindow> windows; |
651 ReadWindows(&(windows.get())); | 652 ReadWindows(&(windows.get())); |
652 | 653 |
653 ASSERT_TRUE(windows->empty()); | 654 ASSERT_TRUE(windows->empty()); |
654 } | 655 } |
OLD | NEW |