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

Side by Side 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 unified diff | Download patch
OLDNEW
(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
5 #include "base/logging.h"
6 #include "base/message_loop/message_loop.h"
7 #include "mojo/public/cpp/bindings/binding.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #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.
10
11 namespace ui {
12
13 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.
14 public:
15 explicit DisplayModeProxyTestImpl(
16 mojo::InterfaceRequest<mojom::DisplayModeProxyTest> request)
17 : binding_(this, std::move(request)) {}
18
19 // DisplayModeProxyTest:
20 void BounceDisplayModeProxy(
21 const DisplayMode_Params& input,
22 const BounceDisplayModeProxyCallback& callback) override {
23 callback.Run(input);
24 }
25
26 private:
27 mojo::Binding<DisplayModeProxyTest> binding_;
28
29 DISALLOW_COPY_AND_ASSIGN(DisplayModeProxyTestImpl);
30 };
31
32 TEST(MojoDisplayModeStructTraitsTest, Basic) {
33 // A MessageLoop is needed for Mojo IPC to work.
34 base::MessageLoop message_loop;
35
36 mojom::DisplayModeProxyTestPtr proxy;
37 DisplayModeProxyTestImpl impl(MakeRequest(&proxy));
38
39 // sample random data
40 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.
41 bool is_interlaced = true;
42 float refresh_rate = 61;
43
44 // prepare input values
45 DisplayMode_Params input;
46 input.size = size;
47 input.is_interlaced = is_interlaced;
48 input.refresh_rate = refresh_rate;
49 ui::DisplayMode_Params output;
50
51 EXPECT_TRUE(proxy->BounceDisplayModeProxy(input, &output));
52
53 // We want to test each component individually to make sure each data member
54 // was correctly serialized and deserialized.
55 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!
56 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.
57 EXPECT_EQ(input.size.height(), output.size.height());
58 EXPECT_EQ(input.is_interlaced, output.is_interlaced);
59 EXPECT_EQ(input.refresh_rate, output.refresh_rate);
60 }
61
62 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698