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

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

Issue 20185002: ContextProvider in OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: contextprovider: don't access Context3d() in OutputSurface contructors, it's not bound yet Created 7 years, 4 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
« no previous file with comments | « cc/resources/resource_provider_unittest.cc ('k') | cc/resources/scoped_resource_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/resource_update_controller.h" 5 #include "cc/resources/resource_update_controller.h"
6 6
7 #include "base/test/test_simple_task_runner.h" 7 #include "base/test/test_simple_task_runner.h"
8 #include "cc/debug/test_web_graphics_context_3d.h" 8 #include "cc/debug/test_web_graphics_context_3d.h"
9 #include "cc/resources/prioritized_resource_manager.h" 9 #include "cc/resources/prioritized_resource_manager.h"
10 #include "cc/test/fake_output_surface.h" 10 #include "cc/test/fake_output_surface.h"
11 #include "cc/test/fake_output_surface_client.h"
11 #include "cc/test/fake_proxy.h" 12 #include "cc/test/fake_proxy.h"
12 #include "cc/test/scheduler_test_common.h" 13 #include "cc/test/scheduler_test_common.h"
13 #include "cc/test/tiled_layer_test_common.h" 14 #include "cc/test/tiled_layer_test_common.h"
14 #include "cc/trees/single_thread_proxy.h" // For DebugScopedSetImplThread 15 #include "cc/trees/single_thread_proxy.h" // For DebugScopedSetImplThread
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/khronos/GLES2/gl2ext.h" 17 #include "third_party/khronos/GLES2/gl2ext.h"
17 18
18 using testing::Test; 19 using testing::Test;
19 using WebKit::WGC3Denum; 20 using WebKit::WGC3Denum;
20 using WebKit::WGC3Dint; 21 using WebKit::WGC3Dint;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 bool IsQueryResultAvailable() { 118 bool IsQueryResultAvailable() {
118 if (!query_results_available_) 119 if (!query_results_available_)
119 return false; 120 return false;
120 121
121 query_results_available_--; 122 query_results_available_--;
122 return true; 123 return true;
123 } 124 }
124 125
125 protected: 126 protected:
126 virtual void SetUp() { 127 virtual void SetUp() {
127 output_surface_ =
128 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(
129 new WebGraphicsContext3DForUploadTest(this)));
130 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, 300, 150); 128 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, 300, 150);
131 bitmap_.allocPixels(); 129 bitmap_.allocPixels();
132 130
133 for (int i = 0; i < 4; i++) { 131 for (int i = 0; i < 4; i++) {
134 textures_[i] = PrioritizedResource::Create(resource_manager_.get(), 132 textures_[i] = PrioritizedResource::Create(resource_manager_.get(),
135 gfx::Size(300, 150), GL_RGBA); 133 gfx::Size(300, 150), GL_RGBA);
136 textures_[i]-> 134 textures_[i]->
137 set_request_priority(PriorityCalculator::VisiblePriority(true)); 135 set_request_priority(PriorityCalculator::VisiblePriority(true));
138 } 136 }
139 resource_manager_->PrioritizeTextures(); 137 resource_manager_->PrioritizeTextures();
140 138
139 output_surface_ = FakeOutputSurface::Create3d(
140 scoped_ptr<TestWebGraphicsContext3D>(
141 new WebGraphicsContext3DForUploadTest(this)));
142 CHECK(output_surface_->BindToClient(&output_surface_client_));
143
141 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); 144 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0);
142 } 145 }
143 146
144 void AppendFullUploadsOfIndexedTextureToUpdateQueue(int count, 147 void AppendFullUploadsOfIndexedTextureToUpdateQueue(int count,
145 int texture_index) { 148 int texture_index) {
146 full_upload_count_expected_ += count; 149 full_upload_count_expected_ += count;
147 total_upload_count_expected_ += count; 150 total_upload_count_expected_ += count;
148 151
149 const gfx::Rect rect(0, 0, 300, 150); 152 const gfx::Rect rect(0, 0, 300, 150);
150 const ResourceUpdate upload = ResourceUpdate::Create( 153 const ResourceUpdate upload = ResourceUpdate::Create(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 queue_.Pass(), 189 queue_.Pass(),
187 resource_provider_.get()); 190 resource_provider_.get());
188 update_controller->Finalize(); 191 update_controller->Finalize();
189 } 192 }
190 193
191 void MakeQueryResultAvailable() { query_results_available_++; } 194 void MakeQueryResultAvailable() { query_results_available_++; }
192 195
193 protected: 196 protected:
194 // Classes required to interact and test the ResourceUpdateController 197 // Classes required to interact and test the ResourceUpdateController
195 FakeProxy proxy_; 198 FakeProxy proxy_;
199 FakeOutputSurfaceClient output_surface_client_;
196 scoped_ptr<OutputSurface> output_surface_; 200 scoped_ptr<OutputSurface> output_surface_;
197 scoped_ptr<ResourceProvider> resource_provider_; 201 scoped_ptr<ResourceProvider> resource_provider_;
198 scoped_ptr<ResourceUpdateQueue> queue_; 202 scoped_ptr<ResourceUpdateQueue> queue_;
199 scoped_ptr<PrioritizedResource> textures_[4]; 203 scoped_ptr<PrioritizedResource> textures_[4];
200 scoped_ptr<PrioritizedResourceManager> resource_manager_; 204 scoped_ptr<PrioritizedResourceManager> resource_manager_;
201 SkBitmap bitmap_; 205 SkBitmap bitmap_;
202 int query_results_available_; 206 int query_results_available_;
203 207
204 // Properties / expectations of this test 208 // Properties / expectations of this test
205 int full_upload_count_expected_; 209 int full_upload_count_expected_;
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 RunPendingTask(task_runner.get(), controller.get()); 514 RunPendingTask(task_runner.get(), controller.get());
511 } 515 }
512 516
513 EXPECT_FALSE(task_runner->HasPendingTask()); 517 EXPECT_FALSE(task_runner->HasPendingTask());
514 EXPECT_TRUE(client.ReadyToFinalizeCalled()); 518 EXPECT_TRUE(client.ReadyToFinalizeCalled());
515 EXPECT_EQ(2, num_total_uploads_); 519 EXPECT_EQ(2, num_total_uploads_);
516 } 520 }
517 521
518 } // namespace 522 } // namespace
519 } // namespace cc 523 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider_unittest.cc ('k') | cc/resources/scoped_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698