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

Side by Side Diff: ui/latency/mojo/struct_traits_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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <utility> 5 #include <utility>
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "mojo/public/cpp/bindings/binding_set.h" 8 #include "mojo/public/cpp/bindings/binding_set.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/latency/mojo/latency_info_struct_traits.h" 10 #include "ui/latency/mojo/latency_info_struct_traits.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 base::MessageLoop loop_; 44 base::MessageLoop loop_;
45 mojo::BindingSet<TraitsTestService> traits_test_bindings_; 45 mojo::BindingSet<TraitsTestService> traits_test_bindings_;
46 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); 46 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest);
47 }; 47 };
48 48
49 } // namespace 49 } // namespace
50 50
51 TEST_F(StructTraitsTest, LatencyComponent) { 51 TEST_F(StructTraitsTest, LatencyComponent) {
52 const int64_t sequence_number = 13371337;
53 const base::TimeTicks event_time = base::TimeTicks::Now(); 52 const base::TimeTicks event_time = base::TimeTicks::Now();
54 const uint32_t event_count = 1234; 53 const uint32_t event_count = 1234;
55 LatencyInfo::LatencyComponent input; 54 LatencyInfo::LatencyComponent input;
56 input.sequence_number = sequence_number;
57 input.event_time = event_time; 55 input.event_time = event_time;
58 input.event_count = event_count; 56 input.event_count = event_count;
59 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 57 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
60 LatencyInfo::LatencyComponent output; 58 LatencyInfo::LatencyComponent output;
61 proxy->EchoLatencyComponent(input, &output); 59 proxy->EchoLatencyComponent(input, &output);
62 EXPECT_EQ(sequence_number, output.sequence_number);
63 EXPECT_EQ(event_time, output.event_time); 60 EXPECT_EQ(event_time, output.event_time);
64 EXPECT_EQ(event_count, output.event_count); 61 EXPECT_EQ(event_count, output.event_count);
65 } 62 }
66 63
67 TEST_F(StructTraitsTest, LatencyComponentId) { 64 TEST_F(StructTraitsTest, LatencyComponentId) {
68 const LatencyComponentType type = 65 const LatencyComponentType type =
69 INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT; 66 INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT;
70 const int64_t id = 1337; 67 const int64_t id = 1337;
71 std::pair<LatencyComponentType, int64_t> input(type, id); 68 std::pair<LatencyComponentType, int64_t> input(type, id);
72 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 69 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
73 std::pair<LatencyComponentType, int64_t> output; 70 std::pair<LatencyComponentType, int64_t> output;
74 proxy->EchoLatencyComponentId(input, &output); 71 proxy->EchoLatencyComponentId(input, &output);
75 EXPECT_EQ(type, output.first); 72 EXPECT_EQ(type, output.first);
76 EXPECT_EQ(id, output.second); 73 EXPECT_EQ(id, output.second);
77 } 74 }
78 75
79 TEST_F(StructTraitsTest, LatencyInfo) { 76 TEST_F(StructTraitsTest, LatencyInfo) {
80 LatencyInfo latency; 77 LatencyInfo latency;
81 ASSERT_FALSE(latency.terminated()); 78 ASSERT_FALSE(latency.terminated());
82 latency.AddLatencyNumber(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1234, 0); 79 latency.AddLatencyNumber(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1234);
83 latency.AddLatencyNumber(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1234, 100); 80 latency.AddLatencyNumber(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1234);
84 latency.AddLatencyNumber(INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 81 latency.AddLatencyNumber(INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT,
85 1234, 0); 82 1234);
86 83
87 EXPECT_EQ(100, latency.trace_id());
88 EXPECT_TRUE(latency.terminated()); 84 EXPECT_TRUE(latency.terminated());
89 85
90 latency.set_source_event_type(ui::TOUCH); 86 latency.set_source_event_type(ui::TOUCH);
91 87
92 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 88 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
93 LatencyInfo output; 89 LatencyInfo output;
94 proxy->EchoLatencyInfo(latency, &output); 90 proxy->EchoLatencyInfo(latency, &output);
95 91
96 EXPECT_EQ(latency.trace_id(), output.trace_id()); 92 EXPECT_EQ(latency.trace_id(), output.trace_id());
97 EXPECT_EQ(latency.terminated(), output.terminated()); 93 EXPECT_EQ(latency.terminated(), output.terminated());
98 EXPECT_EQ(latency.source_event_type(), output.source_event_type()); 94 EXPECT_EQ(latency.source_event_type(), output.source_event_type());
99 95
100 EXPECT_TRUE(output.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1234, 96 EXPECT_TRUE(output.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1234,
101 nullptr)); 97 nullptr));
102 98
103 LatencyInfo::LatencyComponent rwh_comp; 99 LatencyInfo::LatencyComponent rwh_comp;
104 EXPECT_TRUE(output.FindLatency(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1234, 100 EXPECT_TRUE(output.FindLatency(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1234,
105 &rwh_comp)); 101 &rwh_comp));
106 EXPECT_EQ(100, rwh_comp.sequence_number);
107 EXPECT_EQ(1u, rwh_comp.event_count); 102 EXPECT_EQ(1u, rwh_comp.event_count);
108 103
109 EXPECT_TRUE(output.FindLatency( 104 EXPECT_TRUE(output.FindLatency(
110 INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 1234, nullptr)); 105 INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 1234, nullptr));
111 } 106 }
112 107
113 } // namespace ui 108 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698