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 "content/public/common/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 class GPUInfoCollectorTest : public testing::Test { | 16 class GPUInfoCollectorTest : public testing::Test { |
17 public: | 17 public: |
18 GPUInfoCollectorTest() {} | 18 GPUInfoCollectorTest() {} |
19 virtual ~GPUInfoCollectorTest() { } | 19 virtual ~GPUInfoCollectorTest() { } |
20 | 20 |
21 void SetUp() { | 21 virtual void SetUp() { |
22 // TODO(kbr): make this setup robust in the case where | 22 // TODO(kbr): make this setup robust in the case where |
23 // GLSurface::InitializeOneOff() has already been called by | 23 // GLSurface::InitializeOneOff() has already been called by |
24 // another unit test. http://crbug.com/100285 | 24 // another unit test. http://crbug.com/100285 |
25 gfx::InitializeGLBindings(gfx::kGLImplementationMockGL); | 25 gfx::InitializeGLBindings(gfx::kGLImplementationMockGL); |
26 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>()); | 26 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>()); |
27 ::gfx::GLInterface::SetGLInterface(gl_.get()); | 27 ::gfx::GLInterface::SetGLInterface(gl_.get()); |
28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
29 const uint32 vendor_id = 0x10de; | 29 const uint32 vendor_id = 0x10de; |
30 const uint32 device_id = 0x0658; | 30 const uint32 device_id = 0x0658; |
31 const char* driver_vendor = ""; // not implemented | 31 const char* driver_vendor = ""; // not implemented |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>( | 91 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>( |
92 gl_version_string))); | 92 gl_version_string))); |
93 EXPECT_CALL(*gl_, GetString(GL_VENDOR)) | 93 EXPECT_CALL(*gl_, GetString(GL_VENDOR)) |
94 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>( | 94 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>( |
95 gl_vendor))); | 95 gl_vendor))); |
96 EXPECT_CALL(*gl_, GetString(GL_RENDERER)) | 96 EXPECT_CALL(*gl_, GetString(GL_RENDERER)) |
97 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>( | 97 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>( |
98 gl_renderer))); | 98 gl_renderer))); |
99 } | 99 } |
100 | 100 |
101 void TearDown() { | 101 virtual void TearDown() { |
102 ::gfx::GLInterface::SetGLInterface(NULL); | 102 ::gfx::GLInterface::SetGLInterface(NULL); |
103 gl_.reset(); | 103 gl_.reset(); |
104 } | 104 } |
105 | 105 |
106 public: | 106 public: |
107 // Use StrictMock to make 100% sure we know how GL will be called. | 107 // Use StrictMock to make 100% sure we know how GL will be called. |
108 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; | 108 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; |
109 content::GPUInfo test_values_; | 109 content::GPUInfo test_values_; |
110 }; | 110 }; |
111 | 111 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 EXPECT_EQ(test_values_.gl_vendor, | 172 EXPECT_EQ(test_values_.gl_vendor, |
173 gpu_info.gl_vendor); | 173 gpu_info.gl_vendor); |
174 } | 174 } |
175 | 175 |
176 TEST_F(GPUInfoCollectorTest, DISABLED_GLExtensionsGL) { | 176 TEST_F(GPUInfoCollectorTest, DISABLED_GLExtensionsGL) { |
177 content::GPUInfo gpu_info; | 177 content::GPUInfo gpu_info; |
178 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); | 178 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); |
179 EXPECT_EQ(test_values_.gl_extensions, | 179 EXPECT_EQ(test_values_.gl_extensions, |
180 gpu_info.gl_extensions); | 180 gpu_info.gl_extensions); |
181 } | 181 } |
OLD | NEW |