| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.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/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 3795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3806 | 3806 |
| 3807 // Force the session service to be created. | 3807 // Force the session service to be created. |
| 3808 SessionService* service = new SessionService(profile()); | 3808 SessionService* service = new SessionService(profile()); |
| 3809 SessionServiceFactory::SetForTestProfile(profile(), service); | 3809 SessionServiceFactory::SetForTestProfile(profile(), service); |
| 3810 service->SetWindowType(window_id, Browser::TYPE_TABBED); | 3810 service->SetWindowType(window_id, Browser::TYPE_TABBED); |
| 3811 service->SetWindowBounds(window_id, gfx::Rect(0, 1, 2, 3), false); | 3811 service->SetWindowBounds(window_id, gfx::Rect(0, 1, 2, 3), false); |
| 3812 service->SetTabIndexInWindow(window_id, | 3812 service->SetTabIndexInWindow(window_id, |
| 3813 controller.session_id(), 0); | 3813 controller.session_id(), 0); |
| 3814 controller.SetWindowID(window_id); | 3814 controller.SetWindowID(window_id); |
| 3815 | 3815 |
| 3816 session_helper_.set_service(service); | 3816 session_helper_.SetService(service); |
| 3817 } | 3817 } |
| 3818 | 3818 |
| 3819 virtual void TearDown() { | 3819 virtual void TearDown() { |
| 3820 // Release profile's reference to the session service. Otherwise the file | 3820 // Release profile's reference to the session service. Otherwise the file |
| 3821 // will still be open and we won't be able to delete the directory below. | 3821 // will still be open and we won't be able to delete the directory below. |
| 3822 session_helper_.ReleaseService(); // profile owns this | 3822 session_helper_.ReleaseService(); // profile owns this |
| 3823 SessionServiceFactory::SetForTestProfile(profile(), NULL); | 3823 SessionServiceFactory::SetForTestProfile(profile(), NULL); |
| 3824 | 3824 |
| 3825 // Make sure we wait for history to shut down before continuing. The task | 3825 // Make sure we wait for history to shut down before continuing. The task |
| 3826 // we add will cause our message loop to quit once it is destroyed. | 3826 // we add will cause our message loop to quit once it is destroyed. |
| 3827 HistoryService* history = HistoryServiceFactory::GetForProfiles( | 3827 HistoryService* history = HistoryServiceFactory::GetForProfiles( |
| 3828 profile(), Profile::IMPLICIT_ACCESS); | 3828 profile(), Profile::IMPLICIT_ACCESS); |
| 3829 if (history) { | 3829 if (history) { |
| 3830 history->SetOnBackendDestroyTask(base::MessageLoop::QuitClosure()); | 3830 history->SetOnBackendDestroyTask(base::MessageLoop::QuitClosure()); |
| 3831 base::MessageLoop::current()->Run(); | 3831 base::MessageLoop::current()->Run(); |
| 3832 } | 3832 } |
| 3833 | 3833 |
| 3834 // Do normal cleanup before deleting the profile directory below. | 3834 // Do normal cleanup before deleting the profile directory below. |
| 3835 NavigationControllerTest::TearDown(); | 3835 NavigationControllerTest::TearDown(); |
| 3836 | 3836 |
| 3837 ASSERT_TRUE(base::DeleteFile(test_dir_, true)); | 3837 ASSERT_TRUE(base::DeleteFile(test_dir_, true)); |
| 3838 ASSERT_FALSE(base::PathExists(test_dir_)); | 3838 ASSERT_FALSE(base::PathExists(test_dir_)); |
| 3839 } | 3839 } |
| 3840 | 3840 |
| 3841 // Deletes the current profile manager and creates a new one. Indirectly this | 3841 // Deletes the current profile manager and creates a new one. Indirectly this |
| 3842 // shuts down the history database and reopens it. | 3842 // shuts down the history database and reopens it. |
| 3843 void ReopenDatabase() { | 3843 void ReopenDatabase() { |
| 3844 session_helper_.set_service(NULL); | 3844 session_helper_.SetService(NULL); |
| 3845 SessionServiceFactory::SetForTestProfile(profile(), NULL); | 3845 SessionServiceFactory::SetForTestProfile(profile(), NULL); |
| 3846 | 3846 |
| 3847 SessionService* service = new SessionService(profile()); | 3847 SessionService* service = new SessionService(profile()); |
| 3848 SessionServiceFactory::SetForTestProfile(profile(), service); | 3848 SessionServiceFactory::SetForTestProfile(profile(), service); |
| 3849 session_helper_.set_service(service); | 3849 session_helper_.SetService(service); |
| 3850 } | 3850 } |
| 3851 | 3851 |
| 3852 void GetLastSession() { | 3852 void GetLastSession() { |
| 3853 SessionServiceFactory::GetForProfile(profile())->TabClosed( | 3853 SessionServiceFactory::GetForProfile(profile())->TabClosed( |
| 3854 controller.window_id(), controller.session_id(), false); | 3854 controller.window_id(), controller.session_id(), false); |
| 3855 | 3855 |
| 3856 ReopenDatabase(); | 3856 ReopenDatabase(); |
| 3857 Time close_time; | 3857 Time close_time; |
| 3858 | 3858 |
| 3859 session_helper_.ReadWindows(&windows_); | 3859 session_helper_.ReadWindows(&windows_); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3951 PAGE_TRANSITION_LINK); | 3951 PAGE_TRANSITION_LINK); |
| 3952 session_helper_.AssertNavigationEquals(nav, | 3952 session_helper_.AssertNavigationEquals(nav, |
| 3953 windows_[0]->tabs[0]->navigations[0]); | 3953 windows_[0]->tabs[0]->navigations[0]); |
| 3954 nav.set_url(url2); | 3954 nav.set_url(url2); |
| 3955 session_helper_.AssertNavigationEquals(nav, | 3955 session_helper_.AssertNavigationEquals(nav, |
| 3956 windows_[0]->tabs[0]->navigations[1]); | 3956 windows_[0]->tabs[0]->navigations[1]); |
| 3957 } | 3957 } |
| 3958 */ | 3958 */ |
| 3959 | 3959 |
| 3960 } // namespace content | 3960 } // namespace content |
| OLD | NEW |