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 |
| 17 gfx::AcceleratedWidget castToAcceleratedWidget(int i) { |
| 18 #if defined(USE_OZONE) || defined(USE_X11) |
| 19 return static_cast<gfx::AcceleratedWidget>(i); |
| 20 #else |
| 21 return reinterpret_cast<gfx::AcceleratedWidget>(i); |
| 22 #endif |
| 23 } |
| 24 |
16 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { | 25 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { |
17 public: | 26 public: |
18 StructTraitsTest() {} | 27 StructTraitsTest() {} |
19 | 28 |
20 protected: | 29 protected: |
21 mojom::TraitsTestServicePtr GetTraitsTestProxy() { | 30 mojom::TraitsTestServicePtr GetTraitsTestProxy() { |
22 return traits_test_bindings_.CreateInterfacePtrAndBind(this); | 31 return traits_test_bindings_.CreateInterfacePtrAndBind(this); |
23 } | 32 } |
24 | 33 |
25 private: | 34 private: |
26 // TraitsTestService: | 35 // TraitsTestService: |
27 void EchoSelectionBound(const SelectionBound& s, | 36 void EchoSelectionBound(const SelectionBound& s, |
28 const EchoSelectionBoundCallback& callback) override { | 37 const EchoSelectionBoundCallback& callback) override { |
29 callback.Run(s); | 38 callback.Run(s); |
30 } | 39 } |
31 | 40 |
32 void EchoTransform(const Transform& t, | 41 void EchoTransform(const Transform& t, |
33 const EchoTransformCallback& callback) override { | 42 const EchoTransformCallback& callback) override { |
34 callback.Run(t); | 43 callback.Run(t); |
35 } | 44 } |
36 | 45 |
| 46 void EchoAcceleratedWidget( |
| 47 const AcceleratedWidget& t, |
| 48 const EchoAcceleratedWidgetCallback& callback) override { |
| 49 callback.Run(t); |
| 50 } |
| 51 |
37 base::MessageLoop loop_; | 52 base::MessageLoop loop_; |
38 mojo::BindingSet<TraitsTestService> traits_test_bindings_; | 53 mojo::BindingSet<TraitsTestService> traits_test_bindings_; |
39 | 54 |
40 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); | 55 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); |
41 }; | 56 }; |
42 | 57 |
43 } // namespace | 58 } // namespace |
44 | 59 |
45 TEST_F(StructTraitsTest, SelectionBound) { | 60 TEST_F(StructTraitsTest, SelectionBound) { |
46 const gfx::SelectionBound::Type type = gfx::SelectionBound::CENTER; | 61 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)); | 112 EXPECT_EQ(col1row3, output.matrix().get(2, 0)); |
98 EXPECT_EQ(col2row3, output.matrix().get(2, 1)); | 113 EXPECT_EQ(col2row3, output.matrix().get(2, 1)); |
99 EXPECT_EQ(col3row3, output.matrix().get(2, 2)); | 114 EXPECT_EQ(col3row3, output.matrix().get(2, 2)); |
100 EXPECT_EQ(col4row3, output.matrix().get(2, 3)); | 115 EXPECT_EQ(col4row3, output.matrix().get(2, 3)); |
101 EXPECT_EQ(col1row4, output.matrix().get(3, 0)); | 116 EXPECT_EQ(col1row4, output.matrix().get(3, 0)); |
102 EXPECT_EQ(col2row4, output.matrix().get(3, 1)); | 117 EXPECT_EQ(col2row4, output.matrix().get(3, 1)); |
103 EXPECT_EQ(col3row4, output.matrix().get(3, 2)); | 118 EXPECT_EQ(col3row4, output.matrix().get(3, 2)); |
104 EXPECT_EQ(col4row4, output.matrix().get(3, 3)); | 119 EXPECT_EQ(col4row4, output.matrix().get(3, 3)); |
105 } | 120 } |
106 | 121 |
| 122 // AcceleratedWidgets can only be sent between processes on X11, Ozone, Win |
| 123 #if defined(OS_WIN) || defined(USE_OZONE) || defined(USE_X11) |
| 124 #define MAYBE_AcceleratedWidget AcceleratedWidget |
| 125 #else |
| 126 #define MAYBE_AcceleratedWidget DISABLED_AcceleratedWidget |
| 127 #endif |
| 128 |
| 129 TEST_F(StructTraitsTest, MAYBE_AcceleratedWidget) { |
| 130 gfx::AcceleratedWidget input(castToAcceleratedWidget(1001)); |
| 131 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 132 gfx::AcceleratedWidget output; |
| 133 proxy->EchoAcceleratedWidget(input, &output); |
| 134 EXPECT_EQ(input, output); |
| 135 } |
| 136 |
107 } // namespace gfx | 137 } // namespace gfx |
OLD | NEW |