Remove extra line from unit_tests.isolate
[chromium-blink-merge.git] / cc / CCScopedTextureTest.cpp
blobb707a7fcb153878a422444a39696627f0e56a810
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
3 // found in the LICENSE file.
5 #include "config.h"
7 #include "CCScopedTexture.h"
9 #include "CCRenderer.h"
10 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread
11 #include "CCTiledLayerTestCommon.h"
12 #include "FakeCCGraphicsContext.h"
13 #include "GraphicsContext3D.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 using namespace cc;
17 using namespace WebKit;
18 using namespace WebKitTests;
20 namespace {
22 TEST(CCScopedTextureTest, NewScopedTexture)
24 scoped_ptr<CCGraphicsContext> context(createFakeCCGraphicsContext());
25 DebugScopedSetImplThread implThread;
26 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get()));
27 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvider.get());
29 // New scoped textures do not hold a texture yet.
30 EXPECT_EQ(0u, texture->id());
32 // New scoped textures do not have a size yet.
33 EXPECT_EQ(IntSize(), texture->size());
34 EXPECT_EQ(0u, texture->bytes());
37 TEST(CCScopedTextureTest, CreateScopedTexture)
39 scoped_ptr<CCGraphicsContext> context(createFakeCCGraphicsContext());
40 DebugScopedSetImplThread implThread;
41 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get()));
42 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvider.get());
43 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny);
45 // The texture has an allocated byte-size now.
46 size_t expectedBytes = 30 * 30 * 4;
47 EXPECT_EQ(expectedBytes, texture->bytes());
49 EXPECT_LT(0u, texture->id());
50 EXPECT_EQ(GraphicsContext3D::RGBA, texture->format());
51 EXPECT_EQ(IntSize(30, 30), texture->size());
54 TEST(CCScopedTextureTest, ScopedTextureIsDeleted)
56 scoped_ptr<CCGraphicsContext> context(createFakeCCGraphicsContext());
57 DebugScopedSetImplThread implThread;
58 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get()));
61 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvider.get());
63 EXPECT_EQ(0u, resourceProvider->numResources());
64 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny);
65 EXPECT_LT(0u, texture->id());
66 EXPECT_EQ(1u, resourceProvider->numResources());
69 EXPECT_EQ(0u, resourceProvider->numResources());
72 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvider.get());
73 EXPECT_EQ(0u, resourceProvider->numResources());
74 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny);
75 EXPECT_LT(0u, texture->id());
76 EXPECT_EQ(1u, resourceProvider->numResources());
77 texture->free();
78 EXPECT_EQ(0u, resourceProvider->numResources());
82 TEST(CCScopedTextureTest, LeakScopedTexture)
84 scoped_ptr<CCGraphicsContext> context(createFakeCCGraphicsContext());
85 DebugScopedSetImplThread implThread;
86 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get()));
89 OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(resourceProvider.get());
91 EXPECT_EQ(0u, resourceProvider->numResources());
92 texture->allocate(CCRenderer::ImplPool, IntSize(30, 30), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny);
93 EXPECT_LT(0u, texture->id());
94 EXPECT_EQ(1u, resourceProvider->numResources());
96 texture->leak();
97 EXPECT_EQ(0u, texture->id());
98 EXPECT_EQ(1u, resourceProvider->numResources());
100 texture->free();
101 EXPECT_EQ(0u, texture->id());
102 EXPECT_EQ(1u, resourceProvider->numResources());
105 EXPECT_EQ(1u, resourceProvider->numResources());