Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: chrome/browser/sessions/session_service_unittest.cc

Issue 10854217: Debug the generic session restore failure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: maybe test fix Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/run_loop.h"
11 #include "base/scoped_temp_dir.h" 12 #include "base/scoped_temp_dir.h"
12 #include "base/stl_util.h" 13 #include "base/stl_util.h"
13 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
14 #include "base/time.h" 15 #include "base/time.h"
15 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/defaults.h" 17 #include "chrome/browser/defaults.h"
17 #include "chrome/browser/sessions/session_backend.h" 18 #include "chrome/browser/sessions/session_backend.h"
18 #include "chrome/browser/sessions/session_service.h" 19 #include "chrome/browser/sessions/session_service.h"
19 #include "chrome/browser/sessions/session_service_test_helper.h" 20 #include "chrome/browser/sessions/session_service_test_helper.h"
20 #include "chrome/browser/sessions/session_types.h" 21 #include "chrome/browser/sessions/session_types.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 entry->SetIsOverridingUserAgent(navigation.is_overriding_user_agent()); 90 entry->SetIsOverridingUserAgent(navigation.is_overriding_user_agent());
90 service()->UpdateTabNavigation(window_id, tab_id, index, *entry.get()); 91 service()->UpdateTabNavigation(window_id, tab_id, index, *entry.get());
91 if (select) 92 if (select)
92 service()->SetSelectedNavigationIndex(window_id, tab_id, index); 93 service()->SetSelectedNavigationIndex(window_id, tab_id, index);
93 } 94 }
94 95
95 void ReadWindows(std::vector<SessionWindow*>* windows) { 96 void ReadWindows(std::vector<SessionWindow*>* windows) {
96 // Forces closing the file. 97 // Forces closing the file.
97 helper_.set_service(NULL); 98 helper_.set_service(NULL);
98 99
100 // SessionBackend posts delayed tasks and might stay alive a bit longer than
101 // SessionService. Make sure the tasks run and the backend is destroyed.
102 base::RunLoop loop;
103 loop.RunUntilIdle();
104
99 SessionService* session_service = new SessionService(path_); 105 SessionService* session_service = new SessionService(path_);
100 helper_.set_service(session_service); 106 helper_.set_service(session_service);
101 helper_.ReadWindows(windows); 107 helper_.ReadWindows(windows);
102 } 108 }
103 109
104 // Configures the session service with one window with one tab and a single 110 // Configures the session service with one window with one tab and a single
105 // navigation. If |pinned_state| is true or |write_always| is true, the 111 // navigation. If |pinned_state| is true or |write_always| is true, the
106 // pinned state of the tab is updated. The session service is then recreated 112 // pinned state of the tab is updated. The session service is then recreated
107 // and the pinned state of the read back tab is returned. 113 // and the pinned state of the read back tab is returned.
108 bool CreateAndWriteSessionWithOneTab(bool pinned_state, bool write_always) { 114 bool CreateAndWriteSessionWithOneTab(bool pinned_state, bool write_always) {
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 ASSERT_TRUE(file_util::CopyFile(v1_file_path, dest_file_path)); 872 ASSERT_TRUE(file_util::CopyFile(v1_file_path, dest_file_path));
867 873
868 SessionService* session_service = new SessionService(path_); 874 SessionService* session_service = new SessionService(path_);
869 helper_.set_service(session_service); 875 helper_.set_service(session_service);
870 ScopedVector<SessionWindow> windows; 876 ScopedVector<SessionWindow> windows;
871 helper_.ReadWindows(&(windows.get())); 877 helper_.ReadWindows(&(windows.get()));
872 ASSERT_EQ(1u, windows.size()); 878 ASSERT_EQ(1u, windows.size());
873 EXPECT_EQ(1u, windows[0]->tabs.size()); 879 EXPECT_EQ(1u, windows[0]->tabs.size());
874 } 880 }
875 #endif 881 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698