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

Side by Side Diff: gpu/ipc/common/struct_traits_unittest.cc

Issue 2147693002: Struct traits used by GpuInfo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: The right public_deps Created 4 years, 4 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
« no previous file with comments | « gpu/ipc/common/gpu_info_struct_traits.cc ('k') | gpu/ipc/common/traits_test_service.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 11
12 namespace gpu { 12 namespace gpu {
13 13
14 namespace { 14 namespace {
15 15
16 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { 16 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
17 public: 17 public:
18 StructTraitsTest() {} 18 StructTraitsTest() {}
19 19
20 protected: 20 protected:
21 mojom::TraitsTestServicePtr GetTraitsTestProxy() { 21 mojom::TraitsTestServicePtr GetTraitsTestProxy() {
22 return traits_test_bindings_.CreateInterfacePtrAndBind(this); 22 return traits_test_bindings_.CreateInterfacePtrAndBind(this);
23 } 23 }
24 24
25 private: 25 private:
26 // TraitsTestService: 26 // TraitsTestService:
27 void EchoDxDiagNode(const DxDiagNode& d,
28 const EchoDxDiagNodeCallback& callback) override {
29 callback.Run(d);
30 }
31
27 void EchoGpuDevice(const GPUInfo::GPUDevice& g, 32 void EchoGpuDevice(const GPUInfo::GPUDevice& g,
28 const EchoGpuDeviceCallback& callback) override { 33 const EchoGpuDeviceCallback& callback) override {
29 callback.Run(g); 34 callback.Run(g);
30 } 35 }
31 36
32 void EchoMailbox(const Mailbox& m, 37 void EchoMailbox(const Mailbox& m,
33 const EchoMailboxCallback& callback) override { 38 const EchoMailboxCallback& callback) override {
34 callback.Run(m); 39 callback.Run(m);
35 } 40 }
36 41
37 void EchoMailboxHolder(const MailboxHolder& r, 42 void EchoMailboxHolder(const MailboxHolder& r,
38 const EchoMailboxHolderCallback& callback) override { 43 const EchoMailboxHolderCallback& callback) override {
39 callback.Run(r); 44 callback.Run(r);
40 } 45 }
41 46
42 void EchoSyncToken(const SyncToken& s, 47 void EchoSyncToken(const SyncToken& s,
43 const EchoSyncTokenCallback& callback) override { 48 const EchoSyncTokenCallback& callback) override {
44 callback.Run(s); 49 callback.Run(s);
45 } 50 }
46 51
52 void EchoVideoDecodeAcceleratorSupportedProfile(
53 const VideoDecodeAcceleratorSupportedProfile& v,
54 const EchoVideoDecodeAcceleratorSupportedProfileCallback& callback)
55 override {
56 callback.Run(v);
57 }
58
59 void EchoVideoDecodeAcceleratorCapabilities(
60 const VideoDecodeAcceleratorCapabilities& v,
61 const EchoVideoDecodeAcceleratorCapabilitiesCallback& callback) override {
62 callback.Run(v);
63 }
64
65 void EchoVideoEncodeAcceleratorSupportedProfile(
66 const VideoEncodeAcceleratorSupportedProfile& v,
67 const EchoVideoEncodeAcceleratorSupportedProfileCallback& callback)
68 override {
69 callback.Run(v);
70 }
71
47 base::MessageLoop loop_; 72 base::MessageLoop loop_;
48 mojo::BindingSet<TraitsTestService> traits_test_bindings_; 73 mojo::BindingSet<TraitsTestService> traits_test_bindings_;
49 74
50 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); 75 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest);
51 }; 76 };
52 77
53 } // namespace 78 } // namespace
54 79
80 TEST_F(StructTraitsTest, DxDiagNode) {
81 gpu::DxDiagNode input;
82 input.values["abc"] = "123";
83 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
84 gpu::DxDiagNode output;
85 proxy->EchoDxDiagNode(input, &output);
86
87 gpu::DxDiagNode test_dx_diag_node;
88 test_dx_diag_node.values["abc"] = "123";
89 EXPECT_EQ(test_dx_diag_node.values, output.values);
90 }
91
55 TEST_F(StructTraitsTest, GPUDevice) { 92 TEST_F(StructTraitsTest, GPUDevice) {
56 gpu::GPUInfo::GPUDevice input; 93 gpu::GPUInfo::GPUDevice input;
57 // Using the values from gpu/config/gpu_info_collector_unittest.cc::nvidia_gpu 94 // Using the values from gpu/config/gpu_info_collector_unittest.cc::nvidia_gpu
58 const uint32_t vendor_id = 0x10de; 95 const uint32_t vendor_id = 0x10de;
59 const uint32_t device_id = 0x0df8; 96 const uint32_t device_id = 0x0df8;
60 const std::string vendor_string = "vendor_string"; 97 const std::string vendor_string = "vendor_string";
61 const std::string device_string = "device_string"; 98 const std::string device_string = "device_string";
62 99
63 input.vendor_id = vendor_id; 100 input.vendor_id = vendor_id;
64 input.device_id = device_id; 101 input.device_id = device_id;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 168 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
132 gpu::SyncToken output; 169 gpu::SyncToken output;
133 proxy->EchoSyncToken(input, &output); 170 proxy->EchoSyncToken(input, &output);
134 EXPECT_EQ(namespace_id, output.namespace_id()); 171 EXPECT_EQ(namespace_id, output.namespace_id());
135 EXPECT_EQ(extra_data_field, output.extra_data_field()); 172 EXPECT_EQ(extra_data_field, output.extra_data_field());
136 EXPECT_EQ(command_buffer_id, output.command_buffer_id()); 173 EXPECT_EQ(command_buffer_id, output.command_buffer_id());
137 EXPECT_EQ(release_count, output.release_count()); 174 EXPECT_EQ(release_count, output.release_count());
138 EXPECT_EQ(verified_flush, output.verified_flush()); 175 EXPECT_EQ(verified_flush, output.verified_flush());
139 } 176 }
140 177
178 TEST_F(StructTraitsTest, VideoDecodeAcceleratorSupportedProfile) {
179 const gpu::VideoCodecProfile profile =
180 gpu::VideoCodecProfile::H264PROFILE_MAIN;
181 const int32_t max_width = 1920;
182 const int32_t max_height = 1080;
183 const int32_t min_width = 640;
184 const int32_t min_height = 480;
185 const gfx::Size max_resolution(max_width, max_height);
186 const gfx::Size min_resolution(min_width, min_height);
187
188 gpu::VideoDecodeAcceleratorSupportedProfile input;
189 input.profile = profile;
190 input.max_resolution = max_resolution;
191 input.min_resolution = min_resolution;
192 input.encrypted_only = false;
193
194 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
195 gpu::VideoDecodeAcceleratorSupportedProfile output;
196 proxy->EchoVideoDecodeAcceleratorSupportedProfile(input, &output);
197 EXPECT_EQ(profile, output.profile);
198 EXPECT_EQ(max_resolution, output.max_resolution);
199 EXPECT_EQ(min_resolution, output.min_resolution);
200 EXPECT_FALSE(output.encrypted_only);
201 }
202
203 TEST_F(StructTraitsTest, VideoDecodeAcceleratorCapabilities) {
204 const uint32_t flags = 1234;
205
206 gpu::VideoDecodeAcceleratorCapabilities input;
207 input.flags = flags;
208
209 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
210 gpu::VideoDecodeAcceleratorCapabilities output;
211 proxy->EchoVideoDecodeAcceleratorCapabilities(input, &output);
212 EXPECT_EQ(flags, output.flags);
213 }
214
215 TEST_F(StructTraitsTest, VideoEncodeAcceleratorSupportedProfile) {
216 const gpu::VideoCodecProfile profile =
217 gpu::VideoCodecProfile::H264PROFILE_MAIN;
218 const gfx::Size max_resolution(1920, 1080);
219 const uint32_t max_framerate_numerator = 144;
220 const uint32_t max_framerate_denominator = 12;
221
222 gpu::VideoEncodeAcceleratorSupportedProfile input;
223 input.profile = profile;
224 input.max_resolution = max_resolution;
225 input.max_framerate_numerator = max_framerate_numerator;
226 input.max_framerate_denominator = max_framerate_denominator;
227
228 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
229 gpu::VideoEncodeAcceleratorSupportedProfile output;
230 proxy->EchoVideoEncodeAcceleratorSupportedProfile(input, &output);
231 EXPECT_EQ(profile, output.profile);
232 EXPECT_EQ(max_resolution, output.max_resolution);
233 EXPECT_EQ(max_framerate_numerator, output.max_framerate_numerator);
234 EXPECT_EQ(max_framerate_denominator, output.max_framerate_denominator);
235 }
236
141 } // namespace gpu 237 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/common/gpu_info_struct_traits.cc ('k') | gpu/ipc/common/traits_test_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698