diff options
author | rlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-21 22:31:00 +0000 |
---|---|---|
committer | rlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-21 22:31:00 +0000 |
commit | 3d8d1c9f38d1f4f26a56ad03d3fa920791bc50ea (patch) | |
tree | 01f610e88a53cbd3af89ffd2d3b6c63f66728ff1 /chrome/gpu/gpu_info_unittest_win.cc | |
parent | eaf16c467545cf40e3ea38960f2b6042743e2a18 (diff) | |
download | chromium_src-3d8d1c9f38d1f4f26a56ad03d3fa920791bc50ea.zip chromium_src-3d8d1c9f38d1f4f26a56ad03d3fa920791bc50ea.tar.gz chromium_src-3d8d1c9f38d1f4f26a56ad03d3fa920791bc50ea.tar.bz2 |
Adding the gpu_info classes to get gpu info. The actual integration will be in another CL. Just want to get the classes and tests in there first.
BUG=38736
TEST=unittests included
Review URL: http://codereview.chromium.org/2733004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50401 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/gpu/gpu_info_unittest_win.cc')
-rw-r--r-- | chrome/gpu/gpu_info_unittest_win.cc | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/chrome/gpu/gpu_info_unittest_win.cc b/chrome/gpu/gpu_info_unittest_win.cc new file mode 100644 index 0000000..195cded --- /dev/null +++ b/chrome/gpu/gpu_info_unittest_win.cc @@ -0,0 +1,84 @@ +// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/logging.h" +#include "base/scoped_ptr.h" +#include "chrome/gpu/gpu_idirect3d9_mock_win.h" +#include "chrome/gpu/gpu_info.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +using ::testing::_; +using ::testing::Return; +using ::testing::SetArgumentPointee; + +class GPUInfoTest : public testing::Test { + public: + GPUInfoTest() { } + virtual ~GPUInfoTest() { } + + protected: + void SetUp() { + gpu_info_.reset(new GPUInfo()); + ASSERT_TRUE(gpu_info() != NULL); + + // Test variables taken from Lenovo T61 + test_identifier_.VendorId = 0x10de; + test_identifier_.DeviceId = 0x429; + test_identifier_.DriverVersion.QuadPart = 0x6000e000b1e23; // 6.14.11.7715 + test_caps_.PixelShaderVersion = 0xffff0300; // 3.0 + test_caps_.VertexShaderVersion = 0xfffe0300; // 3.0 + + EXPECT_CALL(d3d_, GetAdapterIdentifier(_, _, _)) + .WillOnce(DoAll(SetArgumentPointee<2>(test_identifier_), + Return(D3D_OK))); + EXPECT_CALL(d3d_, Release()); + EXPECT_CALL(d3d_, GetDeviceCaps(_, _, _)) + .WillOnce(DoAll(SetArgumentPointee<2>(test_caps_), + Return(D3D_OK))); + } + void TearDown() { + gpu_info_.reset(); + } + + public: + GPUInfo* gpu_info() { + return gpu_info_.get(); + } + + IDirect3D9Mock d3d_; + private: + scoped_ptr<GPUInfo> gpu_info_; + D3DADAPTER_IDENTIFIER9 test_identifier_; + D3DCAPS9 test_caps_; +}; + +TEST_F(GPUInfoTest, VendorIdD3D) { + ASSERT_TRUE(gpu_info()->CollectGraphicsInfoD3D(&d3d_)); + EXPECT_EQ(gpu_info()->vendor_id(), 0x10de); +} + +TEST_F(GPUInfoTest, DeviceIdD3D) { + ASSERT_TRUE(gpu_info()->CollectGraphicsInfoD3D(&d3d_)); + EXPECT_EQ(gpu_info()->device_id(), 0x429); +} + +TEST_F(GPUInfoTest, DriverVersionD3D) { + ASSERT_TRUE(gpu_info()->CollectGraphicsInfoD3D(&d3d_)); + std::wstring driver_version = gpu_info()->driver_version(); + EXPECT_FALSE(driver_version.empty()); + EXPECT_EQ(driver_version, L"6.14.11.7715"); +} + +TEST_F(GPUInfoTest, PixelShaderVersionD3D) { + ASSERT_TRUE(gpu_info()->CollectGraphicsInfoD3D(&d3d_)); + uint32 ps_version = gpu_info()->pixel_shader_version(); + EXPECT_EQ(ps_version, D3DPS_VERSION(3, 0)); +} + +TEST_F(GPUInfoTest, VertexShaderVersionD3D) { + ASSERT_TRUE(gpu_info()->CollectGraphicsInfoD3D(&d3d_)); + uint32 vs_version = gpu_info()->vertex_shader_version(); + EXPECT_EQ(vs_version, D3DVS_VERSION(3, 0)); +} |