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/tiled_layer_test_common.h" | 9 #include "cc/test/tiled_layer_test_common.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 scoped_ptr<ScopedResource> texture = | 35 scoped_ptr<ScopedResource> texture = |
36 ScopedResource::create(resource_provider.get()); | 36 ScopedResource::create(resource_provider.get()); |
37 texture->Allocate( | 37 texture->Allocate( |
38 gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny); | 38 gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny); |
39 | 39 |
40 // The texture has an allocated byte-size now. | 40 // The texture has an allocated byte-size now. |
41 size_t expected_bytes = 30 * 30 * 4; | 41 size_t expected_bytes = 30 * 30 * 4; |
42 EXPECT_EQ(expected_bytes, texture->bytes()); | 42 EXPECT_EQ(expected_bytes, texture->bytes()); |
43 | 43 |
44 EXPECT_LT(0u, texture->id()); | 44 EXPECT_LT(0u, texture->id()); |
45 EXPECT_EQ(GL_RGBA, texture->format()); | 45 EXPECT_EQ(static_cast<unsigned>(GL_RGBA), texture->format()); |
46 EXPECT_EQ(gfx::Size(30, 30), texture->size()); | 46 EXPECT_EQ(gfx::Size(30, 30), texture->size()); |
47 } | 47 } |
48 | 48 |
49 TEST(ScopedResourceTest, ScopedResourceIsDeleted) { | 49 TEST(ScopedResourceTest, ScopedResourceIsDeleted) { |
50 scoped_ptr<OutputSurface> context(CreateFakeOutputSurface()); | 50 scoped_ptr<OutputSurface> context(CreateFakeOutputSurface()); |
51 scoped_ptr<ResourceProvider> resource_provider( | 51 scoped_ptr<ResourceProvider> resource_provider( |
52 ResourceProvider::Create(context.get())); | 52 ResourceProvider::Create(context.get())); |
53 { | 53 { |
54 scoped_ptr<ScopedResource> texture = | 54 scoped_ptr<ScopedResource> texture = |
55 ScopedResource::create(resource_provider.get()); | 55 ScopedResource::create(resource_provider.get()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 texture->Free(); | 96 texture->Free(); |
97 EXPECT_EQ(0u, texture->id()); | 97 EXPECT_EQ(0u, texture->id()); |
98 EXPECT_EQ(1u, resource_provider->num_resources()); | 98 EXPECT_EQ(1u, resource_provider->num_resources()); |
99 } | 99 } |
100 | 100 |
101 EXPECT_EQ(1u, resource_provider->num_resources()); | 101 EXPECT_EQ(1u, resource_provider->num_resources()); |
102 } | 102 } |
103 | 103 |
104 } // namespace | 104 } // namespace |
105 } // namespace cc | 105 } // namespace cc |
OLD | NEW |