OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import <objc/runtime.h> | 5 #import <objc/runtime.h> |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/mac/scoped_nsautorelease_pool.h" | 8 #include "base/mac/scoped_nsautorelease_pool.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
12 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 12 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
13 #include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h" | 13 #include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h" |
14 #include "ios/chrome/browser/chrome_url_constants.h" | 14 #include "ios/chrome/browser/chrome_url_constants.h" |
15 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" | 15 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" |
16 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h" | 16 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h" |
| 17 #import "ios/chrome/browser/sessions/session_ios.h" |
17 #import "ios/chrome/browser/sessions/session_window_ios.h" | 18 #import "ios/chrome/browser/sessions/session_window_ios.h" |
18 #import "ios/chrome/browser/sessions/test_session_service.h" | 19 #import "ios/chrome/browser/sessions/test_session_service.h" |
19 #import "ios/chrome/browser/tabs/legacy_tab_helper.h" | 20 #import "ios/chrome/browser/tabs/legacy_tab_helper.h" |
20 #import "ios/chrome/browser/tabs/tab.h" | 21 #import "ios/chrome/browser/tabs/tab.h" |
21 #import "ios/chrome/browser/tabs/tab_helper_util.h" | 22 #import "ios/chrome/browser/tabs/tab_helper_util.h" |
22 #import "ios/chrome/browser/tabs/tab_model.h" | 23 #import "ios/chrome/browser/tabs/tab_model.h" |
23 #import "ios/chrome/browser/tabs/tab_model_observer.h" | 24 #import "ios/chrome/browser/tabs/tab_model_observer.h" |
24 #import "ios/chrome/browser/tabs/tab_private.h" | 25 #import "ios/chrome/browser/tabs/tab_private.h" |
25 #import "ios/chrome/browser/web/chrome_web_client.h" | 26 #import "ios/chrome/browser/web/chrome_web_client.h" |
26 #import "ios/chrome/browser/web_state_list/web_state_list.h" | 27 #import "ios/chrome/browser/web_state_list/web_state_list.h" |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:0]]); | 1144 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:0]]); |
1144 | 1145 |
1145 // Force state to flush to disk on the main thread so it can be immediately | 1146 // Force state to flush to disk on the main thread so it can be immediately |
1146 // tested below. | 1147 // tested below. |
1147 [test_session_service setPerformIO:YES]; | 1148 [test_session_service setPerformIO:YES]; |
1148 [tab_model_ saveSessionImmediately:YES]; | 1149 [tab_model_ saveSessionImmediately:YES]; |
1149 [test_session_service setPerformIO:NO]; | 1150 [test_session_service setPerformIO:NO]; |
1150 | 1151 |
1151 NSString* state_path = base::SysUTF8ToNSString( | 1152 NSString* state_path = base::SysUTF8ToNSString( |
1152 chrome_browser_state_->GetStatePath().AsUTF8Unsafe()); | 1153 chrome_browser_state_->GetStatePath().AsUTF8Unsafe()); |
1153 SessionWindowIOS* session_window = | 1154 SessionIOS* session = |
1154 [test_session_service loadSessionWindowFromDirectory:state_path]; | 1155 [test_session_service loadSessionFromDirectory:state_path]; |
| 1156 ASSERT_EQ(1u, session.sessionWindows.count); |
| 1157 SessionWindowIOS* session_window = session.sessionWindows[0]; |
1155 | 1158 |
1156 // Create tab model from saved session. | 1159 // Create tab model from saved session. |
1157 SetTabModel(CreateTabModel(test_session_service.get(), session_window)); | 1160 SetTabModel(CreateTabModel(test_session_service.get(), session_window)); |
1158 | 1161 |
1159 ASSERT_EQ(3u, [tab_model_ count]); | 1162 ASSERT_EQ(3u, [tab_model_ count]); |
1160 | 1163 |
1161 EXPECT_EQ([tab_model_ tabAtIndex:1], [tab_model_ currentTab]); | 1164 EXPECT_EQ([tab_model_ tabAtIndex:1], [tab_model_ currentTab]); |
1162 EXPECT_EQ(nil, [tab_model_ openerOfTab:[tab_model_ tabAtIndex:1]]); | 1165 EXPECT_EQ(nil, [tab_model_ openerOfTab:[tab_model_ tabAtIndex:1]]); |
1163 EXPECT_EQ([tab_model_ tabAtIndex:1], | 1166 EXPECT_EQ([tab_model_ tabAtIndex:1], |
1164 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:2]]); | 1167 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:2]]); |
1165 EXPECT_EQ([tab_model_ tabAtIndex:2], | 1168 EXPECT_EQ([tab_model_ tabAtIndex:2], |
1166 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:0]]); | 1169 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:0]]); |
1167 | 1170 |
1168 // Clean up. | 1171 // Clean up. |
1169 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath | 1172 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath |
1170 error:nullptr]); | 1173 error:nullptr]); |
1171 } | 1174 } |
1172 | 1175 |
1173 } // anonymous namespace | 1176 } // anonymous namespace |
OLD | NEW |