OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 #include "base/logging.h" |
| 5 #include "base/message_loop/message_loop.h" |
| 6 #include "mojo/public/cpp/bindings/binding.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/ozone/common/mojo/display_mode_params_test.mojom.h" |
| 9 |
| 10 namespace ui { |
| 11 |
| 12 class DisplayModeParamsTestImpl : public mojom::DisplayModeParamsTest { |
| 13 public: |
| 14 explicit DisplayModeParamsTestImpl(mojo::InterfaceRequest<mojom::DisplayModePa
ramsTest> request) |
| 15 : binding_(this, std::move(request)) { |
| 16 } |
| 17 |
| 18 // DisplayModeParamsTest: |
| 19 void BounceDisplayModeParams(const DisplayMode_Params& input, const BounceDisp
layModeParamsCallback& callback) override { |
| 20 |
| 21 LOG(ERROR) << "in function bouncing: in.is_interlaced:" << input.is_interla
ced; |
| 22 LOG(ERROR) << "in function bouncing: in.refresh_rate:" << input.refresh_rat
e; |
| 23 |
| 24 callback.Run(input); |
| 25 } |
| 26 |
| 27 private: |
| 28 mojo::Binding<DisplayModeParamsTest> binding_; |
| 29 }; |
| 30 |
| 31 void EchoBack(const DisplayMode_Params& input) { |
| 32 |
| 33 LOG(ERROR) << "echo: input.is_interlaced:" << input.is_interlaced; |
| 34 LOG(ERROR) << "echo: input.refresh_rate:" << input.refresh_rate; |
| 35 } |
| 36 |
| 37 TEST(MojoDisplayModeStructTraitsTest, Basic) { |
| 38 base::MessageLoop message_loop; |
| 39 |
| 40 mojom::DisplayModeParamsTestPtr proxy; |
| 41 LOG(ERROR) << "before proxy"; |
| 42 DisplayModeParamsTestImpl impl(MakeRequest(&proxy)); |
| 43 |
| 44 LOG(ERROR) << "after proxy"; |
| 45 //sample random data |
| 46 gfx::Size size(15,29); |
| 47 bool is_interlaced = true; |
| 48 float refresh_rate = 61; |
| 49 |
| 50 DisplayMode_Params input; |
| 51 input.size = size; |
| 52 input.is_interlaced = is_interlaced; |
| 53 input.refresh_rate = refresh_rate; |
| 54 DisplayMode_Params output; |
| 55 |
| 56 EchoBack(input); |
| 57 |
| 58 LOG(ERROR) << "before bouncing: input.is_interlaced:" << input.is_interlaced; |
| 59 LOG(ERROR) << "before bouncing: input.refresh_rate:" << input.refresh_rate; |
| 60 EXPECT_TRUE(proxy->BounceDisplayModeParams(input, &output)); |
| 61 |
| 62 // We want to test each component individually to make sure each data member |
| 63 // was correctly serialized and deserialized, not just the spec. |
| 64 // EXPECT_EQ(input.size, output.size); |
| 65 EXPECT_EQ(input.is_interlaced, output.is_interlaced); |
| 66 EXPECT_EQ(input.refresh_rate, output.refresh_rate); |
| 67 } |
| 68 |
| 69 } |
OLD | NEW |