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

Side by Side Diff: webkit/plugins/ppapi/resource_tracker_unittest.cc

Issue 6538028: A proposal for an initial postMessage interface. This will allow JavaScript ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppapi_unittest.h" 5 #include "webkit/plugins/ppapi/ppapi_unittest.h"
6 6
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "ppapi/c/pp_var.h" 8 #include "ppapi/c/pp_var.h"
9 #include "ppapi/c/ppp_instance.h" 9 #include "ppapi/c/ppp_instance.h"
10 #include "third_party/npapi/bindings/npruntime.h" 10 #include "third_party/npapi/bindings/npruntime.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 ASSERT_EQ(1, TrackedMockResource::tracked_objects_alive); 136 ASSERT_EQ(1, TrackedMockResource::tracked_objects_alive);
137 tracker().UnrefResource(resource_id); 137 tracker().UnrefResource(resource_id);
138 ASSERT_EQ(0, TrackedMockResource::tracked_objects_alive); 138 ASSERT_EQ(0, TrackedMockResource::tracked_objects_alive);
139 } 139 }
140 140
141 TEST_F(ResourceTrackerTest, DeleteResourceWithInstance) { 141 TEST_F(ResourceTrackerTest, DeleteResourceWithInstance) {
142 // Make a second instance (the test harness already creates & manages one). 142 // Make a second instance (the test harness already creates & manages one).
143 scoped_refptr<PluginInstance> instance2( 143 scoped_refptr<PluginInstance> instance2(
144 new PluginInstance(delegate(), module(), 144 new PluginInstance(delegate(), module(),
145 static_cast<const PPP_Instance*>( 145 static_cast<const PPP_Instance*>(
146 GetMockInterface(PPP_INSTANCE_INTERFACE)))); 146 GetMockInterface(PPP_INSTANCE_INTERFACE)),
147 PluginInstance::PLUGIN_OWNS_INTERFACE));
147 PP_Instance pp_instance2 = instance2->pp_instance(); 148 PP_Instance pp_instance2 = instance2->pp_instance();
148 149
149 // Make two resources and take refs on behalf of the "plugin" for each. 150 // Make two resources and take refs on behalf of the "plugin" for each.
150 scoped_refptr<TrackedMockResource> resource1( 151 scoped_refptr<TrackedMockResource> resource1(
151 new TrackedMockResource(instance2)); 152 new TrackedMockResource(instance2));
152 resource1->GetReference(); 153 resource1->GetReference();
153 scoped_refptr<TrackedMockResource> resource2( 154 scoped_refptr<TrackedMockResource> resource2(
154 new TrackedMockResource(instance2)); 155 new TrackedMockResource(instance2));
155 resource2->GetReference(); 156 resource2->GetReference();
156 157
(...skipping 14 matching lines...) Expand all
171 ASSERT_EQ(1, TrackedMockResource::tracked_objects_alive); 172 ASSERT_EQ(1, TrackedMockResource::tracked_objects_alive);
172 resource1 = NULL; 173 resource1 = NULL;
173 ASSERT_EQ(0, TrackedMockResource::tracked_objects_alive); 174 ASSERT_EQ(0, TrackedMockResource::tracked_objects_alive);
174 } 175 }
175 176
176 TEST_F(ResourceTrackerTest, DeleteObjectVarWithInstance) { 177 TEST_F(ResourceTrackerTest, DeleteObjectVarWithInstance) {
177 // Make a second instance (the test harness already creates & manages one). 178 // Make a second instance (the test harness already creates & manages one).
178 scoped_refptr<PluginInstance> instance2( 179 scoped_refptr<PluginInstance> instance2(
179 new PluginInstance(delegate(), module(), 180 new PluginInstance(delegate(), module(),
180 static_cast<const PPP_Instance*>( 181 static_cast<const PPP_Instance*>(
181 GetMockInterface(PPP_INSTANCE_INTERFACE)))); 182 GetMockInterface(PPP_INSTANCE_INTERFACE)),
183 PluginInstance::PLUGIN_OWNS_INTERFACE));
182 PP_Instance pp_instance2 = instance2->pp_instance(); 184 PP_Instance pp_instance2 = instance2->pp_instance();
183 185
184 // Make an object var. 186 // Make an object var.
185 scoped_ptr<NPObject> npobject(NewTrackedNPObject()); 187 scoped_ptr<NPObject> npobject(NewTrackedNPObject());
186 ObjectVar::NPObjectToPPVar(instance2.get(), npobject.get()); 188 ObjectVar::NPObjectToPPVar(instance2.get(), npobject.get());
187 189
188 EXPECT_EQ(1, g_npobjects_alive); 190 EXPECT_EQ(1, g_npobjects_alive);
189 EXPECT_EQ(1u, tracker().GetLiveObjectsForInstance(pp_instance2)); 191 EXPECT_EQ(1u, tracker().GetLiveObjectsForInstance(pp_instance2));
190 192
191 // Free the instance, this should release the ObjectVar. 193 // Free the instance, this should release the ObjectVar.
(...skipping 28 matching lines...) Expand all
220 222
221 // Releasing the resource should free the internal ref, and so making a new 223 // Releasing the resource should free the internal ref, and so making a new
222 // one now should generate a new ID. 224 // one now should generate a new ID.
223 PP_Var pp_object3 = ObjectVar::NPObjectToPPVar(instance(), npobject.get()); 225 PP_Var pp_object3 = ObjectVar::NPObjectToPPVar(instance(), npobject.get());
224 EXPECT_NE(pp_object1.value.as_id, pp_object3.value.as_id); 226 EXPECT_NE(pp_object1.value.as_id, pp_object3.value.as_id);
225 tracker().UnrefVar(static_cast<int32_t>(pp_object3.value.as_id)); 227 tracker().UnrefVar(static_cast<int32_t>(pp_object3.value.as_id));
226 } 228 }
227 229
228 } // namespace ppapi 230 } // namespace ppapi
229 } // namespace webkit 231 } // namespace webkit
OLDNEW
« webkit/plugins/ppapi/ppapi_webplugin_impl.cc ('K') | « webkit/plugins/ppapi/ppapi_webplugin_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698