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

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

Powered by Google App Engine
This is Rietveld 408576698