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(const DisplayMode& input, |
| 24 const EchoDisplayModeCallback& callback) override { |
| 25 callback.Run(input); |
| 26 } |
| 27 |
| 28 private: |
| 29 mojo::Binding<DisplayStructTraitsTest> binding_; |
| 30 |
| 31 DISALLOW_COPY_AND_ASSIGN(DisplayStructTraitsTestImpl); |
| 32 }; |
| 33 |
| 34 TEST(DisplayStructTraitsTest, Basic) { |
| 35 // A MessageLoop is needed for Mojo IPC to work. |
| 36 base::MessageLoop message_loop; |
| 37 |
| 38 mojom::DisplayStructTraitsTestPtr proxy; |
| 39 DisplayStructTraitsTestImpl impl(MakeRequest(&proxy)); |
| 40 |
| 41 // prepare sample input with random values |
| 42 const DisplayMode input(gfx::Size(15, 29), true, 61.0); |
| 43 |
| 44 DisplayMode output; |
| 45 |
| 46 EXPECT_TRUE(proxy->EchoDisplayMode(input, &output)); |
| 47 |
| 48 // We want to test each component individually to make sure each data member |
| 49 // was correctly serialized and deserialized. |
| 50 EXPECT_EQ(input.size(), output.size()); |
| 51 EXPECT_EQ(input.is_interlaced(), output.is_interlaced()); |
| 52 EXPECT_EQ(input.refresh_rate(), output.refresh_rate()); |
| 53 } |
| 54 |
| 55 } // namespace |
| 56 |
| 57 } // namespace display |
OLD | NEW |