summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-15 23:55:33 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-15 23:55:33 +0000
commit8af4d5e43646529448d460cd6031613379b57861 (patch)
tree4b146e7b64f4a657e1344a129251db9ff5c49681 /gpu
parent6b577b74030a8f92b6daa1e4383e3c3d7e158ac3 (diff)
downloadchromium_src-8af4d5e43646529448d460cd6031613379b57861.zip
chromium_src-8af4d5e43646529448d460cd6031613379b57861.tar.gz
chromium_src-8af4d5e43646529448d460cd6031613379b57861.tar.bz2
Set the GL implementation during unit tests.
BUG=196334 Review URL: https://chromiumcodereview.appspot.com/12830007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188514 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc8
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc1
-rw-r--r--gpu/command_buffer/service/test_helper.cc10
-rw-r--r--gpu/command_buffer/service/test_helper.h13
4 files changed, 26 insertions, 6 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 5e3bea65d..e58ce00 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -107,12 +107,8 @@ static void GetShaderPrecisionFormatImpl(GLenum shader_type,
break;
}
- // TODO(kbr): fix this to not require testing for the mock. Tests
- // should be able to change what GetGLImplementation returns in
- // order to test all code paths.
- if (gfx::GetGLImplementation() == gfx::kGLImplementationMockGL ||
- (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 &&
- gfx::g_driver_gl.fn.glGetShaderPrecisionFormatFn)) {
+ if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 &&
+ gfx::g_driver_gl.fn.glGetShaderPrecisionFormatFn) {
// This function is sometimes defined even though it's really just
// a stub, so we need to set range and precision as if it weren't
// defined before calling it.
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index 8d86800..f923619 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -1368,6 +1368,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetAttachedShadersBadSharedMemoryFails) {
}
TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatSucceeds) {
+ ScopedGLImplementationSetter gl_impl(::gfx::kGLImplementationEGLGLES2);
GetShaderPrecisionFormat cmd;
typedef GetShaderPrecisionFormat::Result Result;
Result* result = static_cast<Result*>(shared_memory_address_);
diff --git a/gpu/command_buffer/service/test_helper.cc b/gpu/command_buffer/service/test_helper.cc
index 10f2e33..1d12d86 100644
--- a/gpu/command_buffer/service/test_helper.cc
+++ b/gpu/command_buffer/service/test_helper.cc
@@ -544,6 +544,16 @@ void TestHelper::SetTexParameterWithExpectations(
manager->SetParameter("", decoder, texture, pname, value);
}
+ScopedGLImplementationSetter::ScopedGLImplementationSetter(
+ gfx::GLImplementation implementation)
+ : old_implementation_(gfx::GetGLImplementation()) {
+ gfx::SetGLImplementation(implementation);
+}
+
+ScopedGLImplementationSetter::~ScopedGLImplementationSetter() {
+ gfx::SetGLImplementation(old_implementation_);
+}
+
} // namespace gles2
} // namespace gpu
diff --git a/gpu/command_buffer/service/test_helper.h b/gpu/command_buffer/service/test_helper.h
index a7a088d..9082b3d 100644
--- a/gpu/command_buffer/service/test_helper.h
+++ b/gpu/command_buffer/service/test_helper.h
@@ -5,6 +5,7 @@
#ifndef GPU_COMMAND_BUFFER_SERVICE_TEST_HELPER_H_
#define GPU_COMMAND_BUFFER_SERVICE_TEST_HELPER_H_
+#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_mock.h"
namespace gpu {
@@ -109,6 +110,18 @@ class TestHelper {
::gfx::MockGLInterface* gl, GLenum target);
};
+// This object temporaritly Sets what gfx::GetGLImplementation returns. During
+// testing the GLImplementation is set to kGLImplemenationMockGL but lots of
+// code branches based on what gfx::GetGLImplementation returns.
+class ScopedGLImplementationSetter {
+ public:
+ explicit ScopedGLImplementationSetter(gfx::GLImplementation implementation);
+ ~ScopedGLImplementationSetter();
+
+ private:
+ gfx::GLImplementation old_implementation_;
+};
+
} // namespace gles2
} // namespace gpu