| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/resources/scoped_resource.h" | 5 #include "cc/resources/scoped_resource.h" |
| 6 | 6 |
| 7 #include "cc/output/renderer.h" | 7 #include "cc/output/renderer.h" |
| 8 #include "cc/test/fake_output_surface.h" | 8 #include "cc/test/fake_output_surface.h" |
| 9 #include "cc/test/fake_output_surface_client.h" | 9 #include "cc/test/fake_output_surface_client.h" |
| 10 #include "cc/test/test_shared_bitmap_manager.h" | 10 #include "cc/test/test_shared_bitmap_manager.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 EXPECT_EQ(0u, resource_provider->num_resources()); | 105 EXPECT_EQ(0u, resource_provider->num_resources()); |
| 106 texture->Allocate( | 106 texture->Allocate( |
| 107 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888); | 107 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888); |
| 108 EXPECT_LT(0u, texture->id()); | 108 EXPECT_LT(0u, texture->id()); |
| 109 EXPECT_EQ(1u, resource_provider->num_resources()); | 109 EXPECT_EQ(1u, resource_provider->num_resources()); |
| 110 texture->Free(); | 110 texture->Free(); |
| 111 EXPECT_EQ(0u, resource_provider->num_resources()); | 111 EXPECT_EQ(0u, resource_provider->num_resources()); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 TEST(ScopedResourceTest, LeakScopedResource) { | |
| 116 FakeOutputSurfaceClient output_surface_client; | |
| 117 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); | |
| 118 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 119 | |
| 120 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | |
| 121 new TestSharedBitmapManager()); | |
| 122 scoped_ptr<ResourceProvider> resource_provider( | |
| 123 ResourceProvider::Create(output_surface.get(), | |
| 124 shared_bitmap_manager.get(), | |
| 125 NULL, | |
| 126 NULL, | |
| 127 0, | |
| 128 false, | |
| 129 1, | |
| 130 false)); | |
| 131 { | |
| 132 scoped_ptr<ScopedResource> texture = | |
| 133 ScopedResource::Create(resource_provider.get()); | |
| 134 | |
| 135 EXPECT_EQ(0u, resource_provider->num_resources()); | |
| 136 texture->Allocate( | |
| 137 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888); | |
| 138 EXPECT_LT(0u, texture->id()); | |
| 139 EXPECT_EQ(1u, resource_provider->num_resources()); | |
| 140 | |
| 141 texture->Leak(); | |
| 142 EXPECT_EQ(0u, texture->id()); | |
| 143 EXPECT_EQ(1u, resource_provider->num_resources()); | |
| 144 | |
| 145 texture->Free(); | |
| 146 EXPECT_EQ(0u, texture->id()); | |
| 147 EXPECT_EQ(1u, resource_provider->num_resources()); | |
| 148 } | |
| 149 | |
| 150 EXPECT_EQ(1u, resource_provider->num_resources()); | |
| 151 } | |
| 152 | |
| 153 } // namespace | 115 } // namespace |
| 154 } // namespace cc | 116 } // namespace cc |
| OLD | NEW |