Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: ppapi/proxy/ppp_instance_private_proxy_unittest.cc

Issue 1548813002: Switch to standard integer types in ppapi/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ppapi/proxy/ppp_instance_private_proxy.h ('k') | ppapi/proxy/ppp_instance_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
7 #include "base/test/test_timeouts.h" 9 #include "base/test/test_timeouts.h"
8 #include "base/time/time.h" 10 #include "base/time/time.h"
9 #include "ppapi/c/dev/ppb_var_deprecated.h" 11 #include "ppapi/c/dev/ppb_var_deprecated.h"
10 #include "ppapi/c/dev/ppp_class_deprecated.h" 12 #include "ppapi/c/dev/ppp_class_deprecated.h"
11 #include "ppapi/c/pp_var.h" 13 #include "ppapi/c/pp_var.h"
12 #include "ppapi/c/ppb_var.h" 14 #include "ppapi/c/ppb_var.h"
13 #include "ppapi/c/ppp_instance.h" 15 #include "ppapi/c/ppp_instance.h"
14 #include "ppapi/c/private/ppp_instance_private.h" 16 #include "ppapi/c/private/ppp_instance_private.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 PPP_INSTANCE_INTERFACE_1_1)); 173 PPP_INSTANCE_INTERFACE_1_1));
172 174
173 // Initialize an Instance, so that the plugin-side machinery will work 175 // Initialize an Instance, so that the plugin-side machinery will work
174 // properly. 176 // properly.
175 EXPECT_EQ(PP_TRUE, ppp_instance->DidCreate(kInstance, 0, NULL, NULL)); 177 EXPECT_EQ(PP_TRUE, ppp_instance->DidCreate(kInstance, 0, NULL, NULL));
176 178
177 // Check the plugin-side reference count. 179 // Check the plugin-side reference count.
178 EXPECT_EQ(1, plugin().var_tracker().GetRefCountForObject(instance_obj)); 180 EXPECT_EQ(1, plugin().var_tracker().GetRefCountForObject(instance_obj));
179 // Check the host-side var exists with the expected id and has 1 refcount (the 181 // Check the host-side var exists with the expected id and has 1 refcount (the
180 // refcount on behalf of the plugin). 182 // refcount on behalf of the plugin).
181 int32 expected_host_id = 183 int32_t expected_host_id =
182 plugin().var_tracker().GetHostObject(instance_obj).value.as_id; 184 plugin().var_tracker().GetHostObject(instance_obj).value.as_id;
183 Var* host_var = host().var_tracker().GetVar(expected_host_id); 185 Var* host_var = host().var_tracker().GetVar(expected_host_id);
184 ASSERT_TRUE(host_var); 186 ASSERT_TRUE(host_var);
185 EXPECT_EQ( 187 EXPECT_EQ(
186 1, 188 1,
187 host().var_tracker().GetRefCountForObject(GetPPVarNoAddRef(host_var))); 189 host().var_tracker().GetRefCountForObject(GetPPVarNoAddRef(host_var)));
188 190
189 // Call from the browser side to get the instance object. 191 // Call from the browser side to get the instance object.
190 PP_Var host_pp_var = ppp_instance_private->GetInstanceObject(kInstance); 192 PP_Var host_pp_var = ppp_instance_private->GetInstanceObject(kInstance);
191 EXPECT_EQ(instance_obj.type, host_pp_var.type); 193 EXPECT_EQ(instance_obj.type, host_pp_var.type);
192 EXPECT_EQ(host_pp_var.value.as_id, expected_host_id); 194 EXPECT_EQ(host_pp_var.value.as_id, expected_host_id);
193 EXPECT_EQ(1, plugin().var_tracker().GetRefCountForObject(instance_obj)); 195 EXPECT_EQ(1, plugin().var_tracker().GetRefCountForObject(instance_obj));
194 // A reference is passed to the browser, which we consume here. 196 // A reference is passed to the browser, which we consume here.
195 host().var_tracker().ReleaseVar(host_pp_var); 197 host().var_tracker().ReleaseVar(host_pp_var);
196 EXPECT_EQ(1, host().var_tracker().GetRefCountForObject(host_pp_var)); 198 EXPECT_EQ(1, host().var_tracker().GetRefCountForObject(host_pp_var));
197 199
198 // The plugin is going away; generally, so will all references to its instance 200 // The plugin is going away; generally, so will all references to its instance
199 // object. 201 // object.
200 host().var_tracker().ReleaseVar(host_pp_var); 202 host().var_tracker().ReleaseVar(host_pp_var);
201 // Destroy the instance. DidDestroy above decrements the reference count for 203 // Destroy the instance. DidDestroy above decrements the reference count for
202 // instance_obj, so it should also be destroyed. 204 // instance_obj, so it should also be destroyed.
203 ppp_instance->DidDestroy(kInstance); 205 ppp_instance->DidDestroy(kInstance);
204 EXPECT_EQ(-1, plugin().var_tracker().GetRefCountForObject(instance_obj)); 206 EXPECT_EQ(-1, plugin().var_tracker().GetRefCountForObject(instance_obj));
205 EXPECT_EQ(-1, host().var_tracker().GetRefCountForObject(host_pp_var)); 207 EXPECT_EQ(-1, host().var_tracker().GetRefCountForObject(host_pp_var));
206 } 208 }
207 209
208 } // namespace proxy 210 } // namespace proxy
209 } // namespace ppapi 211 } // namespace ppapi
210 212
OLDNEW
« no previous file with comments | « ppapi/proxy/ppp_instance_private_proxy.h ('k') | ppapi/proxy/ppp_instance_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698