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 <stdint.h> |
| 6 |
5 #include "ipc/ipc_test_sink.h" | 7 #include "ipc/ipc_test_sink.h" |
6 #include "ppapi/c/dev/ppp_class_deprecated.h" | 8 #include "ppapi/c/dev/ppp_class_deprecated.h" |
7 #include "ppapi/proxy/plugin_var_tracker.h" | 9 #include "ppapi/proxy/plugin_var_tracker.h" |
8 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
9 #include "ppapi/proxy/ppapi_proxy_test.h" | 11 #include "ppapi/proxy/ppapi_proxy_test.h" |
10 #include "ppapi/proxy/proxy_object_var.h" | 12 #include "ppapi/proxy/proxy_object_var.h" |
11 #include "ppapi/shared_impl/proxy_lock.h" | 13 #include "ppapi/shared_impl/proxy_lock.h" |
12 | 14 |
13 namespace ppapi { | 15 namespace ppapi { |
14 namespace proxy { | 16 namespace proxy { |
15 | 17 |
16 namespace { | 18 namespace { |
17 | 19 |
18 PP_Var MakeObject(int32 object_id) { | 20 PP_Var MakeObject(int32_t object_id) { |
19 PP_Var ret; | 21 PP_Var ret; |
20 ret.type = PP_VARTYPE_OBJECT; | 22 ret.type = PP_VARTYPE_OBJECT; |
21 ret.value.as_id = object_id; | 23 ret.value.as_id = object_id; |
22 return ret; | 24 return ret; |
23 } | 25 } |
24 | 26 |
25 // A Deallocate() function for PPP_Class that just increments the integer | 27 // A Deallocate() function for PPP_Class that just increments the integer |
26 // referenced by the pointer so we know how often Deallocate was called. | 28 // referenced by the pointer so we know how often Deallocate was called. |
27 void MarkOnDeallocate(void* object) { | 29 void MarkOnDeallocate(void* object) { |
28 (*static_cast<int*>(object))++; | 30 (*static_cast<int*>(object))++; |
(...skipping 14 matching lines...) Expand all Loading... |
43 | 45 |
44 } // namespace | 46 } // namespace |
45 | 47 |
46 class PluginVarTrackerTest : public PluginProxyTest { | 48 class PluginVarTrackerTest : public PluginProxyTest { |
47 public: | 49 public: |
48 PluginVarTrackerTest() {} | 50 PluginVarTrackerTest() {} |
49 | 51 |
50 protected: | 52 protected: |
51 // Asserts that there is a unique "release object" IPC message in the test | 53 // Asserts that there is a unique "release object" IPC message in the test |
52 // sink. This will return the var ID from the message or -1 if none found. | 54 // sink. This will return the var ID from the message or -1 if none found. |
53 int32 GetObjectIDForUniqueReleaseObject() { | 55 int32_t GetObjectIDForUniqueReleaseObject() { |
54 const IPC::Message* release_msg = sink().GetUniqueMessageMatching( | 56 const IPC::Message* release_msg = sink().GetUniqueMessageMatching( |
55 PpapiHostMsg_PPBVar_ReleaseObject::ID); | 57 PpapiHostMsg_PPBVar_ReleaseObject::ID); |
56 if (!release_msg) | 58 if (!release_msg) |
57 return -1; | 59 return -1; |
58 | 60 |
59 base::Tuple<int64> id; | 61 base::Tuple<int64_t> id; |
60 PpapiHostMsg_PPBVar_ReleaseObject::Read(release_msg, &id); | 62 PpapiHostMsg_PPBVar_ReleaseObject::Read(release_msg, &id); |
61 return base::get<0>(id); | 63 return base::get<0>(id); |
62 } | 64 } |
63 }; | 65 }; |
64 | 66 |
65 TEST_F(PluginVarTrackerTest, GetHostObject) { | 67 TEST_F(PluginVarTrackerTest, GetHostObject) { |
66 ProxyAutoLock lock; | 68 ProxyAutoLock lock; |
67 PP_Var host_object = MakeObject(12345); | 69 PP_Var host_object = MakeObject(12345); |
68 | 70 |
69 // Round-trip through the tracker to make sure the host object comes out the | 71 // Round-trip through the tracker to make sure the host object comes out the |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 241 |
240 // Release the plugin ref to the var. Since the instance is gone this should | 242 // Release the plugin ref to the var. Since the instance is gone this should |
241 // call deallocate. | 243 // call deallocate. |
242 object = NULL; | 244 object = NULL; |
243 var_tracker().ReleaseVar(plugin_var); | 245 var_tracker().ReleaseVar(plugin_var); |
244 EXPECT_EQ(1, deallocate_called); | 246 EXPECT_EQ(1, deallocate_called); |
245 } | 247 } |
246 | 248 |
247 } // namespace proxy | 249 } // namespace proxy |
248 } // namespace ppapi | 250 } // namespace ppapi |
OLD | NEW |