| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "content/gpu/gpu_info_collector.h" | 6 #include "content/gpu/gpu_info_collector.h" |
| 7 #include "content/public/common/gpu_info.h" | 7 #include "gpu/config/gpu_info.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.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 | 12 |
| 13 using ::gfx::MockGLInterface; | 13 using ::gfx::MockGLInterface; |
| 14 using ::testing::Return; | 14 using ::testing::Return; |
| 15 | 15 |
| 16 namespace gpu { |
| 17 |
| 16 class GPUInfoCollectorTest : public testing::Test { | 18 class GPUInfoCollectorTest : public testing::Test { |
| 17 public: | 19 public: |
| 18 GPUInfoCollectorTest() {} | 20 GPUInfoCollectorTest() {} |
| 19 virtual ~GPUInfoCollectorTest() { } | 21 virtual ~GPUInfoCollectorTest() { } |
| 20 | 22 |
| 21 virtual void SetUp() { | 23 virtual void SetUp() { |
| 22 // TODO(kbr): make this setup robust in the case where | 24 // TODO(kbr): make this setup robust in the case where |
| 23 // GLSurface::InitializeOneOff() has already been called by | 25 // GLSurface::InitializeOneOff() has already been called by |
| 24 // another unit test. http://crbug.com/100285 | 26 // another unit test. http://crbug.com/100285 |
| 25 gfx::InitializeGLBindings(gfx::kGLImplementationMockGL); | 27 gfx::InitializeGLBindings(gfx::kGLImplementationMockGL); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 101 } |
| 100 | 102 |
| 101 virtual void TearDown() { | 103 virtual void TearDown() { |
| 102 ::gfx::GLInterface::SetGLInterface(NULL); | 104 ::gfx::GLInterface::SetGLInterface(NULL); |
| 103 gl_.reset(); | 105 gl_.reset(); |
| 104 } | 106 } |
| 105 | 107 |
| 106 public: | 108 public: |
| 107 // Use StrictMock to make 100% sure we know how GL will be called. | 109 // Use StrictMock to make 100% sure we know how GL will be called. |
| 108 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; | 110 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; |
| 109 content::GPUInfo test_values_; | 111 GPUInfo test_values_; |
| 110 }; | 112 }; |
| 111 | 113 |
| 112 // TODO(rlp): Test the vendor and device id collection if deemed necessary as | 114 // TODO(rlp): Test the vendor and device id collection if deemed necessary as |
| 113 // it involves several complicated mocks for each platform. | 115 // it involves several complicated mocks for each platform. |
| 114 | 116 |
| 115 // TODO(kbr): re-enable these tests; see http://crbug.com/100285 . | 117 // TODO(kbr): re-enable these tests; see http://crbug.com/100285 . |
| 116 | 118 |
| 117 TEST_F(GPUInfoCollectorTest, DISABLED_DriverVendorGL) { | 119 TEST_F(GPUInfoCollectorTest, DISABLED_DriverVendorGL) { |
| 118 content::GPUInfo gpu_info; | 120 GPUInfo gpu_info; |
| 119 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); | 121 CollectGraphicsInfoGL(&gpu_info); |
| 120 EXPECT_EQ(test_values_.driver_vendor, | 122 EXPECT_EQ(test_values_.driver_vendor, |
| 121 gpu_info.driver_vendor); | 123 gpu_info.driver_vendor); |
| 122 } | 124 } |
| 123 | 125 |
| 124 // Skip Windows because the driver version is obtained from bot registry. | 126 // Skip Windows because the driver version is obtained from bot registry. |
| 125 #if !defined(OS_WIN) | 127 #if !defined(OS_WIN) |
| 126 TEST_F(GPUInfoCollectorTest, DISABLED_DriverVersionGL) { | 128 TEST_F(GPUInfoCollectorTest, DISABLED_DriverVersionGL) { |
| 127 content::GPUInfo gpu_info; | 129 GPUInfo gpu_info; |
| 128 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); | 130 CollectGraphicsInfoGL(&gpu_info); |
| 129 EXPECT_EQ(test_values_.driver_version, | 131 EXPECT_EQ(test_values_.driver_version, |
| 130 gpu_info.driver_version); | 132 gpu_info.driver_version); |
| 131 } | 133 } |
| 132 #endif | 134 #endif |
| 133 | 135 |
| 134 TEST_F(GPUInfoCollectorTest, DISABLED_PixelShaderVersionGL) { | 136 TEST_F(GPUInfoCollectorTest, DISABLED_PixelShaderVersionGL) { |
| 135 content::GPUInfo gpu_info; | 137 GPUInfo gpu_info; |
| 136 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); | 138 CollectGraphicsInfoGL(&gpu_info); |
| 137 EXPECT_EQ(test_values_.pixel_shader_version, | 139 EXPECT_EQ(test_values_.pixel_shader_version, |
| 138 gpu_info.pixel_shader_version); | 140 gpu_info.pixel_shader_version); |
| 139 } | 141 } |
| 140 | 142 |
| 141 TEST_F(GPUInfoCollectorTest, DISABLED_VertexShaderVersionGL) { | 143 TEST_F(GPUInfoCollectorTest, DISABLED_VertexShaderVersionGL) { |
| 142 content::GPUInfo gpu_info; | 144 GPUInfo gpu_info; |
| 143 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); | 145 CollectGraphicsInfoGL(&gpu_info); |
| 144 EXPECT_EQ(test_values_.vertex_shader_version, | 146 EXPECT_EQ(test_values_.vertex_shader_version, |
| 145 gpu_info.vertex_shader_version); | 147 gpu_info.vertex_shader_version); |
| 146 } | 148 } |
| 147 | 149 |
| 148 TEST_F(GPUInfoCollectorTest, DISABLED_GLVersionGL) { | 150 TEST_F(GPUInfoCollectorTest, DISABLED_GLVersionGL) { |
| 149 content::GPUInfo gpu_info; | 151 GPUInfo gpu_info; |
| 150 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); | 152 CollectGraphicsInfoGL(&gpu_info); |
| 151 EXPECT_EQ(test_values_.gl_version, | 153 EXPECT_EQ(test_values_.gl_version, |
| 152 gpu_info.gl_version); | 154 gpu_info.gl_version); |
| 153 } | 155 } |
| 154 | 156 |
| 155 TEST_F(GPUInfoCollectorTest, DISABLED_GLVersionStringGL) { | 157 TEST_F(GPUInfoCollectorTest, DISABLED_GLVersionStringGL) { |
| 156 content::GPUInfo gpu_info; | 158 GPUInfo gpu_info; |
| 157 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); | 159 CollectGraphicsInfoGL(&gpu_info); |
| 158 EXPECT_EQ(test_values_.gl_version_string, | 160 EXPECT_EQ(test_values_.gl_version_string, |
| 159 gpu_info.gl_version_string); | 161 gpu_info.gl_version_string); |
| 160 } | 162 } |
| 161 | 163 |
| 162 TEST_F(GPUInfoCollectorTest, DISABLED_GLRendererGL) { | 164 TEST_F(GPUInfoCollectorTest, DISABLED_GLRendererGL) { |
| 163 content::GPUInfo gpu_info; | 165 GPUInfo gpu_info; |
| 164 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); | 166 CollectGraphicsInfoGL(&gpu_info); |
| 165 EXPECT_EQ(test_values_.gl_renderer, | 167 EXPECT_EQ(test_values_.gl_renderer, |
| 166 gpu_info.gl_renderer); | 168 gpu_info.gl_renderer); |
| 167 } | 169 } |
| 168 | 170 |
| 169 TEST_F(GPUInfoCollectorTest, DISABLED_GLVendorGL) { | 171 TEST_F(GPUInfoCollectorTest, DISABLED_GLVendorGL) { |
| 170 content::GPUInfo gpu_info; | 172 GPUInfo gpu_info; |
| 171 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); | 173 CollectGraphicsInfoGL(&gpu_info); |
| 172 EXPECT_EQ(test_values_.gl_vendor, | 174 EXPECT_EQ(test_values_.gl_vendor, |
| 173 gpu_info.gl_vendor); | 175 gpu_info.gl_vendor); |
| 174 } | 176 } |
| 175 | 177 |
| 176 TEST_F(GPUInfoCollectorTest, DISABLED_GLExtensionsGL) { | 178 TEST_F(GPUInfoCollectorTest, DISABLED_GLExtensionsGL) { |
| 177 content::GPUInfo gpu_info; | 179 GPUInfo gpu_info; |
| 178 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); | 180 CollectGraphicsInfoGL(&gpu_info); |
| 179 EXPECT_EQ(test_values_.gl_extensions, | 181 EXPECT_EQ(test_values_.gl_extensions, |
| 180 gpu_info.gl_extensions); | 182 gpu_info.gl_extensions); |
| 181 } | 183 } |
| 184 |
| 185 } // namespace gpu |
| 186 |
| OLD | NEW |