OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "mojo/public/cpp/bindings/binding_set.h" | 10 #include "mojo/public/cpp/bindings/binding_set.h" |
11 #include "mojo/public/cpp/bindings/interface_request.h" | 11 #include "mojo/public/cpp/bindings/interface_request.h" |
12 #include "mojo/public/cpp/bindings/tests/rect_blink.h" | 12 #include "mojo/public/cpp/bindings/tests/rect_blink.h" |
13 #include "mojo/public/cpp/bindings/tests/rect_chromium.h" | 13 #include "mojo/public/cpp/bindings/tests/rect_chromium.h" |
14 #include "mojo/public/cpp/bindings/tests/struct_with_traits_impl.h" | 14 #include "mojo/public/cpp/bindings/tests/struct_with_traits_impl.h" |
| 15 #include "mojo/public/cpp/bindings/tests/variant_test_util.h" |
15 #include "mojo/public/interfaces/bindings/tests/struct_with_traits.mojom.h" | 16 #include "mojo/public/interfaces/bindings/tests/struct_with_traits.mojom.h" |
16 #include "mojo/public/interfaces/bindings/tests/test_native_types.mojom-blink.h" | 17 #include "mojo/public/interfaces/bindings/tests/test_native_types.mojom-blink.h" |
17 #include "mojo/public/interfaces/bindings/tests/test_native_types.mojom-chromium
.h" | 18 #include "mojo/public/interfaces/bindings/tests/test_native_types.mojom-chromium
.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 | 20 |
20 namespace mojo { | 21 namespace mojo { |
21 namespace test { | 22 namespace test { |
22 namespace { | 23 namespace { |
23 | 24 |
24 // Converts a request of Interface1 to a request of Interface0. Interface0 and | |
25 // Interface1 are expected to be two variants of the same mojom interface. | |
26 // In real-world use cases, users shouldn't need to worry about this. Because it | |
27 // is rare to deal with two variants of the same interface in the same app. | |
28 template <typename Interface0, typename Interface1> | |
29 InterfaceRequest<Interface0> ConvertInterfaceRequest( | |
30 InterfaceRequest<Interface1> request) { | |
31 DCHECK_EQ(0, strcmp(Interface0::Name_, Interface1::Name_)); | |
32 InterfaceRequest<Interface0> result; | |
33 result.Bind(request.PassMessagePipe()); | |
34 return result; | |
35 } | |
36 | |
37 template <typename T> | 25 template <typename T> |
38 void DoExpectResult(const T& expected, | 26 void DoExpectResult(const T& expected, |
39 const base::Closure& callback, | 27 const base::Closure& callback, |
40 const T& actual) { | 28 const T& actual) { |
41 EXPECT_EQ(expected.x(), actual.x()); | 29 EXPECT_EQ(expected.x(), actual.x()); |
42 EXPECT_EQ(expected.y(), actual.y()); | 30 EXPECT_EQ(expected.y(), actual.y()); |
43 EXPECT_EQ(expected.width(), actual.width()); | 31 EXPECT_EQ(expected.width(), actual.width()); |
44 EXPECT_EQ(expected.height(), actual.height()); | 32 EXPECT_EQ(expected.height(), actual.height()); |
45 callback.Run(); | 33 callback.Run(); |
46 } | 34 } |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 EXPECT_EQ(input.get_uint32(), passed.get_uint32()); | 224 EXPECT_EQ(input.get_uint32(), passed.get_uint32()); |
237 EXPECT_EQ(input.get_uint64(), passed.get_uint64()); | 225 EXPECT_EQ(input.get_uint64(), passed.get_uint64()); |
238 EXPECT_EQ(input.get_string(), passed.get_string()); | 226 EXPECT_EQ(input.get_string(), passed.get_string()); |
239 loop.Quit(); | 227 loop.Quit(); |
240 }); | 228 }); |
241 loop.Run(); | 229 loop.Run(); |
242 } | 230 } |
243 | 231 |
244 } // namespace test | 232 } // namespace test |
245 } // namespace mojo | 233 } // namespace mojo |
OLD | NEW |