OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/logging.h" | |
6 #include "base/message_loop/message_loop.h" | |
7 #include "mojo/public/cpp/bindings/binding.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | |
9 #include "ui/display/mojo/display_mode_mojo.h" | |
10 #include "ui/display/mojo/display_struct_traits_test.mojom.h" | |
11 | |
12 namespace display { | |
13 | |
14 namespace { | |
15 | |
16 class DisplayStructTraitsTestImpl : public mojom::DisplayStructTraitsTest { | |
17 public: | |
18 explicit DisplayStructTraitsTestImpl( | |
19 mojo::InterfaceRequest<mojom::DisplayStructTraitsTest> request) | |
20 : binding_(this, std::move(request)) {} | |
21 | |
22 // DisplayStructTraitsTest: | |
23 void EchoDisplayModeMojo( | |
24 const DisplayModeMojo& input, | |
25 const EchoDisplayModeMojoCallback& callback) override { | |
26 callback.Run(input); | |
27 } | |
28 | |
29 private: | |
30 mojo::Binding<DisplayStructTraitsTest> binding_; | |
31 | |
32 DISALLOW_COPY_AND_ASSIGN(DisplayStructTraitsTestImpl); | |
33 }; | |
34 | |
35 TEST(DisplayStructTraitsTest, Basic) { | |
36 // A MessageLoop is needed for Mojo IPC to work. | |
37 base::MessageLoop message_loop; | |
38 | |
39 mojom::DisplayStructTraitsTestPtr proxy; | |
40 DisplayStructTraitsTestImpl impl(MakeRequest(&proxy)); | |
41 | |
42 // prepare sample input with random values | |
43 DisplayModeMojo input; | |
44 input.set_size(gfx::Size(15, 29)); | |
45 input.set_is_interlaced(true); | |
46 input.set_refresh_rate(61); | |
kylechar
2017/01/24 21:15:07
61.0f
thanhph1
2017/01/25 16:26:17
Done.
| |
47 | |
48 DisplayModeMojo output; | |
49 | |
50 EXPECT_TRUE(proxy->EchoDisplayModeMojo(input, &output)); | |
51 | |
52 // We want to test each component individually to make sure each data member | |
53 // was correctly serialized and deserialized. | |
54 EXPECT_EQ(input.size(), output.size()); | |
55 EXPECT_EQ(input.is_interlaced(), output.is_interlaced()); | |
56 EXPECT_EQ(input.refresh_rate(), output.refresh_rate()); | |
57 } | |
58 | |
59 } // namespace | |
60 | |
61 } // namespace display | |
OLD | NEW |