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/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "mojo/common/common_custom_types.mojom.h" | 9 #include "mojo/common/common_custom_types.mojom.h" |
10 #include "mojo/common/test_common_custom_types.mojom.h" | 10 #include "mojo/common/test_common_custom_types.mojom.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 TEST_F(CommonCustomTypesTest, Value) { | 157 TEST_F(CommonCustomTypesTest, Value) { |
158 TestValuePtr ptr; | 158 TestValuePtr ptr; |
159 TestValueImpl impl(GetProxy(&ptr)); | 159 TestValueImpl impl(GetProxy(&ptr)); |
160 | 160 |
161 base::DictionaryValue dict; | 161 base::DictionaryValue dict; |
162 dict.SetBoolean("bool", false); | 162 dict.SetBoolean("bool", false); |
163 dict.SetInteger("int", 2); | 163 dict.SetInteger("int", 2); |
164 dict.SetString("string", "some string"); | 164 dict.SetString("string", "some string"); |
165 dict.SetBoolean("nested.bool", true); | 165 dict.SetBoolean("nested.bool", true); |
166 dict.SetInteger("nested.int", 9); | 166 dict.SetInteger("nested.int", 9); |
167 dict.Set( | 167 dict.Set("some_binary", base::BinaryValue::CreateWithCopiedBuffer("mojo", 4)); |
168 "some_binary", | |
169 base::WrapUnique(base::BinaryValue::CreateWithCopiedBuffer("mojo", 4))); | |
170 { | 168 { |
171 std::unique_ptr<base::ListValue> dict_list(new base::ListValue()); | 169 std::unique_ptr<base::ListValue> dict_list(new base::ListValue()); |
172 dict_list->AppendString("string"); | 170 dict_list->AppendString("string"); |
173 dict_list->AppendBoolean(true); | 171 dict_list->AppendBoolean(true); |
174 dict.Set("list", std::move(dict_list)); | 172 dict.Set("list", std::move(dict_list)); |
175 } | 173 } |
176 { | 174 { |
177 base::RunLoop run_loop; | 175 base::RunLoop run_loop; |
178 ptr->BounceDictionaryValue( | 176 ptr->BounceDictionaryValue( |
179 dict, [&run_loop, &dict](const base::DictionaryValue& out) { | 177 dict, [&run_loop, &dict](const base::DictionaryValue& out) { |
180 EXPECT_TRUE(dict.Equals(&out)); | 178 EXPECT_TRUE(dict.Equals(&out)); |
181 run_loop.Quit(); | 179 run_loop.Quit(); |
182 }); | 180 }); |
183 run_loop.Run(); | 181 run_loop.Run(); |
184 } | 182 } |
185 | 183 |
186 base::ListValue list; | 184 base::ListValue list; |
187 list.AppendString("string"); | 185 list.AppendString("string"); |
188 list.AppendDouble(42.1); | 186 list.AppendDouble(42.1); |
189 list.AppendBoolean(true); | 187 list.AppendBoolean(true); |
190 list.Append( | 188 list.Append(base::BinaryValue::CreateWithCopiedBuffer("mojo", 4)); |
191 base::WrapUnique(base::BinaryValue::CreateWithCopiedBuffer("mojo", 4))); | |
192 { | 189 { |
193 std::unique_ptr<base::DictionaryValue> list_dict( | 190 std::unique_ptr<base::DictionaryValue> list_dict( |
194 new base::DictionaryValue()); | 191 new base::DictionaryValue()); |
195 list_dict->SetString("string", "str"); | 192 list_dict->SetString("string", "str"); |
196 list.Append(std::move(list_dict)); | 193 list.Append(std::move(list_dict)); |
197 } | 194 } |
198 { | 195 { |
199 base::RunLoop run_loop; | 196 base::RunLoop run_loop; |
200 ptr->BounceListValue(list, [&run_loop, &list](const base::ListValue& out) { | 197 ptr->BounceListValue(list, [&run_loop, &list](const base::ListValue& out) { |
201 EXPECT_TRUE(list.Equals(&out)); | 198 EXPECT_TRUE(list.Equals(&out)); |
202 run_loop.Quit(); | 199 run_loop.Quit(); |
203 }); | 200 }); |
204 run_loop.Run(); | 201 run_loop.Run(); |
205 } | 202 } |
206 } | 203 } |
207 | 204 |
208 } // namespace test | 205 } // namespace test |
209 } // namespace common | 206 } // namespace common |
210 } // namespace mojo | 207 } // namespace mojo |
OLD | NEW |