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

Side by Side Diff: ppapi/shared_impl/resource_tracker_unittest.cc

Issue 8342016: Revert 106142 - Add a new globals object for PPAPI tracking information. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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
« no previous file with comments | « ppapi/shared_impl/resource.cc ('k') | ppapi/shared_impl/scoped_pp_resource.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) 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "ppapi/shared_impl/resource.h" 8 #include "ppapi/shared_impl/resource.h"
9 #include "ppapi/shared_impl/resource_tracker.h" 9 #include "ppapi/shared_impl/resource_tracker.h"
10 #include "ppapi/shared_impl/test_globals.h"
11 #include "ppapi/shared_impl/tracker_base.h" 10 #include "ppapi/shared_impl/tracker_base.h"
12 11
13 namespace ppapi { 12 namespace ppapi {
14 13
15 namespace { 14 namespace {
16 15
17 int mock_resource_alive_count = 0; 16 int mock_resource_alive_count = 0;
18 int last_plugin_ref_was_deleted_count = 0; 17 int last_plugin_ref_was_deleted_count = 0;
19 int instance_was_deleted_count = 0; 18 int instance_was_deleted_count = 0;
20 19
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 my_tracker_base = NULL; 61 my_tracker_base = NULL;
63 TrackerBase::Init(NULL); 62 TrackerBase::Init(NULL);
64 } 63 }
65 64
66 // TrackerBase implementation. 65 // TrackerBase implementation.
67 virtual FunctionGroupBase* GetFunctionAPI( 66 virtual FunctionGroupBase* GetFunctionAPI(
68 PP_Instance inst, 67 PP_Instance inst,
69 ppapi::proxy::InterfaceID id) OVERRIDE { 68 ppapi::proxy::InterfaceID id) OVERRIDE {
70 return NULL; 69 return NULL;
71 } 70 }
71 virtual VarTracker* GetVarTracker() OVERRIDE {
72 return NULL;
73 }
74 virtual ResourceTracker* GetResourceTracker() OVERRIDE {
75 return &resource_tracker_;
76 }
72 virtual PP_Module GetModuleForInstance(PP_Instance /* instance */) OVERRIDE { 77 virtual PP_Module GetModuleForInstance(PP_Instance /* instance */) OVERRIDE {
73 return 0; 78 return 0;
74 } 79 }
75 80
76 ResourceTracker& resource_tracker() { return *globals_.GetResourceTracker(); } 81 ResourceTracker& resource_tracker() { return resource_tracker_; }
77 82
78 private: 83 private:
79 TestGlobals globals_; 84 ResourceTracker resource_tracker_;
80 }; 85 };
81 86
82 // Test that LastPluginRefWasDeleted is called when the last plugin ref was 87 // Test that LastPluginRefWasDeleted is called when the last plugin ref was
83 // deleted but the object lives on. 88 // deleted but the object lives on.
84 TEST_F(ResourceTrackerTest, LastPluginRef) { 89 TEST_F(ResourceTrackerTest, LastPluginRef) {
85 PP_Instance instance = 0x1234567; 90 PP_Instance instance = 0x1234567;
86 resource_tracker().DidCreateInstance(instance); 91 resource_tracker().DidCreateInstance(instance);
87 92
88 scoped_refptr<MyMockResource> resource(new MyMockResource(instance)); 93 scoped_refptr<MyMockResource> resource(new MyMockResource(instance));
89 PP_Resource pp_resource = resource->GetReference(); 94 PP_Resource pp_resource = resource->GetReference();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 EXPECT_EQ(1, mock_resource_alive_count); 142 EXPECT_EQ(1, mock_resource_alive_count);
138 EXPECT_EQ(1, last_plugin_ref_was_deleted_count); 143 EXPECT_EQ(1, last_plugin_ref_was_deleted_count);
139 EXPECT_EQ(1, instance_was_deleted_count); 144 EXPECT_EQ(1, instance_was_deleted_count);
140 EXPECT_EQ(0, resource->pp_instance()); 145 EXPECT_EQ(0, resource->pp_instance());
141 146
142 resource = NULL; 147 resource = NULL;
143 EXPECT_EQ(0, mock_resource_alive_count); 148 EXPECT_EQ(0, mock_resource_alive_count);
144 } 149 }
145 150
146 } // namespace ppapi 151 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/resource.cc ('k') | ppapi/shared_impl/scoped_pp_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698