| Index: ui/ozone/common/mojo/display_mode_params_struct_traits_unittest.cc
|
| diff --git a/ui/ozone/common/mojo/display_mode_params_struct_traits_unittest.cc b/ui/ozone/common/mojo/display_mode_params_struct_traits_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cb230c8ac5253ddfba1f6c93ca5172ced796b89a
|
| --- /dev/null
|
| +++ b/ui/ozone/common/mojo/display_mode_params_struct_traits_unittest.cc
|
| @@ -0,0 +1,69 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +#include "base/logging.h"
|
| +#include "base/message_loop/message_loop.h"
|
| +#include "mojo/public/cpp/bindings/binding.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "ui/ozone/common/mojo/display_mode_params_test.mojom.h"
|
| +
|
| +namespace ui {
|
| +
|
| +class DisplayModeParamsTestImpl : public mojom::DisplayModeParamsTest {
|
| + public:
|
| + explicit DisplayModeParamsTestImpl(mojo::InterfaceRequest<mojom::DisplayModeParamsTest> request)
|
| + : binding_(this, std::move(request)) {
|
| + }
|
| +
|
| + // DisplayModeParamsTest:
|
| + void BounceDisplayModeParams(const DisplayMode_Params& input, const BounceDisplayModeParamsCallback& callback) override {
|
| +
|
| + LOG(ERROR) << "in function bouncing: in.is_interlaced:" << input.is_interlaced;
|
| + LOG(ERROR) << "in function bouncing: in.refresh_rate:" << input.refresh_rate;
|
| +
|
| + callback.Run(input);
|
| + }
|
| +
|
| + private:
|
| + mojo::Binding<DisplayModeParamsTest> binding_;
|
| +};
|
| +
|
| +void EchoBack(const DisplayMode_Params& input) {
|
| +
|
| + LOG(ERROR) << "echo: input.is_interlaced:" << input.is_interlaced;
|
| + LOG(ERROR) << "echo: input.refresh_rate:" << input.refresh_rate;
|
| + }
|
| +
|
| +TEST(MojoDisplayModeStructTraitsTest, Basic) {
|
| + base::MessageLoop message_loop;
|
| +
|
| + mojom::DisplayModeParamsTestPtr proxy;
|
| + LOG(ERROR) << "before proxy";
|
| + DisplayModeParamsTestImpl impl(MakeRequest(&proxy));
|
| +
|
| + LOG(ERROR) << "after proxy";
|
| + //sample random data
|
| + gfx::Size size(15,29);
|
| + bool is_interlaced = true;
|
| + float refresh_rate = 61;
|
| +
|
| + DisplayMode_Params input;
|
| + input.size = size;
|
| + input.is_interlaced = is_interlaced;
|
| + input.refresh_rate = refresh_rate;
|
| + DisplayMode_Params output;
|
| +
|
| + EchoBack(input);
|
| +
|
| + LOG(ERROR) << "before bouncing: input.is_interlaced:" << input.is_interlaced;
|
| + LOG(ERROR) << "before bouncing: input.refresh_rate:" << input.refresh_rate;
|
| + EXPECT_TRUE(proxy->BounceDisplayModeParams(input, &output));
|
| +
|
| + // We want to test each component individually to make sure each data member
|
| + // was correctly serialized and deserialized, not just the spec.
|
| + // EXPECT_EQ(input.size, output.size);
|
| + EXPECT_EQ(input.is_interlaced, output.is_interlaced);
|
| + EXPECT_EQ(input.refresh_rate, output.refresh_rate);
|
| +}
|
| +
|
| +}
|
|
|