OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/proxy/ppapi_proxy_test.h" | 5 #include "ppapi/proxy/ppapi_proxy_test.h" |
6 | 6 |
7 #include "ppapi/proxy/serialized_var.h" | 7 #include "ppapi/proxy/serialized_var.h" |
8 #include "ppapi/shared_impl/proxy_lock.h" | 8 #include "ppapi/shared_impl/proxy_lock.h" |
9 | 9 |
10 namespace ppapi { | 10 namespace ppapi { |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 EXPECT_EQ(old_message_count, sink().message_count()); | 265 EXPECT_EQ(old_message_count, sink().message_count()); |
266 } | 266 } |
267 | 267 |
268 // Since we didn't keep any refs to the objects or strings, so they should | 268 // Since we didn't keep any refs to the objects or strings, so they should |
269 // have been freed. | 269 // have been freed. |
270 EXPECT_EQ(-1, var_tracker().GetRefCountForObject(plugin_objects[0])); | 270 EXPECT_EQ(-1, var_tracker().GetRefCountForObject(plugin_objects[0])); |
271 EXPECT_EQ(-1, var_tracker().GetRefCountForObject(plugin_objects[1])); | 271 EXPECT_EQ(-1, var_tracker().GetRefCountForObject(plugin_objects[1])); |
272 EXPECT_EQ(-1, var_tracker().GetRefCountForObject(plugin_objects2[1])); | 272 EXPECT_EQ(-1, var_tracker().GetRefCountForObject(plugin_objects2[1])); |
273 } | 273 } |
274 | 274 |
275 // Tests the browser sending a String var as a return value to make sure we | |
276 // ref-count the host side properly. | |
277 typedef HostProxyTest HostSerializedVarTest; | |
278 TEST_F(HostSerializedVarTest, PluginReceiveStringReturn) { | |
279 PP_Var string_var = StringVar::StringToPPVar("Hello"); | |
280 EXPECT_EQ(1, var_tracker().GetRefCountForObject(string_var)); | |
281 GetDispatcher()->serialization_rules()->BeginSendPassRef(string_var); | |
282 GetDispatcher()->serialization_rules()->EndSendPassRef(string_var); | |
283 // It should be gone, so we should get -1 to indicate that. | |
284 EXPECT_EQ(-1, var_tracker().GetRefCountForObject(string_var)); | |
raymes
2015/01/27 00:12:44
Should we test the object var case too? Or does th
| |
285 } | |
286 | |
275 // Tests the plugin receiving a var as a return value from the browser | 287 // Tests the plugin receiving a var as a return value from the browser |
276 // two different times (passing ownership). | 288 // two different times (passing ownership). |
277 TEST_F(SerializedVarTest, PluginReceiveReturn) { | 289 TEST_F(SerializedVarTest, PluginReceiveReturn) { |
278 ProxyAutoLock lock; | 290 ProxyAutoLock lock; |
279 PP_Var host_object = MakeObjectVar(0x31337); | 291 PP_Var host_object = MakeObjectVar(0x31337); |
280 | 292 |
281 PP_Var plugin_object; | 293 PP_Var plugin_object; |
282 { | 294 { |
283 // Receive the first param, we should be tracking it with a refcount of 1. | 295 // Receive the first param, we should be tracking it with a refcount of 1. |
284 SerializedVarTestConstructor input1(host_object); | 296 SerializedVarTestConstructor input1(host_object); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 } | 357 } |
346 | 358 |
347 // When the ReturnValue object goes out of scope, it should have sent a | 359 // When the ReturnValue object goes out of scope, it should have sent a |
348 // release message to the browser. | 360 // release message to the browser. |
349 EXPECT_EQ(-1, var_tracker().GetRefCountForObject(plugin_object)); | 361 EXPECT_EQ(-1, var_tracker().GetRefCountForObject(plugin_object)); |
350 EXPECT_EQ(1u, sink().message_count()); | 362 EXPECT_EQ(1u, sink().message_count()); |
351 } | 363 } |
352 | 364 |
353 } // namespace proxy | 365 } // namespace proxy |
354 } // namespace ppapi | 366 } // namespace ppapi |
OLD | NEW |