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

Side by Side Diff: ui/latency/ipc/latency_info_param_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "ipc/ipc_message_macros.h" 8 #include "ipc/ipc_message_macros.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/gfx/ipc/geometry/gfx_param_traits.h" 10 #include "ui/gfx/ipc/geometry/gfx_param_traits.h"
11 #include "ui/latency/ipc/latency_info_param_traits.h" 11 #include "ui/latency/ipc/latency_info_param_traits.h"
12 #include "ui/latency/ipc/latency_info_param_traits_macros.h" 12 #include "ui/latency/ipc/latency_info_param_traits_macros.h"
13 13
14 namespace ui { 14 namespace ui {
15 15
16 TEST(LatencyInfoParamTraitsTest, Basic) { 16 TEST(LatencyInfoParamTraitsTest, Basic) {
17 LatencyInfo latency; 17 LatencyInfo latency;
18 latency.set_trace_id(5); 18 latency.set_trace_id(5);
19 ASSERT_FALSE(latency.terminated()); 19 ASSERT_FALSE(latency.terminated());
20 latency.AddLatencyNumber(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1234, 0); 20 latency.AddLatencyNumber(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 1234);
21 latency.AddLatencyNumber(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1234, 100); 21 latency.AddLatencyNumber(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1234);
22 latency.AddLatencyNumber(INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 22 latency.AddLatencyNumber(INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT,
23 1234, 0); 23 1234);
24 24
25 EXPECT_EQ(5, latency.trace_id()); 25 EXPECT_EQ(5, latency.trace_id());
26 EXPECT_TRUE(latency.terminated()); 26 EXPECT_TRUE(latency.terminated());
27 27
28 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 28 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
29 IPC::WriteParam(&msg, latency); 29 IPC::WriteParam(&msg, latency);
30 base::PickleIterator iter(msg); 30 base::PickleIterator iter(msg);
31 LatencyInfo output; 31 LatencyInfo output;
32 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); 32 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output));
33 33
34 EXPECT_EQ(latency.trace_id(), output.trace_id()); 34 EXPECT_EQ(latency.trace_id(), output.trace_id());
35 EXPECT_EQ(latency.terminated(), output.terminated()); 35 EXPECT_EQ(latency.terminated(), output.terminated());
36 36
37 EXPECT_TRUE(output.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 37 EXPECT_TRUE(output.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
38 1234, 38 1234,
39 nullptr)); 39 nullptr));
40 40
41 LatencyInfo::LatencyComponent rwh_comp; 41 LatencyInfo::LatencyComponent rwh_comp;
42 EXPECT_TRUE(output.FindLatency(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 42 EXPECT_TRUE(output.FindLatency(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
43 1234, 43 1234,
44 &rwh_comp)); 44 &rwh_comp));
45 EXPECT_EQ(100, rwh_comp.sequence_number);
46 EXPECT_EQ(1u, rwh_comp.event_count); 45 EXPECT_EQ(1u, rwh_comp.event_count);
47 46
48 EXPECT_TRUE(output.FindLatency( 47 EXPECT_TRUE(output.FindLatency(
49 INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 1234, nullptr)); 48 INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 1234, nullptr));
50 } 49 }
51 50
52 TEST(LatencyInfoParamTraitsTest, InvalidData) { 51 TEST(LatencyInfoParamTraitsTest, InvalidData) {
53 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 52 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
54 IPC::WriteParam(&msg, std::string()); 53 IPC::WriteParam(&msg, std::string());
55 ui::LatencyInfo::LatencyMap components; 54 ui::LatencyInfo::LatencyMap components;
56 IPC::WriteParam(&msg, components); 55 IPC::WriteParam(&msg, components);
57 IPC::WriteParam(&msg, static_cast<int64_t>(1234)); 56 IPC::WriteParam(&msg, static_cast<int64_t>(1234));
58 IPC::WriteParam(&msg, true); 57 IPC::WriteParam(&msg, true);
59 58
60 base::PickleIterator iter(msg); 59 base::PickleIterator iter(msg);
61 LatencyInfo output; 60 LatencyInfo output;
62 EXPECT_FALSE(IPC::ReadParam(&msg, &iter, &output)); 61 EXPECT_FALSE(IPC::ReadParam(&msg, &iter, &output));
63 } 62 }
64 63
65 } // namespace ui 64 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698