OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" |
6 #include "chrome/common/gpu_info.h" | 6 #include "chrome/common/gpu_info.h" |
7 #include "chrome/common/gpu_messages.h" | 7 #include "chrome/common/gpu_messages.h" |
8 #include "ipc/ipc_message.h" | 8 #include "ipc/ipc_message.h" |
9 #include "ipc/ipc_message_utils.h" | 9 #include "ipc/ipc_message_utils.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 // Test GPUInfo serialization | 12 // Test GPUInfo serialization |
13 TEST(GPUIPCMessageTest, GPUInfo) { | 13 TEST(GPUIPCMessageTest, GPUInfo) { |
14 GPUInfo input; | 14 GPUInfo input; |
15 // Test variables taken from Lenovo T61 | 15 // Test variables taken from HP Z600 Workstation |
16 input.SetProgress(GPUInfo::kPartial); | 16 input.SetProgress(GPUInfo::kPartial); |
17 input.SetInitializationTime(base::TimeDelta::FromMilliseconds(100)); | 17 input.SetInitializationTime(base::TimeDelta::FromMilliseconds(100)); |
18 input.SetGraphicsInfo(0x10de, 0x429, L"6.14.11.7715", | 18 input.SetVideoCardInfo(0x10de, 0x0658); |
19 0xffff0300, | 19 input.SetDriverInfo("NVIDIA", "195.36.24"); |
20 0xfffe0300, | 20 input.SetShaderVersion(0x0162, 0x0162); |
21 0x00010005, | 21 input.SetGLVersion(0x0302); |
22 true); | 22 input.SetGLVersionString("3.2.0 NVIDIA 195.36.24"); |
| 23 input.SetGLVendor("NVIDIA Corporation"); |
| 24 input.SetGLRenderer("Quadro FX 380/PCI/SSE2"); |
| 25 input.SetCanLoseContext(false); |
23 | 26 |
24 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); | 27 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
25 IPC::WriteParam(&msg, input); | 28 IPC::WriteParam(&msg, input); |
26 | 29 |
27 GPUInfo output; | 30 GPUInfo output; |
28 void* iter = NULL; | 31 void* iter = NULL; |
29 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); | 32 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); |
30 EXPECT_EQ(input.progress(), output.progress()); | 33 EXPECT_EQ(input.progress(), output.progress()); |
31 EXPECT_EQ(input.initialization_time().InMilliseconds(), | 34 EXPECT_EQ(input.initialization_time().InMilliseconds(), |
32 output.initialization_time().InMilliseconds()); | 35 output.initialization_time().InMilliseconds()); |
33 EXPECT_EQ(input.vendor_id(), output.vendor_id()); | 36 EXPECT_EQ(input.vendor_id(), output.vendor_id()); |
34 EXPECT_EQ(input.device_id(), output.device_id()); | 37 EXPECT_EQ(input.device_id(), output.device_id()); |
| 38 EXPECT_EQ(input.driver_vendor(), output.driver_vendor()); |
35 EXPECT_EQ(input.driver_version(), output.driver_version()); | 39 EXPECT_EQ(input.driver_version(), output.driver_version()); |
36 EXPECT_EQ(input.pixel_shader_version(), output.pixel_shader_version()); | 40 EXPECT_EQ(input.pixel_shader_version(), output.pixel_shader_version()); |
37 EXPECT_EQ(input.vertex_shader_version(), output.vertex_shader_version()); | 41 EXPECT_EQ(input.vertex_shader_version(), output.vertex_shader_version()); |
38 EXPECT_EQ(input.gl_version(), output.gl_version()); | 42 EXPECT_EQ(input.gl_version(), output.gl_version()); |
| 43 EXPECT_EQ(input.gl_version_string(), output.gl_version_string()); |
| 44 EXPECT_EQ(input.gl_vendor(), output.gl_vendor()); |
| 45 EXPECT_EQ(input.gl_renderer(), output.gl_renderer()); |
39 EXPECT_EQ(input.can_lose_context(), output.can_lose_context()); | 46 EXPECT_EQ(input.can_lose_context(), output.can_lose_context()); |
40 | 47 |
41 std::string log_message; | 48 std::string log_message; |
42 IPC::LogParam(output, &log_message); | 49 IPC::LogParam(output, &log_message); |
43 EXPECT_STREQ("<GPUInfo> 1 100 10de 429 6.14.11.7715 1", log_message.c_str()); | 50 EXPECT_STREQ("<GPUInfo> 1 100 10de 658 NVIDIA 195.36.24 162 162 302 0", |
| 51 log_message.c_str()); |
44 } | 52 } |
OLD | NEW |