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

Side by Side Diff: content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc

Issue 2570893003: Clean up LatencyInfo and RWHLatencyTracker. (Closed)
Patch Set: Avoid introducing new bare calls to FactoryGet. Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/test/histogram_tester.h" 5 #include "base/test/histogram_tester.h"
6 #include "components/rappor/public/rappor_utils.h" 6 #include "components/rappor/public/rappor_utils.h"
7 #include "components/rappor/test_rappor_service.h" 7 #include "components/rappor/test_rappor_service.h"
8 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h" 8 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h"
9 #include "content/common/input/synthetic_web_input_event_builders.h" 9 #include "content/common/input/synthetic_web_input_event_builders.h"
10 #include "content/public/browser/native_web_keyboard_event.h" 10 #include "content/public/browser/native_web_keyboard_event.h"
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollBegin( 624 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollBegin(
625 5.f, -5.f, blink::WebGestureDeviceTouchscreen); 625 5.f, -5.f, blink::WebGestureDeviceTouchscreen);
626 ui::LatencyInfo scroll_latency; 626 ui::LatencyInfo scroll_latency;
627 AddFakeComponents(*tracker(), &scroll_latency); 627 AddFakeComponents(*tracker(), &scroll_latency);
628 // Don't include the rendering schedule component, since we're testing the 628 // Don't include the rendering schedule component, since we're testing the
629 // case where rendering isn't scheduled. 629 // case where rendering isn't scheduled.
630 tracker()->OnInputEvent(scroll, &scroll_latency); 630 tracker()->OnInputEvent(scroll, &scroll_latency);
631 tracker()->OnInputEventAck(scroll, &scroll_latency, 631 tracker()->OnInputEventAck(scroll, &scroll_latency,
632 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 632 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
633 EXPECT_TRUE(scroll_latency.FindLatency( 633 EXPECT_TRUE(scroll_latency.FindLatency(
634 ui::INPUT_EVENT_LATENCY_TERMINATED_GESTURE_COMPONENT, 0, nullptr)); 634 ui::INPUT_EVENT_LATENCY_TERMINATED_NO_SWAP_COMPONENT, 0, nullptr));
635 EXPECT_TRUE(scroll_latency.terminated()); 635 EXPECT_TRUE(scroll_latency.terminated());
636 } 636 }
637 637
638 { 638 {
639 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( 639 auto wheel = SyntheticWebMouseWheelEventBuilder::Build(
640 blink::WebMouseWheelEvent::PhaseChanged); 640 blink::WebMouseWheelEvent::PhaseChanged);
641 ui::LatencyInfo wheel_latency; 641 ui::LatencyInfo wheel_latency;
642 AddFakeComponents(*tracker(), &wheel_latency); 642 AddFakeComponents(*tracker(), &wheel_latency);
643 tracker()->OnInputEvent(wheel, &wheel_latency); 643 tracker()->OnInputEvent(wheel, &wheel_latency);
644 tracker()->OnInputEventAck(wheel, &wheel_latency, 644 tracker()->OnInputEventAck(wheel, &wheel_latency,
645 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 645 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
646 EXPECT_TRUE(wheel_latency.FindLatency( 646 EXPECT_TRUE(wheel_latency.FindLatency(
647 ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_WHEEL_COMPONENT, 0, nullptr)); 647 ui::INPUT_EVENT_LATENCY_TERMINATED_NO_SWAP_COMPONENT, 0, nullptr));
648 EXPECT_TRUE(wheel_latency.terminated()); 648 EXPECT_TRUE(wheel_latency.terminated());
649 } 649 }
650 650
651 { 651 {
652 SyntheticWebTouchEvent touch; 652 SyntheticWebTouchEvent touch;
653 touch.PressPoint(0, 0); 653 touch.PressPoint(0, 0);
654 ui::LatencyInfo touch_latency; 654 ui::LatencyInfo touch_latency;
655 AddFakeComponents(*tracker(), &touch_latency); 655 AddFakeComponents(*tracker(), &touch_latency);
656 tracker()->OnInputEvent(touch, &touch_latency); 656 tracker()->OnInputEvent(touch, &touch_latency);
657 tracker()->OnInputEventAck(touch, &touch_latency, 657 tracker()->OnInputEventAck(touch, &touch_latency,
658 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 658 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
659 EXPECT_TRUE(touch_latency.FindLatency( 659 EXPECT_TRUE(touch_latency.FindLatency(
660 ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, nullptr)); 660 ui::INPUT_EVENT_LATENCY_TERMINATED_NO_SWAP_COMPONENT, 0, nullptr));
661 EXPECT_TRUE(touch_latency.terminated()); 661 EXPECT_TRUE(touch_latency.terminated());
662 tracker()->OnFrameSwapped(touch_latency, false); 662 tracker()->OnFrameSwapped(touch_latency, false);
663 } 663 }
664 664
665 { 665 {
666 auto mouse_move = SyntheticWebMouseEventBuilder::Build( 666 auto mouse_move = SyntheticWebMouseEventBuilder::Build(
667 blink::WebMouseEvent::MouseMove); 667 blink::WebMouseEvent::MouseMove);
668 ui::LatencyInfo mouse_latency; 668 ui::LatencyInfo mouse_latency;
669 AddFakeComponents(*tracker(), &mouse_latency); 669 AddFakeComponents(*tracker(), &mouse_latency);
670 tracker()->OnInputEvent(mouse_move, &mouse_latency); 670 tracker()->OnInputEvent(mouse_move, &mouse_latency);
671 tracker()->OnInputEventAck(mouse_move, &mouse_latency, 671 tracker()->OnInputEventAck(mouse_move, &mouse_latency,
672 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 672 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
673 EXPECT_TRUE(mouse_latency.FindLatency( 673 EXPECT_TRUE(mouse_latency.FindLatency(
674 ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_COMPONENT, 0, nullptr)); 674 ui::INPUT_EVENT_LATENCY_TERMINATED_NO_SWAP_COMPONENT, 0, nullptr));
675 EXPECT_TRUE(mouse_latency.terminated()); 675 EXPECT_TRUE(mouse_latency.terminated());
676 } 676 }
677 677
678 { 678 {
679 auto key_event = SyntheticWebKeyboardEventBuilder::Build( 679 auto key_event = SyntheticWebKeyboardEventBuilder::Build(
680 blink::WebKeyboardEvent::Char); 680 blink::WebKeyboardEvent::Char);
681 ui::LatencyInfo key_latency; 681 ui::LatencyInfo key_latency;
682 AddFakeComponents(*tracker(), &key_latency); 682 AddFakeComponents(*tracker(), &key_latency);
683 tracker()->OnInputEvent(key_event, &key_latency); 683 tracker()->OnInputEvent(key_event, &key_latency);
684 tracker()->OnInputEventAck(key_event, &key_latency, 684 tracker()->OnInputEventAck(key_event, &key_latency,
685 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 685 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
686 EXPECT_TRUE(key_latency.FindLatency( 686 EXPECT_TRUE(key_latency.FindLatency(
687 ui::INPUT_EVENT_LATENCY_TERMINATED_KEYBOARD_COMPONENT, 0, nullptr)); 687 ui::INPUT_EVENT_LATENCY_TERMINATED_NO_SWAP_COMPONENT, 0, nullptr));
688 EXPECT_TRUE(key_latency.terminated()); 688 EXPECT_TRUE(key_latency.terminated());
689 } 689 }
690 690
691 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelUI", 1)); 691 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelUI", 1));
692 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.TouchUI", 1)); 692 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.TouchUI", 1));
693 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelAcked", 1)); 693 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelAcked", 1));
694 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.TouchAcked", 1)); 694 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.TouchAcked", 1));
695 EXPECT_TRUE( 695 EXPECT_TRUE(
696 HistogramSizeEq("Event.Latency.TouchToFirstScrollUpdateSwapBegin", 1)); 696 HistogramSizeEq("Event.Latency.TouchToFirstScrollUpdateSwapBegin", 1));
697 EXPECT_TRUE(HistogramSizeEq("Event.Latency.TouchToScrollUpdateSwapBegin", 1)); 697 EXPECT_TRUE(HistogramSizeEq("Event.Latency.TouchToScrollUpdateSwapBegin", 1));
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]), 857 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]),
858 1); 858 1);
859 859
860 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 860 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
861 // overwriting components. 861 // overwriting components.
862 tracker()->ComputeInputLatencyHistograms( 862 tracker()->ComputeInputLatencyHistograms(
863 event.type(), tracker()->latency_component_id(), fake_latency, 863 event.type(), tracker()->latency_component_id(), fake_latency,
864 blocking); 864 blocking);
865 865
866 tracker()->OnInputEventAck(event, &latency, 866 tracker()->OnInputEventAck(event, &latency,
867 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 867 blocking);
868 } 868 }
869 869
870 { 870 {
871 // Touch move. 871 // Touch move.
872 ui::LatencyInfo latency; 872 ui::LatencyInfo latency;
873 event.MovePoint(0, 20, 20); 873 event.MovePoint(0, 20, 20);
874 tracker()->OnInputEvent(event, &latency); 874 tracker()->OnInputEvent(event, &latency);
875 875
876 EXPECT_TRUE(latency.FindLatency( 876 EXPECT_TRUE(latency.FindLatency(
877 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 877 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"), 1003 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"),
1004 ElementsAre(Bucket( 1004 ElementsAre(Bucket(
1005 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); 1005 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1)));
1006 EXPECT_THAT(histogram_tester().GetAllSamples( 1006 EXPECT_THAT(histogram_tester().GetAllSamples(
1007 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"), 1007 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"),
1008 ElementsAre(Bucket( 1008 ElementsAre(Bucket(
1009 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); 1009 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1)));
1010 } 1010 }
1011 1011
1012 } // namespace content 1012 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/render_widget_host_latency_tracker.cc ('k') | ui/events/latency_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698