Chromium Code Reviews| 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_struct_traits_test.mojom.h" | |
| 10 #include "ui/display/types/display_mode.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 EchoDisplayMode( | |
| 24 const DisplayMode& input, | |
| 25 const EchoDisplayModeCallback& 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 DisplayMode input(gfx::Size(15, 29), true, 61.0); | |
|
kylechar
2017/01/25 16:59:45
const DisplayMode input
thanhph1
2017/01/25 20:28:40
Done.
| |
| 44 | |
| 45 DisplayMode output; | |
| 46 | |
| 47 EXPECT_TRUE(proxy->EchoDisplayMode(input, &output)); | |
| 48 | |
| 49 // We want to test each component individually to make sure each data member | |
| 50 // was correctly serialized and deserialized. | |
| 51 EXPECT_EQ(input.size(), output.size()); | |
| 52 EXPECT_EQ(input.is_interlaced(), output.is_interlaced()); | |
| 53 EXPECT_EQ(input.refresh_rate(), output.refresh_rate()); | |
| 54 } | |
| 55 | |
| 56 } // namespace | |
| 57 | |
| 58 } // namespace display | |
| OLD | NEW |