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

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

Issue 6346007: Refactor and improve gpu_info_collector: collect information on linux;... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: This should turn three trybots green Created 9 years, 11 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')
Property Changes:
Added: svn:eol-style
+ LF
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/common/gpu_info.h"
8 #include "chrome/gpu/gpu_info_collector.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 #elif defined(OS_MACOSX)
37 const uint32 vendor_id = 0x10de;
38 const uint32 device_id = 0x0640;
39 const char* driver_vendor = ""; // not implemented
40 const char* driver_version = "1.6.18";
41 const uint32 shader_version = 0x00000114;
42 const uint32 gl_version = 0x00000201;
43 const char* gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine";
44 const char* gl_vendor = "NVIDIA Corporation";
45 const char* gl_version_string = "2.1 NVIDIA-1.6.18";
46 const char* gl_shading_language_version = "1.20 ";
47 #else // defined (OS_LINUX)
48 const uint32 vendor_id = 0x10de;
49 const uint32 device_id = 0x0658;
50 const char* driver_vendor = "NVIDIA";
51 const char* driver_version = "195.36.24";
52 const uint32 shader_version = 0x00000132;
53 const uint32 gl_version = 0x00000302;
54 const char* gl_renderer = "Quadro FX 380/PCI/SSE2";
55 const char* gl_vendor = "NVIDIA Corporation";
56 const char* gl_version_string = "3.2.0 NVIDIA 195.36.24";
57 const char* gl_shading_language_version = "1.50 NVIDIA via Cg compiler";
58 #endif
59 test_values_.SetVideoCardInfo(vendor_id, device_id);
60 test_values_.SetDriverInfo(driver_vendor, driver_version);
61 test_values_.SetShaderVersion(shader_version, shader_version);
62 test_values_.SetGLVersion(gl_version);
63 test_values_.SetGLRenderer(gl_renderer);
64 test_values_.SetGLVendor(gl_vendor);
65 test_values_.SetGLVersionString(gl_version_string);
66 test_values_.SetCanLoseContext(false);
67
68 EXPECT_CALL(*gl_, GetString(GL_EXTENSIONS))
69 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
70 "GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 "
71 "GL_EXT_read_format_bgra")));
72 EXPECT_CALL(*gl_, GetString(GL_SHADING_LANGUAGE_VERSION))
73 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
74 gl_shading_language_version)));
75 EXPECT_CALL(*gl_, GetString(GL_VERSION))
76 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
77 gl_version_string)));
78 EXPECT_CALL(*gl_, GetString(GL_VENDOR))
79 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
80 gl_vendor)));
81 EXPECT_CALL(*gl_, GetString(GL_RENDERER))
82 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>(
83 gl_renderer)));
84 }
85
86 void TearDown() {
87 ::gfx::GLInterface::SetGLInterface(NULL);
88 gl_.reset();
89 }
90
91 public:
92 // Use StrictMock to make 100% sure we know how GL will be called.
93 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_;
94 GPUInfo test_values_;
95 };
96
97 // TODO(rlp): Test the vendor and device id collection if deemed necessary as
98 // it involves several complicated mocks for each platform.
99
100 TEST_F(GPUInfoCollectorTest, DriverVendorGL) {
101 GPUInfo gpu_info;
102 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
103 std::string driver_vendor = gpu_info.driver_vendor();
104 EXPECT_EQ(test_values_.driver_vendor(), driver_vendor);
105 }
106
107 TEST_F(GPUInfoCollectorTest, DriverVersionGL) {
108 GPUInfo gpu_info;
109 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
110 std::string driver_version = gpu_info.driver_version();
111 EXPECT_EQ(test_values_.driver_version(), driver_version);
112 }
113
114 TEST_F(GPUInfoCollectorTest, PixelShaderVersionGL) {
115 GPUInfo gpu_info;
116 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
117 uint32 ps_version = gpu_info.pixel_shader_version();
118 EXPECT_EQ(test_values_.pixel_shader_version(), ps_version);
119 }
120
121 TEST_F(GPUInfoCollectorTest, VertexShaderVersionGL) {
122 GPUInfo gpu_info;
123 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
124 uint32 vs_version = gpu_info.vertex_shader_version();
125 EXPECT_EQ(test_values_.vertex_shader_version(), vs_version);
126 }
127
128 TEST_F(GPUInfoCollectorTest, GLVersionGL) {
129 GPUInfo gpu_info;
130 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
131 uint32 gl_version = gpu_info.gl_version();
132 EXPECT_EQ(test_values_.gl_version(), gl_version);
133 }
134
135 TEST_F(GPUInfoCollectorTest, GLVersionStringGL) {
136 GPUInfo gpu_info;
137 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
138 std::string gl_version_string = gpu_info.gl_version_string();
139 EXPECT_EQ(test_values_.gl_version_string(), gl_version_string);
140 }
141
142 TEST_F(GPUInfoCollectorTest, GLRendererGL) {
143 GPUInfo gpu_info;
144 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
145 std::string gl_renderer = gpu_info.gl_renderer();
146 EXPECT_EQ(test_values_.gl_renderer(), gl_renderer);
147 }
148
149 TEST_F(GPUInfoCollectorTest, GLVendorGL) {
150 GPUInfo gpu_info;
151 gpu_info_collector::CollectGraphicsInfoGL(&gpu_info);
152 std::string gl_vendor = gpu_info.gl_vendor();
153 EXPECT_EQ(test_values_.gl_vendor(), gl_vendor);
154 }
155
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