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

Side by Side Diff: chrome/browser/autofill/autofill_interactive_uitest.cc

Issue 2756893002: Add Keyboard Latency UMA Metrics. (Closed)
Patch Set: Fix test issue 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 blink::WebInputEvent::NoModifiers, 459 blink::WebInputEvent::NoModifiers,
460 ui::EventTimeForNow()); 460 ui::EventTimeForNow());
461 event.windowsKeyCode = key_code; 461 event.windowsKeyCode = key_code;
462 event.domCode = static_cast<int>(code); 462 event.domCode = static_cast<int>(code);
463 event.domKey = key; 463 event.domKey = key;
464 test_delegate_.Reset(); 464 test_delegate_.Reset();
465 // Install the key press event sink to ensure that any events that are not 465 // Install the key press event sink to ensure that any events that are not
466 // handled by the installed callbacks do not end up crashing the test. 466 // handled by the installed callbacks do not end up crashing the test.
467 GetRenderViewHost()->GetWidget()->AddKeyPressEventCallback( 467 GetRenderViewHost()->GetWidget()->AddKeyPressEventCallback(
468 key_press_event_sink_); 468 key_press_event_sink_);
469 GetRenderViewHost()->GetWidget()->ForwardKeyboardEvent(event); 469 GetRenderViewHost()->GetWidget()->ForwardKeyboardEventWithLatencyInfo(
470 event, ui::LatencyInfo());
470 test_delegate_.Wait(); 471 test_delegate_.Wait();
471 GetRenderViewHost()->GetWidget()->RemoveKeyPressEventCallback( 472 GetRenderViewHost()->GetWidget()->RemoveKeyPressEventCallback(
472 key_press_event_sink_); 473 key_press_event_sink_);
473 } 474 }
474 475
475 void SendKeyToDataListPopup(ui::DomKey key) { 476 void SendKeyToDataListPopup(ui::DomKey key) {
476 ui::KeyboardCode key_code = ui::NonPrintableDomKeyToKeyboardCode(key); 477 ui::KeyboardCode key_code = ui::NonPrintableDomKeyToKeyboardCode(key);
477 ui::DomCode code = ui::UsLayoutKeyboardCodeToDomCode(key_code); 478 ui::DomCode code = ui::UsLayoutKeyboardCodeToDomCode(key_code);
478 SendKeyToDataListPopup(key, code, key_code); 479 SendKeyToDataListPopup(key, code, key_code);
479 } 480 }
480 481
481 // Datalist does not support autofill preview. There is no need to start 482 // Datalist does not support autofill preview. There is no need to start
482 // message loop for Datalist. 483 // message loop for Datalist.
483 void SendKeyToDataListPopup(ui::DomKey key, 484 void SendKeyToDataListPopup(ui::DomKey key,
484 ui::DomCode code, 485 ui::DomCode code,
485 ui::KeyboardCode key_code) { 486 ui::KeyboardCode key_code) {
486 // Route popup-targeted key presses via the render view host. 487 // Route popup-targeted key presses via the render view host.
487 content::NativeWebKeyboardEvent event(blink::WebKeyboardEvent::RawKeyDown, 488 content::NativeWebKeyboardEvent event(blink::WebKeyboardEvent::RawKeyDown,
488 blink::WebInputEvent::NoModifiers, 489 blink::WebInputEvent::NoModifiers,
489 ui::EventTimeForNow()); 490 ui::EventTimeForNow());
490 event.windowsKeyCode = key_code; 491 event.windowsKeyCode = key_code;
491 event.domCode = static_cast<int>(code); 492 event.domCode = static_cast<int>(code);
492 event.domKey = key; 493 event.domKey = key;
493 // Install the key press event sink to ensure that any events that are not 494 // Install the key press event sink to ensure that any events that are not
494 // handled by the installed callbacks do not end up crashing the test. 495 // handled by the installed callbacks do not end up crashing the test.
495 GetRenderViewHost()->GetWidget()->AddKeyPressEventCallback( 496 GetRenderViewHost()->GetWidget()->AddKeyPressEventCallback(
496 key_press_event_sink_); 497 key_press_event_sink_);
497 GetRenderViewHost()->GetWidget()->ForwardKeyboardEvent(event); 498 GetRenderViewHost()->GetWidget()->ForwardKeyboardEventWithLatencyInfo(
499 event, ui::LatencyInfo());
498 GetRenderViewHost()->GetWidget()->RemoveKeyPressEventCallback( 500 GetRenderViewHost()->GetWidget()->RemoveKeyPressEventCallback(
499 key_press_event_sink_); 501 key_press_event_sink_);
500 } 502 }
501 503
502 void TryBasicFormFill() { 504 void TryBasicFormFill() {
503 FocusFirstNameField(); 505 FocusFirstNameField();
504 506
505 // Start filling the first name field with "M" and wait for the popup to be 507 // Start filling the first name field with "M" and wait for the popup to be
506 // shown. 508 // shown.
507 SendKeyToPageAndWait(ui::DomKey::FromCharacter('M'), ui::DomCode::US_M, 509 SendKeyToPageAndWait(ui::DomKey::FromCharacter('M'), ui::DomCode::US_M,
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), url)); 1731 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), url));
1730 1732
1731 ASSERT_TRUE(content::ExecuteScript( 1733 ASSERT_TRUE(content::ExecuteScript(
1732 GetRenderViewHost(), 1734 GetRenderViewHost(),
1733 "document.getElementById('user').value = 'user';")); 1735 "document.getElementById('user').value = 'user';"));
1734 FocusFieldByName("password"); 1736 FocusFieldByName("password");
1735 PasteStringAndWait("foobar"); 1737 PasteStringAndWait("foobar");
1736 } 1738 }
1737 1739
1738 } // namespace autofill 1740 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698