OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/macros.h" | 6 #include "base/macros.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "mojo/public/cpp/bindings/binding.h" | 9 #include "mojo/public/cpp/bindings/binding.h" |
10 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h" | 10 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 mojo::internal::Deserialize<MojomType>(data, &strs2, &context); | 151 mojo::internal::Deserialize<MojomType>(data, &strs2, &context); |
152 | 152 |
153 ASSERT_EQ(4u, strs2.size()); | 153 ASSERT_EQ(4u, strs2.size()); |
154 EXPECT_FALSE(strs2[0]); | 154 EXPECT_FALSE(strs2[0]); |
155 EXPECT_EQ("", *strs2[1]); | 155 EXPECT_EQ("", *strs2[1]); |
156 EXPECT_EQ(kHelloWorld, *strs2[2]); | 156 EXPECT_EQ(kHelloWorld, *strs2[2]); |
157 EXPECT_EQ(kUTF8HelloWorld, *strs2[3]); | 157 EXPECT_EQ(kUTF8HelloWorld, *strs2[3]); |
158 } | 158 } |
159 | 159 |
160 TEST_F(WTFTypesTest, Serialization_PublicAPI) { | 160 TEST_F(WTFTypesTest, Serialization_PublicAPI) { |
161 blink::TestWTFStructPtr input(blink::TestWTFStruct::New()); | 161 blink::TestWTFStructPtr input(blink::TestWTFStruct::New(kHelloWorld, 42)); |
162 input->str = kHelloWorld; | |
163 input->integer = 42; | |
164 | 162 |
165 blink::TestWTFStructPtr cloned_input = input.Clone(); | 163 blink::TestWTFStructPtr cloned_input = input.Clone(); |
166 | 164 |
167 auto data = blink::TestWTFStruct::Serialize(&input); | 165 auto data = blink::TestWTFStruct::Serialize(&input); |
168 | 166 |
169 blink::TestWTFStructPtr output; | 167 blink::TestWTFStructPtr output; |
170 ASSERT_TRUE(blink::TestWTFStruct::Deserialize(std::move(data), &output)); | 168 ASSERT_TRUE(blink::TestWTFStruct::Deserialize(std::move(data), &output)); |
171 EXPECT_TRUE(cloned_input.Equals(output)); | 169 EXPECT_TRUE(cloned_input.Equals(output)); |
172 } | 170 } |
173 | 171 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // WTF::String>>. | 236 // WTF::String>>. |
239 ptr->EchoStringMap(maps[i], | 237 ptr->EchoStringMap(maps[i], |
240 base::Bind(&ExpectStringMap, base::Unretained(&maps[i]), | 238 base::Bind(&ExpectStringMap, base::Unretained(&maps[i]), |
241 loop.QuitClosure())); | 239 loop.QuitClosure())); |
242 loop.Run(); | 240 loop.Run(); |
243 } | 241 } |
244 } | 242 } |
245 | 243 |
246 } // namespace test | 244 } // namespace test |
247 } // namespace mojo | 245 } // namespace mojo |
OLD | NEW |