OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "mojo/public/cpp/bindings/binding_set.h" | 6 #include "mojo/public/cpp/bindings/binding_set.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/gfx/mojo/traits_test_service.mojom.h" | 8 #include "ui/gfx/mojo/traits_test_service.mojom.h" |
| 9 #include "ui/gfx/native_widget_types.h" |
9 #include "ui/gfx/selection_bound.h" | 10 #include "ui/gfx/selection_bound.h" |
10 #include "ui/gfx/transform.h" | 11 #include "ui/gfx/transform.h" |
11 | 12 |
12 namespace gfx { | 13 namespace gfx { |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { | 17 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { |
17 public: | 18 public: |
18 StructTraitsTest() {} | 19 StructTraitsTest() {} |
19 | 20 |
20 protected: | 21 protected: |
21 mojom::TraitsTestServicePtr GetTraitsTestProxy() { | 22 mojom::TraitsTestServicePtr GetTraitsTestProxy() { |
22 return traits_test_bindings_.CreateInterfacePtrAndBind(this); | 23 return traits_test_bindings_.CreateInterfacePtrAndBind(this); |
23 } | 24 } |
24 | 25 |
25 private: | 26 private: |
26 // TraitsTestService: | 27 // TraitsTestService: |
27 void EchoSelectionBound(const SelectionBound& s, | 28 void EchoSelectionBound(const SelectionBound& s, |
28 const EchoSelectionBoundCallback& callback) override { | 29 const EchoSelectionBoundCallback& callback) override { |
29 callback.Run(s); | 30 callback.Run(s); |
30 } | 31 } |
31 | 32 |
32 void EchoTransform(const Transform& t, | 33 void EchoTransform(const Transform& t, |
33 const EchoTransformCallback& callback) override { | 34 const EchoTransformCallback& callback) override { |
34 callback.Run(t); | 35 callback.Run(t); |
35 } | 36 } |
36 | 37 |
| 38 void EchoAcceleratedWidget( |
| 39 const AcceleratedWidget& t, |
| 40 const EchoAcceleratedWidgetCallback& callback) override { |
| 41 callback.Run(t); |
| 42 } |
| 43 |
37 base::MessageLoop loop_; | 44 base::MessageLoop loop_; |
38 mojo::BindingSet<TraitsTestService> traits_test_bindings_; | 45 mojo::BindingSet<TraitsTestService> traits_test_bindings_; |
39 | 46 |
40 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); | 47 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); |
41 }; | 48 }; |
42 | 49 |
43 } // namespace | 50 } // namespace |
44 | 51 |
45 TEST_F(StructTraitsTest, SelectionBound) { | 52 TEST_F(StructTraitsTest, SelectionBound) { |
46 const gfx::SelectionBound::Type type = gfx::SelectionBound::CENTER; | 53 const gfx::SelectionBound::Type type = gfx::SelectionBound::CENTER; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 EXPECT_EQ(col1row3, output.matrix().get(2, 0)); | 104 EXPECT_EQ(col1row3, output.matrix().get(2, 0)); |
98 EXPECT_EQ(col2row3, output.matrix().get(2, 1)); | 105 EXPECT_EQ(col2row3, output.matrix().get(2, 1)); |
99 EXPECT_EQ(col3row3, output.matrix().get(2, 2)); | 106 EXPECT_EQ(col3row3, output.matrix().get(2, 2)); |
100 EXPECT_EQ(col4row3, output.matrix().get(2, 3)); | 107 EXPECT_EQ(col4row3, output.matrix().get(2, 3)); |
101 EXPECT_EQ(col1row4, output.matrix().get(3, 0)); | 108 EXPECT_EQ(col1row4, output.matrix().get(3, 0)); |
102 EXPECT_EQ(col2row4, output.matrix().get(3, 1)); | 109 EXPECT_EQ(col2row4, output.matrix().get(3, 1)); |
103 EXPECT_EQ(col3row4, output.matrix().get(3, 2)); | 110 EXPECT_EQ(col3row4, output.matrix().get(3, 2)); |
104 EXPECT_EQ(col4row4, output.matrix().get(3, 3)); | 111 EXPECT_EQ(col4row4, output.matrix().get(3, 3)); |
105 } | 112 } |
106 | 113 |
| 114 // AcceleratedWidgets can only be sent between processes on X11, Ozone, Win |
| 115 #if defined(OS_WIN) || defined(USE_OZONE) || defined(USE_X11) |
| 116 #define MAYBE_AcceleratedWidget AcceleratedWidget |
| 117 #else |
| 118 #define MAYBE_AcceleratedWidget DISABLED_AcceleratedWidget |
| 119 #endif |
| 120 |
| 121 TEST_F(StructTraitsTest, MAYBE_AcceleratedWidget) { |
| 122 gfx::AcceleratedWidget input(gfx::AcceleratedWidget(1001)); |
| 123 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 124 gfx::AcceleratedWidget output; |
| 125 proxy->EchoAcceleratedWidget(input, &output); |
| 126 EXPECT_EQ(input, output); |
| 127 } |
| 128 |
107 } // namespace gfx | 129 } // namespace gfx |
OLD | NEW |