| 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 <string.h> | |
| 6 | |
| 7 #include <string> | 5 #include <string> |
| 8 | 6 |
| 9 #include "base/bind.h" | 7 #include "base/bind.h" |
| 10 #include "base/callback.h" | 8 #include "base/callback.h" |
| 11 #include "base/logging.h" | 9 #include "base/logging.h" |
| 12 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 14 #include "mojo/public/cpp/bindings/binding_set.h" | 12 #include "mojo/public/cpp/bindings/binding_set.h" |
| 15 #include "mojo/public/cpp/bindings/interface_request.h" | 13 #include "mojo/public/cpp/bindings/interface_request.h" |
| 16 #include "mojo/public/cpp/bindings/tests/pickled_struct_blink.h" | 14 #include "mojo/public/cpp/bindings/tests/pickled_struct_blink.h" |
| 17 #include "mojo/public/cpp/bindings/tests/pickled_struct_chromium.h" | 15 #include "mojo/public/cpp/bindings/tests/pickled_struct_chromium.h" |
| 16 #include "mojo/public/cpp/bindings/tests/variant_test_util.h" |
| 18 #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" |
| 19 #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" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 20 |
| 22 namespace mojo { | 21 namespace mojo { |
| 23 namespace test { | 22 namespace test { |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| 26 // Converts a request of Interface1 to a request of Interface0. Interface0 and | |
| 27 // Interface1 are expected to be two variants of the same mojom interface. | |
| 28 // In real-world use cases, users shouldn't need to worry about this. Because it | |
| 29 // is rare to deal with two variants of the same interface in the same app. | |
| 30 template <typename Interface0, typename Interface1> | |
| 31 InterfaceRequest<Interface0> ConvertInterfaceRequest( | |
| 32 InterfaceRequest<Interface1> request) { | |
| 33 DCHECK_EQ(0, strcmp(Interface0::Name_, Interface1::Name_)); | |
| 34 InterfaceRequest<Interface0> result; | |
| 35 result.Bind(request.PassMessagePipe()); | |
| 36 return result; | |
| 37 } | |
| 38 | |
| 39 template <typename T> | 25 template <typename T> |
| 40 void DoExpectResult(int foo, | 26 void DoExpectResult(int foo, |
| 41 int bar, | 27 int bar, |
| 42 const base::Closure& callback, | 28 const base::Closure& callback, |
| 43 const T& actual) { | 29 const T& actual) { |
| 44 EXPECT_EQ(foo, actual.foo()); | 30 EXPECT_EQ(foo, actual.foo()); |
| 45 EXPECT_EQ(bar, actual.bar()); | 31 EXPECT_EQ(bar, actual.bar()); |
| 46 callback.Run(); | 32 callback.Run(); |
| 47 } | 33 } |
| 48 | 34 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 EXPECT_EQ(43, passed->pickle.bar()); | 306 EXPECT_EQ(43, passed->pickle.bar()); |
| 321 EXPECT_EQ(0, passed->pickle.baz()); | 307 EXPECT_EQ(0, passed->pickle.baz()); |
| 322 run_loop.Quit(); | 308 run_loop.Quit(); |
| 323 }); | 309 }); |
| 324 run_loop.Run(); | 310 run_loop.Run(); |
| 325 } | 311 } |
| 326 } | 312 } |
| 327 | 313 |
| 328 } // namespace test | 314 } // namespace test |
| 329 } // namespace mojo | 315 } // namespace mojo |
| OLD | NEW |