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

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

Issue 664803003: Update from chromium a8e7c94b1b79a0948d05a1fcfff53391d22ce37a (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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
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/test_shared_bitmap_manager.h"
(...skipping 10 matching lines...) Expand all
21 21
22 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 22 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
23 new TestSharedBitmapManager()); 23 new TestSharedBitmapManager());
24 scoped_ptr<ResourceProvider> resource_provider( 24 scoped_ptr<ResourceProvider> resource_provider(
25 ResourceProvider::Create(output_surface.get(), 25 ResourceProvider::Create(output_surface.get(),
26 shared_bitmap_manager.get(), 26 shared_bitmap_manager.get(),
27 NULL, 27 NULL,
28 NULL, 28 NULL,
29 0, 29 0,
30 false, 30 false,
31 1, 31 1));
32 false));
33 scoped_ptr<ScopedResource> texture = 32 scoped_ptr<ScopedResource> texture =
34 ScopedResource::Create(resource_provider.get()); 33 ScopedResource::Create(resource_provider.get());
35 34
36 // New scoped textures do not hold a texture yet. 35 // New scoped textures do not hold a texture yet.
37 EXPECT_EQ(0u, texture->id()); 36 EXPECT_EQ(0u, texture->id());
38 37
39 // New scoped textures do not have a size yet. 38 // New scoped textures do not have a size yet.
40 EXPECT_EQ(gfx::Size(), texture->size()); 39 EXPECT_EQ(gfx::Size(), texture->size());
41 EXPECT_EQ(0u, texture->bytes()); 40 EXPECT_EQ(0u, texture->bytes());
42 } 41 }
43 42
44 TEST(ScopedResourceTest, CreateScopedResource) { 43 TEST(ScopedResourceTest, CreateScopedResource) {
45 FakeOutputSurfaceClient output_surface_client; 44 FakeOutputSurfaceClient output_surface_client;
46 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); 45 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d());
47 CHECK(output_surface->BindToClient(&output_surface_client)); 46 CHECK(output_surface->BindToClient(&output_surface_client));
48 47
49 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 48 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
50 new TestSharedBitmapManager()); 49 new TestSharedBitmapManager());
51 scoped_ptr<ResourceProvider> resource_provider( 50 scoped_ptr<ResourceProvider> resource_provider(
52 ResourceProvider::Create(output_surface.get(), 51 ResourceProvider::Create(output_surface.get(),
53 shared_bitmap_manager.get(), 52 shared_bitmap_manager.get(),
54 NULL, 53 NULL,
55 NULL, 54 NULL,
56 0, 55 0,
57 false, 56 false,
58 1, 57 1));
59 false));
60 scoped_ptr<ScopedResource> texture = 58 scoped_ptr<ScopedResource> texture =
61 ScopedResource::Create(resource_provider.get()); 59 ScopedResource::Create(resource_provider.get());
62 texture->Allocate( 60 texture->Allocate(
63 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888); 61 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888);
64 62
65 // The texture has an allocated byte-size now. 63 // The texture has an allocated byte-size now.
66 size_t expected_bytes = 30 * 30 * 4; 64 size_t expected_bytes = 30 * 30 * 4;
67 EXPECT_EQ(expected_bytes, texture->bytes()); 65 EXPECT_EQ(expected_bytes, texture->bytes());
68 66
69 EXPECT_LT(0u, texture->id()); 67 EXPECT_LT(0u, texture->id());
70 EXPECT_EQ(static_cast<unsigned>(RGBA_8888), texture->format()); 68 EXPECT_EQ(static_cast<unsigned>(RGBA_8888), texture->format());
71 EXPECT_EQ(gfx::Size(30, 30), texture->size()); 69 EXPECT_EQ(gfx::Size(30, 30), texture->size());
72 } 70 }
73 71
74 TEST(ScopedResourceTest, ScopedResourceIsDeleted) { 72 TEST(ScopedResourceTest, ScopedResourceIsDeleted) {
75 FakeOutputSurfaceClient output_surface_client; 73 FakeOutputSurfaceClient output_surface_client;
76 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); 74 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d());
77 CHECK(output_surface->BindToClient(&output_surface_client)); 75 CHECK(output_surface->BindToClient(&output_surface_client));
78 76
79 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 77 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
80 new TestSharedBitmapManager()); 78 new TestSharedBitmapManager());
81 scoped_ptr<ResourceProvider> resource_provider( 79 scoped_ptr<ResourceProvider> resource_provider(
82 ResourceProvider::Create(output_surface.get(), 80 ResourceProvider::Create(output_surface.get(),
83 shared_bitmap_manager.get(), 81 shared_bitmap_manager.get(),
84 NULL, 82 NULL,
85 NULL, 83 NULL,
86 0, 84 0,
87 false, 85 false,
88 1, 86 1));
89 false));
90 { 87 {
91 scoped_ptr<ScopedResource> texture = 88 scoped_ptr<ScopedResource> texture =
92 ScopedResource::Create(resource_provider.get()); 89 ScopedResource::Create(resource_provider.get());
93 90
94 EXPECT_EQ(0u, resource_provider->num_resources()); 91 EXPECT_EQ(0u, resource_provider->num_resources());
95 texture->Allocate( 92 texture->Allocate(
96 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888); 93 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888);
97 EXPECT_LT(0u, texture->id()); 94 EXPECT_LT(0u, texture->id());
98 EXPECT_EQ(1u, resource_provider->num_resources()); 95 EXPECT_EQ(1u, resource_provider->num_resources());
99 } 96 }
100 97
101 EXPECT_EQ(0u, resource_provider->num_resources()); 98 EXPECT_EQ(0u, resource_provider->num_resources());
102 { 99 {
103 scoped_ptr<ScopedResource> texture = 100 scoped_ptr<ScopedResource> texture =
104 ScopedResource::Create(resource_provider.get()); 101 ScopedResource::Create(resource_provider.get());
105 EXPECT_EQ(0u, resource_provider->num_resources()); 102 EXPECT_EQ(0u, resource_provider->num_resources());
106 texture->Allocate( 103 texture->Allocate(
107 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888); 104 gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888);
108 EXPECT_LT(0u, texture->id()); 105 EXPECT_LT(0u, texture->id());
109 EXPECT_EQ(1u, resource_provider->num_resources()); 106 EXPECT_EQ(1u, resource_provider->num_resources());
110 texture->Free(); 107 texture->Free();
111 EXPECT_EQ(0u, resource_provider->num_resources()); 108 EXPECT_EQ(0u, resource_provider->num_resources());
112 } 109 }
113 } 110 }
114 111
115 } // namespace 112 } // namespace
116 } // namespace cc 113 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_update_controller_unittest.cc ('k') | cc/resources/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698