OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "gpu/command_buffer/service/gpu_service_test.h" | 5 #include "gpu/command_buffer/service/gpu_service_test.h" |
6 | 6 |
7 #include "gpu/command_buffer/service/test_helper.h" | 7 #include "gpu/command_buffer/service/test_helper.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/gl/gl_context_stub_with_extensions.h" | 9 #include "ui/gl/gl_context_stub_with_extensions.h" |
10 #include "ui/gl/gl_implementation.h" | 10 #include "ui/gl/gl_implementation.h" |
11 #include "ui/gl/gl_mock.h" | 11 #include "ui/gl/gl_mock.h" |
12 #include "ui/gl/gl_surface.h" | 12 #include "ui/gl/gl_surface.h" |
13 | 13 |
14 namespace gpu { | 14 namespace gpu { |
15 namespace gles2 { | 15 namespace gles2 { |
16 | 16 |
17 GpuServiceTest::GpuServiceTest() : ran_setup_(false), ran_teardown_(false) { | 17 GpuServiceTest::GpuServiceTest() : ran_setup_(false), ran_teardown_(false) { |
18 } | 18 } |
19 | 19 |
20 GpuServiceTest::~GpuServiceTest() { | 20 GpuServiceTest::~GpuServiceTest() { |
21 DCHECK(ran_teardown_); | 21 DCHECK(ran_teardown_); |
22 } | 22 } |
23 | 23 |
24 void GpuServiceTest::SetUp() { | 24 void GpuServiceTest::SetUpWithGLVersion(const char* gl_version, |
| 25 const char* gl_extensions) { |
25 testing::Test::SetUp(); | 26 testing::Test::SetUp(); |
26 | 27 |
27 gfx::SetGLGetProcAddressProc(gfx::MockGLInterface::GetGLProcAddress); | 28 gfx::SetGLGetProcAddressProc(gfx::MockGLInterface::GetGLProcAddress); |
28 gfx::GLSurface::InitializeOneOffWithMockBindingsForTests(); | 29 gfx::GLSurface::InitializeOneOffWithMockBindingsForTests(); |
29 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>()); | 30 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>()); |
30 ::gfx::MockGLInterface::SetGLInterface(gl_.get()); | 31 ::gfx::MockGLInterface::SetGLInterface(gl_.get()); |
31 | 32 |
32 context_ = new gfx::GLContextStubWithExtensions; | 33 context_ = new gfx::GLContextStubWithExtensions; |
33 context_->AddExtensionsString(NULL); | 34 context_->AddExtensionsString(gl_extensions); |
34 context_->SetGLVersionString("3.0"); | 35 context_->SetGLVersionString(gl_version); |
35 gfx::GLSurface::InitializeDynamicMockBindingsForTests(context_); | 36 gfx::GLSurface::InitializeDynamicMockBindingsForTests(context_); |
36 ran_setup_ = true; | 37 ran_setup_ = true; |
37 } | 38 } |
38 | 39 |
| 40 void GpuServiceTest::SetUp() { |
| 41 SetUpWithGLVersion("2.0", NULL); |
| 42 } |
| 43 |
39 void GpuServiceTest::TearDown() { | 44 void GpuServiceTest::TearDown() { |
40 DCHECK(ran_setup_); | 45 DCHECK(ran_setup_); |
41 ::gfx::MockGLInterface::SetGLInterface(NULL); | 46 ::gfx::MockGLInterface::SetGLInterface(NULL); |
42 gl_.reset(); | 47 gl_.reset(); |
43 gfx::ClearGLBindings(); | 48 gfx::ClearGLBindings(); |
44 ran_teardown_ = true; | 49 ran_teardown_ = true; |
45 | 50 |
46 testing::Test::TearDown(); | 51 testing::Test::TearDown(); |
47 } | 52 } |
48 | 53 |
49 } // namespace gles2 | 54 } // namespace gles2 |
50 } // namespace gpu | 55 } // namespace gpu |
OLD | NEW |