| OLD | NEW |
| 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" | 10 #include "ppapi/shared_impl/test_globals.h" |
| 11 | 11 |
| 12 namespace ppapi { | 12 namespace ppapi { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 int mock_resource_alive_count = 0; | 16 int mock_resource_alive_count = 0; |
| 17 int last_plugin_ref_was_deleted_count = 0; | 17 int last_plugin_ref_was_deleted_count = 0; |
| 18 int instance_was_deleted_count = 0; | 18 int instance_was_deleted_count = 0; |
| 19 | 19 |
| 20 class MyMockResource : public Resource { | 20 class MyMockResource : public Resource { |
| 21 public: | 21 public: |
| 22 MyMockResource(PP_Instance instance) : Resource(instance) { | 22 MyMockResource(PP_Instance instance) : Resource(OBJECT_IS_IMPL, instance) { |
| 23 mock_resource_alive_count++; | 23 mock_resource_alive_count++; |
| 24 } | 24 } |
| 25 virtual ~MyMockResource() { | 25 virtual ~MyMockResource() { |
| 26 mock_resource_alive_count--; | 26 mock_resource_alive_count--; |
| 27 } | 27 } |
| 28 | 28 |
| 29 virtual void LastPluginRefWasDeleted() OVERRIDE { | 29 virtual void LastPluginRefWasDeleted() OVERRIDE { |
| 30 Resource::LastPluginRefWasDeleted(); | 30 Resource::LastPluginRefWasDeleted(); |
| 31 last_plugin_ref_was_deleted_count++; | 31 last_plugin_ref_was_deleted_count++; |
| 32 } | 32 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 EXPECT_EQ(1, mock_resource_alive_count); | 115 EXPECT_EQ(1, mock_resource_alive_count); |
| 116 EXPECT_EQ(1, last_plugin_ref_was_deleted_count); | 116 EXPECT_EQ(1, last_plugin_ref_was_deleted_count); |
| 117 EXPECT_EQ(1, instance_was_deleted_count); | 117 EXPECT_EQ(1, instance_was_deleted_count); |
| 118 EXPECT_EQ(0, resource->pp_instance()); | 118 EXPECT_EQ(0, resource->pp_instance()); |
| 119 | 119 |
| 120 resource = NULL; | 120 resource = NULL; |
| 121 EXPECT_EQ(0, mock_resource_alive_count); | 121 EXPECT_EQ(0, mock_resource_alive_count); |
| 122 } | 122 } |
| 123 | 123 |
| 124 } // namespace ppapi | 124 } // namespace ppapi |
| OLD | NEW |