OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/raster_worker_pool.h" | 5 #include "cc/resources/raster_worker_pool.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
| 9 #include "cc/debug/test_web_graphics_context_3d.h" |
9 #include "cc/resources/image_raster_worker_pool.h" | 10 #include "cc/resources/image_raster_worker_pool.h" |
10 #include "cc/resources/picture_pile.h" | 11 #include "cc/resources/picture_pile.h" |
11 #include "cc/resources/picture_pile_impl.h" | 12 #include "cc/resources/picture_pile_impl.h" |
12 #include "cc/resources/pixel_buffer_raster_worker_pool.h" | 13 #include "cc/resources/pixel_buffer_raster_worker_pool.h" |
13 #include "cc/resources/resource_provider.h" | 14 #include "cc/resources/resource_provider.h" |
14 #include "cc/resources/scoped_resource.h" | 15 #include "cc/resources/scoped_resource.h" |
15 #include "cc/test/fake_output_surface.h" | 16 #include "cc/test/fake_output_surface.h" |
| 17 #include "cc/test/fake_output_surface_client.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
17 | 19 |
18 namespace cc { | 20 namespace cc { |
19 | 21 |
20 class TestRasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask { | 22 class TestRasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask { |
21 public: | 23 public: |
22 typedef base::Callback<void(const PicturePileImpl::Analysis& analysis, | 24 typedef base::Callback<void(const PicturePileImpl::Analysis& analysis, |
23 bool was_canceled, | 25 bool was_canceled, |
24 bool did_raster)> Reply; | 26 bool did_raster)> Reply; |
25 | 27 |
(...skipping 22 matching lines...) Expand all Loading... |
48 const Reply reply_; | 50 const Reply reply_; |
49 bool did_raster_; | 51 bool did_raster_; |
50 | 52 |
51 DISALLOW_COPY_AND_ASSIGN(TestRasterWorkerPoolTaskImpl); | 53 DISALLOW_COPY_AND_ASSIGN(TestRasterWorkerPoolTaskImpl); |
52 }; | 54 }; |
53 | 55 |
54 class RasterWorkerPoolTest : public testing::Test, | 56 class RasterWorkerPoolTest : public testing::Test, |
55 public RasterWorkerPoolClient { | 57 public RasterWorkerPoolClient { |
56 public: | 58 public: |
57 RasterWorkerPoolTest() | 59 RasterWorkerPoolTest() |
58 : output_surface_(FakeOutputSurface::Create3d()), | 60 : context_provider_(TestContextProvider::Create()), |
59 resource_provider_( | |
60 ResourceProvider::Create(output_surface_.get(), 0)), | |
61 check_interval_milliseconds_(1), | 61 check_interval_milliseconds_(1), |
62 timeout_seconds_(5), | 62 timeout_seconds_(5), |
63 timed_out_(false) { | 63 timed_out_(false) { |
| 64 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); |
| 65 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 66 |
| 67 resource_provider_ = ResourceProvider::Create(output_surface_.get(), |
| 68 0).Pass(); |
64 } | 69 } |
65 virtual ~RasterWorkerPoolTest() { | 70 virtual ~RasterWorkerPoolTest() { |
66 resource_provider_.reset(); | 71 resource_provider_.reset(); |
67 } | 72 } |
68 | 73 |
69 // Overridden from testing::Test: | 74 // Overridden from testing::Test: |
70 virtual void TearDown() OVERRIDE { | 75 virtual void TearDown() OVERRIDE { |
71 if (!raster_worker_pool_) | 76 if (!raster_worker_pool_) |
72 return; | 77 return; |
73 raster_worker_pool_->Shutdown(); | 78 raster_worker_pool_->Shutdown(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 raster_worker_pool_->CheckForCompletedTasks(); | 188 raster_worker_pool_->CheckForCompletedTasks(); |
184 ScheduleCheckForCompletedTasks(); | 189 ScheduleCheckForCompletedTasks(); |
185 } | 190 } |
186 | 191 |
187 void OnTimeout() { | 192 void OnTimeout() { |
188 timed_out_ = true; | 193 timed_out_ = true; |
189 base::MessageLoop::current()->Quit(); | 194 base::MessageLoop::current()->Quit(); |
190 } | 195 } |
191 | 196 |
192 protected: | 197 protected: |
| 198 scoped_refptr<TestContextProvider> context_provider_; |
| 199 FakeOutputSurfaceClient output_surface_client_; |
193 scoped_ptr<FakeOutputSurface> output_surface_; | 200 scoped_ptr<FakeOutputSurface> output_surface_; |
194 scoped_ptr<ResourceProvider> resource_provider_; | 201 scoped_ptr<ResourceProvider> resource_provider_; |
195 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 202 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
196 base::CancelableClosure check_; | 203 base::CancelableClosure check_; |
197 int check_interval_milliseconds_; | 204 int check_interval_milliseconds_; |
198 base::CancelableClosure timeout_; | 205 base::CancelableClosure timeout_; |
199 int timeout_seconds_; | 206 int timeout_seconds_; |
200 bool timed_out_; | 207 bool timed_out_; |
201 std::vector<RasterWorkerPool::RasterTask> tasks_; | 208 std::vector<RasterWorkerPool::RasterTask> tasks_; |
202 }; | 209 }; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 unsigned id, | 259 unsigned id, |
253 const PicturePileImpl::Analysis& analysis, | 260 const PicturePileImpl::Analysis& analysis, |
254 bool was_canceled, | 261 bool was_canceled, |
255 bool did_raster) OVERRIDE { | 262 bool did_raster) OVERRIDE { |
256 EXPECT_FALSE(did_raster); | 263 EXPECT_FALSE(did_raster); |
257 EndTest(); | 264 EndTest(); |
258 } | 265 } |
259 | 266 |
260 // Overridden from RasterWorkerPoolTest: | 267 // Overridden from RasterWorkerPoolTest: |
261 virtual void BeginTest() OVERRIDE { | 268 virtual void BeginTest() OVERRIDE { |
262 TestWebGraphicsContext3D* context3d = | 269 TestWebGraphicsContext3D* context3d = context_provider_->TestContext3d(); |
263 static_cast<TestWebGraphicsContext3D*>(output_surface_->context3d()); | |
264 context3d->set_times_map_image_chromium_succeeds(0); | 270 context3d->set_times_map_image_chromium_succeeds(0); |
265 context3d->set_times_map_buffer_chromium_succeeds(0); | 271 context3d->set_times_map_buffer_chromium_succeeds(0); |
266 AppendTask(0u); | 272 AppendTask(0u); |
267 ScheduleTasks(); | 273 ScheduleTasks(); |
268 } | 274 } |
269 | 275 |
270 virtual void AfterTest() OVERRIDE { | 276 virtual void AfterTest() OVERRIDE { |
271 ASSERT_EQ(1u, tasks_.size()); | 277 ASSERT_EQ(1u, tasks_.size()); |
272 tasks_.clear(); | 278 tasks_.clear(); |
273 } | 279 } |
274 }; | 280 }; |
275 | 281 |
276 PIXEL_BUFFER_AND_IMAGE_TEST_F(RasterWorkerPoolTestFailedMapResource); | 282 PIXEL_BUFFER_AND_IMAGE_TEST_F(RasterWorkerPoolTestFailedMapResource); |
277 | 283 |
278 } // namespace | 284 } // namespace |
279 | 285 |
280 } // namespace cc | 286 } // namespace cc |
OLD | NEW |