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

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

Issue 6684015: Move chrome\gpu to content\gpu. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 | « chrome/gpu/gpu_info_collector_mac.mm ('k') | chrome/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) 2011 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 "app/gfx/gl/gl_implementation.h"
6 #include "base/scoped_ptr.h"
7 #include "chrome/gpu/gpu_info_collector.h"
8 #include "content/common/gpu_info.h"
9 #include "gpu/command_buffer/common/gl_mock.h"
10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.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 void SetUp() {
22 gfx::InitializeGLBindings(gfx::kGLImplementationMockGL);
23 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>());
24 ::gfx::GLInterface::SetGLInterface(gl_.get());
25 #if defined(OS_WIN)
26 const uint32 vendor_id = 0x10de;
27 const uint32 device_id = 0x0658;
28 const char* driver_vendor = ""; // not implemented
29 const char* driver_version = "";
30 const uint32 shader_version = 0x00000128;
31 const uint32 gl_version = 0x00000301;
32 const char* gl_renderer = "Quadro FX 380/PCI/SSE2";
33 const char* gl_vendor = "NVIDIA Corporation";
34 const char* gl_version_string = "3.1.0";
35 const char* gl_shading_language_version = "1.40 NVIDIA via Cg compiler";
36 const char* gl_extensions =
37 "GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 "
38 "GL_EXT_read_format_bgra";
39 #elif defined(OS_MACOSX)
40 const uint32 vendor_id = 0x10de;
41 const uint32 device_id = 0x0640;
42 const char* driver_vendor = ""; // not implemented
43 const char* driver_version = "1.6.18";
44 const uint32 shader_version = 0x00000114;
45 const uint32 gl_version = 0x00000201;
46 const char* gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine";
47 const char* gl_vendor = "NVIDIA Corporation";
48 const char* gl_version_string = "2.1 NVIDIA-1.6.18";
49 const char* gl_shading_language_version = "1.20 ";
50 const char* gl_extensions =
51 "GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 "
52 "GL_EXT_read_format_bgra";
53 #else // defined (OS_LINUX)
54 const uint32 vendor_id = 0x10de;
55 const uint32 device_id = 0x0658;
56 const char* driver_vendor = "NVIDIA";
57 const char* driver_version = "195.36.24";
58 const uint32 shader_version = 0x00000132;
59 const uint32 gl_version = 0x00000302;
60 const char* gl_renderer = "Quadro FX 380/PCI/SSE2";
61 const char* gl_vendor = "NVIDIA Corporation";
62 const char* gl_version_string = "3.2.0 NVIDIA 195.36.24";
63 const char* gl_shading_language_version = "1.50 NVIDIA via Cg compiler";
64 const char* gl_extensions =
65 "GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 "
66 "GL_EXT_read_format_bgra";
67 #endif
68 test_values_.vendor_id = vendor_id;
69 test_values_.device_id = device_id;
70 test_values_.driver_vendor = driver_vendor;
71 test_values_.driver_version =driver_version;
72 test_values_.driver_date = "";
73 test_values_.pixel_shader_version = shader_version;
74 test_values_.vertex_shader_version = shader_version;
75 test_values_.gl_version = gl_version;
76 test_values_.gl_renderer = gl_renderer;
77 test_values_.gl_vendor = gl_vendor;
78 test_values_.gl_version_string = gl_version_string;
79 test_values_.gl_extensions = gl_extensions;
80 test_values_.can_lose_context = false;
81
82 EXPECT_CALL(*gl_, GetString(GL_EXTENSIONS))
83 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
84 gl_extensions)));
85 EXPECT_CALL(*gl_, GetString(GL_SHADING_LANGUAGE_VERSION))
86 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
87 gl_shading_language_version)));
88 EXPECT_CALL(*gl_, GetString(GL_VERSION))
89 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
90 gl_version_string)));
91 EXPECT_CALL(*gl_, GetString(GL_VENDOR))
92 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
93 gl_vendor)));
94 EXPECT_CALL(*gl_, GetString(GL_RENDERER))
95 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
96 gl_renderer)));
97 }
98
99 void TearDown() {
100 ::gfx::GLInterface::SetGLInterface(NULL);
101 gl_.reset();
102 }
103
104 public:
105 // Use StrictMock to make 100% sure we know how GL will be called.
106 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_;
107 GPUInfo test_values_;
108 };
109
110 // TODO(rlp): Test the vendor and device id collection if deemed necessary as
111 // it involves several complicated mocks for each platform.
112
113 TEST_F(GPUInfoCollectorTest, DriverVendorGL) {
114 GPUInfo gpu_info;
115 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
116 std::string driver_vendor = gpu_info.driver_vendor;
117 EXPECT_EQ(test_values_.driver_vendor, driver_vendor);
118 }
119
120 // Skip Windows because the driver version is obtained from bot registry.
121 #if !defined(OS_WIN)
122 TEST_F(GPUInfoCollectorTest, DriverVersionGL) {
123 GPUInfo gpu_info;
124 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
125 std::string driver_version = gpu_info.driver_version;
126 EXPECT_EQ(test_values_.driver_version, driver_version);
127 }
128 #endif
129
130 TEST_F(GPUInfoCollectorTest, PixelShaderVersionGL) {
131 GPUInfo gpu_info;
132 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
133 uint32 ps_version = gpu_info.pixel_shader_version;
134 EXPECT_EQ(test_values_.pixel_shader_version, ps_version);
135 }
136
137 TEST_F(GPUInfoCollectorTest, VertexShaderVersionGL) {
138 GPUInfo gpu_info;
139 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
140 uint32 vs_version = gpu_info.vertex_shader_version;
141 EXPECT_EQ(test_values_.vertex_shader_version, vs_version);
142 }
143
144 TEST_F(GPUInfoCollectorTest, GLVersionGL) {
145 GPUInfo gpu_info;
146 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
147 uint32 gl_version = gpu_info.gl_version;
148 EXPECT_EQ(test_values_.gl_version, gl_version);
149 }
150
151 TEST_F(GPUInfoCollectorTest, GLVersionStringGL) {
152 GPUInfo gpu_info;
153 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
154 std::string gl_version_string = gpu_info.gl_version_string;
155 EXPECT_EQ(test_values_.gl_version_string, gl_version_string);
156 }
157
158 TEST_F(GPUInfoCollectorTest, GLRendererGL) {
159 GPUInfo gpu_info;
160 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
161 std::string gl_renderer = gpu_info.gl_renderer;
162 EXPECT_EQ(test_values_.gl_renderer, gl_renderer);
163 }
164
165 TEST_F(GPUInfoCollectorTest, GLVendorGL) {
166 GPUInfo gpu_info;
167 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
168 std::string gl_vendor = gpu_info.gl_vendor;
169 EXPECT_EQ(test_values_.gl_vendor, gl_vendor);
170 }
171
172 TEST_F(GPUInfoCollectorTest, GLExtensionsGL) {
173 GPUInfo gpu_info;
174 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
175 std::string gl_extensions = gpu_info.gl_extensions;
176 EXPECT_EQ(test_values_.gl_extensions, gl_extensions);
177 }
OLDNEW
« no previous file with comments | « chrome/gpu/gpu_info_collector_mac.mm ('k') | chrome/gpu/gpu_info_collector_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698