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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 ScopedVector<SessionWindow> windows; | 818 ScopedVector<SessionWindow> windows; |
819 ReadWindows(&(windows.get()), NULL); | 819 ReadWindows(&(windows.get()), NULL); |
820 | 820 |
821 helper_.AssertSingleWindowWithSingleTab(windows.get(), 1); | 821 helper_.AssertSingleWindowWithSingleTab(windows.get(), 1); |
822 | 822 |
823 // Expected: the HTTP body was removed from the page state of the POST | 823 // Expected: the HTTP body was removed from the page state of the POST |
824 // navigation with passwords. | 824 // navigation with passwords. |
825 EXPECT_NE(page_state, windows[0]->tabs[0]->navigations[0].page_state()); | 825 EXPECT_NE(page_state, windows[0]->tabs[0]->navigations[0].page_state()); |
826 } | 826 } |
827 | 827 |
828 // This test is only applicable to chromeos. | |
829 #if defined(OS_CHROMEOS) | |
830 // Verifies migration of tab/window closed works. | |
831 TEST_F(SessionServiceTest, CanOpenV1TabClosed) { | |
832 base::FilePath v1_file_path; | |
833 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &v1_file_path)); | |
834 // v1_session_file contains a tab closed command with the original id. The | |
835 // file was generated from ClosingTabStaysClosed. If we successfully processed | |
836 // the file we'll have one tab. | |
837 v1_file_path = | |
838 v1_file_path.AppendASCII("sessions").AppendASCII("v1_session_file"); | |
839 base::FilePath dest_file_path(path_); | |
840 dest_file_path = dest_file_path.AppendASCII("Current Session"); | |
841 | |
842 // Forces closing the file. | |
843 helper_.SetService(NULL); | |
844 | |
845 ASSERT_TRUE(base::CopyFile(v1_file_path, dest_file_path)); | |
846 | |
847 SessionService* session_service = new SessionService(path_); | |
848 helper_.SetService(session_service); | |
849 ScopedVector<SessionWindow> windows; | |
850 SessionID::id_type active_window_id = 0; | |
851 helper_.ReadWindows(&(windows.get()), &active_window_id); | |
852 ASSERT_EQ(1u, windows.size()); | |
853 EXPECT_EQ(1u, windows[0]->tabs.size()); | |
854 } | |
855 #endif // defined(OS_CHROMEOS) | |
856 | |
857 TEST_F(SessionServiceTest, ReplacePendingNavigation) { | 828 TEST_F(SessionServiceTest, ReplacePendingNavigation) { |
858 const std::string base_url("http://google.com/"); | 829 const std::string base_url("http://google.com/"); |
859 SessionID tab_id; | 830 SessionID tab_id; |
860 | 831 |
861 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 832 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
862 | 833 |
863 // Add 5 navigations, some with the same index | 834 // Add 5 navigations, some with the same index |
864 for (int i = 0; i < 5; ++i) { | 835 for (int i = 0; i < 5; ++i) { |
865 SerializedNavigationEntry nav = | 836 SerializedNavigationEntry nav = |
866 SerializedNavigationEntryTestHelper::CreateNavigation( | 837 SerializedNavigationEntryTestHelper::CreateNavigation( |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 &cancelable_task_tracker); | 1012 &cancelable_task_tracker); |
1042 helper_.RunTaskOnBackendThread( | 1013 helper_.RunTaskOnBackendThread( |
1043 FROM_HERE, | 1014 FROM_HERE, |
1044 base::Bind(&PostBackToThread, | 1015 base::Bind(&PostBackToThread, |
1045 base::Unretained(base::MessageLoop::current()), | 1016 base::Unretained(base::MessageLoop::current()), |
1046 base::Unretained(&run_loop))); | 1017 base::Unretained(&run_loop))); |
1047 delete helper_.ReleaseService(); | 1018 delete helper_.ReleaseService(); |
1048 event.Signal(); | 1019 event.Signal(); |
1049 run_loop.Run(); | 1020 run_loop.Run(); |
1050 } | 1021 } |
OLD | NEW |