OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 public: | 1231 public: |
1232 UnionInterfaceImpl() {} | 1232 UnionInterfaceImpl() {} |
1233 ~UnionInterfaceImpl() override {} | 1233 ~UnionInterfaceImpl() override {} |
1234 | 1234 |
1235 private: | 1235 private: |
1236 void Echo(PodUnionPtr in, const EchoCallback& callback) override { | 1236 void Echo(PodUnionPtr in, const EchoCallback& callback) override { |
1237 callback.Run(std::move(in)); | 1237 callback.Run(std::move(in)); |
1238 } | 1238 } |
1239 }; | 1239 }; |
1240 | 1240 |
| 1241 void ExpectInt16(int16_t value, PodUnionPtr out) { |
| 1242 EXPECT_EQ(value, out->get_f_int16()); |
| 1243 } |
| 1244 |
1241 TEST(UnionTest, UnionInInterface) { | 1245 TEST(UnionTest, UnionInInterface) { |
1242 base::MessageLoop run_loop; | 1246 base::MessageLoop run_loop; |
1243 UnionInterfaceImpl impl; | 1247 UnionInterfaceImpl impl; |
1244 UnionInterfacePtr ptr; | 1248 UnionInterfacePtr ptr; |
1245 Binding<UnionInterface> bindings(&impl, GetProxy(&ptr)); | 1249 Binding<UnionInterface> bindings(&impl, GetProxy(&ptr)); |
1246 | 1250 |
1247 PodUnionPtr pod(PodUnion::New()); | 1251 PodUnionPtr pod(PodUnion::New()); |
1248 pod->set_f_int16(16); | 1252 pod->set_f_int16(16); |
1249 | 1253 |
1250 ptr->Echo(std::move(pod), | 1254 ptr->Echo(std::move(pod), base::Bind(&ExpectInt16, 16)); |
1251 [](PodUnionPtr out) { EXPECT_EQ(16, out->get_f_int16()); }); | |
1252 run_loop.RunUntilIdle(); | 1255 run_loop.RunUntilIdle(); |
1253 } | 1256 } |
1254 | 1257 |
1255 } // namespace test | 1258 } // namespace test |
1256 } // namespace mojo | 1259 } // namespace mojo |
OLD | NEW |