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

Side by Side Diff: ui/latency/latency_info_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 2013 The Chromium Authors. All rights reserved. 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 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 "ui/latency/latency_info.h" 5 #include "ui/latency/latency_info.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace ui { 11 namespace ui {
12 12
13 TEST(LatencyInfoTest, AddTwoSeparateEvent) { 13 TEST(LatencyInfoTest, AddTwoSeparateEvent) {
14 LatencyInfo info; 14 LatencyInfo info;
15 info.set_trace_id(1); 15 info.set_trace_id(1);
16 EXPECT_FALSE(info.began()); 16 EXPECT_FALSE(info.began());
17 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 17 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
18 0, 18 0,
19 1,
20 base::TimeTicks::FromInternalValue(100), 19 base::TimeTicks::FromInternalValue(100),
21 1); 20 1);
22 EXPECT_TRUE(info.began()); 21 EXPECT_TRUE(info.began());
23 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 22 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
24 1, 23 1,
25 5,
26 base::TimeTicks::FromInternalValue(1000), 24 base::TimeTicks::FromInternalValue(1000),
27 2); 25 2);
28 26
29 EXPECT_EQ(info.latency_components().size(), 2u); 27 EXPECT_EQ(info.latency_components().size(), 2u);
30 LatencyInfo::LatencyComponent component; 28 LatencyInfo::LatencyComponent component;
31 EXPECT_FALSE( 29 EXPECT_FALSE(
32 info.FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &component)); 30 info.FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &component));
33 EXPECT_FALSE( 31 EXPECT_FALSE(
34 info.FindLatency(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1, &component)); 32 info.FindLatency(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1, &component));
35 EXPECT_TRUE( 33 EXPECT_TRUE(
36 info.FindLatency(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, &component)); 34 info.FindLatency(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, &component));
37 EXPECT_EQ(component.sequence_number, 1);
38 EXPECT_EQ(component.event_count, 1u); 35 EXPECT_EQ(component.event_count, 1u);
39 EXPECT_EQ(component.event_time.ToInternalValue(), 100); 36 EXPECT_EQ(component.event_time.ToInternalValue(), 100);
40 EXPECT_TRUE( 37 EXPECT_TRUE(
41 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, &component)); 38 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, &component));
42 EXPECT_EQ(component.sequence_number, 5);
43 EXPECT_EQ(component.event_count, 2u); 39 EXPECT_EQ(component.event_count, 2u);
44 EXPECT_EQ(component.event_time.ToInternalValue(), 1000); 40 EXPECT_EQ(component.event_time.ToInternalValue(), 1000);
45 } 41 }
46 42
47 TEST(LatencyInfoTest, AddTwoSameEvent) { 43 TEST(LatencyInfoTest, AddTwoSameEvent) {
48 LatencyInfo info; 44 LatencyInfo info;
49 info.set_trace_id(1); 45 info.set_trace_id(1);
50 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 46 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
51 0, 47 0,
52 30,
53 base::TimeTicks::FromInternalValue(100), 48 base::TimeTicks::FromInternalValue(100),
54 2); 49 2);
55 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 50 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
56 0, 51 0,
57 13,
58 base::TimeTicks::FromInternalValue(200), 52 base::TimeTicks::FromInternalValue(200),
59 3); 53 3);
60 54
61 EXPECT_EQ(info.latency_components().size(), 1u); 55 EXPECT_EQ(info.latency_components().size(), 1u);
62 LatencyInfo::LatencyComponent component; 56 LatencyInfo::LatencyComponent component;
63 EXPECT_FALSE( 57 EXPECT_FALSE(
64 info.FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &component)); 58 info.FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &component));
65 EXPECT_FALSE( 59 EXPECT_FALSE(
66 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, &component)); 60 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, &component));
67 EXPECT_TRUE( 61 EXPECT_TRUE(
68 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, &component)); 62 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, &component));
69 EXPECT_EQ(component.sequence_number, 30);
70 EXPECT_EQ(component.event_count, 5u); 63 EXPECT_EQ(component.event_count, 5u);
71 EXPECT_EQ(component.event_time.ToInternalValue(), (100 * 2 + 200 * 3) / 5); 64 EXPECT_EQ(component.event_time.ToInternalValue(), (100 * 2 + 200 * 3) / 5);
72 } 65 }
73 66
74 TEST(LatencyInfoTest, RemoveLatency) { 67 TEST(LatencyInfoTest, RemoveLatency) {
75 LatencyInfo info; 68 LatencyInfo info;
76 info.set_trace_id(1); 69 info.set_trace_id(1);
77 info.AddLatencyNumber(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0); 70 info.AddLatencyNumber(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0);
78 info.AddLatencyNumber(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, 0); 71 info.AddLatencyNumber(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1);
79 info.AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 72 info.AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0);
80 73
81 info.RemoveLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); 74 info.RemoveLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT);
82 75
83 EXPECT_FALSE(info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0)); 76 EXPECT_FALSE(
84 EXPECT_FALSE(info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, 0)); 77 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, nullptr));
85 EXPECT_TRUE(info.FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0)); 78 EXPECT_FALSE(
79 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, nullptr));
80 EXPECT_TRUE(info.FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, nullptr));
86 } 81 }
87 82
88 } // namespace ui 83 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698