| 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 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 | 1171 |
| 1172 int64_t int_value_; | 1172 int64_t int_value_; |
| 1173 base::Closure closure_; | 1173 base::Closure closure_; |
| 1174 }; | 1174 }; |
| 1175 | 1175 |
| 1176 TEST(UnionTest, InterfaceInUnion) { | 1176 TEST(UnionTest, InterfaceInUnion) { |
| 1177 base::MessageLoop message_loop; | 1177 base::MessageLoop message_loop; |
| 1178 base::RunLoop run_loop; | 1178 base::RunLoop run_loop; |
| 1179 SmallCacheImpl impl(run_loop.QuitClosure()); | 1179 SmallCacheImpl impl(run_loop.QuitClosure()); |
| 1180 SmallCachePtr ptr; | 1180 SmallCachePtr ptr; |
| 1181 Binding<SmallCache> bindings(&impl, GetProxy(&ptr)); | 1181 Binding<SmallCache> bindings(&impl, MakeRequest(&ptr)); |
| 1182 | 1182 |
| 1183 HandleUnionPtr handle(HandleUnion::New()); | 1183 HandleUnionPtr handle(HandleUnion::New()); |
| 1184 handle->set_f_small_cache(std::move(ptr)); | 1184 handle->set_f_small_cache(std::move(ptr)); |
| 1185 | 1185 |
| 1186 handle->get_f_small_cache()->SetIntValue(10); | 1186 handle->get_f_small_cache()->SetIntValue(10); |
| 1187 run_loop.Run(); | 1187 run_loop.Run(); |
| 1188 EXPECT_EQ(10, impl.int_value()); | 1188 EXPECT_EQ(10, impl.int_value()); |
| 1189 } | 1189 } |
| 1190 | 1190 |
| 1191 TEST(UnionTest, InterfaceInUnionSerialization) { | 1191 TEST(UnionTest, InterfaceInUnionSerialization) { |
| 1192 base::MessageLoop message_loop; | 1192 base::MessageLoop message_loop; |
| 1193 base::RunLoop run_loop; | 1193 base::RunLoop run_loop; |
| 1194 SmallCacheImpl impl(run_loop.QuitClosure()); | 1194 SmallCacheImpl impl(run_loop.QuitClosure()); |
| 1195 SmallCachePtr ptr; | 1195 SmallCachePtr ptr; |
| 1196 Binding<SmallCache> bindings(&impl, GetProxy(&ptr)); | 1196 Binding<SmallCache> bindings(&impl, MakeRequest(&ptr)); |
| 1197 | 1197 |
| 1198 mojo::internal::SerializationContext context; | 1198 mojo::internal::SerializationContext context; |
| 1199 HandleUnionPtr handle(HandleUnion::New()); | 1199 HandleUnionPtr handle(HandleUnion::New()); |
| 1200 handle->set_f_small_cache(std::move(ptr)); | 1200 handle->set_f_small_cache(std::move(ptr)); |
| 1201 size_t size = mojo::internal::PrepareToSerialize<HandleUnionDataView>( | 1201 size_t size = mojo::internal::PrepareToSerialize<HandleUnionDataView>( |
| 1202 handle, false, &context); | 1202 handle, false, &context); |
| 1203 EXPECT_EQ(16U, size); | 1203 EXPECT_EQ(16U, size); |
| 1204 | 1204 |
| 1205 mojo::internal::FixedBufferForTesting buf(size); | 1205 mojo::internal::FixedBufferForTesting buf(size); |
| 1206 internal::HandleUnion_Data* data = nullptr; | 1206 internal::HandleUnion_Data* data = nullptr; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1228 }; | 1228 }; |
| 1229 | 1229 |
| 1230 void ExpectInt16(int16_t value, PodUnionPtr out) { | 1230 void ExpectInt16(int16_t value, PodUnionPtr out) { |
| 1231 EXPECT_EQ(value, out->get_f_int16()); | 1231 EXPECT_EQ(value, out->get_f_int16()); |
| 1232 } | 1232 } |
| 1233 | 1233 |
| 1234 TEST(UnionTest, UnionInInterface) { | 1234 TEST(UnionTest, UnionInInterface) { |
| 1235 base::MessageLoop message_loop; | 1235 base::MessageLoop message_loop; |
| 1236 UnionInterfaceImpl impl; | 1236 UnionInterfaceImpl impl; |
| 1237 UnionInterfacePtr ptr; | 1237 UnionInterfacePtr ptr; |
| 1238 Binding<UnionInterface> bindings(&impl, GetProxy(&ptr)); | 1238 Binding<UnionInterface> bindings(&impl, MakeRequest(&ptr)); |
| 1239 | 1239 |
| 1240 PodUnionPtr pod(PodUnion::New()); | 1240 PodUnionPtr pod(PodUnion::New()); |
| 1241 pod->set_f_int16(16); | 1241 pod->set_f_int16(16); |
| 1242 | 1242 |
| 1243 ptr->Echo(std::move(pod), base::Bind(&ExpectInt16, 16)); | 1243 ptr->Echo(std::move(pod), base::Bind(&ExpectInt16, 16)); |
| 1244 base::RunLoop().RunUntilIdle(); | 1244 base::RunLoop().RunUntilIdle(); |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 } // namespace test | 1247 } // namespace test |
| 1248 } // namespace mojo | 1248 } // namespace mojo |
| OLD | NEW |