forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmojom_traits_unittest.cc
67 lines (51 loc) · 2 KB
/
mojom_traits_unittest.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <utility>
#include "base/test/task_environment.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/latency/mojom/latency_info_mojom_traits.h"
#include "ui/latency/mojom/traits_test_service.mojom.h"
namespace ui {
namespace {
class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
public:
StructTraitsTest() {}
StructTraitsTest(const StructTraitsTest&) = delete;
StructTraitsTest& operator=(const StructTraitsTest&) = delete;
protected:
mojo::Remote<mojom::TraitsTestService> GetTraitsTestRemote() {
mojo::Remote<mojom::TraitsTestService> remote;
traits_test_receivers_.Add(this, remote.BindNewPipeAndPassReceiver());
return remote;
}
private:
// TraitsTestService:
void EchoLatencyInfo(const LatencyInfo& info,
EchoLatencyInfoCallback callback) override {
std::move(callback).Run(info);
}
base::test::TaskEnvironment task_environment_;
mojo::ReceiverSet<TraitsTestService> traits_test_receivers_;
};
} // namespace
TEST_F(StructTraitsTest, LatencyInfo) {
LatencyInfo latency;
latency.set_trace_id(5);
ASSERT_FALSE(latency.terminated());
latency.AddLatencyNumber(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT);
latency.AddLatencyNumber(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT);
latency.AddLatencyNumber(INPUT_EVENT_LATENCY_FRAME_SWAP_COMPONENT);
EXPECT_EQ(5, latency.trace_id());
EXPECT_TRUE(latency.terminated());
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
LatencyInfo output;
remote->EchoLatencyInfo(latency, &output);
EXPECT_EQ(latency.trace_id(), output.trace_id());
EXPECT_EQ(latency.terminated(), output.terminated());
EXPECT_TRUE(
output.FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, nullptr));
}
} // namespace ui