Chromium Code Reviews| Index: ui/ozone/common/mojo/ozone_gpu_messages_params_struct_traits_unittest.cc |
| diff --git a/ui/ozone/common/mojo/ozone_gpu_messages_params_struct_traits_unittest.cc b/ui/ozone/common/mojo/ozone_gpu_messages_params_struct_traits_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9176ed6890b566e3e796e87d91f127ce4849c83b |
| --- /dev/null |
| +++ b/ui/ozone/common/mojo/ozone_gpu_messages_params_struct_traits_unittest.cc |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2017 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/gpu/ozone_gpu_message_params.h" |
| +#include "ui/ozone/common/mojo/ozone_gpu_message_params_test.mojom.h" |
| + |
| +namespace ui { |
| + |
| +class OzoneGpuMessageParamsTestImpl : public mojom::OzoneGpuMessageParamsTest { |
|
kylechar
2017/01/17 21:39:46
You can put this class in an anonymous namespace.
thanhph1
2017/01/17 22:30:30
Done.
|
| + public: |
| + explicit OzoneGpuMessageParamsTestImpl( |
| + mojo::InterfaceRequest<mojom::OzoneGpuMessageParamsTest> request) |
| + : binding_(this, std::move(request)) {} |
| + |
| + // DisplayModeParamsTest: |
| + void BounceDisplayModeParams( |
| + const DisplayMode_Params& input, |
| + const BounceDisplayModeParamsCallback& callback) override { |
| + callback.Run(input); |
| + } |
| + |
| + private: |
| + mojo::Binding<OzoneGpuMessageParamsTest> binding_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(OzoneGpuMessageParamsTestImpl); |
| +}; |
| + |
| +TEST(MojoDisplayModeStructTraitsTest, Basic) { |
|
kylechar
2017/01/17 21:39:46
TEST(OzoneGpuStructTraitsTest, DisplayMode) {
thanhph1
2017/01/17 22:30:30
Done.
|
| + // A MessageLoop is needed for Mojo IPC to work. |
| + base::MessageLoop message_loop; |
| + |
| + mojom::OzoneGpuMessageParamsTestPtr proxy; |
| + OzoneGpuMessageParamsTestImpl impl(MakeRequest(&proxy)); |
| + |
| + // prepare sample input with random values |
| + DisplayMode_Params input; |
| + input.size = gfx::Size(15, 29); |
| + input.is_interlaced = true; |
| + input.refresh_rate = 61; |
| + |
| + ui::DisplayMode_Params output; |
| + |
| + EXPECT_TRUE(proxy->BounceDisplayModeParams(input, &output)); |
| + |
| + // We want to test each component individually to make sure each data member |
| + // was correctly serialized and deserialized. |
| + EXPECT_EQ(input.size, output.size); |
| + EXPECT_EQ(input.is_interlaced, output.is_interlaced); |
| + EXPECT_EQ(input.refresh_rate, output.refresh_rate); |
| +} |
| + |
| +} // namespace ui |