| Index: ui/display/mojo/display_struct_traits_unittest.cc
|
| diff --git a/ui/display/mojo/display_struct_traits_unittest.cc b/ui/display/mojo/display_struct_traits_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..728e04b09d836be36d1c8548357dcbf6c5d1f849
|
| --- /dev/null
|
| +++ b/ui/display/mojo/display_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/display/mojo/display_struct_traits_test.mojom.h"
|
| +#include "ui/display/types/display_mode.h"
|
| +
|
| +namespace display {
|
| +
|
| +namespace {
|
| +
|
| +class DisplayStructTraitsTestImpl : public mojom::DisplayStructTraitsTest {
|
| + public:
|
| + explicit DisplayStructTraitsTestImpl(
|
| + mojo::InterfaceRequest<mojom::DisplayStructTraitsTest> request)
|
| + : binding_(this, std::move(request)) {}
|
| +
|
| + // DisplayStructTraitsTest:
|
| + void EchoDisplayMode(const DisplayMode& input,
|
| + const EchoDisplayModeCallback& callback) override {
|
| + callback.Run(input);
|
| + }
|
| +
|
| + private:
|
| + mojo::Binding<DisplayStructTraitsTest> binding_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(DisplayStructTraitsTestImpl);
|
| +};
|
| +
|
| +TEST(DisplayStructTraitsTest, Basic) {
|
| + // A MessageLoop is needed for Mojo IPC to work.
|
| + base::MessageLoop message_loop;
|
| +
|
| + mojom::DisplayStructTraitsTestPtr proxy;
|
| + DisplayStructTraitsTestImpl impl(MakeRequest(&proxy));
|
| +
|
| + // prepare sample input with random values
|
| + const DisplayMode input(gfx::Size(15, 29), true, 61.0);
|
| +
|
| + DisplayMode output;
|
| +
|
| + EXPECT_TRUE(proxy->EchoDisplayMode(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
|
| +
|
| +} // namespace display
|
|
|