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 3749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3760 | 3760 |
3761 // Force the session service to be created. | 3761 // Force the session service to be created. |
3762 SessionService* service = new SessionService(profile()); | 3762 SessionService* service = new SessionService(profile()); |
3763 SessionServiceFactory::SetForTestProfile(profile(), service); | 3763 SessionServiceFactory::SetForTestProfile(profile(), service); |
3764 service->SetWindowType(window_id, Browser::TYPE_TABBED); | 3764 service->SetWindowType(window_id, Browser::TYPE_TABBED); |
3765 service->SetWindowBounds(window_id, gfx::Rect(0, 1, 2, 3), false); | 3765 service->SetWindowBounds(window_id, gfx::Rect(0, 1, 2, 3), false); |
3766 service->SetTabIndexInWindow(window_id, | 3766 service->SetTabIndexInWindow(window_id, |
3767 controller.session_id(), 0); | 3767 controller.session_id(), 0); |
3768 controller.SetWindowID(window_id); | 3768 controller.SetWindowID(window_id); |
3769 | 3769 |
3770 session_helper_.set_service(service); | 3770 session_helper_.SetService(service); |
3771 } | 3771 } |
3772 | 3772 |
3773 virtual void TearDown() { | 3773 virtual void TearDown() { |
3774 // Release profile's reference to the session service. Otherwise the file | 3774 // Release profile's reference to the session service. Otherwise the file |
3775 // will still be open and we won't be able to delete the directory below. | 3775 // will still be open and we won't be able to delete the directory below. |
3776 session_helper_.ReleaseService(); // profile owns this | 3776 session_helper_.ReleaseService(); // profile owns this |
3777 SessionServiceFactory::SetForTestProfile(profile(), NULL); | 3777 SessionServiceFactory::SetForTestProfile(profile(), NULL); |
3778 | 3778 |
3779 // Make sure we wait for history to shut down before continuing. The task | 3779 // Make sure we wait for history to shut down before continuing. The task |
3780 // we add will cause our message loop to quit once it is destroyed. | 3780 // we add will cause our message loop to quit once it is destroyed. |
3781 HistoryService* history = HistoryServiceFactory::GetForProfiles( | 3781 HistoryService* history = HistoryServiceFactory::GetForProfiles( |
3782 profile(), Profile::IMPLICIT_ACCESS); | 3782 profile(), Profile::IMPLICIT_ACCESS); |
3783 if (history) { | 3783 if (history) { |
3784 history->SetOnBackendDestroyTask(base::MessageLoop::QuitClosure()); | 3784 history->SetOnBackendDestroyTask(base::MessageLoop::QuitClosure()); |
3785 base::MessageLoop::current()->Run(); | 3785 base::MessageLoop::current()->Run(); |
3786 } | 3786 } |
3787 | 3787 |
3788 // Do normal cleanup before deleting the profile directory below. | 3788 // Do normal cleanup before deleting the profile directory below. |
3789 NavigationControllerTest::TearDown(); | 3789 NavigationControllerTest::TearDown(); |
3790 | 3790 |
3791 ASSERT_TRUE(base::DeleteFile(test_dir_, true)); | 3791 ASSERT_TRUE(base::DeleteFile(test_dir_, true)); |
3792 ASSERT_FALSE(base::PathExists(test_dir_)); | 3792 ASSERT_FALSE(base::PathExists(test_dir_)); |
3793 } | 3793 } |
3794 | 3794 |
3795 // Deletes the current profile manager and creates a new one. Indirectly this | 3795 // Deletes the current profile manager and creates a new one. Indirectly this |
3796 // shuts down the history database and reopens it. | 3796 // shuts down the history database and reopens it. |
3797 void ReopenDatabase() { | 3797 void ReopenDatabase() { |
3798 session_helper_.set_service(NULL); | 3798 session_helper_.SetService(NULL); |
3799 SessionServiceFactory::SetForTestProfile(profile(), NULL); | 3799 SessionServiceFactory::SetForTestProfile(profile(), NULL); |
3800 | 3800 |
3801 SessionService* service = new SessionService(profile()); | 3801 SessionService* service = new SessionService(profile()); |
3802 SessionServiceFactory::SetForTestProfile(profile(), service); | 3802 SessionServiceFactory::SetForTestProfile(profile(), service); |
3803 session_helper_.set_service(service); | 3803 session_helper_.SetService(service); |
3804 } | 3804 } |
3805 | 3805 |
3806 void GetLastSession() { | 3806 void GetLastSession() { |
3807 SessionServiceFactory::GetForProfile(profile())->TabClosed( | 3807 SessionServiceFactory::GetForProfile(profile())->TabClosed( |
3808 controller.window_id(), controller.session_id(), false); | 3808 controller.window_id(), controller.session_id(), false); |
3809 | 3809 |
3810 ReopenDatabase(); | 3810 ReopenDatabase(); |
3811 Time close_time; | 3811 Time close_time; |
3812 | 3812 |
3813 session_helper_.ReadWindows(&windows_); | 3813 session_helper_.ReadWindows(&windows_); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3905 PAGE_TRANSITION_LINK); | 3905 PAGE_TRANSITION_LINK); |
3906 session_helper_.AssertNavigationEquals(nav, | 3906 session_helper_.AssertNavigationEquals(nav, |
3907 windows_[0]->tabs[0]->navigations[0]); | 3907 windows_[0]->tabs[0]->navigations[0]); |
3908 nav.set_url(url2); | 3908 nav.set_url(url2); |
3909 session_helper_.AssertNavigationEquals(nav, | 3909 session_helper_.AssertNavigationEquals(nav, |
3910 windows_[0]->tabs[0]->navigations[1]); | 3910 windows_[0]->tabs[0]->navigations[1]); |
3911 } | 3911 } |
3912 */ | 3912 */ |
3913 | 3913 |
3914 } // namespace content | 3914 } // namespace content |
OLD | NEW |