Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Unified Diff: ui/ozone/common/mojo/display_mode_proxy_struct_traits_unittest.cc

Issue 2636073002: Create mojom and StructTraits for ui/display/types/display_mode.cc (Closed)
Patch Set: convert mojo type to ui::DisplayMode_Params instead. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/ozone/common/mojo/display_mode_proxy_struct_traits_unittest.cc
diff --git a/ui/ozone/common/mojo/display_mode_proxy_struct_traits_unittest.cc b/ui/ozone/common/mojo/display_mode_proxy_struct_traits_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..41a5c1f8915ce5895dac166ab1e12f09c297a56b
--- /dev/null
+++ b/ui/ozone/common/mojo/display_mode_proxy_struct_traits_unittest.cc
@@ -0,0 +1,62 @@
+// 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_proxy_test.mojom.h"
kylechar 2017/01/17 17:19:27 Missing #include for ui::DisplayMode_Params.
thanhph1 2017/01/17 20:19:06 Done.
+
+namespace ui {
+
+class DisplayModeProxyTestImpl : public mojom::DisplayModeProxyTest {
kylechar 2017/01/17 17:19:27 You'll want to put the DisplaySnapshotParams test
thanhph1 2017/01/17 20:19:06 Done.
+ public:
+ explicit DisplayModeProxyTestImpl(
+ mojo::InterfaceRequest<mojom::DisplayModeProxyTest> request)
+ : binding_(this, std::move(request)) {}
+
+ // DisplayModeProxyTest:
+ void BounceDisplayModeProxy(
+ const DisplayMode_Params& input,
+ const BounceDisplayModeProxyCallback& callback) override {
+ callback.Run(input);
+ }
+
+ private:
+ mojo::Binding<DisplayModeProxyTest> binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(DisplayModeProxyTestImpl);
+};
+
+TEST(MojoDisplayModeStructTraitsTest, Basic) {
+ // A MessageLoop is needed for Mojo IPC to work.
+ base::MessageLoop message_loop;
+
+ mojom::DisplayModeProxyTestPtr proxy;
+ DisplayModeProxyTestImpl impl(MakeRequest(&proxy));
+
+ // sample random data
+ gfx::Size size(15, 29);
kylechar 2017/01/17 17:19:27 If you aren't going to use these again, there is n
thanhph1 2017/01/17 20:19:06 Done.
+ bool is_interlaced = true;
+ float refresh_rate = 61;
+
+ // prepare input values
+ DisplayMode_Params input;
+ input.size = size;
+ input.is_interlaced = is_interlaced;
+ input.refresh_rate = refresh_rate;
+ ui::DisplayMode_Params output;
+
+ EXPECT_TRUE(proxy->BounceDisplayModeProxy(input, &output));
+
+ // We want to test each component individually to make sure each data member
+ // was correctly serialized and deserialized.
+ EXPECT_NE(&input, &output); // Make sure they aren't the same object.
kylechar 2017/01/17 17:19:27 You know what input and output aren't the same obj
thanhph1 2017/01/17 20:19:06 Done, thanks!
+ EXPECT_EQ(input.size.width(), output.size.width());
kylechar 2017/01/17 17:19:27 gfx::Size has == defined, so you can compare them
thanhph1 2017/01/17 20:19:06 Done.
+ EXPECT_EQ(input.size.height(), output.size.height());
+ EXPECT_EQ(input.is_interlaced, output.is_interlaced);
+ EXPECT_EQ(input.refresh_rate, output.refresh_rate);
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698