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

Side by Side Diff: ui/latency/latency_info_unittest.cc

Issue 2953073002: LatencyInfo trace_id_ no longer dependent on sequence_number. (Closed)
Patch Set: Address nit. 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
« no previous file with comments | « ui/latency/latency_info.cc ('k') | ui/latency/mojo/latency_info.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
16 EXPECT_FALSE(info.began());
15 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 17 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
16 0, 18 0,
17 1, 19 1,
18 base::TimeTicks::FromInternalValue(100), 20 base::TimeTicks::FromInternalValue(100),
19 1); 21 1);
22 EXPECT_TRUE(info.began());
20 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 23 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
21 1, 24 1,
22 5, 25 5,
23 base::TimeTicks::FromInternalValue(1000), 26 base::TimeTicks::FromInternalValue(1000),
24 2); 27 2);
25 28
26 EXPECT_EQ(info.latency_components().size(), 2u); 29 EXPECT_EQ(info.latency_components().size(), 2u);
27 LatencyInfo::LatencyComponent component; 30 LatencyInfo::LatencyComponent component;
28 EXPECT_FALSE( 31 EXPECT_FALSE(
29 info.FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &component)); 32 info.FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &component));
30 EXPECT_FALSE( 33 EXPECT_FALSE(
31 info.FindLatency(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1, &component)); 34 info.FindLatency(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1, &component));
32 EXPECT_TRUE( 35 EXPECT_TRUE(
33 info.FindLatency(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, &component)); 36 info.FindLatency(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, &component));
34 EXPECT_EQ(component.sequence_number, 1); 37 EXPECT_EQ(component.sequence_number, 1);
35 EXPECT_EQ(component.event_count, 1u); 38 EXPECT_EQ(component.event_count, 1u);
36 EXPECT_EQ(component.event_time.ToInternalValue(), 100); 39 EXPECT_EQ(component.event_time.ToInternalValue(), 100);
37 EXPECT_TRUE( 40 EXPECT_TRUE(
38 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, &component)); 41 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, &component));
39 EXPECT_EQ(component.sequence_number, 5); 42 EXPECT_EQ(component.sequence_number, 5);
40 EXPECT_EQ(component.event_count, 2u); 43 EXPECT_EQ(component.event_count, 2u);
41 EXPECT_EQ(component.event_time.ToInternalValue(), 1000); 44 EXPECT_EQ(component.event_time.ToInternalValue(), 1000);
42 } 45 }
43 46
44 TEST(LatencyInfoTest, AddTwoSameEvent) { 47 TEST(LatencyInfoTest, AddTwoSameEvent) {
45 LatencyInfo info; 48 LatencyInfo info;
49 info.set_trace_id(1);
46 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 50 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
47 0, 51 0,
48 30, 52 30,
49 base::TimeTicks::FromInternalValue(100), 53 base::TimeTicks::FromInternalValue(100),
50 2); 54 2);
51 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 55 info.AddLatencyNumberWithTimestamp(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
52 0, 56 0,
53 13, 57 13,
54 base::TimeTicks::FromInternalValue(200), 58 base::TimeTicks::FromInternalValue(200),
55 3); 59 3);
56 60
57 EXPECT_EQ(info.latency_components().size(), 1u); 61 EXPECT_EQ(info.latency_components().size(), 1u);
58 LatencyInfo::LatencyComponent component; 62 LatencyInfo::LatencyComponent component;
59 EXPECT_FALSE( 63 EXPECT_FALSE(
60 info.FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &component)); 64 info.FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &component));
61 EXPECT_FALSE( 65 EXPECT_FALSE(
62 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, &component)); 66 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, &component));
63 EXPECT_TRUE( 67 EXPECT_TRUE(
64 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, &component)); 68 info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, &component));
65 EXPECT_EQ(component.sequence_number, 30); 69 EXPECT_EQ(component.sequence_number, 30);
66 EXPECT_EQ(component.event_count, 5u); 70 EXPECT_EQ(component.event_count, 5u);
67 EXPECT_EQ(component.event_time.ToInternalValue(), (100 * 2 + 200 * 3) / 5); 71 EXPECT_EQ(component.event_time.ToInternalValue(), (100 * 2 + 200 * 3) / 5);
68 } 72 }
69 73
70 TEST(LatencyInfoTest, RemoveLatency) { 74 TEST(LatencyInfoTest, RemoveLatency) {
71 LatencyInfo info; 75 LatencyInfo info;
76 info.set_trace_id(1);
72 info.AddLatencyNumber(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0); 77 info.AddLatencyNumber(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0);
73 info.AddLatencyNumber(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, 0); 78 info.AddLatencyNumber(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, 0);
74 info.AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 79 info.AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
75 80
76 info.RemoveLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); 81 info.RemoveLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT);
77 82
78 EXPECT_FALSE(info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0)); 83 EXPECT_FALSE(info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0));
79 EXPECT_FALSE(info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, 0)); 84 EXPECT_FALSE(info.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1, 0));
80 EXPECT_TRUE(info.FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0)); 85 EXPECT_TRUE(info.FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0));
81 } 86 }
82 87
83 } // namespace ui 88 } // namespace ui
OLDNEW
« no previous file with comments | « ui/latency/latency_info.cc ('k') | ui/latency/mojo/latency_info.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698