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

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: Fix Windows. Created 3 years, 6 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 14 matching lines...) Expand all
25 namespace content { 25 namespace content {
26 namespace { 26 namespace {
27 27
28 const char kUrl[] = "http://www.foo.bar.com/subpage/1"; 28 const char kUrl[] = "http://www.foo.bar.com/subpage/1";
29 29
30 void AddFakeComponentsWithTimeStamp( 30 void AddFakeComponentsWithTimeStamp(
31 const RenderWidgetHostLatencyTracker& tracker, 31 const RenderWidgetHostLatencyTracker& tracker,
32 ui::LatencyInfo* latency, 32 ui::LatencyInfo* latency,
33 base::TimeTicks time_stamp) { 33 base::TimeTicks time_stamp) {
34 latency->AddLatencyNumberWithTimestamp(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 34 latency->AddLatencyNumberWithTimestamp(ui::INPUT_EVENT_LATENCY_UI_COMPONENT,
35 0, 0, time_stamp, 1); 35 0, time_stamp, 1);
36 latency->AddLatencyNumberWithTimestamp( 36 latency->AddLatencyNumberWithTimestamp(
37 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, time_stamp, 37 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, time_stamp,
38 1); 38 1);
39 latency->AddLatencyNumberWithTimestamp( 39 latency->AddLatencyNumberWithTimestamp(
40 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, time_stamp, 1); 40 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, time_stamp, 1);
41 latency->AddLatencyNumberWithTimestamp( 41 latency->AddLatencyNumberWithTimestamp(
42 ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, 0, time_stamp, 1); 42 ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, time_stamp, 1);
43 latency->AddLatencyNumberWithTimestamp( 43 latency->AddLatencyNumberWithTimestamp(
44 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, 0, 0, time_stamp, 1); 44 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, 0, time_stamp, 1);
45 } 45 }
46 46
47 void AddFakeComponents(const RenderWidgetHostLatencyTracker& tracker, 47 void AddFakeComponents(const RenderWidgetHostLatencyTracker& tracker,
48 ui::LatencyInfo* latency) { 48 ui::LatencyInfo* latency) {
49 latency->AddLatencyNumberWithTimestamp( 49 latency->AddLatencyNumberWithTimestamp(
50 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 50 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
51 tracker.latency_component_id(), 0, base::TimeTicks::Now(), 1); 51 tracker.latency_component_id(), base::TimeTicks::Now(), 1);
52 AddFakeComponentsWithTimeStamp(tracker, latency, base::TimeTicks::Now()); 52 AddFakeComponentsWithTimeStamp(tracker, latency, base::TimeTicks::Now());
53 } 53 }
54 54
55 void AddRenderingScheduledComponent(ui::LatencyInfo* latency, 55 void AddRenderingScheduledComponent(ui::LatencyInfo* latency,
56 bool main, 56 bool main,
57 base::TimeTicks time_stamp) { 57 base::TimeTicks time_stamp) {
58 if (main) { 58 if (main) {
59 latency->AddLatencyNumberWithTimestamp( 59 latency->AddLatencyNumberWithTimestamp(
60 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, 0, 60 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0,
61 time_stamp, 1); 61 time_stamp, 1);
62 62
63 } else { 63 } else {
64 latency->AddLatencyNumberWithTimestamp( 64 latency->AddLatencyNumberWithTimestamp(
65 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, 0, 65 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0,
66 time_stamp, 1); 66 time_stamp, 1);
67 } 67 }
68 } 68 }
69 69
70 } // namespace 70 } // namespace
71 71
72 class RenderWidgetHostLatencyTrackerTestBrowserClient 72 class RenderWidgetHostLatencyTrackerTestBrowserClient
73 : public TestContentBrowserClient { 73 : public TestContentBrowserClient {
74 public: 74 public:
75 RenderWidgetHostLatencyTrackerTestBrowserClient() {} 75 RenderWidgetHostLatencyTrackerTestBrowserClient() {}
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 for (bool rendering_on_main : {false, true}) { 230 for (bool rendering_on_main : {false, true}) {
231 ResetHistograms(); 231 ResetHistograms();
232 { 232 {
233 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( 233 auto wheel = SyntheticWebMouseWheelEventBuilder::Build(
234 blink::WebMouseWheelEvent::kPhaseChanged); 234 blink::WebMouseWheelEvent::kPhaseChanged);
235 base::TimeTicks now = base::TimeTicks::Now(); 235 base::TimeTicks now = base::TimeTicks::Now();
236 wheel.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); 236 wheel.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF());
237 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL); 237 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL);
238 wheel_latency.AddLatencyNumberWithTimestamp( 238 wheel_latency.AddLatencyNumberWithTimestamp(
239 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 239 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
240 tracker()->latency_component_id(), 0, now, 1); 240 tracker()->latency_component_id(), now, 1);
241 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now); 241 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now);
242 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); 242 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now);
243 tracker()->OnInputEvent(wheel, &wheel_latency); 243 tracker()->OnInputEvent(wheel, &wheel_latency);
244 EXPECT_TRUE(wheel_latency.FindLatency( 244 EXPECT_TRUE(wheel_latency.FindLatency(
245 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 245 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
246 tracker()->latency_component_id(), nullptr)); 246 tracker()->latency_component_id(), nullptr));
247 EXPECT_TRUE(wheel_latency.FindLatency( 247 EXPECT_TRUE(wheel_latency.FindLatency(
248 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 248 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
249 tracker()->OnInputEventAck(wheel, &wheel_latency, 249 tracker()->OnInputEventAck(wheel, &wheel_latency,
250 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 250 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 for (bool rendering_on_main : {false, true}) { 326 for (bool rendering_on_main : {false, true}) {
327 ResetHistograms(); 327 ResetHistograms();
328 { 328 {
329 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( 329 auto wheel = SyntheticWebMouseWheelEventBuilder::Build(
330 blink::WebMouseWheelEvent::kPhaseChanged); 330 blink::WebMouseWheelEvent::kPhaseChanged);
331 base::TimeTicks now = base::TimeTicks::Now(); 331 base::TimeTicks now = base::TimeTicks::Now();
332 wheel.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); 332 wheel.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF());
333 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL); 333 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL);
334 wheel_latency.AddLatencyNumberWithTimestamp( 334 wheel_latency.AddLatencyNumberWithTimestamp(
335 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 335 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
336 tracker()->latency_component_id(), 0, now, 1); 336 tracker()->latency_component_id(), now, 1);
337 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now); 337 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now);
338 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); 338 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now);
339 tracker()->OnInputEvent(wheel, &wheel_latency); 339 tracker()->OnInputEvent(wheel, &wheel_latency);
340 EXPECT_TRUE(wheel_latency.FindLatency( 340 EXPECT_TRUE(wheel_latency.FindLatency(
341 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 341 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
342 tracker()->latency_component_id(), nullptr)); 342 tracker()->latency_component_id(), nullptr));
343 EXPECT_TRUE(wheel_latency.FindLatency( 343 EXPECT_TRUE(wheel_latency.FindLatency(
344 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 344 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
345 tracker()->OnInputEventAck(wheel, &wheel_latency, 345 tracker()->OnInputEventAck(wheel, &wheel_latency,
346 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 346 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 for (bool rendering_on_main : {false, true}) { 401 for (bool rendering_on_main : {false, true}) {
402 ResetHistograms(); 402 ResetHistograms();
403 { 403 {
404 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate( 404 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate(
405 5.f, -5.f, 0, blink::kWebGestureDeviceTouchscreen); 405 5.f, -5.f, 0, blink::kWebGestureDeviceTouchscreen);
406 base::TimeTicks now = base::TimeTicks::Now(); 406 base::TimeTicks now = base::TimeTicks::Now();
407 scroll.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); 407 scroll.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF());
408 ui::LatencyInfo scroll_latency; 408 ui::LatencyInfo scroll_latency;
409 scroll_latency.AddLatencyNumberWithTimestamp( 409 scroll_latency.AddLatencyNumberWithTimestamp(
410 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 410 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
411 tracker()->latency_component_id(), 0, now, 1); 411 tracker()->latency_component_id(), now, 1);
412 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now); 412 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now);
413 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); 413 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now);
414 tracker()->OnInputEvent(scroll, &scroll_latency); 414 tracker()->OnInputEvent(scroll, &scroll_latency);
415 EXPECT_TRUE(scroll_latency.FindLatency( 415 EXPECT_TRUE(scroll_latency.FindLatency(
416 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 416 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
417 tracker()->latency_component_id(), nullptr)); 417 tracker()->latency_component_id(), nullptr));
418 EXPECT_TRUE(scroll_latency.FindLatency( 418 EXPECT_TRUE(scroll_latency.FindLatency(
419 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 419 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
420 tracker()->OnInputEventAck(scroll, &scroll_latency, 420 tracker()->OnInputEventAck(scroll, &scroll_latency,
421 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 421 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
422 } 422 }
423 423
424 { 424 {
425 SyntheticWebTouchEvent touch; 425 SyntheticWebTouchEvent touch;
426 touch.PressPoint(0, 0); 426 touch.PressPoint(0, 0);
427 touch.PressPoint(1, 1); 427 touch.PressPoint(1, 1);
428 ui::LatencyInfo touch_latency(ui::SourceEventType::TOUCH); 428 ui::LatencyInfo touch_latency(ui::SourceEventType::TOUCH);
429 base::TimeTicks now = base::TimeTicks::Now(); 429 base::TimeTicks now = base::TimeTicks::Now();
430 touch_latency.AddLatencyNumberWithTimestamp( 430 touch_latency.AddLatencyNumberWithTimestamp(
431 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 431 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
432 tracker()->latency_component_id(), 0, now, 1); 432 tracker()->latency_component_id(), now, 1);
433 AddFakeComponentsWithTimeStamp(*tracker(), &touch_latency, now); 433 AddFakeComponentsWithTimeStamp(*tracker(), &touch_latency, now);
434 AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now); 434 AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now);
435 tracker()->OnInputEvent(touch, &touch_latency); 435 tracker()->OnInputEvent(touch, &touch_latency);
436 EXPECT_TRUE(touch_latency.FindLatency( 436 EXPECT_TRUE(touch_latency.FindLatency(
437 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 437 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
438 tracker()->latency_component_id(), nullptr)); 438 tracker()->latency_component_id(), nullptr));
439 EXPECT_TRUE(touch_latency.FindLatency( 439 EXPECT_TRUE(touch_latency.FindLatency(
440 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 440 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
441 tracker()->OnInputEventAck(touch, &touch_latency, 441 tracker()->OnInputEventAck(touch, &touch_latency,
442 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 442 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 EXPECT_EQ(0, 525 EXPECT_EQ(0,
526 test_browser_client_.getTestRapporService()->GetReportsCount()); 526 test_browser_client_.getTestRapporService()->GetReportsCount());
527 { 527 {
528 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate( 528 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate(
529 5.f, -5.f, 0, blink::kWebGestureDeviceTouchscreen); 529 5.f, -5.f, 0, blink::kWebGestureDeviceTouchscreen);
530 base::TimeTicks now = base::TimeTicks::Now(); 530 base::TimeTicks now = base::TimeTicks::Now();
531 scroll.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); 531 scroll.SetTimeStampSeconds((now - base::TimeTicks()).InSecondsF());
532 ui::LatencyInfo scroll_latency; 532 ui::LatencyInfo scroll_latency;
533 scroll_latency.AddLatencyNumberWithTimestamp( 533 scroll_latency.AddLatencyNumberWithTimestamp(
534 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 534 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
535 tracker()->latency_component_id(), 0, now, 1); 535 tracker()->latency_component_id(), now, 1);
536 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now); 536 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now);
537 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); 537 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now);
538 tracker()->OnInputEvent(scroll, &scroll_latency); 538 tracker()->OnInputEvent(scroll, &scroll_latency);
539 EXPECT_TRUE(scroll_latency.FindLatency( 539 EXPECT_TRUE(scroll_latency.FindLatency(
540 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 540 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
541 tracker()->latency_component_id(), nullptr)); 541 tracker()->latency_component_id(), nullptr));
542 EXPECT_TRUE(scroll_latency.FindLatency( 542 EXPECT_TRUE(scroll_latency.FindLatency(
543 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 543 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
544 tracker()->OnInputEventAck(scroll, &scroll_latency, 544 tracker()->OnInputEventAck(scroll, &scroll_latency,
545 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 545 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
546 } 546 }
547 547
548 { 548 {
549 SyntheticWebTouchEvent touch; 549 SyntheticWebTouchEvent touch;
550 touch.PressPoint(0, 0); 550 touch.PressPoint(0, 0);
551 touch.PressPoint(1, 1); 551 touch.PressPoint(1, 1);
552 ui::LatencyInfo touch_latency(ui::SourceEventType::TOUCH); 552 ui::LatencyInfo touch_latency(ui::SourceEventType::TOUCH);
553 base::TimeTicks now = base::TimeTicks::Now(); 553 base::TimeTicks now = base::TimeTicks::Now();
554 touch_latency.AddLatencyNumberWithTimestamp( 554 touch_latency.AddLatencyNumberWithTimestamp(
555 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 555 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
556 tracker()->latency_component_id(), 0, now, 1); 556 tracker()->latency_component_id(), now, 1);
557 AddFakeComponentsWithTimeStamp(*tracker(), &touch_latency, now); 557 AddFakeComponentsWithTimeStamp(*tracker(), &touch_latency, now);
558 AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now); 558 AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now);
559 tracker()->OnInputEvent(touch, &touch_latency); 559 tracker()->OnInputEvent(touch, &touch_latency);
560 EXPECT_TRUE(touch_latency.FindLatency( 560 EXPECT_TRUE(touch_latency.FindLatency(
561 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 561 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
562 tracker()->latency_component_id(), nullptr)); 562 tracker()->latency_component_id(), nullptr));
563 EXPECT_TRUE(touch_latency.FindLatency( 563 EXPECT_TRUE(touch_latency.FindLatency(
564 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 564 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
565 tracker()->OnInputEventAck(touch, &touch_latency, 565 tracker()->OnInputEventAck(touch, &touch_latency,
566 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 566 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", 0)); 730 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", 0));
731 EXPECT_TRUE(HistogramSizeEq( 731 EXPECT_TRUE(HistogramSizeEq(
732 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", 0)); 732 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", 0));
733 EXPECT_TRUE(HistogramSizeEq("Event.Latency.ScrollUpdate.GpuSwap", 0)); 733 EXPECT_TRUE(HistogramSizeEq("Event.Latency.ScrollUpdate.GpuSwap", 0));
734 } 734 }
735 735
736 TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) { 736 TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) {
737 auto scroll_begin = SyntheticWebGestureEventBuilder::BuildScrollBegin( 737 auto scroll_begin = SyntheticWebGestureEventBuilder::BuildScrollBegin(
738 5, -5, blink::kWebGestureDeviceTouchscreen); 738 5, -5, blink::kWebGestureDeviceTouchscreen);
739 ui::LatencyInfo scroll_latency; 739 ui::LatencyInfo scroll_latency;
740 scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 740 scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
741 0); 741 0);
742 tracker()->OnInputEvent(scroll_begin, &scroll_latency); 742 tracker()->OnInputEvent(scroll_begin, &scroll_latency);
743 EXPECT_TRUE( 743 EXPECT_TRUE(
744 scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 744 scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
745 tracker()->latency_component_id(), nullptr)); 745 tracker()->latency_component_id(), nullptr));
746 EXPECT_EQ(2U, scroll_latency.latency_components().size()); 746 EXPECT_EQ(2U, scroll_latency.latency_components().size());
747 747
748 // The first GestureScrollUpdate should be provided with 748 // The first GestureScrollUpdate should be provided with
749 // INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT. 749 // INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT.
750 auto first_scroll_update = SyntheticWebGestureEventBuilder::BuildScrollUpdate( 750 auto first_scroll_update = SyntheticWebGestureEventBuilder::BuildScrollUpdate(
751 5.f, -5.f, 0, blink::kWebGestureDeviceTouchscreen); 751 5.f, -5.f, 0, blink::kWebGestureDeviceTouchscreen);
752 scroll_latency = ui::LatencyInfo(); 752 scroll_latency = ui::LatencyInfo();
753 scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 753 scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
754 0); 754 0);
755 tracker()->OnInputEvent(first_scroll_update, &scroll_latency); 755 tracker()->OnInputEvent(first_scroll_update, &scroll_latency);
756 EXPECT_TRUE( 756 EXPECT_TRUE(
757 scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 757 scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
758 tracker()->latency_component_id(), nullptr)); 758 tracker()->latency_component_id(), nullptr));
759 EXPECT_TRUE(scroll_latency.FindLatency( 759 EXPECT_TRUE(scroll_latency.FindLatency(
760 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 760 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
761 tracker()->latency_component_id(), nullptr)); 761 tracker()->latency_component_id(), nullptr));
762 EXPECT_FALSE(scroll_latency.FindLatency( 762 EXPECT_FALSE(scroll_latency.FindLatency(
763 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 763 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
764 tracker()->latency_component_id(), nullptr)); 764 tracker()->latency_component_id(), nullptr));
765 EXPECT_EQ(3U, scroll_latency.latency_components().size()); 765 EXPECT_EQ(3U, scroll_latency.latency_components().size());
766 766
767 // Subsequent GestureScrollUpdates should be provided with 767 // Subsequent GestureScrollUpdates should be provided with
768 // INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT. 768 // INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT.
769 auto scroll_update = SyntheticWebGestureEventBuilder::BuildScrollUpdate( 769 auto scroll_update = SyntheticWebGestureEventBuilder::BuildScrollUpdate(
770 -5.f, 5.f, 0, blink::kWebGestureDeviceTouchscreen); 770 -5.f, 5.f, 0, blink::kWebGestureDeviceTouchscreen);
771 scroll_latency = ui::LatencyInfo(); 771 scroll_latency = ui::LatencyInfo();
772 scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 772 scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
773 0); 773 0);
774 tracker()->OnInputEvent(scroll_update, &scroll_latency); 774 tracker()->OnInputEvent(scroll_update, &scroll_latency);
775 EXPECT_TRUE( 775 EXPECT_TRUE(
776 scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 776 scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
777 tracker()->latency_component_id(), nullptr)); 777 tracker()->latency_component_id(), nullptr));
778 EXPECT_FALSE(scroll_latency.FindLatency( 778 EXPECT_FALSE(scroll_latency.FindLatency(
779 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 779 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
780 tracker()->latency_component_id(), nullptr)); 780 tracker()->latency_component_id(), nullptr));
781 EXPECT_TRUE(scroll_latency.FindLatency( 781 EXPECT_TRUE(scroll_latency.FindLatency(
782 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 782 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
(...skipping 15 matching lines...) Expand all
798 event.PressPoint(1, 1); 798 event.PressPoint(1, 1);
799 799
800 ui::LatencyInfo latency; 800 ui::LatencyInfo latency;
801 latency.set_source_event_type(ui::SourceEventType::TOUCH); 801 latency.set_source_event_type(ui::SourceEventType::TOUCH);
802 tracker()->OnInputEvent(event, &latency); 802 tracker()->OnInputEvent(event, &latency);
803 803
804 ui::LatencyInfo fake_latency; 804 ui::LatencyInfo fake_latency;
805 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); 805 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
806 fake_latency.AddLatencyNumberWithTimestamp( 806 fake_latency.AddLatencyNumberWithTimestamp(
807 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 807 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
808 tracker()->latency_component_id(), 0, 808 tracker()->latency_component_id(),
809 base::TimeTicks() + 809 base::TimeTicks() +
810 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]), 810 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]),
811 1); 811 1);
812 812
813 fake_latency.AddLatencyNumberWithTimestamp( 813 fake_latency.AddLatencyNumberWithTimestamp(
814 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 814 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0,
815 base::TimeTicks() + 815 base::TimeTicks() +
816 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[1]), 816 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[1]),
817 1); 817 1);
818 818
819 fake_latency.AddLatencyNumberWithTimestamp( 819 fake_latency.AddLatencyNumberWithTimestamp(
820 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 820 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0,
821 base::TimeTicks() + 821 base::TimeTicks() +
822 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]), 822 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]),
823 1); 823 1);
824 824
825 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 825 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
826 // overwriting components. 826 // overwriting components.
827 tracker()->ComputeInputLatencyHistograms( 827 tracker()->ComputeInputLatencyHistograms(
828 event.GetType(), tracker()->latency_component_id(), fake_latency, 828 event.GetType(), tracker()->latency_component_id(), fake_latency,
829 blocking); 829 blocking);
830 830
(...skipping 13 matching lines...) Expand all
844 EXPECT_TRUE( 844 EXPECT_TRUE(
845 latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 845 latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
846 tracker()->latency_component_id(), nullptr)); 846 tracker()->latency_component_id(), nullptr));
847 847
848 EXPECT_EQ(2U, latency.latency_components().size()); 848 EXPECT_EQ(2U, latency.latency_components().size());
849 849
850 ui::LatencyInfo fake_latency; 850 ui::LatencyInfo fake_latency;
851 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); 851 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
852 fake_latency.AddLatencyNumberWithTimestamp( 852 fake_latency.AddLatencyNumberWithTimestamp(
853 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 853 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
854 tracker()->latency_component_id(), 0, 854 tracker()->latency_component_id(),
855 base::TimeTicks() + 855 base::TimeTicks() +
856 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[0]), 856 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[0]),
857 1); 857 1);
858 858
859 fake_latency.AddLatencyNumberWithTimestamp( 859 fake_latency.AddLatencyNumberWithTimestamp(
860 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 860 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0,
861 base::TimeTicks() + 861 base::TimeTicks() +
862 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[1]), 862 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[1]),
863 1); 863 1);
864 864
865 fake_latency.AddLatencyNumberWithTimestamp( 865 fake_latency.AddLatencyNumberWithTimestamp(
866 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 866 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0,
867 base::TimeTicks() + 867 base::TimeTicks() +
868 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[2]), 868 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[2]),
869 1); 869 1);
870 870
871 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 871 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
872 // overwriting components. 872 // overwriting components.
873 tracker()->ComputeInputLatencyHistograms( 873 tracker()->ComputeInputLatencyHistograms(
874 event.GetType(), tracker()->latency_component_id(), fake_latency, 874 event.GetType(), tracker()->latency_component_id(), fake_latency,
875 blocking); 875 blocking);
876 } 876 }
(...skipping 10 matching lines...) Expand all
887 EXPECT_TRUE( 887 EXPECT_TRUE(
888 latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 888 latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
889 tracker()->latency_component_id(), nullptr)); 889 tracker()->latency_component_id(), nullptr));
890 890
891 EXPECT_EQ(2U, latency.latency_components().size()); 891 EXPECT_EQ(2U, latency.latency_components().size());
892 892
893 ui::LatencyInfo fake_latency; 893 ui::LatencyInfo fake_latency;
894 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); 894 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
895 fake_latency.AddLatencyNumberWithTimestamp( 895 fake_latency.AddLatencyNumberWithTimestamp(
896 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 896 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
897 tracker()->latency_component_id(), 0, 897 tracker()->latency_component_id(),
898 base::TimeTicks() + 898 base::TimeTicks() +
899 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[0]), 899 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[0]),
900 1); 900 1);
901 901
902 fake_latency.AddLatencyNumberWithTimestamp( 902 fake_latency.AddLatencyNumberWithTimestamp(
903 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 903 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0,
904 base::TimeTicks() + 904 base::TimeTicks() +
905 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[1]), 905 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[1]),
906 1); 906 1);
907 907
908 fake_latency.AddLatencyNumberWithTimestamp( 908 fake_latency.AddLatencyNumberWithTimestamp(
909 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 909 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0,
910 base::TimeTicks() + 910 base::TimeTicks() +
911 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[2]), 911 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[2]),
912 1); 912 1);
913 913
914 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 914 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
915 // overwriting components. 915 // overwriting components.
916 tracker()->ComputeInputLatencyHistograms( 916 tracker()->ComputeInputLatencyHistograms(
917 event.GetType(), tracker()->latency_component_id(), fake_latency, 917 event.GetType(), tracker()->latency_component_id(), fake_latency,
918 blocking); 918 blocking);
919 } 919 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 blink::WebInputEvent::kNoModifiers, 989 blink::WebInputEvent::kNoModifiers,
990 base::TimeTicks::Now()); 990 base::TimeTicks::Now());
991 ui::LatencyInfo latency_info; 991 ui::LatencyInfo latency_info;
992 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); 992 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS);
993 tracker()->OnInputEvent(event, &latency_info); 993 tracker()->OnInputEvent(event, &latency_info);
994 994
995 ui::LatencyInfo fake_latency; 995 ui::LatencyInfo fake_latency;
996 fake_latency.set_source_event_type(ui::SourceEventType::KEY_PRESS); 996 fake_latency.set_source_event_type(ui::SourceEventType::KEY_PRESS);
997 fake_latency.AddLatencyNumberWithTimestamp( 997 fake_latency.AddLatencyNumberWithTimestamp(
998 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 998 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
999 tracker()->latency_component_id(), 0, 999 tracker()->latency_component_id(),
1000 base::TimeTicks() + 1000 base::TimeTicks() +
1001 base::TimeDelta::FromMilliseconds(event_timestamps_ms[0]), 1001 base::TimeDelta::FromMilliseconds(event_timestamps_ms[0]),
1002 1); 1002 1);
1003 1003
1004 fake_latency.AddLatencyNumberWithTimestamp( 1004 fake_latency.AddLatencyNumberWithTimestamp(
1005 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 1005 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0,
1006 base::TimeTicks() + 1006 base::TimeTicks() +
1007 base::TimeDelta::FromMilliseconds(event_timestamps_ms[1]), 1007 base::TimeDelta::FromMilliseconds(event_timestamps_ms[1]),
1008 1); 1008 1);
1009 1009
1010 fake_latency.AddLatencyNumberWithTimestamp( 1010 fake_latency.AddLatencyNumberWithTimestamp(
1011 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 1011 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0,
1012 base::TimeTicks() + 1012 base::TimeTicks() +
1013 base::TimeDelta::FromMilliseconds(event_timestamps_ms[2]), 1013 base::TimeDelta::FromMilliseconds(event_timestamps_ms[2]),
1014 1); 1014 1);
1015 1015
1016 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 1016 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
1017 // overwriting components. 1017 // overwriting components.
1018 tracker()->ComputeInputLatencyHistograms( 1018 tracker()->ComputeInputLatencyHistograms(
1019 event.GetType(), tracker()->latency_component_id(), fake_latency, 1019 event.GetType(), tracker()->latency_component_id(), fake_latency,
1020 blocking); 1020 blocking);
1021 1021
(...skipping 22 matching lines...) Expand all
1044 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyUILatency) { 1044 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyUILatency) {
1045 // These numbers are sensitive to where the histogram buckets are. 1045 // These numbers are sensitive to where the histogram buckets are.
1046 int event_timestamps_microseconds[] = {100, 185}; 1046 int event_timestamps_microseconds[] = {100, 185};
1047 1047
1048 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kChar, 1048 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kChar,
1049 blink::WebInputEvent::kNoModifiers, 1049 blink::WebInputEvent::kNoModifiers,
1050 base::TimeTicks::Now()); 1050 base::TimeTicks::Now());
1051 ui::LatencyInfo latency_info; 1051 ui::LatencyInfo latency_info;
1052 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); 1052 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS);
1053 latency_info.AddLatencyNumberWithTimestamp( 1053 latency_info.AddLatencyNumberWithTimestamp(
1054 ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0, 1054 ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0,
1055 base::TimeTicks() + 1055 base::TimeTicks() +
1056 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]), 1056 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
1057 1); 1057 1);
1058 1058
1059 latency_info.AddLatencyNumberWithTimestamp( 1059 latency_info.AddLatencyNumberWithTimestamp(
1060 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1060 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1061 tracker()->latency_component_id(), 0, 1061 tracker()->latency_component_id(),
1062 base::TimeTicks() + 1062 base::TimeTicks() +
1063 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]), 1063 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]),
1064 1); 1064 1);
1065 1065
1066 tracker()->OnInputEvent(event, &latency_info); 1066 tracker()->OnInputEvent(event, &latency_info);
1067 tracker()->OnInputEventAck(event, &latency_info, 1067 tracker()->OnInputEventAck(event, &latency_info,
1068 InputEventAckState::INPUT_EVENT_ACK_STATE_UNKNOWN); 1068 InputEventAckState::INPUT_EVENT_ACK_STATE_UNKNOWN);
1069 EXPECT_THAT( 1069 EXPECT_THAT(
1070 histogram_tester().GetAllSamples("Event.Latency.Browser.KeyPressUI"), 1070 histogram_tester().GetAllSamples("Event.Latency.Browser.KeyPressUI"),
1071 ElementsAre(Bucket( 1071 ElementsAre(Bucket(
1072 event_timestamps_microseconds[1] - event_timestamps_microseconds[0], 1072 event_timestamps_microseconds[1] - event_timestamps_microseconds[0],
1073 1))); 1073 1)));
1074 } 1074 }
1075 1075
1076 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyAckedLatency) { 1076 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyAckedLatency) {
1077 // These numbers are sensitive to where the histogram buckets are. 1077 // These numbers are sensitive to where the histogram buckets are.
1078 int event_timestamps_microseconds[] = {11, 24}; 1078 int event_timestamps_microseconds[] = {11, 24};
1079 1079
1080 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kRawKeyDown, 1080 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kRawKeyDown,
1081 blink::WebInputEvent::kNoModifiers, 1081 blink::WebInputEvent::kNoModifiers,
1082 base::TimeTicks::Now()); 1082 base::TimeTicks::Now());
1083 ui::LatencyInfo latency_info; 1083 ui::LatencyInfo latency_info;
1084 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); 1084 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS);
1085 1085
1086 latency_info.AddLatencyNumberWithTimestamp( 1086 latency_info.AddLatencyNumberWithTimestamp(
1087 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1087 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1088 tracker()->latency_component_id(), 0, 1088 tracker()->latency_component_id(),
1089 base::TimeTicks() + 1089 base::TimeTicks() +
1090 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]), 1090 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
1091 1); 1091 1);
1092 1092
1093 latency_info.AddLatencyNumberWithTimestamp( 1093 latency_info.AddLatencyNumberWithTimestamp(
1094 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 1094 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0,
1095 base::TimeTicks() + 1095 base::TimeTicks() +
1096 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]), 1096 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]),
1097 1); 1097 1);
1098 1098
1099 tracker()->OnInputEvent(event, &latency_info); 1099 tracker()->OnInputEvent(event, &latency_info);
1100 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 1100 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
1101 // overwriting components. 1101 // overwriting components.
1102 tracker()->ComputeInputLatencyHistograms( 1102 tracker()->ComputeInputLatencyHistograms(
1103 event.GetType(), tracker()->latency_component_id(), latency_info, 1103 event.GetType(), tracker()->latency_component_id(), latency_info,
1104 InputEventAckState::INPUT_EVENT_ACK_STATE_UNKNOWN); 1104 InputEventAckState::INPUT_EVENT_ACK_STATE_UNKNOWN);
1105 1105
1106 EXPECT_THAT( 1106 EXPECT_THAT(
1107 histogram_tester().GetAllSamples("Event.Latency.Browser.KeyPressAcked"), 1107 histogram_tester().GetAllSamples("Event.Latency.Browser.KeyPressAcked"),
1108 ElementsAre(Bucket( 1108 ElementsAre(Bucket(
1109 event_timestamps_microseconds[1] - event_timestamps_microseconds[0], 1109 event_timestamps_microseconds[1] - event_timestamps_microseconds[0],
1110 1))); 1110 1)));
1111 } 1111 }
1112 1112
1113 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyEndToEndLatency) { 1113 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyEndToEndLatency) {
1114 // These numbers are sensitive to where the histogram buckets are. 1114 // These numbers are sensitive to where the histogram buckets are.
1115 int event_timestamps_microseconds[] = {11, 24}; 1115 int event_timestamps_microseconds[] = {11, 24};
1116 1116
1117 ui::LatencyInfo latency_info; 1117 ui::LatencyInfo latency_info;
1118 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); 1118 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS);
1119 latency_info.AddLatencyNumberWithTimestamp( 1119 latency_info.AddLatencyNumberWithTimestamp(
1120 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, 1120 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0,
1121 base::TimeTicks() + 1121 base::TimeTicks() +
1122 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]), 1122 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
1123 1); 1123 1);
1124 1124
1125 latency_info.AddLatencyNumberWithTimestamp( 1125 latency_info.AddLatencyNumberWithTimestamp(
1126 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1126 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1127 tracker()->latency_component_id(), 0, 1127 tracker()->latency_component_id(),
1128 base::TimeTicks() + 1128 base::TimeTicks() +
1129 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]), 1129 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
1130 1); 1130 1);
1131 1131
1132 latency_info.AddLatencyNumberWithTimestamp( 1132 latency_info.AddLatencyNumberWithTimestamp(
1133 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, 1133 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0,
1134 base::TimeTicks() + 1134 base::TimeTicks() +
1135 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]), 1135 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]),
1136 1); 1136 1);
1137 1137
1138 latency_info.AddLatencyNumberWithTimestamp( 1138 latency_info.AddLatencyNumberWithTimestamp(
1139 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, 1139 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0,
1140 base::TimeTicks() + 1140 base::TimeTicks() +
1141 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]), 1141 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]),
1142 1); 1142 1);
1143 1143
1144 tracker()->OnGpuSwapBuffersCompleted(latency_info); 1144 tracker()->OnGpuSwapBuffersCompleted(latency_info);
1145 1145
1146 EXPECT_THAT( 1146 EXPECT_THAT(
1147 histogram_tester().GetAllSamples("Event.Latency.EndToEnd.KeyPress"), 1147 histogram_tester().GetAllSamples("Event.Latency.EndToEnd.KeyPress"),
1148 ElementsAre(Bucket( 1148 ElementsAre(Bucket(
1149 event_timestamps_microseconds[1] - event_timestamps_microseconds[0], 1149 event_timestamps_microseconds[1] - event_timestamps_microseconds[0],
(...skipping 19 matching lines...) Expand all
1169 // Additional touch start will be ignored for queueing and blocking time 1169 // Additional touch start will be ignored for queueing and blocking time
1170 // metrics. 1170 // metrics.
1171 int touchstart_timestamps_ms[] = {11, 25, 35}; 1171 int touchstart_timestamps_ms[] = {11, 25, 35};
1172 ui::LatencyInfo latency; 1172 ui::LatencyInfo latency;
1173 event.PressPoint(1, 1); 1173 event.PressPoint(1, 1);
1174 tracker()->OnInputEvent(event, &latency); 1174 tracker()->OnInputEvent(event, &latency);
1175 1175
1176 ui::LatencyInfo fake_latency; 1176 ui::LatencyInfo fake_latency;
1177 fake_latency.AddLatencyNumberWithTimestamp( 1177 fake_latency.AddLatencyNumberWithTimestamp(
1178 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1178 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1179 tracker()->latency_component_id(), 0, 1179 tracker()->latency_component_id(),
1180 base::TimeTicks() + 1180 base::TimeTicks() +
1181 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]), 1181 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]),
1182 1); 1182 1);
1183 1183
1184 fake_latency.AddLatencyNumberWithTimestamp( 1184 fake_latency.AddLatencyNumberWithTimestamp(
1185 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 1185 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0,
1186 base::TimeTicks() + 1186 base::TimeTicks() +
1187 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[1]), 1187 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[1]),
1188 1); 1188 1);
1189 1189
1190 fake_latency.AddLatencyNumberWithTimestamp( 1190 fake_latency.AddLatencyNumberWithTimestamp(
1191 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 1191 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0,
1192 base::TimeTicks() + 1192 base::TimeTicks() +
1193 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]), 1193 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]),
1194 1); 1194 1);
1195 1195
1196 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 1196 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
1197 // overwriting components. 1197 // overwriting components.
1198 tracker()->ComputeInputLatencyHistograms(event.GetType(), 1198 tracker()->ComputeInputLatencyHistograms(event.GetType(),
1199 tracker()->latency_component_id(), 1199 tracker()->latency_component_id(),
1200 fake_latency, ack_state); 1200 fake_latency, ack_state);
1201 1201
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 // These numbers are sensitive to where the histogram buckets are. 1239 // These numbers are sensitive to where the histogram buckets are.
1240 int timestamps_ms[] = {11, 25, 35}; 1240 int timestamps_ms[] = {11, 25, 35};
1241 auto wheel_event = SyntheticWebMouseWheelEventBuilder::Build( 1241 auto wheel_event = SyntheticWebMouseWheelEventBuilder::Build(
1242 blink::WebMouseWheelEvent::kPhaseChanged); 1242 blink::WebMouseWheelEvent::kPhaseChanged);
1243 tracker()->OnInputEvent(touch_event, &latency); 1243 tracker()->OnInputEvent(touch_event, &latency);
1244 1244
1245 ui::LatencyInfo fake_latency; 1245 ui::LatencyInfo fake_latency;
1246 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); 1246 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
1247 fake_latency.AddLatencyNumberWithTimestamp( 1247 fake_latency.AddLatencyNumberWithTimestamp(
1248 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1248 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1249 tracker()->latency_component_id(), 0, 1249 tracker()->latency_component_id(),
1250 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[0]), 1250 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[0]),
1251 1); 1251 1);
1252 1252
1253 fake_latency.AddLatencyNumberWithTimestamp( 1253 fake_latency.AddLatencyNumberWithTimestamp(
1254 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 1254 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0,
1255 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[1]), 1255 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[1]),
1256 1); 1256 1);
1257 1257
1258 fake_latency.AddLatencyNumberWithTimestamp( 1258 fake_latency.AddLatencyNumberWithTimestamp(
1259 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 1259 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0,
1260 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[2]), 1260 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[2]),
1261 1); 1261 1);
1262 1262
1263 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 1263 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
1264 // overwriting components. 1264 // overwriting components.
1265 tracker()->ComputeInputLatencyHistograms(wheel_event.GetType(), 1265 tracker()->ComputeInputLatencyHistograms(wheel_event.GetType(),
1266 tracker()->latency_component_id(), 1266 tracker()->latency_component_id(),
1267 fake_latency, ack_state); 1267 fake_latency, ack_state);
1268 1268
1269 tracker()->OnInputEventAck(wheel_event, &latency, ack_state); 1269 tracker()->OnInputEventAck(wheel_event, &latency, ack_state);
1270 } 1270 }
1271 1271
1272 EXPECT_THAT(histogram_tester().GetAllSamples( 1272 EXPECT_THAT(histogram_tester().GetAllSamples(
1273 "Event.Latency.QueueingTime.MouseWheelDefaultAllowed"), 1273 "Event.Latency.QueueingTime.MouseWheelDefaultAllowed"),
1274 ElementsAre(Bucket(14, 1))); 1274 ElementsAre(Bucket(14, 1)));
1275 } 1275 }
1276 1276
1277 } // namespace content 1277 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698