OLD | NEW |
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/resources/prioritized_resource_manager.h" | 8 #include "cc/resources/prioritized_resource_manager.h" |
9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
10 #include "cc/test/fake_output_surface_client.h" | 10 #include "cc/test/fake_output_surface_client.h" |
11 #include "cc/test/fake_proxy.h" | 11 #include "cc/test/fake_proxy.h" |
12 #include "cc/test/scheduler_test_common.h" | 12 #include "cc/test/scheduler_test_common.h" |
13 #include "cc/test/test_web_graphics_context_3d.h" | 13 #include "cc/test/test_web_graphics_context_3d.h" |
14 #include "cc/test/tiled_layer_test_common.h" | 14 #include "cc/test/tiled_layer_test_common.h" |
15 #include "cc/trees/single_thread_proxy.h" // For DebugScopedSetImplThread | 15 #include "cc/trees/single_thread_proxy.h" // For DebugScopedSetImplThread |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/khronos/GLES2/gl2ext.h" | 17 #include "third_party/khronos/GLES2/gl2ext.h" |
18 | 18 |
19 using testing::Test; | 19 using testing::Test; |
20 using blink::WGC3Denum; | |
21 using blink::WGC3Dint; | |
22 using blink::WGC3Duint; | |
23 using blink::WGC3Dsizei; | |
24 using blink::WebGLId; | |
25 using blink::WebString; | |
26 | 20 |
27 namespace cc { | 21 namespace cc { |
28 namespace { | 22 namespace { |
29 | 23 |
30 const int kFlushPeriodFull = 4; | 24 const int kFlushPeriodFull = 4; |
31 const int kFlushPeriodPartial = kFlushPeriodFull; | 25 const int kFlushPeriodPartial = kFlushPeriodFull; |
32 | 26 |
33 class ResourceUpdateControllerTest; | 27 class ResourceUpdateControllerTest; |
34 | 28 |
35 class WebGraphicsContext3DForUploadTest : public TestWebGraphicsContext3D { | 29 class WebGraphicsContext3DForUploadTest : public TestWebGraphicsContext3D { |
36 public: | 30 public: |
37 explicit WebGraphicsContext3DForUploadTest(ResourceUpdateControllerTest* test) | 31 explicit WebGraphicsContext3DForUploadTest(ResourceUpdateControllerTest* test) |
38 : test_(test) {} | 32 : test_(test) {} |
39 | 33 |
40 virtual void flush() OVERRIDE; | 34 virtual void flush() OVERRIDE; |
41 virtual void shallowFlushCHROMIUM() OVERRIDE; | 35 virtual void shallowFlushCHROMIUM() OVERRIDE; |
42 virtual void texSubImage2D( | 36 virtual void texSubImage2D(GLenum target, |
43 WGC3Denum target, | 37 GLint level, |
44 WGC3Dint level, | 38 GLint xoffset, |
45 WGC3Dint xoffset, | 39 GLint yoffset, |
46 WGC3Dint yoffset, | 40 GLsizei width, |
47 WGC3Dsizei width, | 41 GLsizei height, |
48 WGC3Dsizei height, | 42 GLenum format, |
49 WGC3Denum format, | 43 GLenum type, |
50 WGC3Denum type, | 44 const void* pixels) OVERRIDE; |
51 const void* pixels) OVERRIDE; | |
52 virtual GrGLInterface* createGrGLInterface() OVERRIDE { return NULL; } | 45 virtual GrGLInterface* createGrGLInterface() OVERRIDE { return NULL; } |
53 | 46 |
54 virtual void getQueryObjectuivEXT( | 47 virtual void getQueryObjectuivEXT(GLuint id, GLenum pname, GLuint* value); |
55 WebGLId id, | |
56 WGC3Denum pname, | |
57 WGC3Duint* value); | |
58 | 48 |
59 private: | 49 private: |
60 ResourceUpdateControllerTest* test_; | 50 ResourceUpdateControllerTest* test_; |
61 }; | 51 }; |
62 | 52 |
63 class ResourceUpdateControllerTest : public Test { | 53 class ResourceUpdateControllerTest : public Test { |
64 public: | 54 public: |
65 ResourceUpdateControllerTest() | 55 ResourceUpdateControllerTest() |
66 : proxy_(), | 56 : proxy_(), |
67 queue_(make_scoped_ptr(new ResourceUpdateQueue)), | 57 queue_(make_scoped_ptr(new ResourceUpdateQueue)), |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 int num_total_uploads_; | 201 int num_total_uploads_; |
212 int num_total_flushes_; | 202 int num_total_flushes_; |
213 }; | 203 }; |
214 | 204 |
215 void WebGraphicsContext3DForUploadTest::flush() { test_->OnFlush(); } | 205 void WebGraphicsContext3DForUploadTest::flush() { test_->OnFlush(); } |
216 | 206 |
217 void WebGraphicsContext3DForUploadTest::shallowFlushCHROMIUM() { | 207 void WebGraphicsContext3DForUploadTest::shallowFlushCHROMIUM() { |
218 test_->OnFlush(); | 208 test_->OnFlush(); |
219 } | 209 } |
220 | 210 |
221 void WebGraphicsContext3DForUploadTest::texSubImage2D( | 211 void WebGraphicsContext3DForUploadTest::texSubImage2D(GLenum target, |
222 WGC3Denum target, | 212 GLint level, |
223 WGC3Dint level, | 213 GLint xoffset, |
224 WGC3Dint xoffset, | 214 GLint yoffset, |
225 WGC3Dint yoffset, | 215 GLsizei width, |
226 WGC3Dsizei width, | 216 GLsizei height, |
227 WGC3Dsizei height, | 217 GLenum format, |
228 WGC3Denum format, | 218 GLenum type, |
229 WGC3Denum type, | 219 const void* pixels) { |
230 const void* pixels) { | |
231 test_->OnUpload(); | 220 test_->OnUpload(); |
232 } | 221 } |
233 | 222 |
234 void WebGraphicsContext3DForUploadTest::getQueryObjectuivEXT( | 223 void WebGraphicsContext3DForUploadTest::getQueryObjectuivEXT(GLuint id, |
235 WebGLId id, | 224 GLenum pname, |
236 WGC3Denum pname, | 225 GLuint* params) { |
237 WGC3Duint* params) { | |
238 if (pname == GL_QUERY_RESULT_AVAILABLE_EXT) | 226 if (pname == GL_QUERY_RESULT_AVAILABLE_EXT) |
239 *params = test_->IsQueryResultAvailable(); | 227 *params = test_->IsQueryResultAvailable(); |
240 } | 228 } |
241 | 229 |
242 // ZERO UPLOADS TESTS | 230 // ZERO UPLOADS TESTS |
243 TEST_F(ResourceUpdateControllerTest, ZeroUploads) { | 231 TEST_F(ResourceUpdateControllerTest, ZeroUploads) { |
244 AppendFullUploadsToUpdateQueue(0); | 232 AppendFullUploadsToUpdateQueue(0); |
245 AppendPartialUploadsToUpdateQueue(0); | 233 AppendPartialUploadsToUpdateQueue(0); |
246 UpdateTextures(); | 234 UpdateTextures(); |
247 | 235 |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 RunPendingTask(task_runner.get(), controller.get()); | 500 RunPendingTask(task_runner.get(), controller.get()); |
513 } | 501 } |
514 | 502 |
515 EXPECT_FALSE(task_runner->HasPendingTask()); | 503 EXPECT_FALSE(task_runner->HasPendingTask()); |
516 EXPECT_TRUE(client.ReadyToFinalizeCalled()); | 504 EXPECT_TRUE(client.ReadyToFinalizeCalled()); |
517 EXPECT_EQ(2, num_total_uploads_); | 505 EXPECT_EQ(2, num_total_uploads_); |
518 } | 506 } |
519 | 507 |
520 } // namespace | 508 } // namespace |
521 } // namespace cc | 509 } // namespace cc |
OLD | NEW |