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

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

Issue 2756893002: Add Keyboard Latency UMA Metrics. (Closed)
Patch Set: mfomitchev responses, rebase Created 3 years, 7 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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 content::NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kRawKeyDown, 477 content::NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kRawKeyDown,
478 blink::WebInputEvent::kNoModifiers, 478 blink::WebInputEvent::kNoModifiers,
479 ui::EventTimeForNow()); 479 ui::EventTimeForNow());
480 event.windows_key_code = key_code; 480 event.windows_key_code = key_code;
481 event.dom_code = static_cast<int>(code); 481 event.dom_code = static_cast<int>(code);
482 event.dom_key = key; 482 event.dom_key = key;
483 test_delegate_.Reset(); 483 test_delegate_.Reset();
484 // Install the key press event sink to ensure that any events that are not 484 // Install the key press event sink to ensure that any events that are not
485 // handled by the installed callbacks do not end up crashing the test. 485 // handled by the installed callbacks do not end up crashing the test.
486 widget->AddKeyPressEventCallback(key_press_event_sink_); 486 widget->AddKeyPressEventCallback(key_press_event_sink_);
487 widget->ForwardKeyboardEvent(event); 487 widget->ForwardKeyboardEventWithLatencyInfo(event, ui::LatencyInfo());
488 test_delegate_.Wait(); 488 test_delegate_.Wait();
489 widget->RemoveKeyPressEventCallback(key_press_event_sink_); 489 widget->RemoveKeyPressEventCallback(key_press_event_sink_);
490 } 490 }
491 491
492 void SendKeyToDataListPopup(ui::DomKey key) { 492 void SendKeyToDataListPopup(ui::DomKey key) {
493 ui::KeyboardCode key_code = ui::NonPrintableDomKeyToKeyboardCode(key); 493 ui::KeyboardCode key_code = ui::NonPrintableDomKeyToKeyboardCode(key);
494 ui::DomCode code = ui::UsLayoutKeyboardCodeToDomCode(key_code); 494 ui::DomCode code = ui::UsLayoutKeyboardCodeToDomCode(key_code);
495 SendKeyToDataListPopup(key, code, key_code); 495 SendKeyToDataListPopup(key, code, key_code);
496 } 496 }
497 497
498 // Datalist does not support autofill preview. There is no need to start 498 // Datalist does not support autofill preview. There is no need to start
499 // message loop for Datalist. 499 // message loop for Datalist.
500 void SendKeyToDataListPopup(ui::DomKey key, 500 void SendKeyToDataListPopup(ui::DomKey key,
501 ui::DomCode code, 501 ui::DomCode code,
502 ui::KeyboardCode key_code) { 502 ui::KeyboardCode key_code) {
503 // Route popup-targeted key presses via the render view host. 503 // Route popup-targeted key presses via the render view host.
504 content::NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kRawKeyDown, 504 content::NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kRawKeyDown,
505 blink::WebInputEvent::kNoModifiers, 505 blink::WebInputEvent::kNoModifiers,
506 ui::EventTimeForNow()); 506 ui::EventTimeForNow());
507 event.windows_key_code = key_code; 507 event.windows_key_code = key_code;
508 event.dom_code = static_cast<int>(code); 508 event.dom_code = static_cast<int>(code);
509 event.dom_key = key; 509 event.dom_key = key;
510 // Install the key press event sink to ensure that any events that are not 510 // Install the key press event sink to ensure that any events that are not
511 // handled by the installed callbacks do not end up crashing the test. 511 // handled by the installed callbacks do not end up crashing the test.
512 GetRenderViewHost()->GetWidget()->AddKeyPressEventCallback( 512 GetRenderViewHost()->GetWidget()->AddKeyPressEventCallback(
513 key_press_event_sink_); 513 key_press_event_sink_);
514 GetRenderViewHost()->GetWidget()->ForwardKeyboardEvent(event); 514 GetRenderViewHost()->GetWidget()->ForwardKeyboardEventWithLatencyInfo(
515 event, ui::LatencyInfo());
515 GetRenderViewHost()->GetWidget()->RemoveKeyPressEventCallback( 516 GetRenderViewHost()->GetWidget()->RemoveKeyPressEventCallback(
516 key_press_event_sink_); 517 key_press_event_sink_);
517 } 518 }
518 519
519 void TryBasicFormFill() { 520 void TryBasicFormFill() {
520 FocusFirstNameField(); 521 FocusFirstNameField();
521 522
522 // Start filling the first name field with "M" and wait for the popup to be 523 // Start filling the first name field with "M" and wait for the popup to be
523 // shown. 524 // shown.
524 SendKeyToPageAndWait(ui::DomKey::FromCharacter('M'), ui::DomCode::US_M, 525 SendKeyToPageAndWait(ui::DomKey::FromCharacter('M'), ui::DomCode::US_M,
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 std::string script_focus( 1861 std::string script_focus(
1861 "window.focus();" 1862 "window.focus();"
1862 "document.getElementById('CREDIT_CARD_NUMBER').focus();"); 1863 "document.getElementById('CREDIT_CARD_NUMBER').focus();");
1863 ASSERT_TRUE(content::ExecuteScript(cross_frame, script_focus)); 1864 ASSERT_TRUE(content::ExecuteScript(cross_frame, script_focus));
1864 1865
1865 // Send an arrow dow keypress in order to trigger the autofill popup. 1866 // Send an arrow dow keypress in order to trigger the autofill popup.
1866 SendKeyToPageAndWait(ui::DomKey::ARROW_DOWN); 1867 SendKeyToPageAndWait(ui::DomKey::ARROW_DOWN);
1867 } 1868 }
1868 1869
1869 } // namespace autofill 1870 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698