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

Unified Diff: content/browser/renderer_host/render_widget_host_latency_tracker_unittest.cc

Issue 786113002: Only terminate latency components when no rendering is scheduled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Histogram fix Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_latency_tracker.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_latency_tracker_unittest.cc
diff --git a/content/browser/renderer_host/render_widget_host_latency_tracker_unittest.cc b/content/browser/renderer_host/render_widget_host_latency_tracker_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..41722e0883a975fe4612f2ea40ea31e801a70c44
--- /dev/null
+++ b/content/browser/renderer_host/render_widget_host_latency_tracker_unittest.cc
@@ -0,0 +1,97 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/renderer_host/render_widget_host_latency_tracker.h"
+#include "content/common/input/synthetic_web_input_event_builders.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+namespace {
+
+const int kTestRoutingId = 3;
+const int kTestProcessId = 1;
+
+} // namespace
+
+TEST(RenderWidgetHostLatencyTrackerTest, Basic) {
+ RenderWidgetHostLatencyTracker tracker;
+ tracker.Initialize(kTestRoutingId, kTestProcessId);
+
+ {
+ auto scroll =
+ SyntheticWebGestureEventBuilder::BuildScrollUpdate(5.f, -5.f, 0);
+ ui::LatencyInfo scroll_latency;
+ tracker.OnInputEvent(scroll, &scroll_latency);
+ EXPECT_TRUE(
+ scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
+ tracker.latency_component_id(), nullptr));
+ EXPECT_TRUE(scroll_latency.FindLatency(
+ ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT,
+ tracker.latency_component_id(), nullptr));
+ EXPECT_EQ(1U, scroll_latency.input_coordinates_size);
+ }
+
+ {
+ auto wheel = SyntheticWebMouseWheelEventBuilder::Build(
+ blink::WebMouseWheelEvent::PhaseChanged);
+ ui::LatencyInfo wheel_latency;
+ tracker.OnInputEvent(wheel, &wheel_latency);
+ EXPECT_TRUE(
+ wheel_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
+ tracker.latency_component_id(), nullptr));
+ EXPECT_EQ(1U, wheel_latency.input_coordinates_size);
+ }
+
+ {
+ SyntheticWebTouchEvent touch;
+ touch.PressPoint(0, 0);
+ touch.PressPoint(1, 1);
+ ui::LatencyInfo touch_latency;
+ tracker.OnInputEvent(touch, &touch_latency);
+ EXPECT_TRUE(
+ touch_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
+ tracker.latency_component_id(), nullptr));
+ EXPECT_EQ(2U, touch_latency.input_coordinates_size);
+ }
+}
+
+TEST(RenderWidgetHostLatencyTrackerTest,
+ LatencyTerminatedOnAckIfRenderingNotScheduled) {
+ RenderWidgetHostLatencyTracker tracker;
+ tracker.Initialize(kTestRoutingId, kTestProcessId);
+
+ {
+ auto scroll = SyntheticWebGestureEventBuilder::BuildScrollBegin(5.f, -5.f);
+ ui::LatencyInfo scroll_latency;
+ tracker.OnInputEvent(scroll, &scroll_latency);
+ tracker.OnInputEventAck(scroll, &scroll_latency);
+ EXPECT_TRUE(scroll_latency.FindLatency(
+ ui::INPUT_EVENT_LATENCY_TERMINATED_GESTURE_COMPONENT, 0, nullptr));
+ EXPECT_TRUE(scroll_latency.terminated);
+ }
+
+ {
+ auto wheel = SyntheticWebMouseWheelEventBuilder::Build(
+ blink::WebMouseWheelEvent::PhaseChanged);
+ ui::LatencyInfo wheel_latency;
+ tracker.OnInputEvent(wheel, &wheel_latency);
+ tracker.OnInputEventAck(wheel, &wheel_latency);
+ EXPECT_TRUE(wheel_latency.FindLatency(
+ ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_COMPONENT, 0, nullptr));
+ EXPECT_TRUE(wheel_latency.terminated);
+ }
+
+ {
+ SyntheticWebTouchEvent touch;
+ touch.PressPoint(0, 0);
+ ui::LatencyInfo touch_latency;
+ tracker.OnInputEvent(touch, &touch_latency);
+ tracker.OnInputEventAck(touch, &touch_latency);
+ EXPECT_TRUE(touch_latency.FindLatency(
+ ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, nullptr));
+ EXPECT_TRUE(touch_latency.terminated);
+ }
+}
+
+} // namespace content
« no previous file with comments | « content/browser/renderer_host/render_widget_host_latency_tracker.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698