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 #import <UIKit/UIKit.h> | 5 #import <UIKit/UIKit.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #import "base/test/ios/wait_util.h" | 10 #import "base/test/ios/wait_util.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 std::unique_ptr<WebStateList> web_state_list_; | 208 std::unique_ptr<WebStateList> web_state_list_; |
209 std::unique_ptr<ToolbarModelDelegateIOS> toolbar_model_delegate_; | 209 std::unique_ptr<ToolbarModelDelegateIOS> toolbar_model_delegate_; |
210 std::unique_ptr<ToolbarModelIOS> toolbar_model_ios_; | 210 std::unique_ptr<ToolbarModelIOS> toolbar_model_ios_; |
211 WebToolbarController* toolbar_; | 211 WebToolbarController* toolbar_; |
212 UIWindow* window_; | 212 UIWindow* window_; |
213 KeyboardAppearanceListener* keyboard_listener_; | 213 KeyboardAppearanceListener* keyboard_listener_; |
214 }; | 214 }; |
215 | 215 |
216 // Measures the amount of time it takes the Omnibox text field to activate | 216 // Measures the amount of time it takes the Omnibox text field to activate |
217 // the on-screen keyboard. | 217 // the on-screen keyboard. |
218 TEST_F(OmniboxPerfTest, TestTextFieldDidBeginEditing) { | 218 // TODO(crbug.com/717300): Test disabled because of a DCHECK in Reading List. |
| 219 TEST_F(OmniboxPerfTest, DISABLED_TestTextFieldDidBeginEditing) { |
219 LogPerfTiming("Keyboard preload", PreLoadKeyboard()); | 220 LogPerfTiming("Keyboard preload", PreLoadKeyboard()); |
220 OmniboxTextFieldIOS* textField = (OmniboxTextFieldIOS*)FindViewByClass( | 221 OmniboxTextFieldIOS* textField = (OmniboxTextFieldIOS*)FindViewByClass( |
221 [toolbar_ view], [OmniboxTextFieldIOS class]); | 222 [toolbar_ view], [OmniboxTextFieldIOS class]); |
222 | 223 |
223 // Time how long it takes to "focus" on omnibox. | 224 // Time how long it takes to "focus" on omnibox. |
224 RepeatTimedRuns("Begin editing", | 225 RepeatTimedRuns("Begin editing", |
225 ^base::TimeDelta(int index) { | 226 ^base::TimeDelta(int index) { |
226 return EnableKeyboard(textField); | 227 return EnableKeyboard(textField); |
227 }, | 228 }, |
228 ^() { | 229 ^() { |
229 DisableKeyboard(textField); | 230 DisableKeyboard(textField); |
230 }); | 231 }); |
231 } | 232 } |
232 | 233 |
233 // Measures the amount of time it takes to type in the first character | 234 // Measures the amount of time it takes to type in the first character |
234 // into the Omnibox. | 235 // into the Omnibox. |
235 TEST_F(OmniboxPerfTest, TestTypeOneCharInTextField) { | 236 // TODO(crbug.com/717309): Test disabled because of nullptr dereferencing. |
| 237 TEST_F(OmniboxPerfTest, DISABLED_TestTypeOneCharInTextField) { |
236 OmniboxTextFieldIOS* textField = (OmniboxTextFieldIOS*)FindViewByClass( | 238 OmniboxTextFieldIOS* textField = (OmniboxTextFieldIOS*)FindViewByClass( |
237 [toolbar_ view], [OmniboxTextFieldIOS class]); | 239 [toolbar_ view], [OmniboxTextFieldIOS class]); |
238 RepeatTimedRuns("Type first character", | 240 RepeatTimedRuns("Type first character", |
239 ^base::TimeDelta(int index) { | 241 ^base::TimeDelta(int index) { |
240 EnableKeyboard(textField); | 242 EnableKeyboard(textField); |
241 return TimeInsertText(textField, @"G"); | 243 return TimeInsertText(textField, @"G"); |
242 }, | 244 }, |
243 ^() { | 245 ^() { |
244 [textField setText:@""]; | 246 [textField setText:@""]; |
245 DisableKeyboard(textField); | 247 DisableKeyboard(textField); |
246 }); | 248 }); |
247 } | 249 } |
248 | 250 |
249 // Measures the amount of time it takes to type in the word "google" one | 251 // Measures the amount of time it takes to type in the word "google" one |
250 // letter at a time. | 252 // letter at a time. |
251 TEST_F(OmniboxPerfTest, TestTypingInTextField) { | 253 // TODO(crbug.com/717309): Test disabled because of nullptr dereferencing. |
| 254 TEST_F(OmniboxPerfTest, DISABLED_TestTypingInTextField) { |
252 OmniboxTextFieldIOS* textField = (OmniboxTextFieldIOS*)FindViewByClass( | 255 OmniboxTextFieldIOS* textField = (OmniboxTextFieldIOS*)FindViewByClass( |
253 [toolbar_ view], [OmniboxTextFieldIOS class]); | 256 [toolbar_ view], [OmniboxTextFieldIOS class]); |
254 // The characters to type into the omnibox text field. | 257 // The characters to type into the omnibox text field. |
255 NSArray* inputCharacters = | 258 NSArray* inputCharacters = |
256 [NSArray arrayWithObjects:@"g", @"o", @"o", @"g", @"l", @"e", nil]; | 259 [NSArray arrayWithObjects:@"g", @"o", @"o", @"g", @"l", @"e", nil]; |
257 RepeatTimedRuns( | 260 RepeatTimedRuns( |
258 "Typing", | 261 "Typing", |
259 ^base::TimeDelta(int index) { | 262 ^base::TimeDelta(int index) { |
260 EnableKeyboard(textField); | 263 EnableKeyboard(textField); |
261 NSMutableString* logMessage = [NSMutableString string]; | 264 NSMutableString* logMessage = [NSMutableString string]; |
262 base::TimeDelta elapsed; | 265 base::TimeDelta elapsed; |
263 for (NSString* input in inputCharacters) { | 266 for (NSString* input in inputCharacters) { |
264 base::TimeDelta inputElapsed = TimeInsertText(textField, input); | 267 base::TimeDelta inputElapsed = TimeInsertText(textField, input); |
265 [logMessage appendFormat:@"%@'%@':%.0f", | 268 [logMessage appendFormat:@"%@'%@':%.0f", |
266 [logMessage length] ? @" " : @"", input, | 269 [logMessage length] ? @" " : @"", input, |
267 inputElapsed.InMillisecondsF()]; | 270 inputElapsed.InMillisecondsF()]; |
268 elapsed += inputElapsed; | 271 elapsed += inputElapsed; |
269 } | 272 } |
270 NSLog(@"%2d: %@", index, logMessage); | 273 NSLog(@"%2d: %@", index, logMessage); |
271 return elapsed; | 274 return elapsed; |
272 }, | 275 }, |
273 ^() { | 276 ^() { |
274 [textField setText:@""]; | 277 [textField setText:@""]; |
275 DisableKeyboard(textField); | 278 DisableKeyboard(textField); |
276 }); | 279 }); |
277 } | 280 } |
278 } | 281 } |
OLD | NEW |