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

Side by Side Diff: ui/display/mojo/display_struct_traits_unittest.cc

Issue 2636073002: Create mojom and StructTraits for ui/display/types/display_mode.cc (Closed)
Patch Set: Change structure not to use display_mode_mojo.(cc|h). Instead, use friend class in display_mode.h. Created 3 years, 10 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 2017 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/display/mojo/display_struct_traits_test.mojom.h"
10 #include "ui/display/types/display_mode.h"
11
12 namespace display {
13
14 namespace {
15
16 class DisplayStructTraitsTestImpl : public mojom::DisplayStructTraitsTest {
17 public:
18 explicit DisplayStructTraitsTestImpl(
19 mojo::InterfaceRequest<mojom::DisplayStructTraitsTest> request)
20 : binding_(this, std::move(request)) {}
21
22 // DisplayStructTraitsTest:
23 void EchoDisplayMode(
24 const DisplayMode& input,
25 const EchoDisplayModeCallback& callback) override {
26 callback.Run(input);
27 }
28
29 private:
30 mojo::Binding<DisplayStructTraitsTest> binding_;
31
32 DISALLOW_COPY_AND_ASSIGN(DisplayStructTraitsTestImpl);
33 };
34
35 TEST(DisplayStructTraitsTest, Basic) {
36 // A MessageLoop is needed for Mojo IPC to work.
37 base::MessageLoop message_loop;
38
39 mojom::DisplayStructTraitsTestPtr proxy;
40 DisplayStructTraitsTestImpl impl(MakeRequest(&proxy));
41
42 // prepare sample input with random values
43 DisplayMode input(gfx::Size(15, 29), true, 61.0);
kylechar 2017/01/25 16:59:45 const DisplayMode input
thanhph1 2017/01/25 20:28:40 Done.
44
45 DisplayMode output;
46
47 EXPECT_TRUE(proxy->EchoDisplayMode(input, &output));
48
49 // We want to test each component individually to make sure each data member
50 // was correctly serialized and deserialized.
51 EXPECT_EQ(input.size(), output.size());
52 EXPECT_EQ(input.is_interlaced(), output.is_interlaced());
53 EXPECT_EQ(input.refresh_rate(), output.refresh_rate());
54 }
55
56 } // namespace
57
58 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698