Skip to content

Commit

Permalink
Turn on gpu_info_collector_unittests.
Browse files Browse the repository at this point in the history
Part of the fixit week efforts.

BUG=100285
TEST=gpu_unittests
R=kbr@chromium.org

Review URL: https://codereview.chromium.org/1125013002

Cr-Commit-Position: refs/heads/master@{#328717}
  • Loading branch information
zhenyao authored and Commit bot committed May 7, 2015
1 parent 7ce719b commit eecacfe
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 39 deletions.
67 changes: 28 additions & 39 deletions gpu/config/gpu_info_collector_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
#include "gpu/config/gpu_info_collector.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_mock.h"
#include "ui/gl/gl_surface.h"

using ::gfx::MockGLInterface;
using ::testing::Return;
using ::testing::SetArgPointee;
using ::testing::_;

namespace gpu {

Expand All @@ -20,6 +24,9 @@ class GPUInfoCollectorTest : public testing::Test {
~GPUInfoCollectorTest() override {}

void SetUp() override {
testing::Test::SetUp();
gfx::SetGLGetProcAddressProc(gfx::MockGLInterface::GetGLProcAddress);
gfx::GLSurface::InitializeOneOffWithMockBindingsForTests();
gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>());
::gfx::MockGLInterface::SetGLInterface(gl_.get());
#if defined(OS_WIN)
Expand Down Expand Up @@ -48,6 +55,19 @@ class GPUInfoCollectorTest : public testing::Test {
const char* gl_extensions =
"GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 "
"GL_EXT_read_format_bgra";
#elif defined(OS_ANDROID)
const uint32 vendor_id = 0; // not implemented
const uint32 device_id = 0; // not implemented
const char* driver_vendor = ""; // not implemented
const char* driver_version = "14.0";
const char* shader_version = "1.00";
const char* gl_renderer = "Adreno (TM) 320";
const char* gl_vendor = "Qualcomm";
const char* gl_version = "OpenGL ES 2.0 V@14.0 AU@04.02 (CL@3206)";
const char* gl_shading_language_version = "1.00";
const char* gl_extensions =
"GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 "
"GL_EXT_read_format_bgra";
#else // defined (OS_LINUX)
const uint32 vendor_id = 0x10de;
const uint32 device_id = 0x0658;
Expand Down Expand Up @@ -89,11 +109,17 @@ class GPUInfoCollectorTest : public testing::Test {
EXPECT_CALL(*gl_, GetString(GL_RENDERER))
.WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
gl_renderer)));
EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_SAMPLES, _))
.WillOnce(SetArgPointee<1>(8))
.RetiresOnSaturation();
}

void TearDown() override {
::gfx::MockGLInterface::SetGLInterface(NULL);
gl_.reset();
gfx::ClearGLBindings();

testing::Test::TearDown();
}

public:
Expand All @@ -105,60 +131,23 @@ class GPUInfoCollectorTest : public testing::Test {
// TODO(rlp): Test the vendor and device id collection if deemed necessary as
// it involves several complicated mocks for each platform.

// TODO(kbr): re-enable these tests; see http://crbug.com/100285 .

TEST_F(GPUInfoCollectorTest, DISABLED_DriverVendorGL) {
TEST_F(GPUInfoCollectorTest, CollectGraphicsInfoGL) {
GPUInfo gpu_info;
CollectGraphicsInfoGL(&gpu_info);
EXPECT_EQ(test_values_.driver_vendor,
gpu_info.driver_vendor);
}

// Skip Windows because the driver version is obtained from bot registry.
#if !defined(OS_WIN)
TEST_F(GPUInfoCollectorTest, DISABLED_DriverVersionGL) {
GPUInfo gpu_info;
CollectGraphicsInfoGL(&gpu_info);
// Skip Windows because the driver version is obtained from bot registry.
EXPECT_EQ(test_values_.driver_version,
gpu_info.driver_version);
}
#endif

TEST_F(GPUInfoCollectorTest, DISABLED_PixelShaderVersionGL) {
GPUInfo gpu_info;
CollectGraphicsInfoGL(&gpu_info);
EXPECT_EQ(test_values_.pixel_shader_version,
gpu_info.pixel_shader_version);
}

TEST_F(GPUInfoCollectorTest, DISABLED_VertexShaderVersionGL) {
GPUInfo gpu_info;
CollectGraphicsInfoGL(&gpu_info);
EXPECT_EQ(test_values_.vertex_shader_version,
gpu_info.vertex_shader_version);
}

TEST_F(GPUInfoCollectorTest, DISABLED_GLVersionGL) {
GPUInfo gpu_info;
CollectGraphicsInfoGL(&gpu_info);
EXPECT_EQ(test_values_.gl_version, gpu_info.gl_version);
}

TEST_F(GPUInfoCollectorTest, DISABLED_GLRendererGL) {
GPUInfo gpu_info;
CollectGraphicsInfoGL(&gpu_info);
EXPECT_EQ(test_values_.gl_renderer, gpu_info.gl_renderer);
}

TEST_F(GPUInfoCollectorTest, DISABLED_GLVendorGL) {
GPUInfo gpu_info;
CollectGraphicsInfoGL(&gpu_info);
EXPECT_EQ(test_values_.gl_vendor, gpu_info.gl_vendor);
}

TEST_F(GPUInfoCollectorTest, DISABLED_GLExtensionsGL) {
GPUInfo gpu_info;
CollectGraphicsInfoGL(&gpu_info);
EXPECT_EQ(test_values_.gl_extensions, gpu_info.gl_extensions);
}

Expand Down
2 changes: 2 additions & 0 deletions ui/gl/gl_surface_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
return NULL;
return surface;
}
case kGLImplementationMockGL:
return new GLSurfaceStub;
default:
NOTREACHED();
return NULL;
Expand Down
2 changes: 2 additions & 0 deletions ui/gl/gl_surface_ozone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,8 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
return NULL;
return surface;
}
case kGLImplementationMockGL:
return new GLSurfaceStub;
default:
NOTREACHED();
return NULL;
Expand Down

0 comments on commit eecacfe

Please sign in to comment.