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

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

Issue 12378050: PPAPI: Remove threading options; it's always on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PDFResource unit test Created 7 years, 8 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/proxy/plugin_resource_tracker.cc ('k') | ppapi/proxy/plugin_var_tracker.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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/process.h" 6 #include "base/process.h"
7 #include "ppapi/proxy/mock_resource.h" 7 #include "ppapi/proxy/mock_resource.h"
8 #include "ppapi/proxy/plugin_dispatcher.h" 8 #include "ppapi/proxy/plugin_dispatcher.h"
9 #include "ppapi/proxy/plugin_resource_tracker.h" 9 #include "ppapi/proxy/plugin_resource_tracker.h"
10 #include "ppapi/proxy/ppapi_messages.h" 10 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/proxy/ppapi_proxy_test.h" 11 #include "ppapi/proxy/ppapi_proxy_test.h"
12 #include "ppapi/shared_impl/proxy_lock.h"
12 13
13 namespace ppapi { 14 namespace ppapi {
14 namespace proxy { 15 namespace proxy {
15 16
16 namespace { 17 namespace {
17 18
18 // Object so we know when a resource has been released. 19 // Object so we know when a resource has been released.
19 class TrackedMockResource : public MockResource { 20 class TrackedMockResource : public MockResource {
20 public: 21 public:
21 TrackedMockResource(const HostResource& serialized) 22 TrackedMockResource(const HostResource& serialized)
(...skipping 11 matching lines...) Expand all
33 34
34 } // namespace 35 } // namespace
35 36
36 class PluginResourceTrackerTest : public PluginProxyTest { 37 class PluginResourceTrackerTest : public PluginProxyTest {
37 public: 38 public:
38 PluginResourceTrackerTest() {} 39 PluginResourceTrackerTest() {}
39 ~PluginResourceTrackerTest() {} 40 ~PluginResourceTrackerTest() {}
40 }; 41 };
41 42
42 TEST_F(PluginResourceTrackerTest, PluginResourceForHostResource) { 43 TEST_F(PluginResourceTrackerTest, PluginResourceForHostResource) {
44 ProxyAutoLock lock;
45
43 PP_Resource host_resource = 0x5678; 46 PP_Resource host_resource = 0x5678;
44 47
45 HostResource serialized; 48 HostResource serialized;
46 serialized.SetHostResource(pp_instance(), host_resource); 49 serialized.SetHostResource(pp_instance(), host_resource);
47 50
48 // When we haven't added an object, the return value should be 0. 51 // When we haven't added an object, the return value should be 0.
49 EXPECT_EQ(0, resource_tracker().PluginResourceForHostResource(serialized)); 52 EXPECT_EQ(0, resource_tracker().PluginResourceForHostResource(serialized));
50 53
51 EXPECT_EQ(0, TrackedMockResource::tracked_alive_count); 54 EXPECT_EQ(0, TrackedMockResource::tracked_alive_count);
52 TrackedMockResource* object = new TrackedMockResource(serialized); 55 TrackedMockResource* object = new TrackedMockResource(serialized);
53 EXPECT_EQ(1, TrackedMockResource::tracked_alive_count); 56 EXPECT_EQ(1, TrackedMockResource::tracked_alive_count);
54 PP_Resource plugin_resource = object->GetReference(); 57 PP_Resource plugin_resource = object->GetReference();
55 58
56 // Now that the object has been added, the return value should be the plugin 59 // Now that the object has been added, the return value should be the plugin
57 // resource ID we already got. 60 // resource ID we already got.
58 EXPECT_EQ(plugin_resource, 61 EXPECT_EQ(plugin_resource,
59 resource_tracker().PluginResourceForHostResource(serialized)); 62 resource_tracker().PluginResourceForHostResource(serialized));
60 63
61 // Releasing the resource should have freed it. 64 // Releasing the resource should have freed it.
62 resource_tracker().ReleaseResource(plugin_resource); 65 resource_tracker().ReleaseResource(plugin_resource);
63 EXPECT_EQ(0, TrackedMockResource::tracked_alive_count); 66 EXPECT_EQ(0, TrackedMockResource::tracked_alive_count);
64 EXPECT_EQ(0, resource_tracker().PluginResourceForHostResource(serialized)); 67 EXPECT_EQ(0, resource_tracker().PluginResourceForHostResource(serialized));
65 } 68 }
66 69
67 } // namespace proxy 70 } // namespace proxy
68 } // namespace ppapi 71 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/plugin_resource_tracker.cc ('k') | ppapi/proxy/plugin_var_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698