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

Side by Side Diff: ios/chrome/browser/ui/omnibox_perftest.mm

Issue 2775623002: [ios] WebStateList owns all WebState it manages. (Closed)
Patch Set: Fix gn check Created 3 years, 8 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
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 #import <UIKit/UIKit.h> 5 #import <UIKit/UIKit.h>
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // Sets up the listener for keyboard activation/deactivation notifications. 68 // Sets up the listener for keyboard activation/deactivation notifications.
69 keyboard_listener_.reset([[KeyboardAppearanceListener alloc] init]); 69 keyboard_listener_.reset([[KeyboardAppearanceListener alloc] init]);
70 70
71 // Create a real window to host the Toolbar. 71 // Create a real window to host the Toolbar.
72 CGRect screenBounds = [[UIScreen mainScreen] bounds]; 72 CGRect screenBounds = [[UIScreen mainScreen] bounds];
73 window_.reset([[UIWindow alloc] initWithFrame:screenBounds]); 73 window_.reset([[UIWindow alloc] initWithFrame:screenBounds]);
74 [window_ makeKeyAndVisible]; 74 [window_ makeKeyAndVisible];
75 75
76 // Create a WebStateList that will always return the test WebState as 76 // Create a WebStateList that will always return the test WebState as
77 // the active WebState. 77 // the active WebState.
78 web_state_list_ = base::MakeUnique<WebStateList>( 78 web_state_list_ = base::MakeUnique<WebStateList>(&web_state_list_delegate_);
79 &web_state_list_delegate_, WebStateList::WebStateOwned);
80 std::unique_ptr<web::TestWebState> web_state = 79 std::unique_ptr<web::TestWebState> web_state =
81 base::MakeUnique<web::TestWebState>(); 80 base::MakeUnique<web::TestWebState>();
82 web_state_list_->InsertWebState(0, web_state.release()); 81 web_state_list_->InsertWebState(0, std::move(web_state));
83 82
84 // Creates the Toolbar for testing and sizes it to the width of the screen. 83 // Creates the Toolbar for testing and sizes it to the width of the screen.
85 toolbar_model_delegate_.reset( 84 toolbar_model_delegate_.reset(
86 new ToolbarModelDelegateIOS(web_state_list_.get())); 85 new ToolbarModelDelegateIOS(web_state_list_.get()));
87 toolbar_model_ios_.reset( 86 toolbar_model_ios_.reset(
88 new ToolbarModelImplIOS(toolbar_model_delegate_.get())); 87 new ToolbarModelImplIOS(toolbar_model_delegate_.get()));
89 88
90 // The OCMOCK_VALUE macro doesn't like std::unique_ptr, but it works just 89 // The OCMOCK_VALUE macro doesn't like std::unique_ptr, but it works just
91 // fine if a temporary variable is used. 90 // fine if a temporary variable is used.
92 ToolbarModelIOS* model_for_mock = toolbar_model_ios_.get(); 91 ToolbarModelIOS* model_for_mock = toolbar_model_ios_.get();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 }, 197 },
199 ^bool() { 198 ^bool() {
200 return ![keyboard_listener_ isKeyboardVisible]; 199 return ![keyboard_listener_ isKeyboardVisible];
201 }, 200 },
202 false, base::TimeDelta()); 201 false, base::TimeDelta());
203 } 202 }
204 203
205 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; 204 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
206 FakeWebStateListDelegate web_state_list_delegate_; 205 FakeWebStateListDelegate web_state_list_delegate_;
207 std::unique_ptr<WebStateList> web_state_list_; 206 std::unique_ptr<WebStateList> web_state_list_;
208 web::WebState* web_state_;
209 std::unique_ptr<ToolbarModelDelegateIOS> toolbar_model_delegate_; 207 std::unique_ptr<ToolbarModelDelegateIOS> toolbar_model_delegate_;
210 std::unique_ptr<ToolbarModelIOS> toolbar_model_ios_; 208 std::unique_ptr<ToolbarModelIOS> toolbar_model_ios_;
211 base::scoped_nsobject<WebToolbarController> toolbar_; 209 base::scoped_nsobject<WebToolbarController> toolbar_;
212 base::scoped_nsobject<UIWindow> window_; 210 base::scoped_nsobject<UIWindow> window_;
213 base::scoped_nsobject<KeyboardAppearanceListener> keyboard_listener_; 211 base::scoped_nsobject<KeyboardAppearanceListener> keyboard_listener_;
214 }; 212 };
215 213
216 // Measures the amount of time it takes the Omnibox text field to activate 214 // Measures the amount of time it takes the Omnibox text field to activate
217 // the on-screen keyboard. 215 // the on-screen keyboard.
218 TEST_F(OmniboxPerfTest, TestTextFieldDidBeginEditing) { 216 TEST_F(OmniboxPerfTest, TestTextFieldDidBeginEditing) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 267 }
270 NSLog(@"%2d: %@", index, logMessage); 268 NSLog(@"%2d: %@", index, logMessage);
271 return elapsed; 269 return elapsed;
272 }, 270 },
273 ^() { 271 ^() {
274 [textField setText:@""]; 272 [textField setText:@""];
275 DisableKeyboard(textField); 273 DisableKeyboard(textField);
276 }); 274 });
277 } 275 }
278 } 276 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698