Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: content/gpu/gpu_info_collector_unittest.cc

Issue 15745014: Move GPU device/driver info related code from content to gpu. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/gpu/gpu_info_collector_mac.mm ('k') | content/gpu/gpu_info_collector_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/memory/scoped_ptr.h"
6 #include "content/gpu/gpu_info_collector.h"
7 #include "content/public/common/gpu_info.h"
8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/gl/gl_implementation.h"
11 #include "ui/gl/gl_mock.h"
12
13 using ::gfx::MockGLInterface;
14 using ::testing::Return;
15
16 class GPUInfoCollectorTest : public testing::Test {
17 public:
18 GPUInfoCollectorTest() {}
19 virtual ~GPUInfoCollectorTest() { }
20
21 virtual void SetUp() {
22 // TODO(kbr): make this setup robust in the case where
23 // GLSurface::InitializeOneOff() has already been called by
24 // another unit test. http://crbug.com/100285
25 gfx::InitializeGLBindings(gfx::kGLImplementationMockGL);
26 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>());
27 ::gfx::GLInterface::SetGLInterface(gl_.get());
28 #if defined(OS_WIN)
29 const uint32 vendor_id = 0x10de;
30 const uint32 device_id = 0x0658;
31 const char* driver_vendor = ""; // not implemented
32 const char* driver_version = "";
33 const char* shader_version = "1.40";
34 const char* gl_version = "3.1";
35 const char* gl_renderer = "Quadro FX 380/PCI/SSE2";
36 const char* gl_vendor = "NVIDIA Corporation";
37 const char* gl_version_string = "3.1.0";
38 const char* gl_shading_language_version = "1.40 NVIDIA via Cg compiler";
39 const char* gl_extensions =
40 "GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 "
41 "GL_EXT_read_format_bgra";
42 #elif defined(OS_MACOSX)
43 const uint32 vendor_id = 0x10de;
44 const uint32 device_id = 0x0640;
45 const char* driver_vendor = ""; // not implemented
46 const char* driver_version = "1.6.18";
47 const char* shader_version = "1.20";
48 const char* gl_version = "2.1";
49 const char* gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine";
50 const char* gl_vendor = "NVIDIA Corporation";
51 const char* gl_version_string = "2.1 NVIDIA-1.6.18";
52 const char* gl_shading_language_version = "1.20 ";
53 const char* gl_extensions =
54 "GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 "
55 "GL_EXT_read_format_bgra";
56 #else // defined (OS_LINUX)
57 const uint32 vendor_id = 0x10de;
58 const uint32 device_id = 0x0658;
59 const char* driver_vendor = "NVIDIA";
60 const char* driver_version = "195.36.24";
61 const char* shader_version = "1.50";
62 const char* gl_version = "3.2";
63 const char* gl_renderer = "Quadro FX 380/PCI/SSE2";
64 const char* gl_vendor = "NVIDIA Corporation";
65 const char* gl_version_string = "3.2.0 NVIDIA 195.36.24";
66 const char* gl_shading_language_version = "1.50 NVIDIA via Cg compiler";
67 const char* gl_extensions =
68 "GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 "
69 "GL_EXT_read_format_bgra";
70 #endif
71 test_values_.gpu.vendor_id = vendor_id;
72 test_values_.gpu.device_id = device_id;
73 test_values_.driver_vendor = driver_vendor;
74 test_values_.driver_version =driver_version;
75 test_values_.pixel_shader_version = shader_version;
76 test_values_.vertex_shader_version = shader_version;
77 test_values_.gl_version = gl_version;
78 test_values_.gl_renderer = gl_renderer;
79 test_values_.gl_vendor = gl_vendor;
80 test_values_.gl_version_string = gl_version_string;
81 test_values_.gl_extensions = gl_extensions;
82 test_values_.can_lose_context = false;
83
84 EXPECT_CALL(*gl_, GetString(GL_EXTENSIONS))
85 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
86 gl_extensions)));
87 EXPECT_CALL(*gl_, GetString(GL_SHADING_LANGUAGE_VERSION))
88 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
89 gl_shading_language_version)));
90 EXPECT_CALL(*gl_, GetString(GL_VERSION))
91 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
92 gl_version_string)));
93 EXPECT_CALL(*gl_, GetString(GL_VENDOR))
94 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
95 gl_vendor)));
96 EXPECT_CALL(*gl_, GetString(GL_RENDERER))
97 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
98 gl_renderer)));
99 }
100
101 virtual void TearDown() {
102 ::gfx::GLInterface::SetGLInterface(NULL);
103 gl_.reset();
104 }
105
106 public:
107 // Use StrictMock to make 100% sure we know how GL will be called.
108 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_;
109 content::GPUInfo test_values_;
110 };
111
112 // TODO(rlp): Test the vendor and device id collection if deemed necessary as
113 // it involves several complicated mocks for each platform.
114
115 // TODO(kbr): re-enable these tests; see http://crbug.com/100285 .
116
117 TEST_F(GPUInfoCollectorTest, DISABLED_DriverVendorGL) {
118 content::GPUInfo gpu_info;
119 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
120 EXPECT_EQ(test_values_.driver_vendor,
121 gpu_info.driver_vendor);
122 }
123
124 // Skip Windows because the driver version is obtained from bot registry.
125 #if !defined(OS_WIN)
126 TEST_F(GPUInfoCollectorTest, DISABLED_DriverVersionGL) {
127 content::GPUInfo gpu_info;
128 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
129 EXPECT_EQ(test_values_.driver_version,
130 gpu_info.driver_version);
131 }
132 #endif
133
134 TEST_F(GPUInfoCollectorTest, DISABLED_PixelShaderVersionGL) {
135 content::GPUInfo gpu_info;
136 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
137 EXPECT_EQ(test_values_.pixel_shader_version,
138 gpu_info.pixel_shader_version);
139 }
140
141 TEST_F(GPUInfoCollectorTest, DISABLED_VertexShaderVersionGL) {
142 content::GPUInfo gpu_info;
143 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
144 EXPECT_EQ(test_values_.vertex_shader_version,
145 gpu_info.vertex_shader_version);
146 }
147
148 TEST_F(GPUInfoCollectorTest, DISABLED_GLVersionGL) {
149 content::GPUInfo gpu_info;
150 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
151 EXPECT_EQ(test_values_.gl_version,
152 gpu_info.gl_version);
153 }
154
155 TEST_F(GPUInfoCollectorTest, DISABLED_GLVersionStringGL) {
156 content::GPUInfo gpu_info;
157 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
158 EXPECT_EQ(test_values_.gl_version_string,
159 gpu_info.gl_version_string);
160 }
161
162 TEST_F(GPUInfoCollectorTest, DISABLED_GLRendererGL) {
163 content::GPUInfo gpu_info;
164 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
165 EXPECT_EQ(test_values_.gl_renderer,
166 gpu_info.gl_renderer);
167 }
168
169 TEST_F(GPUInfoCollectorTest, DISABLED_GLVendorGL) {
170 content::GPUInfo gpu_info;
171 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
172 EXPECT_EQ(test_values_.gl_vendor,
173 gpu_info.gl_vendor);
174 }
175
176 TEST_F(GPUInfoCollectorTest, DISABLED_GLExtensionsGL) {
177 content::GPUInfo gpu_info;
178 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
179 EXPECT_EQ(test_values_.gl_extensions,
180 gpu_info.gl_extensions);
181 }
OLDNEW
« no previous file with comments | « content/gpu/gpu_info_collector_mac.mm ('k') | content/gpu/gpu_info_collector_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698