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 #include "ios/chrome/browser/test/perf_test_with_bvc_ios.h" | 5 #include "ios/chrome/browser/test/perf_test_with_bvc_ios.h" |
6 | 6 |
7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
12 #include "components/bookmarks/test/bookmark_test_helpers.h" | 12 #include "components/bookmarks/test/bookmark_test_helpers.h" |
13 #include "ios/chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 13 #include "ios/chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
14 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" | 14 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" |
15 #include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h" | 15 #include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h" |
16 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" | 16 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" |
| 17 #import "ios/chrome/browser/sessions/session_ios.h" |
17 #import "ios/chrome/browser/sessions/session_service_ios.h" | 18 #import "ios/chrome/browser/sessions/session_service_ios.h" |
18 #import "ios/chrome/browser/sessions/session_window_ios.h" | 19 #import "ios/chrome/browser/sessions/session_window_ios.h" |
19 #import "ios/chrome/browser/tabs/tab_model.h" | 20 #import "ios/chrome/browser/tabs/tab_model.h" |
20 #import "ios/chrome/browser/ui/browser_view_controller.h" | 21 #import "ios/chrome/browser/ui/browser_view_controller.h" |
21 #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h" | 22 #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h" |
22 #import "ios/chrome/browser/ui/preload_controller.h" | 23 #import "ios/chrome/browser/ui/preload_controller.h" |
23 #import "ios/chrome/browser/web/chrome_web_client.h" | 24 #import "ios/chrome/browser/web/chrome_web_client.h" |
24 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 25 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
25 | 26 |
26 // Subclass of PrerenderController so it isn't actually used. Using a mock for | 27 // Subclass of PrerenderController so it isn't actually used. Using a mock for |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 chrome_browser_state_.get())); | 112 chrome_browser_state_.get())); |
112 ASSERT_TRUE(chrome_browser_state_->CreateHistoryService(false)); | 113 ASSERT_TRUE(chrome_browser_state_->CreateHistoryService(false)); |
113 | 114 |
114 // Force creation of AutocompleteClassifier instance. | 115 // Force creation of AutocompleteClassifier instance. |
115 ios::AutocompleteClassifierFactory::GetForBrowserState( | 116 ios::AutocompleteClassifierFactory::GetForBrowserState( |
116 chrome_browser_state_.get()); | 117 chrome_browser_state_.get()); |
117 | 118 |
118 // Use the session to create a window which will contain the tab models. | 119 // Use the session to create a window which will contain the tab models. |
119 NSString* state_path = base::SysUTF8ToNSString( | 120 NSString* state_path = base::SysUTF8ToNSString( |
120 chrome_browser_state_->GetStatePath().AsUTF8Unsafe()); | 121 chrome_browser_state_->GetStatePath().AsUTF8Unsafe()); |
121 SessionWindowIOS* session_window = [[SessionServiceIOS sharedService] | 122 SessionIOS* session = |
122 loadSessionWindowFromDirectory:state_path]; | 123 [[SessionServiceIOS sharedService] loadSessionFromDirectory:state_path]; |
| 124 DCHECK_EQ(session.sessionWindows.count, 1u); |
123 | 125 |
124 // Tab models. The off-the-record (OTR) tab model is required for the stack | 126 // Tab models. The off-the-record (OTR) tab model is required for the stack |
125 // view controller, which is created in OpenStackView(). | 127 // view controller, which is created in OpenStackView(). |
126 tab_model_.reset([[TabModel alloc] | 128 tab_model_.reset([[TabModel alloc] |
127 initWithSessionWindow:session_window | 129 initWithSessionWindow:session.sessionWindows[0] |
128 sessionService:[SessionServiceIOS sharedService] | 130 sessionService:[SessionServiceIOS sharedService] |
129 browserState:chrome_browser_state_.get()]); | 131 browserState:chrome_browser_state_.get()]); |
130 otr_tab_model_.reset([[TabModel alloc] | 132 otr_tab_model_.reset([[TabModel alloc] |
131 initWithSessionWindow:session_window | 133 initWithSessionWindow:session.sessionWindows[0] |
132 sessionService:[SessionServiceIOS sharedService] | 134 sessionService:[SessionServiceIOS sharedService] |
133 browserState:chrome_browser_state_ | 135 browserState:chrome_browser_state_ |
134 ->GetOffTheRecordChromeBrowserState()]); | 136 ->GetOffTheRecordChromeBrowserState()]); |
135 | 137 |
136 // Create the browser view controller with its testing factory. | 138 // Create the browser view controller with its testing factory. |
137 bvc_factory_.reset([[TestBVCDependencyFactory alloc] | 139 bvc_factory_.reset([[TestBVCDependencyFactory alloc] |
138 initWithBrowserState:chrome_browser_state_.get()]); | 140 initWithBrowserState:chrome_browser_state_.get()]); |
139 bvc_.reset([[BrowserViewController alloc] | 141 bvc_.reset([[BrowserViewController alloc] |
140 initWithTabModel:tab_model_ | 142 initWithTabModel:tab_model_ |
141 browserState:chrome_browser_state_.get() | 143 browserState:chrome_browser_state_.get() |
(...skipping 26 matching lines...) Expand all Loading... |
168 // NSAutoreleasePool can drain. This needs to be done before | 170 // NSAutoreleasePool can drain. This needs to be done before |
169 // |chrome_browser_state_| can be cleared. For tests that allocate more | 171 // |chrome_browser_state_| can be cleared. For tests that allocate more |
170 // objects, more runloop time may be required. | 172 // objects, more runloop time may be required. |
171 if (slow_teardown_) | 173 if (slow_teardown_) |
172 SpinRunLoop(.5); | 174 SpinRunLoop(.5); |
173 PerfTest::TearDown(); | 175 PerfTest::TearDown(); |
174 | 176 |
175 // The profiles can be deallocated only after the BVC has been deallocated. | 177 // The profiles can be deallocated only after the BVC has been deallocated. |
176 chrome_browser_state_.reset(); | 178 chrome_browser_state_.reset(); |
177 } | 179 } |
OLD | NEW |