Allow the externalfile scheme to be whitelisted as an allowed scheme for component...
[chromium-blink-merge.git] / ui / events / latency_info_unittest.cc
blob2f9ad0562bec525f7c7aeddec50c15c92b4e9a46
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/events/latency_info.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace ui {
11 TEST(LatencyInfoTest, AddTwoSeparateEvent) {
12 LatencyInfo info;
13 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
16 base::TimeTicks::FromInternalValue(100),
17 1);
18 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
21 base::TimeTicks::FromInternalValue(1000),
22 2);
24 EXPECT_EQ(info.latency_components.size(), 2u);
25 LatencyInfo::LatencyComponent component;
26 EXPECT_FALSE(
27 info.FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &component));
28 EXPECT_FALSE(
29 info.FindLatency(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1, &component));
30 EXPECT_TRUE(
31 info.FindLatency(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, &component));
32 EXPECT_EQ(component.sequence_number, 1);
33 EXPECT_EQ(component.event_count, 1u);
34 EXPECT_EQ(component.event_time.ToInternalValue(), 100);
35 EXPECT_TRUE(
36 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, &component));
37 EXPECT_EQ(component.sequence_number, 5);
38 EXPECT_EQ(component.event_count, 2u);
39 EXPECT_EQ(component.event_time.ToInternalValue(), 1000);
42 TEST(LatencyInfoTest, AddTwoSameEvent) {
43 LatencyInfo info;
44 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
46 30,
47 base::TimeTicks::FromInternalValue(100),
48 2);
49 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
51 13,
52 base::TimeTicks::FromInternalValue(200),
53 3);
55 EXPECT_EQ(info.latency_components.size(), 1u);
56 LatencyInfo::LatencyComponent component;
57 EXPECT_FALSE(
58 info.FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &component));
59 EXPECT_FALSE(
60 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, &component));
61 EXPECT_TRUE(
62 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, &component));
63 EXPECT_EQ(component.sequence_number, 30);
64 EXPECT_EQ(component.event_count, 5u);
65 EXPECT_EQ(component.event_time.ToInternalValue(), (100 * 2 + 200 * 3) / 5);
68 TEST(LatencyInfoTest, ClearEvents) {
69 LatencyInfo info;
70 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
72 30,
73 base::TimeTicks::FromInternalValue(100),
74 2);
76 EXPECT_EQ(info.latency_components.size(), 1u);
77 info.Clear();
78 EXPECT_EQ(info.latency_components.size(), 0u);
81 } // namespace ui