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

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: Fix bug with coalesced events. Created 4 years 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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollBegin( 543 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollBegin(
544 5.f, -5.f, blink::WebGestureDeviceTouchscreen); 544 5.f, -5.f, blink::WebGestureDeviceTouchscreen);
545 ui::LatencyInfo scroll_latency; 545 ui::LatencyInfo scroll_latency;
546 AddFakeComponents(*tracker(), &scroll_latency); 546 AddFakeComponents(*tracker(), &scroll_latency);
547 // Don't include the rendering schedule component, since we're testing the 547 // Don't include the rendering schedule component, since we're testing the
548 // case where rendering isn't scheduled. 548 // case where rendering isn't scheduled.
549 tracker()->OnInputEvent(scroll, &scroll_latency); 549 tracker()->OnInputEvent(scroll, &scroll_latency);
550 tracker()->OnInputEventAck(scroll, &scroll_latency, 550 tracker()->OnInputEventAck(scroll, &scroll_latency,
551 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 551 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
552 EXPECT_TRUE(scroll_latency.FindLatency( 552 EXPECT_TRUE(scroll_latency.FindLatency(
553 ui::INPUT_EVENT_LATENCY_TERMINATED_GESTURE_COMPONENT, 0, nullptr)); 553 ui::INPUT_EVENT_LATENCY_TERMINATED_COMPONENT, 0, nullptr));
554 EXPECT_TRUE(scroll_latency.terminated()); 554 EXPECT_TRUE(scroll_latency.terminated());
555 } 555 }
556 556
557 { 557 {
558 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( 558 auto wheel = SyntheticWebMouseWheelEventBuilder::Build(
559 blink::WebMouseWheelEvent::PhaseChanged); 559 blink::WebMouseWheelEvent::PhaseChanged);
560 ui::LatencyInfo wheel_latency; 560 ui::LatencyInfo wheel_latency;
561 AddFakeComponents(*tracker(), &wheel_latency); 561 AddFakeComponents(*tracker(), &wheel_latency);
562 tracker()->OnInputEvent(wheel, &wheel_latency); 562 tracker()->OnInputEvent(wheel, &wheel_latency);
563 tracker()->OnInputEventAck(wheel, &wheel_latency, 563 tracker()->OnInputEventAck(wheel, &wheel_latency,
564 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 564 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
565 EXPECT_TRUE(wheel_latency.FindLatency( 565 EXPECT_TRUE(wheel_latency.FindLatency(
566 ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_WHEEL_COMPONENT, 0, nullptr)); 566 ui::INPUT_EVENT_LATENCY_TERMINATED_COMPONENT, 0, nullptr));
567 EXPECT_TRUE(wheel_latency.terminated()); 567 EXPECT_TRUE(wheel_latency.terminated());
568 } 568 }
569 569
570 { 570 {
571 SyntheticWebTouchEvent touch; 571 SyntheticWebTouchEvent touch;
572 touch.PressPoint(0, 0); 572 touch.PressPoint(0, 0);
573 ui::LatencyInfo touch_latency; 573 ui::LatencyInfo touch_latency;
574 AddFakeComponents(*tracker(), &touch_latency); 574 AddFakeComponents(*tracker(), &touch_latency);
575 tracker()->OnInputEvent(touch, &touch_latency); 575 tracker()->OnInputEvent(touch, &touch_latency);
576 tracker()->OnInputEventAck(touch, &touch_latency, 576 tracker()->OnInputEventAck(touch, &touch_latency,
577 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 577 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
578 EXPECT_TRUE(touch_latency.FindLatency( 578 EXPECT_TRUE(touch_latency.FindLatency(
579 ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, nullptr)); 579 ui::INPUT_EVENT_LATENCY_TERMINATED_COMPONENT, 0, nullptr));
580 EXPECT_TRUE(touch_latency.terminated()); 580 EXPECT_TRUE(touch_latency.terminated());
581 tracker()->OnFrameSwapped(touch_latency, false); 581 tracker()->OnFrameSwapped(touch_latency, false);
582 } 582 }
583 583
584 { 584 {
585 auto mouse_move = SyntheticWebMouseEventBuilder::Build( 585 auto mouse_move = SyntheticWebMouseEventBuilder::Build(
586 blink::WebMouseEvent::MouseMove); 586 blink::WebMouseEvent::MouseMove);
587 ui::LatencyInfo mouse_latency; 587 ui::LatencyInfo mouse_latency;
588 AddFakeComponents(*tracker(), &mouse_latency); 588 AddFakeComponents(*tracker(), &mouse_latency);
589 tracker()->OnInputEvent(mouse_move, &mouse_latency); 589 tracker()->OnInputEvent(mouse_move, &mouse_latency);
590 tracker()->OnInputEventAck(mouse_move, &mouse_latency, 590 tracker()->OnInputEventAck(mouse_move, &mouse_latency,
591 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 591 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
592 EXPECT_TRUE(mouse_latency.FindLatency( 592 EXPECT_TRUE(mouse_latency.FindLatency(
593 ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_COMPONENT, 0, nullptr)); 593 ui::INPUT_EVENT_LATENCY_TERMINATED_COMPONENT, 0, nullptr));
594 EXPECT_TRUE(mouse_latency.terminated()); 594 EXPECT_TRUE(mouse_latency.terminated());
595 } 595 }
596 596
597 { 597 {
598 auto key_event = SyntheticWebKeyboardEventBuilder::Build( 598 auto key_event = SyntheticWebKeyboardEventBuilder::Build(
599 blink::WebKeyboardEvent::Char); 599 blink::WebKeyboardEvent::Char);
600 ui::LatencyInfo key_latency; 600 ui::LatencyInfo key_latency;
601 AddFakeComponents(*tracker(), &key_latency); 601 AddFakeComponents(*tracker(), &key_latency);
602 tracker()->OnInputEvent(key_event, &key_latency); 602 tracker()->OnInputEvent(key_event, &key_latency);
603 tracker()->OnInputEventAck(key_event, &key_latency, 603 tracker()->OnInputEventAck(key_event, &key_latency,
604 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 604 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
605 EXPECT_TRUE(key_latency.FindLatency( 605 EXPECT_TRUE(key_latency.FindLatency(
606 ui::INPUT_EVENT_LATENCY_TERMINATED_KEYBOARD_COMPONENT, 0, nullptr)); 606 ui::INPUT_EVENT_LATENCY_TERMINATED_COMPONENT, 0, nullptr));
607 EXPECT_TRUE(key_latency.terminated()); 607 EXPECT_TRUE(key_latency.terminated());
608 } 608 }
609 609
610 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelUI", 1)); 610 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelUI", 1));
611 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.TouchUI", 1)); 611 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.TouchUI", 1));
612 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelAcked", 1)); 612 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelAcked", 1));
613 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.TouchAcked", 1)); 613 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.TouchAcked", 1));
614 EXPECT_TRUE( 614 EXPECT_TRUE(
615 HistogramSizeEq("Event.Latency.TouchToFirstScrollUpdateSwapBegin", 1)); 615 HistogramSizeEq("Event.Latency.TouchToFirstScrollUpdateSwapBegin", 1));
616 EXPECT_TRUE(HistogramSizeEq("Event.Latency.TouchToScrollUpdateSwapBegin", 1)); 616 EXPECT_TRUE(HistogramSizeEq("Event.Latency.TouchToScrollUpdateSwapBegin", 1));
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]), 775 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]),
776 1); 776 1);
777 777
778 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 778 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
779 // overwriting components. 779 // overwriting components.
780 tracker()->ComputeInputLatencyHistograms( 780 tracker()->ComputeInputLatencyHistograms(
781 event.type, tracker()->latency_component_id(), fake_latency, 781 event.type, tracker()->latency_component_id(), fake_latency,
782 blocking); 782 blocking);
783 783
784 tracker()->OnInputEventAck(event, &latency, 784 tracker()->OnInputEventAck(event, &latency,
785 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 785 blocking);
786 } 786 }
787 787
788 { 788 {
789 // Touch move. 789 // Touch move.
790 ui::LatencyInfo latency; 790 ui::LatencyInfo latency;
791 event.MovePoint(0, 20, 20); 791 event.MovePoint(0, 20, 20);
792 tracker()->OnInputEvent(event, &latency); 792 tracker()->OnInputEvent(event, &latency);
793 793
794 EXPECT_TRUE(latency.FindLatency( 794 EXPECT_TRUE(latency.FindLatency(
795 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 795 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"), 921 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"),
922 ElementsAre(Bucket( 922 ElementsAre(Bucket(
923 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); 923 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1)));
924 EXPECT_THAT(histogram_tester().GetAllSamples( 924 EXPECT_THAT(histogram_tester().GetAllSamples(
925 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"), 925 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"),
926 ElementsAre(Bucket( 926 ElementsAre(Bucket(
927 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); 927 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1)));
928 } 928 }
929 929
930 } // namespace content 930 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698