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

Side by Side Diff: cc/scoped_texture_unittest.cc

Issue 11189043: cc: Rename cc classes and members to match filenames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
OLDNEW
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 "config.h" 5 #include "config.h"
6 6
7 #include "CCScopedTexture.h" 7 #include "CCScopedTexture.h"
8 8
9 #include "CCRenderer.h" 9 #include "CCRenderer.h"
10 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread 10 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread
11 #include "GraphicsContext3D.h" 11 #include "GraphicsContext3D.h"
12 #include "cc/test/fake_graphics_context.h" 12 #include "cc/test/fake_graphics_context.h"
13 #include "cc/test/tiled_layer_test_common.h" 13 #include "cc/test/tiled_layer_test_common.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 using namespace cc; 16 using namespace cc;
17 using namespace WebKit; 17 using namespace WebKit;
18 using namespace WebKitTests; 18 using namespace WebKitTests;
19 19
20 namespace { 20 namespace {
21 21
22 TEST(CCScopedTextureTest, NewScopedTexture) 22 TEST(ScopedTextureTest, NewScopedTexture)
23 { 23 {
24 scoped_ptr<CCGraphicsContext> context(createFakeCCGraphicsContext()); 24 scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
25 DebugScopedSetImplThread implThread; 25 DebugScopedSetImplThread implThread;
26 scoped_ptr<CCResourceProvider> resourceProvider(CCResourceProvider::create(c ontext.get())); 26 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte xt.get()));
27 scoped_ptr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvid er.get()); 27 scoped_ptr<ScopedTexture> texture = ScopedTexture::create(resourceProvider.g et());
28 28
29 // New scoped textures do not hold a texture yet. 29 // New scoped textures do not hold a texture yet.
30 EXPECT_EQ(0u, texture->id()); 30 EXPECT_EQ(0u, texture->id());
31 31
32 // New scoped textures do not have a size yet. 32 // New scoped textures do not have a size yet.
33 EXPECT_EQ(IntSize(), texture->size()); 33 EXPECT_EQ(IntSize(), texture->size());
34 EXPECT_EQ(0u, texture->bytes()); 34 EXPECT_EQ(0u, texture->bytes());
35 } 35 }
36 36
37 TEST(CCScopedTextureTest, CreateScopedTexture) 37 TEST(ScopedTextureTest, CreateScopedTexture)
38 { 38 {
39 scoped_ptr<CCGraphicsContext> context(createFakeCCGraphicsContext()); 39 scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
40 DebugScopedSetImplThread implThread; 40 DebugScopedSetImplThread implThread;
41 scoped_ptr<CCResourceProvider> resourceProvider(CCResourceProvider::create(c ontext.get())); 41 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte xt.get()));
42 scoped_ptr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvid er.get()); 42 scoped_ptr<ScopedTexture> texture = ScopedTexture::create(resourceProvider.g et());
43 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext3D:: RGBA, CCResourceProvider::TextureUsageAny); 43 texture->allocate(Renderer::ImplPool, IntSize(30, 30), GraphicsContext3D::RG BA, ResourceProvider::TextureUsageAny);
44 44
45 // The texture has an allocated byte-size now. 45 // The texture has an allocated byte-size now.
46 size_t expectedBytes = 30 * 30 * 4; 46 size_t expectedBytes = 30 * 30 * 4;
47 EXPECT_EQ(expectedBytes, texture->bytes()); 47 EXPECT_EQ(expectedBytes, texture->bytes());
48 48
49 EXPECT_LT(0u, texture->id()); 49 EXPECT_LT(0u, texture->id());
50 EXPECT_EQ(GraphicsContext3D::RGBA, texture->format()); 50 EXPECT_EQ(GraphicsContext3D::RGBA, texture->format());
51 EXPECT_EQ(IntSize(30, 30), texture->size()); 51 EXPECT_EQ(IntSize(30, 30), texture->size());
52 } 52 }
53 53
54 TEST(CCScopedTextureTest, ScopedTextureIsDeleted) 54 TEST(ScopedTextureTest, ScopedTextureIsDeleted)
55 { 55 {
56 scoped_ptr<CCGraphicsContext> context(createFakeCCGraphicsContext()); 56 scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
57 DebugScopedSetImplThread implThread; 57 DebugScopedSetImplThread implThread;
58 scoped_ptr<CCResourceProvider> resourceProvider(CCResourceProvider::create(c ontext.get())); 58 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte xt.get()));
59 59
60 { 60 {
61 scoped_ptr<CCScopedTexture> texture = CCScopedTexture::create(resourcePr ovider.get()); 61 scoped_ptr<ScopedTexture> texture = ScopedTexture::create(resourceProvid er.get());
62 62
63 EXPECT_EQ(0u, resourceProvider->numResources()); 63 EXPECT_EQ(0u, resourceProvider->numResources());
64 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext 3D::RGBA, CCResourceProvider::TextureUsageAny); 64 texture->allocate(Renderer::ImplPool, IntSize(30, 30), GraphicsContext3D ::RGBA, ResourceProvider::TextureUsageAny);
65 EXPECT_LT(0u, texture->id()); 65 EXPECT_LT(0u, texture->id());
66 EXPECT_EQ(1u, resourceProvider->numResources()); 66 EXPECT_EQ(1u, resourceProvider->numResources());
67 } 67 }
68 68
69 EXPECT_EQ(0u, resourceProvider->numResources()); 69 EXPECT_EQ(0u, resourceProvider->numResources());
70 70
71 { 71 {
72 scoped_ptr<CCScopedTexture> texture = CCScopedTexture::create(resourcePr ovider.get()); 72 scoped_ptr<ScopedTexture> texture = ScopedTexture::create(resourceProvid er.get());
73 EXPECT_EQ(0u, resourceProvider->numResources()); 73 EXPECT_EQ(0u, resourceProvider->numResources());
74 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext 3D::RGBA, CCResourceProvider::TextureUsageAny); 74 texture->allocate(Renderer::ImplPool, IntSize(30, 30), GraphicsContext3D ::RGBA, ResourceProvider::TextureUsageAny);
75 EXPECT_LT(0u, texture->id()); 75 EXPECT_LT(0u, texture->id());
76 EXPECT_EQ(1u, resourceProvider->numResources()); 76 EXPECT_EQ(1u, resourceProvider->numResources());
77 texture->free(); 77 texture->free();
78 EXPECT_EQ(0u, resourceProvider->numResources()); 78 EXPECT_EQ(0u, resourceProvider->numResources());
79 } 79 }
80 } 80 }
81 81
82 TEST(CCScopedTextureTest, LeakScopedTexture) 82 TEST(ScopedTextureTest, LeakScopedTexture)
83 { 83 {
84 scoped_ptr<CCGraphicsContext> context(createFakeCCGraphicsContext()); 84 scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
85 DebugScopedSetImplThread implThread; 85 DebugScopedSetImplThread implThread;
86 scoped_ptr<CCResourceProvider> resourceProvider(CCResourceProvider::create(c ontext.get())); 86 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte xt.get()));
87 87
88 { 88 {
89 scoped_ptr<CCScopedTexture> texture = CCScopedTexture::create(resourcePr ovider.get()); 89 scoped_ptr<ScopedTexture> texture = ScopedTexture::create(resourceProvid er.get());
90 90
91 EXPECT_EQ(0u, resourceProvider->numResources()); 91 EXPECT_EQ(0u, resourceProvider->numResources());
92 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext 3D::RGBA, CCResourceProvider::TextureUsageAny); 92 texture->allocate(Renderer::ImplPool, IntSize(30, 30), GraphicsContext3D ::RGBA, ResourceProvider::TextureUsageAny);
93 EXPECT_LT(0u, texture->id()); 93 EXPECT_LT(0u, texture->id());
94 EXPECT_EQ(1u, resourceProvider->numResources()); 94 EXPECT_EQ(1u, resourceProvider->numResources());
95 95
96 texture->leak(); 96 texture->leak();
97 EXPECT_EQ(0u, texture->id()); 97 EXPECT_EQ(0u, texture->id());
98 EXPECT_EQ(1u, resourceProvider->numResources()); 98 EXPECT_EQ(1u, resourceProvider->numResources());
99 99
100 texture->free(); 100 texture->free();
101 EXPECT_EQ(0u, texture->id()); 101 EXPECT_EQ(0u, texture->id());
102 EXPECT_EQ(1u, resourceProvider->numResources()); 102 EXPECT_EQ(1u, resourceProvider->numResources());
103 } 103 }
104 104
105 EXPECT_EQ(1u, resourceProvider->numResources()); 105 EXPECT_EQ(1u, resourceProvider->numResources());
106 } 106 }
107 107
108 } 108 }
OLDNEW
« cc/active_animation.h ('K') | « cc/scoped_texture.cc ('k') | cc/scoped_thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698