| OLD | NEW |
| 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 "chrome/browser/sessions/session_service_test_helper.h" | 5 #include "chrome/browser/sessions/session_service_test_helper.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "chrome/browser/sessions/session_backend.h" | 9 #include "chrome/browser/sessions/session_backend.h" |
| 10 #include "chrome/browser/sessions/session_service.h" | 10 #include "chrome/browser/sessions/session_service.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 service()->force_browser_not_alive_with_no_windows_ = | 53 service()->force_browser_not_alive_with_no_windows_ = |
| 54 force_browser_not_alive_with_no_windows; | 54 force_browser_not_alive_with_no_windows; |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Be sure and null out service to force closing the file. | 57 // Be sure and null out service to force closing the file. |
| 58 void SessionServiceTestHelper::ReadWindows( | 58 void SessionServiceTestHelper::ReadWindows( |
| 59 std::vector<SessionWindow*>* windows, | 59 std::vector<SessionWindow*>* windows, |
| 60 SessionID::id_type* active_window_id) { | 60 SessionID::id_type* active_window_id) { |
| 61 Time last_time; | 61 Time last_time; |
| 62 ScopedVector<SessionCommand> read_commands; | 62 ScopedVector<SessionCommand> read_commands; |
| 63 backend()->ReadLastSessionCommandsImpl(&read_commands); | 63 service()->GetBaseSessionServiceForTest()->backend()-> |
| 64 ReadLastSessionCommandsImpl(&read_commands); |
| 64 RestoreSessionFromCommands(read_commands, windows, active_window_id); | 65 RestoreSessionFromCommands(read_commands, windows, active_window_id); |
| 65 service()->RemoveUnusedRestoreWindows(windows); | 66 service()->RemoveUnusedRestoreWindows(windows); |
| 66 } | 67 } |
| 67 | 68 |
| 68 void SessionServiceTestHelper::AssertTabEquals(const SessionID& window_id, | 69 void SessionServiceTestHelper::AssertTabEquals(const SessionID& window_id, |
| 69 const SessionID& tab_id, | 70 const SessionID& tab_id, |
| 70 int visual_index, | 71 int visual_index, |
| 71 int nav_index, | 72 int nav_index, |
| 72 size_t nav_count, | 73 size_t nav_count, |
| 73 const SessionTab& session_tab) { | 74 const SessionTab& session_tab) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 96 } | 97 } |
| 97 | 98 |
| 98 void SessionServiceTestHelper::AssertSingleWindowWithSingleTab( | 99 void SessionServiceTestHelper::AssertSingleWindowWithSingleTab( |
| 99 const std::vector<SessionWindow*>& windows, | 100 const std::vector<SessionWindow*>& windows, |
| 100 size_t nav_count) { | 101 size_t nav_count) { |
| 101 ASSERT_EQ(1U, windows.size()); | 102 ASSERT_EQ(1U, windows.size()); |
| 102 EXPECT_EQ(1U, windows[0]->tabs.size()); | 103 EXPECT_EQ(1U, windows[0]->tabs.size()); |
| 103 EXPECT_EQ(nav_count, windows[0]->tabs[0]->navigations.size()); | 104 EXPECT_EQ(nav_count, windows[0]->tabs[0]->navigations.size()); |
| 104 } | 105 } |
| 105 | 106 |
| 106 SessionBackend* SessionServiceTestHelper::backend() { | |
| 107 return service_->backend(); | |
| 108 } | |
| 109 | |
| 110 void SessionServiceTestHelper::SetService(SessionService* service) { | 107 void SessionServiceTestHelper::SetService(SessionService* service) { |
| 111 service_.reset(service); | 108 service_.reset(service); |
| 112 // Execute IO tasks posted by the SessionService. | 109 // Execute IO tasks posted by the SessionService. |
| 113 content::RunAllBlockingPoolTasksUntilIdle(); | 110 content::RunAllBlockingPoolTasksUntilIdle(); |
| 114 } | 111 } |
| 115 | 112 |
| 116 void SessionServiceTestHelper::RunTaskOnBackendThread( | 113 void SessionServiceTestHelper::RunTaskOnBackendThread( |
| 117 const tracked_objects::Location& from_here, | 114 const tracked_objects::Location& from_here, |
| 118 const base::Closure& task) { | 115 const base::Closure& task) { |
| 119 service_->RunTaskOnBackendThread(from_here, task); | 116 service_->GetBaseSessionServiceForTest()->RunTaskOnBackendThread(from_here, |
| 117 task); |
| 120 } | 118 } |
| OLD | NEW |