| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "gpu/ipc/common/traits_test_service.mojom.h" | 8 #include "gpu/ipc/common/traits_test_service.mojom.h" |
| 9 #include "mojo/public/cpp/bindings/binding_set.h" | 9 #include "mojo/public/cpp/bindings/binding_set.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 void EchoDxDiagNode(const DxDiagNode& d, | 27 void EchoDxDiagNode(const DxDiagNode& d, |
| 28 const EchoDxDiagNodeCallback& callback) override { | 28 const EchoDxDiagNodeCallback& callback) override { |
| 29 callback.Run(d); | 29 callback.Run(d); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void EchoGpuDevice(const GPUInfo::GPUDevice& g, | 32 void EchoGpuDevice(const GPUInfo::GPUDevice& g, |
| 33 const EchoGpuDeviceCallback& callback) override { | 33 const EchoGpuDeviceCallback& callback) override { |
| 34 callback.Run(g); | 34 callback.Run(g); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void EchoGpuInfo(const GPUInfo& g, |
| 38 const EchoGpuInfoCallback& callback) override { |
| 39 callback.Run(g); |
| 40 } |
| 41 |
| 37 void EchoMailbox(const Mailbox& m, | 42 void EchoMailbox(const Mailbox& m, |
| 38 const EchoMailboxCallback& callback) override { | 43 const EchoMailboxCallback& callback) override { |
| 39 callback.Run(m); | 44 callback.Run(m); |
| 40 } | 45 } |
| 41 | 46 |
| 42 void EchoMailboxHolder(const MailboxHolder& r, | 47 void EchoMailboxHolder(const MailboxHolder& r, |
| 43 const EchoMailboxHolderCallback& callback) override { | 48 const EchoMailboxHolderCallback& callback) override { |
| 44 callback.Run(r); | 49 callback.Run(r); |
| 45 } | 50 } |
| 46 | 51 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 gpu::GPUInfo::GPUDevice output; | 111 gpu::GPUInfo::GPUDevice output; |
| 107 proxy->EchoGpuDevice(input, &output); | 112 proxy->EchoGpuDevice(input, &output); |
| 108 | 113 |
| 109 EXPECT_EQ(vendor_id, output.vendor_id); | 114 EXPECT_EQ(vendor_id, output.vendor_id); |
| 110 EXPECT_EQ(device_id, output.device_id); | 115 EXPECT_EQ(device_id, output.device_id); |
| 111 EXPECT_FALSE(output.active); | 116 EXPECT_FALSE(output.active); |
| 112 EXPECT_TRUE(vendor_string.compare(output.vendor_string) == 0); | 117 EXPECT_TRUE(vendor_string.compare(output.vendor_string) == 0); |
| 113 EXPECT_TRUE(device_string.compare(output.device_string) == 0); | 118 EXPECT_TRUE(device_string.compare(output.device_string) == 0); |
| 114 } | 119 } |
| 115 | 120 |
| 121 TEST_F(StructTraitsTest, GpuInfo) { |
| 122 const base::TimeDelta initialization_time = base::TimeDelta::Max(); |
| 123 const bool optimus = true; |
| 124 const bool amd_switchable = true; |
| 125 const bool lenovo_dcute = true; |
| 126 const base::Version display_link_version("1.2.3.4"); |
| 127 const gpu::GPUInfo::GPUDevice gpu; |
| 128 const std::vector<gpu::GPUInfo::GPUDevice> secondary_gpus; |
| 129 const uint64_t adapter_luid = 0x10de; |
| 130 const std::string driver_vendor = "driver_vendor"; |
| 131 const std::string driver_version = "driver_version"; |
| 132 const std::string driver_date = "driver_date"; |
| 133 const std::string pixel_shader_version = "pixel_shader_version"; |
| 134 const std::string vertex_shader_version = "vertex_shader_version"; |
| 135 const std::string max_msaa_samples = "max_msaa_samples"; |
| 136 const std::string machine_model_name = "machine_model_name"; |
| 137 const std::string machine_model_version = "machine_model_version"; |
| 138 const std::string gl_version = "gl_version"; |
| 139 const std::string gl_vendor = "gl_vendor"; |
| 140 const std::string gl_renderer = "gl_renderer"; |
| 141 const std::string gl_extensions = "gl_extension"; |
| 142 const std::string gl_ws_vendor = "gl_ws_vendor"; |
| 143 const std::string gl_ws_version = "gl_ws_version"; |
| 144 const std::string gl_ws_extensions = "gl_ws_extensions"; |
| 145 const uint32_t gl_reset_notification_strategy = 0xbeef; |
| 146 const bool can_lose_context = true; |
| 147 const bool software_rendering = true; |
| 148 const bool direct_rendering = true; |
| 149 const bool sandboxed = true; |
| 150 const int process_crash_count = 0xdead; |
| 151 const bool in_process_gpu = true; |
| 152 const gpu::CollectInfoResult basic_info_state = |
| 153 gpu::CollectInfoResult::kCollectInfoSuccess; |
| 154 const gpu::CollectInfoResult context_info_state = |
| 155 gpu::CollectInfoResult::kCollectInfoSuccess; |
| 156 #if defined(OS_WIN) |
| 157 const gpu::CollectInfoResult dx_diagnostics_info_state = |
| 158 gpu::CollectInfoResult::kCollectInfoSuccess; |
| 159 const DxDiagNode dx_diagnostics; |
| 160 #endif |
| 161 const gpu::VideoDecodeAcceleratorCapabilities |
| 162 video_decode_accelerator_capabilities; |
| 163 const std::vector<gpu::VideoEncodeAcceleratorSupportedProfile> |
| 164 video_encode_accelerator_supported_profiles; |
| 165 const bool jpeg_decode_accelerator_supported = true; |
| 166 |
| 167 gpu::GPUInfo input; |
| 168 input.initialization_time = initialization_time; |
| 169 input.optimus = optimus; |
| 170 input.amd_switchable = amd_switchable; |
| 171 input.lenovo_dcute = lenovo_dcute; |
| 172 input.display_link_version = display_link_version; |
| 173 input.gpu = gpu; |
| 174 input.secondary_gpus = secondary_gpus; |
| 175 input.adapter_luid = adapter_luid; |
| 176 input.driver_vendor = driver_vendor; |
| 177 input.driver_version = driver_version; |
| 178 input.driver_date = driver_date; |
| 179 input.pixel_shader_version = pixel_shader_version; |
| 180 input.vertex_shader_version = vertex_shader_version; |
| 181 input.max_msaa_samples = max_msaa_samples; |
| 182 input.machine_model_name = machine_model_name; |
| 183 input.machine_model_version = machine_model_version; |
| 184 input.gl_version = gl_version; |
| 185 input.gl_vendor = gl_vendor; |
| 186 input.gl_renderer = gl_renderer; |
| 187 input.gl_extensions = gl_extensions; |
| 188 input.gl_ws_vendor = gl_ws_vendor; |
| 189 input.gl_ws_version = gl_ws_version; |
| 190 input.gl_ws_extensions = gl_ws_extensions; |
| 191 input.gl_reset_notification_strategy = gl_reset_notification_strategy; |
| 192 input.can_lose_context = can_lose_context; |
| 193 input.software_rendering = software_rendering; |
| 194 input.direct_rendering = direct_rendering; |
| 195 input.sandboxed = sandboxed; |
| 196 input.process_crash_count = process_crash_count; |
| 197 input.in_process_gpu = in_process_gpu; |
| 198 input.basic_info_state = basic_info_state; |
| 199 input.context_info_state = context_info_state; |
| 200 #if defined(OS_WIN) |
| 201 input.dx_diagnostics_info_state = dx_diagnostics_info_state; |
| 202 input.dx_diagnostics = dx_diagnostics; |
| 203 #endif |
| 204 input.video_decode_accelerator_capabilities = |
| 205 video_decode_accelerator_capabilities; |
| 206 input.video_encode_accelerator_supported_profiles = |
| 207 video_encode_accelerator_supported_profiles; |
| 208 input.jpeg_decode_accelerator_supported = jpeg_decode_accelerator_supported; |
| 209 |
| 210 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 211 gpu::GPUInfo output; |
| 212 proxy->EchoGpuInfo(input, &output); |
| 213 |
| 214 EXPECT_EQ(optimus, output.optimus); |
| 215 EXPECT_EQ(amd_switchable, output.amd_switchable); |
| 216 EXPECT_EQ(lenovo_dcute, output.lenovo_dcute); |
| 217 EXPECT_TRUE(display_link_version.CompareTo(output.display_link_version) == 0); |
| 218 EXPECT_EQ(gpu.vendor_id, output.gpu.vendor_id); |
| 219 EXPECT_EQ(gpu.device_id, output.gpu.device_id); |
| 220 EXPECT_EQ(gpu.active, output.gpu.active); |
| 221 EXPECT_EQ(gpu.vendor_string, output.gpu.vendor_string); |
| 222 EXPECT_EQ(gpu.device_string, output.gpu.device_string); |
| 223 EXPECT_EQ(secondary_gpus.size(), output.secondary_gpus.size()); |
| 224 for (size_t i = 0; i < secondary_gpus.size(); ++i) { |
| 225 const gpu::GPUInfo::GPUDevice& expected_gpu = secondary_gpus[i]; |
| 226 const gpu::GPUInfo::GPUDevice& actual_gpu = output.secondary_gpus[i]; |
| 227 EXPECT_EQ(expected_gpu.vendor_id, actual_gpu.vendor_id); |
| 228 EXPECT_EQ(expected_gpu.device_id, actual_gpu.device_id); |
| 229 EXPECT_EQ(expected_gpu.active, actual_gpu.active); |
| 230 EXPECT_EQ(expected_gpu.vendor_string, actual_gpu.vendor_string); |
| 231 EXPECT_EQ(expected_gpu.device_string, actual_gpu.device_string); |
| 232 } |
| 233 EXPECT_EQ(adapter_luid, output.adapter_luid); |
| 234 EXPECT_EQ(driver_vendor, output.driver_vendor); |
| 235 EXPECT_EQ(driver_version, output.driver_version); |
| 236 EXPECT_EQ(driver_date, output.driver_date); |
| 237 EXPECT_EQ(pixel_shader_version, output.pixel_shader_version); |
| 238 EXPECT_EQ(vertex_shader_version, output.vertex_shader_version); |
| 239 EXPECT_EQ(max_msaa_samples, output.max_msaa_samples); |
| 240 EXPECT_EQ(machine_model_name, output.machine_model_name); |
| 241 EXPECT_EQ(machine_model_version, output.machine_model_version); |
| 242 EXPECT_EQ(gl_version, output.gl_version); |
| 243 EXPECT_EQ(gl_vendor, output.gl_vendor); |
| 244 EXPECT_EQ(gl_renderer, output.gl_renderer); |
| 245 EXPECT_EQ(gl_extensions, output.gl_extensions); |
| 246 EXPECT_EQ(gl_ws_vendor, output.gl_ws_vendor); |
| 247 EXPECT_EQ(gl_ws_version, output.gl_ws_version); |
| 248 EXPECT_EQ(gl_ws_extensions, output.gl_ws_extensions); |
| 249 EXPECT_EQ(gl_reset_notification_strategy, |
| 250 output.gl_reset_notification_strategy); |
| 251 EXPECT_EQ(can_lose_context, output.can_lose_context); |
| 252 EXPECT_EQ(software_rendering, output.software_rendering); |
| 253 EXPECT_EQ(direct_rendering, output.direct_rendering); |
| 254 EXPECT_EQ(sandboxed, output.sandboxed); |
| 255 EXPECT_EQ(process_crash_count, output.process_crash_count); |
| 256 EXPECT_EQ(in_process_gpu, output.in_process_gpu); |
| 257 EXPECT_EQ(basic_info_state, output.basic_info_state); |
| 258 EXPECT_EQ(context_info_state, output.context_info_state); |
| 259 #if defined(OS_WIN) |
| 260 EXPECT_EQ(output.dx_diagnostics_info_state, dx_diagnostics_info_state); |
| 261 EXPECT_EQ(dx_diagnostics.values, output.dx_diagnostics.values); |
| 262 #endif |
| 263 EXPECT_EQ(output.video_decode_accelerator_capabilities.flags, |
| 264 video_decode_accelerator_capabilities.flags); |
| 265 EXPECT_EQ( |
| 266 video_decode_accelerator_capabilities.supported_profiles.size(), |
| 267 output.video_decode_accelerator_capabilities.supported_profiles.size()); |
| 268 for (size_t i = 0; |
| 269 i < video_decode_accelerator_capabilities.supported_profiles.size(); |
| 270 ++i) { |
| 271 const gpu::VideoDecodeAcceleratorSupportedProfile& expected = |
| 272 video_decode_accelerator_capabilities.supported_profiles[i]; |
| 273 const gpu::VideoDecodeAcceleratorSupportedProfile& actual = |
| 274 output.video_decode_accelerator_capabilities.supported_profiles[i]; |
| 275 EXPECT_EQ(expected.encrypted_only, actual.encrypted_only); |
| 276 } |
| 277 EXPECT_EQ( |
| 278 output.video_decode_accelerator_capabilities.supported_profiles.size(), |
| 279 video_decode_accelerator_capabilities.supported_profiles.size()); |
| 280 EXPECT_EQ(output.video_encode_accelerator_supported_profiles.size(), |
| 281 video_encode_accelerator_supported_profiles.size()); |
| 282 } |
| 283 |
| 116 TEST_F(StructTraitsTest, Mailbox) { | 284 TEST_F(StructTraitsTest, Mailbox) { |
| 117 const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = { | 285 const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = { |
| 118 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, | 286 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, |
| 119 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7, | 287 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7, |
| 120 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7}; | 288 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7}; |
| 121 gpu::Mailbox input; | 289 gpu::Mailbox input; |
| 122 input.SetName(mailbox_name); | 290 input.SetName(mailbox_name); |
| 123 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 291 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 124 gpu::Mailbox output; | 292 gpu::Mailbox output; |
| 125 proxy->EchoMailbox(input, &output); | 293 proxy->EchoMailbox(input, &output); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 396 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 229 gpu::VideoEncodeAcceleratorSupportedProfile output; | 397 gpu::VideoEncodeAcceleratorSupportedProfile output; |
| 230 proxy->EchoVideoEncodeAcceleratorSupportedProfile(input, &output); | 398 proxy->EchoVideoEncodeAcceleratorSupportedProfile(input, &output); |
| 231 EXPECT_EQ(profile, output.profile); | 399 EXPECT_EQ(profile, output.profile); |
| 232 EXPECT_EQ(max_resolution, output.max_resolution); | 400 EXPECT_EQ(max_resolution, output.max_resolution); |
| 233 EXPECT_EQ(max_framerate_numerator, output.max_framerate_numerator); | 401 EXPECT_EQ(max_framerate_numerator, output.max_framerate_numerator); |
| 234 EXPECT_EQ(max_framerate_denominator, output.max_framerate_denominator); | 402 EXPECT_EQ(max_framerate_denominator, output.max_framerate_denominator); |
| 235 } | 403 } |
| 236 | 404 |
| 237 } // namespace gpu | 405 } // namespace gpu |
| OLD | NEW |