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

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

Issue 174213003: PPAPI: Use clang-format on ppapi/shared_impl (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: remove DEPS Created 6 years, 10 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/shared_impl/resource_tracker.cc ('k') | ppapi/shared_impl/resource_var.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 "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/proxy_lock.h" 8 #include "ppapi/shared_impl/proxy_lock.h"
9 #include "ppapi/shared_impl/resource.h" 9 #include "ppapi/shared_impl/resource.h"
10 #include "ppapi/shared_impl/resource_tracker.h" 10 #include "ppapi/shared_impl/resource_tracker.h"
11 #include "ppapi/shared_impl/test_globals.h" 11 #include "ppapi/shared_impl/test_globals.h"
12 12
13 namespace ppapi { 13 namespace ppapi {
14 14
15 namespace { 15 namespace {
16 16
17 int mock_resource_alive_count = 0; 17 int mock_resource_alive_count = 0;
18 int last_plugin_ref_was_deleted_count = 0; 18 int last_plugin_ref_was_deleted_count = 0;
19 int instance_was_deleted_count = 0; 19 int instance_was_deleted_count = 0;
20 20
21 class MyMockResource : public Resource { 21 class MyMockResource : public Resource {
22 public: 22 public:
23 MyMockResource(PP_Instance instance) : Resource(OBJECT_IS_IMPL, instance) { 23 MyMockResource(PP_Instance instance) : Resource(OBJECT_IS_IMPL, instance) {
24 mock_resource_alive_count++; 24 mock_resource_alive_count++;
25 } 25 }
26 virtual ~MyMockResource() { 26 virtual ~MyMockResource() { mock_resource_alive_count--; }
27 mock_resource_alive_count--;
28 }
29 27
30 virtual void LastPluginRefWasDeleted() OVERRIDE { 28 virtual void LastPluginRefWasDeleted() OVERRIDE {
31 last_plugin_ref_was_deleted_count++; 29 last_plugin_ref_was_deleted_count++;
32 } 30 }
33 virtual void InstanceWasDeleted() OVERRIDE { 31 virtual void InstanceWasDeleted() OVERRIDE { instance_was_deleted_count++; }
34 instance_was_deleted_count++;
35 }
36 }; 32 };
37 33
38 } // namespace 34 } // namespace
39 35
40 class ResourceTrackerTest : public testing::Test { 36 class ResourceTrackerTest : public testing::Test {
41 public: 37 public:
42 ResourceTrackerTest() {} 38 ResourceTrackerTest() {}
43 39
44 // Test implementation. 40 // Test implementation.
45 virtual void SetUp() OVERRIDE { 41 virtual void SetUp() OVERRIDE {
46 ASSERT_EQ(0, mock_resource_alive_count); 42 ASSERT_EQ(0, mock_resource_alive_count);
47 last_plugin_ref_was_deleted_count = 0; 43 last_plugin_ref_was_deleted_count = 0;
48 instance_was_deleted_count = 0; 44 instance_was_deleted_count = 0;
49 } 45 }
50 virtual void TearDown() OVERRIDE { 46 virtual void TearDown() OVERRIDE {}
51 }
52 47
53 ResourceTracker& resource_tracker() { return *globals_.GetResourceTracker(); } 48 ResourceTracker& resource_tracker() { return *globals_.GetResourceTracker(); }
54 49
55 private: 50 private:
56 TestGlobals globals_; 51 TestGlobals globals_;
57 }; 52 };
58 53
59 // Test that LastPluginRefWasDeleted is called when the last plugin ref was 54 // Test that LastPluginRefWasDeleted is called when the last plugin ref was
60 // deleted but the object lives on. 55 // deleted but the object lives on.
61 TEST_F(ResourceTrackerTest, LastPluginRef) { 56 TEST_F(ResourceTrackerTest, LastPluginRef) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 EXPECT_EQ(1, mock_resource_alive_count); 112 EXPECT_EQ(1, mock_resource_alive_count);
118 EXPECT_EQ(1, last_plugin_ref_was_deleted_count); 113 EXPECT_EQ(1, last_plugin_ref_was_deleted_count);
119 EXPECT_EQ(1, instance_was_deleted_count); 114 EXPECT_EQ(1, instance_was_deleted_count);
120 EXPECT_EQ(0, resource->pp_instance()); 115 EXPECT_EQ(0, resource->pp_instance());
121 116
122 resource = NULL; 117 resource = NULL;
123 EXPECT_EQ(0, mock_resource_alive_count); 118 EXPECT_EQ(0, mock_resource_alive_count);
124 } 119 }
125 120
126 } // namespace ppapi 121 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/resource_tracker.cc ('k') | ppapi/shared_impl/resource_var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698