| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/sync_sessions/revisit/sessions_page_revisit_observer.h" | 5 #include "components/sync_sessions/revisit/sessions_page_revisit_observer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 histogram_tester.ExpectTotalCount("Sync.PageRevisitSessionDuration", 1); | 69 histogram_tester.ExpectTotalCount("Sync.PageRevisitSessionDuration", 1); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void CheckAndExpect(const SyncedSession* session, | 72 void CheckAndExpect(const SyncedSession* session, |
| 73 const GURL& url, | 73 const GURL& url, |
| 74 const bool current_match, | 74 const bool current_match, |
| 75 const bool offset_match) { | 75 const bool offset_match) { |
| 76 std::vector<const SyncedSession*> sessions; | 76 std::vector<const SyncedSession*> sessions; |
| 77 sessions.push_back(session); | 77 sessions.push_back(session); |
| 78 SessionsPageRevisitObserver observer( | 78 SessionsPageRevisitObserver observer( |
| 79 base::WrapUnique(new TestForeignSessionsProvider(sessions, true))); | 79 base::MakeUnique<TestForeignSessionsProvider>(sessions, true)); |
| 80 CheckAndExpect(&observer, url, current_match, offset_match); | 80 CheckAndExpect(&observer, url, current_match, offset_match); |
| 81 } | 81 } |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 TEST_F(SessionsPageRevisitObserverTest, RunMatchersNoSessions) { | 84 TEST_F(SessionsPageRevisitObserverTest, RunMatchersNoSessions) { |
| 85 std::vector<const SyncedSession*> sessions; | 85 std::vector<const SyncedSession*> sessions; |
| 86 SessionsPageRevisitObserver observer( | 86 SessionsPageRevisitObserver observer( |
| 87 base::WrapUnique(new TestForeignSessionsProvider(sessions, true))); | 87 base::MakeUnique<TestForeignSessionsProvider>(sessions, true)); |
| 88 CheckAndExpect(&observer, GURL(kExampleUrl), false, false); | 88 CheckAndExpect(&observer, GURL(kExampleUrl), false, false); |
| 89 } | 89 } |
| 90 | 90 |
| 91 TEST_F(SessionsPageRevisitObserverTest, RunMatchersNoWindows) { | 91 TEST_F(SessionsPageRevisitObserverTest, RunMatchersNoWindows) { |
| 92 std::unique_ptr<SyncedSession> session(new SyncedSession()); | 92 std::unique_ptr<SyncedSession> session(new SyncedSession()); |
| 93 CheckAndExpect(session.get(), GURL(kExampleUrl), false, false); | 93 CheckAndExpect(session.get(), GURL(kExampleUrl), false, false); |
| 94 } | 94 } |
| 95 | 95 |
| 96 TEST_F(SessionsPageRevisitObserverTest, RunMatchersNoTabs) { | 96 TEST_F(SessionsPageRevisitObserverTest, RunMatchersNoTabs) { |
| 97 std::unique_ptr<SyncedSession> session(new SyncedSession()); | 97 std::unique_ptr<SyncedSession> session(new SyncedSession()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 std::unique_ptr<SessionWindow> window(new SessionWindow()); | 132 std::unique_ptr<SessionWindow> window(new SessionWindow()); |
| 133 window->tabs.push_back(tab.release()); | 133 window->tabs.push_back(tab.release()); |
| 134 std::unique_ptr<SyncedSession> session(new SyncedSession()); | 134 std::unique_ptr<SyncedSession> session(new SyncedSession()); |
| 135 session->windows[0] = window.release(); | 135 session->windows[0] = window.release(); |
| 136 | 136 |
| 137 // The provider returns false when asked for foreign sessions, even though | 137 // The provider returns false when asked for foreign sessions, even though |
| 138 // it has has a valid tab. | 138 // it has has a valid tab. |
| 139 std::vector<const SyncedSession*> sessions; | 139 std::vector<const SyncedSession*> sessions; |
| 140 sessions.push_back(session.get()); | 140 sessions.push_back(session.get()); |
| 141 SessionsPageRevisitObserver observer( | 141 SessionsPageRevisitObserver observer( |
| 142 base::WrapUnique(new TestForeignSessionsProvider(sessions, false))); | 142 base::MakeUnique<TestForeignSessionsProvider>(sessions, false)); |
| 143 CheckAndExpect(&observer, GURL(kExampleUrl), false, false); | 143 CheckAndExpect(&observer, GURL(kExampleUrl), false, false); |
| 144 } | 144 } |
| 145 | 145 |
| 146 TEST_F(SessionsPageRevisitObserverTest, RunMatchersMany) { | 146 TEST_F(SessionsPageRevisitObserverTest, RunMatchersMany) { |
| 147 std::unique_ptr<SessionTab> tab1(new SessionTab()); | 147 std::unique_ptr<SessionTab> tab1(new SessionTab()); |
| 148 tab1->navigations.push_back( | 148 tab1->navigations.push_back( |
| 149 sessions::SerializedNavigationEntryTestHelper::CreateNavigation( | 149 sessions::SerializedNavigationEntryTestHelper::CreateNavigation( |
| 150 kExampleUrl, "")); | 150 kExampleUrl, "")); |
| 151 tab1->current_navigation_index = 0; | 151 tab1->current_navigation_index = 0; |
| 152 | 152 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 182 std::unique_ptr<SyncedSession> session1(new SyncedSession()); | 182 std::unique_ptr<SyncedSession> session1(new SyncedSession()); |
| 183 session1->windows[1] = window1.release(); | 183 session1->windows[1] = window1.release(); |
| 184 std::unique_ptr<SyncedSession> session2(new SyncedSession()); | 184 std::unique_ptr<SyncedSession> session2(new SyncedSession()); |
| 185 session2->windows[2] = window2.release(); | 185 session2->windows[2] = window2.release(); |
| 186 session2->windows[3] = window3.release(); | 186 session2->windows[3] = window3.release(); |
| 187 | 187 |
| 188 std::vector<const SyncedSession*> sessions; | 188 std::vector<const SyncedSession*> sessions; |
| 189 sessions.push_back(session1.get()); | 189 sessions.push_back(session1.get()); |
| 190 sessions.push_back(session2.get()); | 190 sessions.push_back(session2.get()); |
| 191 SessionsPageRevisitObserver observer( | 191 SessionsPageRevisitObserver observer( |
| 192 base::WrapUnique(new TestForeignSessionsProvider(sessions, true))); | 192 base::MakeUnique<TestForeignSessionsProvider>(sessions, true)); |
| 193 | 193 |
| 194 base::HistogramTester histogram_tester; | 194 base::HistogramTester histogram_tester; |
| 195 CheckAndExpect(&observer, GURL(kExampleUrl), true, true); | 195 CheckAndExpect(&observer, GURL(kExampleUrl), true, true); |
| 196 } | 196 } |
| 197 | 197 |
| 198 } // namespace sync_sessions | 198 } // namespace sync_sessions |
| OLD | NEW |