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

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

Issue 2914023002: Remove LatencyInfo::sequence_number. (May break metrics).
Patch Set: Rebase Created 3 years, 5 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 "content/browser/renderer_host/input/render_widget_host_latency_tracker .h" 5 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h"
6 #include "base/metrics/metrics_hashes.h" 6 #include "base/metrics/metrics_hashes.h"
7 #include "base/test/histogram_tester.h" 7 #include "base/test/histogram_tester.h"
8 #include "components/metrics/proto/ukm/entry.pb.h" 8 #include "components/metrics/proto/ukm/entry.pb.h"
9 #include "components/rappor/public/rappor_utils.h" 9 #include "components/rappor/public/rappor_utils.h"
10 #include "components/rappor/test_rappor_service.h" 10 #include "components/rappor/test_rappor_service.h"
(...skipping 17 matching lines...) Expand all
28 // Trace ids are generated in sequence in practice, but in these tests, we don't 28 // Trace ids are generated in sequence in practice, but in these tests, we don't
29 // care about the value, so we'll just use a constant. 29 // care about the value, so we'll just use a constant.
30 const int kTraceEventId = 5; 30 const int kTraceEventId = 5;
31 const char kUrl[] = "http://www.foo.bar.com/subpage/1"; 31 const char kUrl[] = "http://www.foo.bar.com/subpage/1";
32 32
33 void AddFakeComponentsWithTimeStamp( 33 void AddFakeComponentsWithTimeStamp(
34 const RenderWidgetHostLatencyTracker& tracker, 34 const RenderWidgetHostLatencyTracker& tracker,
35 ui::LatencyInfo* latency, 35 ui::LatencyInfo* latency,
36 base::TimeTicks time_stamp) { 36 base::TimeTicks time_stamp) {
37 latency->AddLatencyNumberWithTimestamp(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 37 latency->AddLatencyNumberWithTimestamp(ui::INPUT_EVENT_LATENCY_UI_COMPONENT,
38 0, 0, time_stamp, 1); 38 0, time_stamp, 1);
39 latency->AddLatencyNumberWithTimestamp( 39 latency->AddLatencyNumberWithTimestamp(
40 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, time_stamp, 40 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, time_stamp,
41 1); 41 1);
42 latency->AddLatencyNumberWithTimestamp( 42 latency->AddLatencyNumberWithTimestamp(
43 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, time_stamp, 1); 43 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, time_stamp, 1);
44 latency->AddLatencyNumberWithTimestamp( 44 latency->AddLatencyNumberWithTimestamp(
45 ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, 0, time_stamp, 1); 45 ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, time_stamp, 1);
46 latency->AddLatencyNumberWithTimestamp( 46 latency->AddLatencyNumberWithTimestamp(
47 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, 0, 0, time_stamp, 1); 47 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, 0, time_stamp, 1);
48 } 48 }
49 49
50 void AddFakeComponents(const RenderWidgetHostLatencyTracker& tracker, 50 void AddFakeComponents(const RenderWidgetHostLatencyTracker& tracker,
51 ui::LatencyInfo* latency) { 51 ui::LatencyInfo* latency) {
52 latency->AddLatencyNumberWithTimestamp( 52 latency->AddLatencyNumberWithTimestamp(
53 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 53 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
54 tracker.latency_component_id(), 0, base::TimeTicks::Now(), 1); 54 tracker.latency_component_id(), base::TimeTicks::Now(), 1);
55 AddFakeComponentsWithTimeStamp(tracker, latency, base::TimeTicks::Now()); 55 AddFakeComponentsWithTimeStamp(tracker, latency, base::TimeTicks::Now());
56 } 56 }
57 57
58 void AddRenderingScheduledComponent(ui::LatencyInfo* latency, 58 void AddRenderingScheduledComponent(ui::LatencyInfo* latency,
59 bool main, 59 bool main,
60 base::TimeTicks time_stamp) { 60 base::TimeTicks time_stamp) {
61 if (main) { 61 if (main) {
62 latency->AddLatencyNumberWithTimestamp( 62 latency->AddLatencyNumberWithTimestamp(
63 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, 0, 63 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0,
64 time_stamp, 1); 64 time_stamp, 1);
65 65
66 } else { 66 } else {
67 latency->AddLatencyNumberWithTimestamp( 67 latency->AddLatencyNumberWithTimestamp(
68 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, 0, 68 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0,
69 time_stamp, 1); 69 time_stamp, 1);
70 } 70 }
71 } 71 }
72 72
73 } // namespace 73 } // namespace
74 74
75 class RenderWidgetHostLatencyTrackerTestBrowserClient 75 class RenderWidgetHostLatencyTrackerTestBrowserClient
76 : public TestContentBrowserClient { 76 : public TestContentBrowserClient {
77 public: 77 public:
78 RenderWidgetHostLatencyTrackerTestBrowserClient() {} 78 RenderWidgetHostLatencyTrackerTestBrowserClient() {}
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 for (bool rendering_on_main : {false, true}) { 235 for (bool rendering_on_main : {false, true}) {
236 ResetHistograms(); 236 ResetHistograms();
237 { 237 {
238 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( 238 auto wheel = SyntheticWebMouseWheelEventBuilder::Build(
239 blink::WebMouseWheelEvent::kPhaseChanged); 239 blink::WebMouseWheelEvent::kPhaseChanged);
240 base::TimeTicks now = base::TimeTicks::Now(); 240 base::TimeTicks now = base::TimeTicks::Now();
241 wheel.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); 241 wheel.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF());
242 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL); 242 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL);
243 wheel_latency.AddLatencyNumberWithTimestamp( 243 wheel_latency.AddLatencyNumberWithTimestamp(
244 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 244 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
245 tracker()->latency_component_id(), 0, now, 1); 245 tracker()->latency_component_id(), now, 1);
246 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now); 246 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now);
247 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); 247 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now);
248 tracker()->OnInputEvent(wheel, &wheel_latency); 248 tracker()->OnInputEvent(wheel, &wheel_latency);
249 EXPECT_TRUE(wheel_latency.FindLatency( 249 EXPECT_TRUE(wheel_latency.FindLatency(
250 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 250 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
251 tracker()->latency_component_id(), nullptr)); 251 tracker()->latency_component_id(), nullptr));
252 EXPECT_TRUE(wheel_latency.FindLatency( 252 EXPECT_TRUE(wheel_latency.FindLatency(
253 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 253 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
254 tracker()->OnInputEventAck(wheel, &wheel_latency, 254 tracker()->OnInputEventAck(wheel, &wheel_latency,
255 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 255 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 for (bool rendering_on_main : {false, true}) { 335 for (bool rendering_on_main : {false, true}) {
336 ResetHistograms(); 336 ResetHistograms();
337 { 337 {
338 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( 338 auto wheel = SyntheticWebMouseWheelEventBuilder::Build(
339 blink::WebMouseWheelEvent::kPhaseChanged); 339 blink::WebMouseWheelEvent::kPhaseChanged);
340 base::TimeTicks now = base::TimeTicks::Now(); 340 base::TimeTicks now = base::TimeTicks::Now();
341 wheel.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); 341 wheel.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF());
342 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL); 342 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL);
343 wheel_latency.AddLatencyNumberWithTimestamp( 343 wheel_latency.AddLatencyNumberWithTimestamp(
344 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 344 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
345 tracker()->latency_component_id(), 0, now, 1); 345 tracker()->latency_component_id(), now, 1);
346 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now); 346 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now);
347 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); 347 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now);
348 tracker()->OnInputEvent(wheel, &wheel_latency); 348 tracker()->OnInputEvent(wheel, &wheel_latency);
349 EXPECT_TRUE(wheel_latency.FindLatency( 349 EXPECT_TRUE(wheel_latency.FindLatency(
350 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 350 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
351 tracker()->latency_component_id(), nullptr)); 351 tracker()->latency_component_id(), nullptr));
352 EXPECT_TRUE(wheel_latency.FindLatency( 352 EXPECT_TRUE(wheel_latency.FindLatency(
353 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 353 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
354 tracker()->OnInputEventAck(wheel, &wheel_latency, 354 tracker()->OnInputEventAck(wheel, &wheel_latency,
355 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 355 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 for (bool rendering_on_main : {false, true}) { 411 for (bool rendering_on_main : {false, true}) {
412 ResetHistograms(); 412 ResetHistograms();
413 { 413 {
414 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate( 414 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate(
415 5.f, -5.f, 0, blink::kWebGestureDeviceTouchscreen); 415 5.f, -5.f, 0, blink::kWebGestureDeviceTouchscreen);
416 base::TimeTicks now = base::TimeTicks::Now(); 416 base::TimeTicks now = base::TimeTicks::Now();
417 scroll.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); 417 scroll.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF());
418 ui::LatencyInfo scroll_latency; 418 ui::LatencyInfo scroll_latency;
419 scroll_latency.AddLatencyNumberWithTimestamp( 419 scroll_latency.AddLatencyNumberWithTimestamp(
420 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 420 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
421 tracker()->latency_component_id(), 0, now, 1); 421 tracker()->latency_component_id(), now, 1);
422 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now); 422 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now);
423 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); 423 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now);
424 tracker()->OnInputEvent(scroll, &scroll_latency); 424 tracker()->OnInputEvent(scroll, &scroll_latency);
425 EXPECT_TRUE(scroll_latency.FindLatency( 425 EXPECT_TRUE(scroll_latency.FindLatency(
426 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 426 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
427 tracker()->latency_component_id(), nullptr)); 427 tracker()->latency_component_id(), nullptr));
428 EXPECT_TRUE(scroll_latency.FindLatency( 428 EXPECT_TRUE(scroll_latency.FindLatency(
429 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 429 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
430 tracker()->OnInputEventAck(scroll, &scroll_latency, 430 tracker()->OnInputEventAck(scroll, &scroll_latency,
431 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 431 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
432 } 432 }
433 433
434 { 434 {
435 SyntheticWebTouchEvent touch; 435 SyntheticWebTouchEvent touch;
436 touch.PressPoint(0, 0); 436 touch.PressPoint(0, 0);
437 touch.PressPoint(1, 1); 437 touch.PressPoint(1, 1);
438 ui::LatencyInfo touch_latency(ui::SourceEventType::TOUCH); 438 ui::LatencyInfo touch_latency(ui::SourceEventType::TOUCH);
439 base::TimeTicks now = base::TimeTicks::Now(); 439 base::TimeTicks now = base::TimeTicks::Now();
440 touch_latency.AddLatencyNumberWithTimestamp( 440 touch_latency.AddLatencyNumberWithTimestamp(
441 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 441 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
442 tracker()->latency_component_id(), 0, now, 1); 442 tracker()->latency_component_id(), now, 1);
443 AddFakeComponentsWithTimeStamp(*tracker(), &touch_latency, now); 443 AddFakeComponentsWithTimeStamp(*tracker(), &touch_latency, now);
444 AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now); 444 AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now);
445 tracker()->OnInputEvent(touch, &touch_latency); 445 tracker()->OnInputEvent(touch, &touch_latency);
446 EXPECT_TRUE(touch_latency.FindLatency( 446 EXPECT_TRUE(touch_latency.FindLatency(
447 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 447 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
448 tracker()->latency_component_id(), nullptr)); 448 tracker()->latency_component_id(), nullptr));
449 EXPECT_TRUE(touch_latency.FindLatency( 449 EXPECT_TRUE(touch_latency.FindLatency(
450 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 450 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
451 tracker()->OnInputEventAck(touch, &touch_latency, 451 tracker()->OnInputEventAck(touch, &touch_latency,
452 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 452 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 EXPECT_EQ(0, 539 EXPECT_EQ(0,
540 test_browser_client_.getTestRapporService()->GetReportsCount()); 540 test_browser_client_.getTestRapporService()->GetReportsCount());
541 { 541 {
542 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate( 542 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate(
543 5.f, -5.f, 0, blink::kWebGestureDeviceTouchscreen); 543 5.f, -5.f, 0, blink::kWebGestureDeviceTouchscreen);
544 base::TimeTicks now = base::TimeTicks::Now(); 544 base::TimeTicks now = base::TimeTicks::Now();
545 scroll.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); 545 scroll.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF());
546 ui::LatencyInfo scroll_latency; 546 ui::LatencyInfo scroll_latency;
547 scroll_latency.AddLatencyNumberWithTimestamp( 547 scroll_latency.AddLatencyNumberWithTimestamp(
548 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 548 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
549 tracker()->latency_component_id(), 0, now, 1); 549 tracker()->latency_component_id(), now, 1);
550 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now); 550 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now);
551 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); 551 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now);
552 tracker()->OnInputEvent(scroll, &scroll_latency); 552 tracker()->OnInputEvent(scroll, &scroll_latency);
553 EXPECT_TRUE(scroll_latency.FindLatency( 553 EXPECT_TRUE(scroll_latency.FindLatency(
554 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 554 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
555 tracker()->latency_component_id(), nullptr)); 555 tracker()->latency_component_id(), nullptr));
556 EXPECT_TRUE(scroll_latency.FindLatency( 556 EXPECT_TRUE(scroll_latency.FindLatency(
557 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 557 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
558 tracker()->OnInputEventAck(scroll, &scroll_latency, 558 tracker()->OnInputEventAck(scroll, &scroll_latency,
559 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 559 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
560 } 560 }
561 561
562 { 562 {
563 SyntheticWebTouchEvent touch; 563 SyntheticWebTouchEvent touch;
564 touch.PressPoint(0, 0); 564 touch.PressPoint(0, 0);
565 touch.PressPoint(1, 1); 565 touch.PressPoint(1, 1);
566 ui::LatencyInfo touch_latency(ui::SourceEventType::TOUCH); 566 ui::LatencyInfo touch_latency(ui::SourceEventType::TOUCH);
567 base::TimeTicks now = base::TimeTicks::Now(); 567 base::TimeTicks now = base::TimeTicks::Now();
568 touch_latency.AddLatencyNumberWithTimestamp( 568 touch_latency.AddLatencyNumberWithTimestamp(
569 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 569 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
570 tracker()->latency_component_id(), 0, now, 1); 570 tracker()->latency_component_id(), now, 1);
571 AddFakeComponentsWithTimeStamp(*tracker(), &touch_latency, now); 571 AddFakeComponentsWithTimeStamp(*tracker(), &touch_latency, now);
572 AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now); 572 AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now);
573 tracker()->OnInputEvent(touch, &touch_latency); 573 tracker()->OnInputEvent(touch, &touch_latency);
574 EXPECT_TRUE(touch_latency.FindLatency( 574 EXPECT_TRUE(touch_latency.FindLatency(
575 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 575 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
576 tracker()->latency_component_id(), nullptr)); 576 tracker()->latency_component_id(), nullptr));
577 EXPECT_TRUE(touch_latency.FindLatency( 577 EXPECT_TRUE(touch_latency.FindLatency(
578 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 578 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
579 tracker()->OnInputEventAck(touch, &touch_latency, 579 tracker()->OnInputEventAck(touch, &touch_latency,
580 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 580 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", 0)); 744 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", 0));
745 EXPECT_TRUE(HistogramSizeEq( 745 EXPECT_TRUE(HistogramSizeEq(
746 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", 0)); 746 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", 0));
747 EXPECT_TRUE(HistogramSizeEq("Event.Latency.ScrollUpdate.GpuSwap", 0)); 747 EXPECT_TRUE(HistogramSizeEq("Event.Latency.ScrollUpdate.GpuSwap", 0));
748 } 748 }
749 749
750 TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) { 750 TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) {
751 auto scroll_begin = SyntheticWebGestureEventBuilder::BuildScrollBegin( 751 auto scroll_begin = SyntheticWebGestureEventBuilder::BuildScrollBegin(
752 5, -5, blink::kWebGestureDeviceTouchscreen); 752 5, -5, blink::kWebGestureDeviceTouchscreen);
753 ui::LatencyInfo scroll_latency; 753 ui::LatencyInfo scroll_latency;
754 scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 754 scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
755 0); 755 0);
756 tracker()->OnInputEvent(scroll_begin, &scroll_latency); 756 tracker()->OnInputEvent(scroll_begin, &scroll_latency);
757 EXPECT_TRUE( 757 EXPECT_TRUE(
758 scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 758 scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
759 tracker()->latency_component_id(), nullptr)); 759 tracker()->latency_component_id(), nullptr));
760 EXPECT_EQ(2U, scroll_latency.latency_components().size()); 760 EXPECT_EQ(2U, scroll_latency.latency_components().size());
761 761
762 // The first GestureScrollUpdate should be provided with 762 // The first GestureScrollUpdate should be provided with
763 // INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT. 763 // INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT.
764 auto first_scroll_update = SyntheticWebGestureEventBuilder::BuildScrollUpdate( 764 auto first_scroll_update = SyntheticWebGestureEventBuilder::BuildScrollUpdate(
765 5.f, -5.f, 0, blink::kWebGestureDeviceTouchscreen); 765 5.f, -5.f, 0, blink::kWebGestureDeviceTouchscreen);
766 scroll_latency = ui::LatencyInfo(); 766 scroll_latency = ui::LatencyInfo();
767 scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 767 scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
768 0); 768 0);
769 tracker()->OnInputEvent(first_scroll_update, &scroll_latency); 769 tracker()->OnInputEvent(first_scroll_update, &scroll_latency);
770 EXPECT_TRUE( 770 EXPECT_TRUE(
771 scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 771 scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
772 tracker()->latency_component_id(), nullptr)); 772 tracker()->latency_component_id(), nullptr));
773 EXPECT_TRUE(scroll_latency.FindLatency( 773 EXPECT_TRUE(scroll_latency.FindLatency(
774 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 774 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
775 tracker()->latency_component_id(), nullptr)); 775 tracker()->latency_component_id(), nullptr));
776 EXPECT_FALSE(scroll_latency.FindLatency( 776 EXPECT_FALSE(scroll_latency.FindLatency(
777 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 777 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
778 tracker()->latency_component_id(), nullptr)); 778 tracker()->latency_component_id(), nullptr));
779 EXPECT_EQ(3U, scroll_latency.latency_components().size()); 779 EXPECT_EQ(3U, scroll_latency.latency_components().size());
780 780
781 // Subsequent GestureScrollUpdates should be provided with 781 // Subsequent GestureScrollUpdates should be provided with
782 // INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT. 782 // INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT.
783 auto scroll_update = SyntheticWebGestureEventBuilder::BuildScrollUpdate( 783 auto scroll_update = SyntheticWebGestureEventBuilder::BuildScrollUpdate(
784 -5.f, 5.f, 0, blink::kWebGestureDeviceTouchscreen); 784 -5.f, 5.f, 0, blink::kWebGestureDeviceTouchscreen);
785 scroll_latency = ui::LatencyInfo(); 785 scroll_latency = ui::LatencyInfo();
786 scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 786 scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
787 0); 787 0);
788 tracker()->OnInputEvent(scroll_update, &scroll_latency); 788 tracker()->OnInputEvent(scroll_update, &scroll_latency);
789 EXPECT_TRUE( 789 EXPECT_TRUE(
790 scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 790 scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
791 tracker()->latency_component_id(), nullptr)); 791 tracker()->latency_component_id(), nullptr));
792 EXPECT_FALSE(scroll_latency.FindLatency( 792 EXPECT_FALSE(scroll_latency.FindLatency(
793 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 793 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
794 tracker()->latency_component_id(), nullptr)); 794 tracker()->latency_component_id(), nullptr));
795 EXPECT_TRUE(scroll_latency.FindLatency( 795 EXPECT_TRUE(scroll_latency.FindLatency(
796 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 796 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
(...skipping 16 matching lines...) Expand all
813 813
814 ui::LatencyInfo latency; 814 ui::LatencyInfo latency;
815 latency.set_source_event_type(ui::SourceEventType::TOUCH); 815 latency.set_source_event_type(ui::SourceEventType::TOUCH);
816 tracker()->OnInputEvent(event, &latency); 816 tracker()->OnInputEvent(event, &latency);
817 817
818 ui::LatencyInfo fake_latency; 818 ui::LatencyInfo fake_latency;
819 fake_latency.set_trace_id(kTraceEventId); 819 fake_latency.set_trace_id(kTraceEventId);
820 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); 820 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
821 fake_latency.AddLatencyNumberWithTimestamp( 821 fake_latency.AddLatencyNumberWithTimestamp(
822 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 822 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
823 tracker()->latency_component_id(), 0, 823 tracker()->latency_component_id(),
824 base::TimeTicks() + 824 base::TimeTicks() +
825 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]), 825 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]),
826 1); 826 1);
827 827
828 fake_latency.AddLatencyNumberWithTimestamp( 828 fake_latency.AddLatencyNumberWithTimestamp(
829 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 829 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0,
830 base::TimeTicks() + 830 base::TimeTicks() +
831 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[1]), 831 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[1]),
832 1); 832 1);
833 833
834 fake_latency.AddLatencyNumberWithTimestamp( 834 fake_latency.AddLatencyNumberWithTimestamp(
835 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 835 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0,
836 base::TimeTicks() + 836 base::TimeTicks() +
837 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]), 837 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]),
838 1); 838 1);
839 839
840 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 840 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
841 // overwriting components. 841 // overwriting components.
842 tracker()->ComputeInputLatencyHistograms( 842 tracker()->ComputeInputLatencyHistograms(
843 event.GetType(), tracker()->latency_component_id(), fake_latency, 843 event.GetType(), tracker()->latency_component_id(), fake_latency,
844 blocking); 844 blocking);
845 845
(...skipping 14 matching lines...) Expand all
860 latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 860 latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
861 tracker()->latency_component_id(), nullptr)); 861 tracker()->latency_component_id(), nullptr));
862 862
863 EXPECT_EQ(2U, latency.latency_components().size()); 863 EXPECT_EQ(2U, latency.latency_components().size());
864 864
865 ui::LatencyInfo fake_latency; 865 ui::LatencyInfo fake_latency;
866 fake_latency.set_trace_id(kTraceEventId); 866 fake_latency.set_trace_id(kTraceEventId);
867 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); 867 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
868 fake_latency.AddLatencyNumberWithTimestamp( 868 fake_latency.AddLatencyNumberWithTimestamp(
869 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 869 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
870 tracker()->latency_component_id(), 0, 870 tracker()->latency_component_id(),
871 base::TimeTicks() + 871 base::TimeTicks() +
872 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[0]), 872 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[0]),
873 1); 873 1);
874 874
875 fake_latency.AddLatencyNumberWithTimestamp( 875 fake_latency.AddLatencyNumberWithTimestamp(
876 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 876 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0,
877 base::TimeTicks() + 877 base::TimeTicks() +
878 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[1]), 878 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[1]),
879 1); 879 1);
880 880
881 fake_latency.AddLatencyNumberWithTimestamp( 881 fake_latency.AddLatencyNumberWithTimestamp(
882 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 882 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0,
883 base::TimeTicks() + 883 base::TimeTicks() +
884 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[2]), 884 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[2]),
885 1); 885 1);
886 886
887 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 887 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
888 // overwriting components. 888 // overwriting components.
889 tracker()->ComputeInputLatencyHistograms( 889 tracker()->ComputeInputLatencyHistograms(
890 event.GetType(), tracker()->latency_component_id(), fake_latency, 890 event.GetType(), tracker()->latency_component_id(), fake_latency,
891 blocking); 891 blocking);
892 } 892 }
(...skipping 11 matching lines...) Expand all
904 latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 904 latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
905 tracker()->latency_component_id(), nullptr)); 905 tracker()->latency_component_id(), nullptr));
906 906
907 EXPECT_EQ(2U, latency.latency_components().size()); 907 EXPECT_EQ(2U, latency.latency_components().size());
908 908
909 ui::LatencyInfo fake_latency; 909 ui::LatencyInfo fake_latency;
910 fake_latency.set_trace_id(kTraceEventId); 910 fake_latency.set_trace_id(kTraceEventId);
911 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); 911 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
912 fake_latency.AddLatencyNumberWithTimestamp( 912 fake_latency.AddLatencyNumberWithTimestamp(
913 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 913 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
914 tracker()->latency_component_id(), 0, 914 tracker()->latency_component_id(),
915 base::TimeTicks() + 915 base::TimeTicks() +
916 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[0]), 916 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[0]),
917 1); 917 1);
918 918
919 fake_latency.AddLatencyNumberWithTimestamp( 919 fake_latency.AddLatencyNumberWithTimestamp(
920 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 920 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0,
921 base::TimeTicks() + 921 base::TimeTicks() +
922 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[1]), 922 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[1]),
923 1); 923 1);
924 924
925 fake_latency.AddLatencyNumberWithTimestamp( 925 fake_latency.AddLatencyNumberWithTimestamp(
926 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 926 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0,
927 base::TimeTicks() + 927 base::TimeTicks() +
928 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[2]), 928 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[2]),
929 1); 929 1);
930 930
931 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 931 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
932 // overwriting components. 932 // overwriting components.
933 tracker()->ComputeInputLatencyHistograms( 933 tracker()->ComputeInputLatencyHistograms(
934 event.GetType(), tracker()->latency_component_id(), fake_latency, 934 event.GetType(), tracker()->latency_component_id(), fake_latency,
935 blocking); 935 blocking);
936 } 936 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 base::TimeTicks::Now()); 1007 base::TimeTicks::Now());
1008 ui::LatencyInfo latency_info; 1008 ui::LatencyInfo latency_info;
1009 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); 1009 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS);
1010 tracker()->OnInputEvent(event, &latency_info); 1010 tracker()->OnInputEvent(event, &latency_info);
1011 1011
1012 ui::LatencyInfo fake_latency; 1012 ui::LatencyInfo fake_latency;
1013 fake_latency.set_trace_id(kTraceEventId); 1013 fake_latency.set_trace_id(kTraceEventId);
1014 fake_latency.set_source_event_type(ui::SourceEventType::KEY_PRESS); 1014 fake_latency.set_source_event_type(ui::SourceEventType::KEY_PRESS);
1015 fake_latency.AddLatencyNumberWithTimestamp( 1015 fake_latency.AddLatencyNumberWithTimestamp(
1016 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1016 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1017 tracker()->latency_component_id(), 0, 1017 tracker()->latency_component_id(),
1018 base::TimeTicks() + 1018 base::TimeTicks() +
1019 base::TimeDelta::FromMilliseconds(event_timestamps_ms[0]), 1019 base::TimeDelta::FromMilliseconds(event_timestamps_ms[0]),
1020 1); 1020 1);
1021 1021
1022 fake_latency.AddLatencyNumberWithTimestamp( 1022 fake_latency.AddLatencyNumberWithTimestamp(
1023 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 1023 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0,
1024 base::TimeTicks() + 1024 base::TimeTicks() +
1025 base::TimeDelta::FromMilliseconds(event_timestamps_ms[1]), 1025 base::TimeDelta::FromMilliseconds(event_timestamps_ms[1]),
1026 1); 1026 1);
1027 1027
1028 fake_latency.AddLatencyNumberWithTimestamp( 1028 fake_latency.AddLatencyNumberWithTimestamp(
1029 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 1029 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0,
1030 base::TimeTicks() + 1030 base::TimeTicks() +
1031 base::TimeDelta::FromMilliseconds(event_timestamps_ms[2]), 1031 base::TimeDelta::FromMilliseconds(event_timestamps_ms[2]),
1032 1); 1032 1);
1033 1033
1034 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 1034 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
1035 // overwriting components. 1035 // overwriting components.
1036 tracker()->ComputeInputLatencyHistograms( 1036 tracker()->ComputeInputLatencyHistograms(
1037 event.GetType(), tracker()->latency_component_id(), fake_latency, 1037 event.GetType(), tracker()->latency_component_id(), fake_latency,
1038 blocking); 1038 blocking);
1039 1039
(...skipping 23 matching lines...) Expand all
1063 // These numbers are sensitive to where the histogram buckets are. 1063 // These numbers are sensitive to where the histogram buckets are.
1064 int event_timestamps_microseconds[] = {100, 185}; 1064 int event_timestamps_microseconds[] = {100, 185};
1065 1065
1066 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kChar, 1066 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kChar,
1067 blink::WebInputEvent::kNoModifiers, 1067 blink::WebInputEvent::kNoModifiers,
1068 base::TimeTicks::Now()); 1068 base::TimeTicks::Now());
1069 ui::LatencyInfo latency_info; 1069 ui::LatencyInfo latency_info;
1070 latency_info.set_trace_id(kTraceEventId); 1070 latency_info.set_trace_id(kTraceEventId);
1071 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); 1071 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS);
1072 latency_info.AddLatencyNumberWithTimestamp( 1072 latency_info.AddLatencyNumberWithTimestamp(
1073 ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0, 1073 ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0,
1074 base::TimeTicks() + 1074 base::TimeTicks() +
1075 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]), 1075 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
1076 1); 1076 1);
1077 1077
1078 latency_info.AddLatencyNumberWithTimestamp( 1078 latency_info.AddLatencyNumberWithTimestamp(
1079 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1079 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1080 tracker()->latency_component_id(), 0, 1080 tracker()->latency_component_id(),
1081 base::TimeTicks() + 1081 base::TimeTicks() +
1082 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]), 1082 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]),
1083 1); 1083 1);
1084 1084
1085 tracker()->OnInputEvent(event, &latency_info); 1085 tracker()->OnInputEvent(event, &latency_info);
1086 tracker()->OnInputEventAck(event, &latency_info, 1086 tracker()->OnInputEventAck(event, &latency_info,
1087 InputEventAckState::INPUT_EVENT_ACK_STATE_UNKNOWN); 1087 InputEventAckState::INPUT_EVENT_ACK_STATE_UNKNOWN);
1088 EXPECT_THAT( 1088 EXPECT_THAT(
1089 histogram_tester().GetAllSamples("Event.Latency.Browser.KeyPressUI"), 1089 histogram_tester().GetAllSamples("Event.Latency.Browser.KeyPressUI"),
1090 ElementsAre(Bucket( 1090 ElementsAre(Bucket(
1091 event_timestamps_microseconds[1] - event_timestamps_microseconds[0], 1091 event_timestamps_microseconds[1] - event_timestamps_microseconds[0],
1092 1))); 1092 1)));
1093 } 1093 }
1094 1094
1095 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyAckedLatency) { 1095 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyAckedLatency) {
1096 // These numbers are sensitive to where the histogram buckets are. 1096 // These numbers are sensitive to where the histogram buckets are.
1097 int event_timestamps_microseconds[] = {11, 24}; 1097 int event_timestamps_microseconds[] = {11, 24};
1098 1098
1099 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kRawKeyDown, 1099 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kRawKeyDown,
1100 blink::WebInputEvent::kNoModifiers, 1100 blink::WebInputEvent::kNoModifiers,
1101 base::TimeTicks::Now()); 1101 base::TimeTicks::Now());
1102 ui::LatencyInfo latency_info; 1102 ui::LatencyInfo latency_info;
1103 latency_info.set_trace_id(kTraceEventId); 1103 latency_info.set_trace_id(kTraceEventId);
1104 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); 1104 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS);
1105 1105
1106 latency_info.AddLatencyNumberWithTimestamp( 1106 latency_info.AddLatencyNumberWithTimestamp(
1107 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1107 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1108 tracker()->latency_component_id(), 0, 1108 tracker()->latency_component_id(),
1109 base::TimeTicks() + 1109 base::TimeTicks() +
1110 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]), 1110 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
1111 1); 1111 1);
1112 1112
1113 latency_info.AddLatencyNumberWithTimestamp( 1113 latency_info.AddLatencyNumberWithTimestamp(
1114 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 1114 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0,
1115 base::TimeTicks() + 1115 base::TimeTicks() +
1116 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]), 1116 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]),
1117 1); 1117 1);
1118 1118
1119 tracker()->OnInputEvent(event, &latency_info); 1119 tracker()->OnInputEvent(event, &latency_info);
1120 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 1120 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
1121 // overwriting components. 1121 // overwriting components.
1122 tracker()->ComputeInputLatencyHistograms( 1122 tracker()->ComputeInputLatencyHistograms(
1123 event.GetType(), tracker()->latency_component_id(), latency_info, 1123 event.GetType(), tracker()->latency_component_id(), latency_info,
1124 InputEventAckState::INPUT_EVENT_ACK_STATE_UNKNOWN); 1124 InputEventAckState::INPUT_EVENT_ACK_STATE_UNKNOWN);
1125 1125
1126 EXPECT_THAT( 1126 EXPECT_THAT(
1127 histogram_tester().GetAllSamples("Event.Latency.Browser.KeyPressAcked"), 1127 histogram_tester().GetAllSamples("Event.Latency.Browser.KeyPressAcked"),
1128 ElementsAre(Bucket( 1128 ElementsAre(Bucket(
1129 event_timestamps_microseconds[1] - event_timestamps_microseconds[0], 1129 event_timestamps_microseconds[1] - event_timestamps_microseconds[0],
1130 1))); 1130 1)));
1131 } 1131 }
1132 1132
1133 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyEndToEndLatency) { 1133 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyEndToEndLatency) {
1134 // These numbers are sensitive to where the histogram buckets are. 1134 // These numbers are sensitive to where the histogram buckets are.
1135 int event_timestamps_microseconds[] = {11, 24}; 1135 int event_timestamps_microseconds[] = {11, 24};
1136 1136
1137 ui::LatencyInfo latency_info; 1137 ui::LatencyInfo latency_info;
1138 latency_info.set_trace_id(kTraceEventId); 1138 latency_info.set_trace_id(kTraceEventId);
1139 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); 1139 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS);
1140 latency_info.AddLatencyNumberWithTimestamp( 1140 latency_info.AddLatencyNumberWithTimestamp(
1141 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, 1141 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0,
1142 base::TimeTicks() + 1142 base::TimeTicks() +
1143 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]), 1143 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
1144 1); 1144 1);
1145 1145
1146 latency_info.AddLatencyNumberWithTimestamp( 1146 latency_info.AddLatencyNumberWithTimestamp(
1147 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1147 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1148 tracker()->latency_component_id(), 0, 1148 tracker()->latency_component_id(),
1149 base::TimeTicks() + 1149 base::TimeTicks() +
1150 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]), 1150 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
1151 1); 1151 1);
1152 1152
1153 latency_info.AddLatencyNumberWithTimestamp( 1153 latency_info.AddLatencyNumberWithTimestamp(
1154 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, 1154 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0,
1155 base::TimeTicks() + 1155 base::TimeTicks() +
1156 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]), 1156 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]),
1157 1); 1157 1);
1158 1158
1159 latency_info.AddLatencyNumberWithTimestamp( 1159 latency_info.AddLatencyNumberWithTimestamp(
1160 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, 1160 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0,
1161 base::TimeTicks() + 1161 base::TimeTicks() +
1162 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]), 1162 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]),
1163 1); 1163 1);
1164 1164
1165 tracker()->OnGpuSwapBuffersCompleted(latency_info); 1165 tracker()->OnGpuSwapBuffersCompleted(latency_info);
1166 1166
1167 EXPECT_THAT( 1167 EXPECT_THAT(
1168 histogram_tester().GetAllSamples("Event.Latency.EndToEnd.KeyPress"), 1168 histogram_tester().GetAllSamples("Event.Latency.EndToEnd.KeyPress"),
1169 ElementsAre(Bucket( 1169 ElementsAre(Bucket(
1170 event_timestamps_microseconds[1] - event_timestamps_microseconds[0], 1170 event_timestamps_microseconds[1] - event_timestamps_microseconds[0],
(...skipping 20 matching lines...) Expand all
1191 // metrics. 1191 // metrics.
1192 int touchstart_timestamps_ms[] = {11, 25, 35}; 1192 int touchstart_timestamps_ms[] = {11, 25, 35};
1193 ui::LatencyInfo latency; 1193 ui::LatencyInfo latency;
1194 event.PressPoint(1, 1); 1194 event.PressPoint(1, 1);
1195 tracker()->OnInputEvent(event, &latency); 1195 tracker()->OnInputEvent(event, &latency);
1196 1196
1197 ui::LatencyInfo fake_latency; 1197 ui::LatencyInfo fake_latency;
1198 fake_latency.set_trace_id(kTraceEventId); 1198 fake_latency.set_trace_id(kTraceEventId);
1199 fake_latency.AddLatencyNumberWithTimestamp( 1199 fake_latency.AddLatencyNumberWithTimestamp(
1200 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1200 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1201 tracker()->latency_component_id(), 0, 1201 tracker()->latency_component_id(),
1202 base::TimeTicks() + 1202 base::TimeTicks() +
1203 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]), 1203 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]),
1204 1); 1204 1);
1205 1205
1206 fake_latency.AddLatencyNumberWithTimestamp( 1206 fake_latency.AddLatencyNumberWithTimestamp(
1207 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 1207 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0,
1208 base::TimeTicks() + 1208 base::TimeTicks() +
1209 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[1]), 1209 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[1]),
1210 1); 1210 1);
1211 1211
1212 fake_latency.AddLatencyNumberWithTimestamp( 1212 fake_latency.AddLatencyNumberWithTimestamp(
1213 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 1213 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0,
1214 base::TimeTicks() + 1214 base::TimeTicks() +
1215 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]), 1215 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]),
1216 1); 1216 1);
1217 1217
1218 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 1218 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
1219 // overwriting components. 1219 // overwriting components.
1220 tracker()->ComputeInputLatencyHistograms(event.GetType(), 1220 tracker()->ComputeInputLatencyHistograms(event.GetType(),
1221 tracker()->latency_component_id(), 1221 tracker()->latency_component_id(),
1222 fake_latency, ack_state); 1222 fake_latency, ack_state);
1223 1223
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 int timestamps_ms[] = {11, 25, 35}; 1262 int timestamps_ms[] = {11, 25, 35};
1263 auto wheel_event = SyntheticWebMouseWheelEventBuilder::Build( 1263 auto wheel_event = SyntheticWebMouseWheelEventBuilder::Build(
1264 blink::WebMouseWheelEvent::kPhaseChanged); 1264 blink::WebMouseWheelEvent::kPhaseChanged);
1265 tracker()->OnInputEvent(touch_event, &latency); 1265 tracker()->OnInputEvent(touch_event, &latency);
1266 1266
1267 ui::LatencyInfo fake_latency; 1267 ui::LatencyInfo fake_latency;
1268 fake_latency.set_trace_id(kTraceEventId); 1268 fake_latency.set_trace_id(kTraceEventId);
1269 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); 1269 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
1270 fake_latency.AddLatencyNumberWithTimestamp( 1270 fake_latency.AddLatencyNumberWithTimestamp(
1271 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1271 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1272 tracker()->latency_component_id(), 0, 1272 tracker()->latency_component_id(),
1273 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[0]), 1273 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[0]),
1274 1); 1274 1);
1275 1275
1276 fake_latency.AddLatencyNumberWithTimestamp( 1276 fake_latency.AddLatencyNumberWithTimestamp(
1277 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 1277 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0,
1278 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[1]), 1278 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[1]),
1279 1); 1279 1);
1280 1280
1281 fake_latency.AddLatencyNumberWithTimestamp( 1281 fake_latency.AddLatencyNumberWithTimestamp(
1282 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 1282 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0,
1283 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[2]), 1283 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[2]),
1284 1); 1284 1);
1285 1285
1286 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 1286 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
1287 // overwriting components. 1287 // overwriting components.
1288 tracker()->ComputeInputLatencyHistograms(wheel_event.GetType(), 1288 tracker()->ComputeInputLatencyHistograms(wheel_event.GetType(),
1289 tracker()->latency_component_id(), 1289 tracker()->latency_component_id(),
1290 fake_latency, ack_state); 1290 fake_latency, ack_state);
1291 1291
1292 tracker()->OnInputEventAck(wheel_event, &latency, ack_state); 1292 tracker()->OnInputEventAck(wheel_event, &latency, ack_state);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 "QueueingDurationWhenExpectedQueueingTime_GreaterThan.300ms"), 1387 "QueueingDurationWhenExpectedQueueingTime_GreaterThan.300ms"),
1388 ElementsAre(Bucket(event_timestamps_ms[1] - event_timestamps_ms[0], 1))); 1388 ElementsAre(Bucket(event_timestamps_ms[1] - event_timestamps_ms[0], 1)));
1389 1389
1390 EXPECT_THAT(histogram_tester().GetAllSamples( 1390 EXPECT_THAT(histogram_tester().GetAllSamples(
1391 "RendererScheduler." 1391 "RendererScheduler."
1392 "QueueingDurationWhenExpectedQueueingTime_GreaterThan.450ms"), 1392 "QueueingDurationWhenExpectedQueueingTime_GreaterThan.450ms"),
1393 ElementsAre()); 1393 ElementsAre());
1394 } 1394 }
1395 1395
1396 } // namespace content 1396 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698