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

Side by Side Diff: cc/resources/scoped_resource_unittest.cc

Issue 202763002: Switch to use SharedBitmapManager all the time in cc_unittests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 "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/tiled_layer_test_common.h" 11 #include "cc/test/tiled_layer_test_common.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace cc { 14 namespace cc {
14 namespace { 15 namespace {
15 16
16 TEST(ScopedResourceTest, NewScopedResource) { 17 TEST(ScopedResourceTest, NewScopedResource) {
17 FakeOutputSurfaceClient output_surface_client; 18 FakeOutputSurfaceClient output_surface_client;
18 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); 19 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d());
19 CHECK(output_surface->BindToClient(&output_surface_client)); 20 CHECK(output_surface->BindToClient(&output_surface_client));
20 21
21 scoped_ptr<ResourceProvider> resource_provider( 22 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
22 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); 23 new TestSharedBitmapManager());
24 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
25 output_surface.get(), shared_bitmap_manager.get(), 0, false, 1));
23 scoped_ptr<ScopedResource> texture = 26 scoped_ptr<ScopedResource> texture =
24 ScopedResource::Create(resource_provider.get()); 27 ScopedResource::Create(resource_provider.get());
25 28
26 // New scoped textures do not hold a texture yet. 29 // New scoped textures do not hold a texture yet.
27 EXPECT_EQ(0u, texture->id()); 30 EXPECT_EQ(0u, texture->id());
28 31
29 // New scoped textures do not have a size yet. 32 // New scoped textures do not have a size yet.
30 EXPECT_EQ(gfx::Size(), texture->size()); 33 EXPECT_EQ(gfx::Size(), texture->size());
31 EXPECT_EQ(0u, texture->bytes()); 34 EXPECT_EQ(0u, texture->bytes());
32 } 35 }
33 36
34 TEST(ScopedResourceTest, CreateScopedResource) { 37 TEST(ScopedResourceTest, CreateScopedResource) {
35 FakeOutputSurfaceClient output_surface_client; 38 FakeOutputSurfaceClient output_surface_client;
36 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); 39 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d());
37 CHECK(output_surface->BindToClient(&output_surface_client)); 40 CHECK(output_surface->BindToClient(&output_surface_client));
38 41
39 scoped_ptr<ResourceProvider> resource_provider( 42 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
40 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); 43 new TestSharedBitmapManager());
44 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
45 output_surface.get(), shared_bitmap_manager.get(), 0, false, 1));
41 scoped_ptr<ScopedResource> texture = 46 scoped_ptr<ScopedResource> texture =
42 ScopedResource::Create(resource_provider.get()); 47 ScopedResource::Create(resource_provider.get());
43 texture->Allocate(gfx::Size(30, 30), 48 texture->Allocate(gfx::Size(30, 30),
44 ResourceProvider::TextureUsageAny, 49 ResourceProvider::TextureUsageAny,
45 RGBA_8888); 50 RGBA_8888);
46 51
47 // The texture has an allocated byte-size now. 52 // The texture has an allocated byte-size now.
48 size_t expected_bytes = 30 * 30 * 4; 53 size_t expected_bytes = 30 * 30 * 4;
49 EXPECT_EQ(expected_bytes, texture->bytes()); 54 EXPECT_EQ(expected_bytes, texture->bytes());
50 55
51 EXPECT_LT(0u, texture->id()); 56 EXPECT_LT(0u, texture->id());
52 EXPECT_EQ(static_cast<unsigned>(RGBA_8888), texture->format()); 57 EXPECT_EQ(static_cast<unsigned>(RGBA_8888), texture->format());
53 EXPECT_EQ(gfx::Size(30, 30), texture->size()); 58 EXPECT_EQ(gfx::Size(30, 30), texture->size());
54 } 59 }
55 60
56 TEST(ScopedResourceTest, ScopedResourceIsDeleted) { 61 TEST(ScopedResourceTest, ScopedResourceIsDeleted) {
57 FakeOutputSurfaceClient output_surface_client; 62 FakeOutputSurfaceClient output_surface_client;
58 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); 63 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d());
59 CHECK(output_surface->BindToClient(&output_surface_client)); 64 CHECK(output_surface->BindToClient(&output_surface_client));
60 65
61 scoped_ptr<ResourceProvider> resource_provider( 66 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
62 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); 67 new TestSharedBitmapManager());
68 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
69 output_surface.get(), shared_bitmap_manager.get(), 0, false, 1));
63 { 70 {
64 scoped_ptr<ScopedResource> texture = 71 scoped_ptr<ScopedResource> texture =
65 ScopedResource::Create(resource_provider.get()); 72 ScopedResource::Create(resource_provider.get());
66 73
67 EXPECT_EQ(0u, resource_provider->num_resources()); 74 EXPECT_EQ(0u, resource_provider->num_resources());
68 texture->Allocate(gfx::Size(30, 30), 75 texture->Allocate(gfx::Size(30, 30),
69 ResourceProvider::TextureUsageAny, 76 ResourceProvider::TextureUsageAny,
70 RGBA_8888); 77 RGBA_8888);
71 EXPECT_LT(0u, texture->id()); 78 EXPECT_LT(0u, texture->id());
72 EXPECT_EQ(1u, resource_provider->num_resources()); 79 EXPECT_EQ(1u, resource_provider->num_resources());
(...skipping 12 matching lines...) Expand all
85 texture->Free(); 92 texture->Free();
86 EXPECT_EQ(0u, resource_provider->num_resources()); 93 EXPECT_EQ(0u, resource_provider->num_resources());
87 } 94 }
88 } 95 }
89 96
90 TEST(ScopedResourceTest, LeakScopedResource) { 97 TEST(ScopedResourceTest, LeakScopedResource) {
91 FakeOutputSurfaceClient output_surface_client; 98 FakeOutputSurfaceClient output_surface_client;
92 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); 99 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d());
93 CHECK(output_surface->BindToClient(&output_surface_client)); 100 CHECK(output_surface->BindToClient(&output_surface_client));
94 101
95 scoped_ptr<ResourceProvider> resource_provider( 102 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
96 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); 103 new TestSharedBitmapManager());
104 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
105 output_surface.get(), shared_bitmap_manager.get(), 0, false, 1));
97 { 106 {
98 scoped_ptr<ScopedResource> texture = 107 scoped_ptr<ScopedResource> texture =
99 ScopedResource::Create(resource_provider.get()); 108 ScopedResource::Create(resource_provider.get());
100 109
101 EXPECT_EQ(0u, resource_provider->num_resources()); 110 EXPECT_EQ(0u, resource_provider->num_resources());
102 texture->Allocate(gfx::Size(30, 30), 111 texture->Allocate(gfx::Size(30, 30),
103 ResourceProvider::TextureUsageAny, 112 ResourceProvider::TextureUsageAny,
104 RGBA_8888); 113 RGBA_8888);
105 EXPECT_LT(0u, texture->id()); 114 EXPECT_LT(0u, texture->id());
106 EXPECT_EQ(1u, resource_provider->num_resources()); 115 EXPECT_EQ(1u, resource_provider->num_resources());
107 116
108 texture->Leak(); 117 texture->Leak();
109 EXPECT_EQ(0u, texture->id()); 118 EXPECT_EQ(0u, texture->id());
110 EXPECT_EQ(1u, resource_provider->num_resources()); 119 EXPECT_EQ(1u, resource_provider->num_resources());
111 120
112 texture->Free(); 121 texture->Free();
113 EXPECT_EQ(0u, texture->id()); 122 EXPECT_EQ(0u, texture->id());
114 EXPECT_EQ(1u, resource_provider->num_resources()); 123 EXPECT_EQ(1u, resource_provider->num_resources());
115 } 124 }
116 125
117 EXPECT_EQ(1u, resource_provider->num_resources()); 126 EXPECT_EQ(1u, resource_provider->num_resources());
118 } 127 }
119 128
120 } // namespace 129 } // namespace
121 } // namespace cc 130 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_update_controller_unittest.cc ('k') | cc/resources/shared_bitmap_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698