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

Side by Side Diff: ui/gl/test/gl_image_test_template.h

Issue 2708923003: Use base::test::ScopedAsyncTaskScheduler in GLImageTest. (Closed)
Patch Set: fix dependency Created 3 years, 10 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
« no previous file with comments | « ui/gl/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « ui/gl/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698