OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // This file defines tests that implementations of GLImage should pass in order | 5 // This file defines tests that implementations of GLImage should pass in order |
6 // to be conformant. | 6 // to be conformant. |
7 | 7 |
8 #ifndef UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ | 8 #ifndef UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ |
9 #define UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ | 9 #define UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ |
10 | 10 |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
13 #include <memory> | 13 #include <memory> |
14 | 14 |
15 #include "base/strings/stringize_macros.h" | 15 #include "base/strings/stringize_macros.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "base/task_scheduler/task_scheduler.h" | 17 #include "base/test/scoped_async_task_scheduler.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "ui/gfx/buffer_format_util.h" | 20 #include "ui/gfx/buffer_format_util.h" |
21 #include "ui/gfx/buffer_types.h" | 21 #include "ui/gfx/buffer_types.h" |
22 #include "ui/gl/gl_bindings.h" | 22 #include "ui/gl/gl_bindings.h" |
23 #include "ui/gl/gl_context.h" | 23 #include "ui/gl/gl_context.h" |
24 #include "ui/gl/gl_helper.h" | 24 #include "ui/gl/gl_helper.h" |
25 #include "ui/gl/gl_image.h" | 25 #include "ui/gl/gl_image.h" |
26 #include "ui/gl/gl_surface.h" | 26 #include "ui/gl/gl_surface.h" |
27 #include "ui/gl/gl_version_info.h" | 27 #include "ui/gl/gl_version_info.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 glDeleteBuffersARB(1, &vertex_buffer); | 156 glDeleteBuffersARB(1, &vertex_buffer); |
157 } | 157 } |
158 | 158 |
159 } // namespace | 159 } // namespace |
160 | 160 |
161 template <typename GLImageTestDelegate> | 161 template <typename GLImageTestDelegate> |
162 class GLImageTest : public testing::Test { | 162 class GLImageTest : public testing::Test { |
163 protected: | 163 protected: |
164 // Overridden from testing::Test: | 164 // Overridden from testing::Test: |
165 void SetUp() override { | 165 void SetUp() override { |
166 constexpr int kMaxTaskSchedulerThreads = 3; | |
167 base::TaskScheduler::CreateAndSetSimpleTaskScheduler( | |
168 kMaxTaskSchedulerThreads); | |
169 | |
170 GLImageTestSupport::InitializeGL(); | 166 GLImageTestSupport::InitializeGL(); |
171 surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size()); | 167 surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size()); |
172 context_ = | 168 context_ = |
173 gl::init::CreateGLContext(nullptr, surface_.get(), GLContextAttribs()); | 169 gl::init::CreateGLContext(nullptr, surface_.get(), GLContextAttribs()); |
174 context_->MakeCurrent(surface_.get()); | 170 context_->MakeCurrent(surface_.get()); |
175 } | 171 } |
176 void TearDown() override { | 172 void TearDown() override { |
177 context_->ReleaseCurrent(surface_.get()); | 173 context_->ReleaseCurrent(surface_.get()); |
178 context_ = nullptr; | 174 context_ = nullptr; |
179 surface_ = nullptr; | 175 surface_ = nullptr; |
180 GLImageTestSupport::CleanupGL(); | 176 GLImageTestSupport::CleanupGL(); |
181 } | 177 } |
182 | 178 |
183 protected: | 179 protected: |
| 180 base::test::ScopedAsyncTaskScheduler scoped_async_task_scheduler_; |
184 scoped_refptr<GLSurface> surface_; | 181 scoped_refptr<GLSurface> surface_; |
185 scoped_refptr<GLContext> context_; | 182 scoped_refptr<GLContext> context_; |
186 GLImageTestDelegate delegate_; | 183 GLImageTestDelegate delegate_; |
187 }; | 184 }; |
188 | 185 |
189 TYPED_TEST_CASE_P(GLImageTest); | 186 TYPED_TEST_CASE_P(GLImageTest); |
190 | 187 |
191 TYPED_TEST_P(GLImageTest, Create) { | 188 TYPED_TEST_P(GLImageTest, Create) { |
192 const gfx::Size small_image_size(4, 4); | 189 const gfx::Size small_image_size(4, 4); |
193 const gfx::Size large_image_size(512, 512); | 190 const gfx::Size large_image_size(512, 512); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 401 } |
405 } | 402 } |
406 | 403 |
407 // The GLImageCopyTest test case verifies that the GLImage implementation | 404 // The GLImageCopyTest test case verifies that the GLImage implementation |
408 // handles CopyTexImage correctly. | 405 // handles CopyTexImage correctly. |
409 REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage); | 406 REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage); |
410 | 407 |
411 } // namespace gl | 408 } // namespace gl |
412 | 409 |
413 #endif // UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ | 410 #endif // UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ |
OLD | NEW |