| 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" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 loop.Run(); | 207 loop.Run(); |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 TEST_F(StructTraitsTest, FieldTypes) { | 211 TEST_F(StructTraitsTest, FieldTypes) { |
| 212 StructWithTraitsImpl input; | 212 StructWithTraitsImpl input; |
| 213 input.set_bool(true); | 213 input.set_bool(true); |
| 214 input.set_uint32(7); | 214 input.set_uint32(7); |
| 215 input.set_uint64(42); | 215 input.set_uint64(42); |
| 216 input.set_string("hello world!"); | 216 input.set_string("hello world!"); |
| 217 input.get_mutable_array_string().assign({"hello", "world!"}); |
| 218 input.get_mutable_element().value = 42; |
| 219 input.get_mutable_array_element().resize(2); |
| 220 input.get_mutable_array_element()[0].value = 1; |
| 221 input.get_mutable_array_element()[1].value = 2; |
| 217 | 222 |
| 218 base::RunLoop loop; | 223 base::RunLoop loop; |
| 219 TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 224 TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 220 proxy->PassStructWithTraits( | 225 proxy->PassStructWithTraits( |
| 221 input, | 226 input, |
| 222 [&] (const StructWithTraitsImpl& passed) { | 227 [&] (const StructWithTraitsImpl& passed) { |
| 223 EXPECT_EQ(input.get_bool(), passed.get_bool()); | 228 EXPECT_EQ(input.get_bool(), passed.get_bool()); |
| 224 EXPECT_EQ(input.get_uint32(), passed.get_uint32()); | 229 EXPECT_EQ(input.get_uint32(), passed.get_uint32()); |
| 225 EXPECT_EQ(input.get_uint64(), passed.get_uint64()); | 230 EXPECT_EQ(input.get_uint64(), passed.get_uint64()); |
| 226 EXPECT_EQ(input.get_string(), passed.get_string()); | 231 EXPECT_EQ(input.get_string(), passed.get_string()); |
| 232 EXPECT_EQ(input.get_array_string(), passed.get_array_string()); |
| 233 EXPECT_EQ(input.get_element(), passed.get_element()); |
| 234 EXPECT_EQ(input.get_array_element(), passed.get_array_element()); |
| 227 loop.Quit(); | 235 loop.Quit(); |
| 228 }); | 236 }); |
| 229 loop.Run(); | 237 loop.Run(); |
| 230 } | 238 } |
| 231 | 239 |
| 232 } // namespace test | 240 } // namespace test |
| 233 } // namespace mojo | 241 } // namespace mojo |
| OLD | NEW |