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> | |
6 | |
5 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
6 #include "gpu/ipc/common/traits_test_service.mojom.h" | 8 #include "gpu/ipc/common/traits_test_service.mojom.h" |
7 #include "mojo/public/cpp/bindings/binding_set.h" | 9 #include "mojo/public/cpp/bindings/binding_set.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
9 | 11 |
10 namespace gpu { | 12 namespace gpu { |
11 | 13 |
12 namespace { | 14 namespace { |
13 | 15 |
14 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { | 16 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { |
15 public: | 17 public: |
16 StructTraitsTest() {} | 18 StructTraitsTest() {} |
17 | 19 |
18 protected: | 20 protected: |
19 mojom::TraitsTestServicePtr GetTraitsTestProxy() { | 21 mojom::TraitsTestServicePtr GetTraitsTestProxy() { |
20 return traits_test_bindings_.CreateInterfacePtrAndBind(this); | 22 return traits_test_bindings_.CreateInterfacePtrAndBind(this); |
21 } | 23 } |
22 | 24 |
23 private: | 25 private: |
24 // TraitsTestService: | 26 // TraitsTestService: |
27 void EchoGpuDevice(const GPUInfo::GPUDevice& g, | |
28 const EchoGpuDeviceCallback& callback) override { | |
29 callback.Run(g); | |
30 } | |
31 | |
25 void EchoMailbox(const Mailbox& m, | 32 void EchoMailbox(const Mailbox& m, |
26 const EchoMailboxCallback& callback) override { | 33 const EchoMailboxCallback& callback) override { |
27 callback.Run(m); | 34 callback.Run(m); |
28 } | 35 } |
29 | 36 |
30 void EchoMailboxHolder(const MailboxHolder& r, | 37 void EchoMailboxHolder(const MailboxHolder& r, |
31 const EchoMailboxHolderCallback& callback) override { | 38 const EchoMailboxHolderCallback& callback) override { |
32 callback.Run(r); | 39 callback.Run(r); |
33 } | 40 } |
34 | 41 |
35 void EchoSyncToken(const SyncToken& s, | 42 void EchoSyncToken(const SyncToken& s, |
36 const EchoSyncTokenCallback& callback) override { | 43 const EchoSyncTokenCallback& callback) override { |
37 callback.Run(s); | 44 callback.Run(s); |
38 } | 45 } |
39 | 46 |
40 base::MessageLoop loop_; | 47 base::MessageLoop loop_; |
41 mojo::BindingSet<TraitsTestService> traits_test_bindings_; | 48 mojo::BindingSet<TraitsTestService> traits_test_bindings_; |
42 | 49 |
43 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); | 50 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); |
44 }; | 51 }; |
45 | 52 |
46 } // namespace | 53 } // namespace |
47 | 54 |
55 TEST_F(StructTraitsTest, GPUDevice) { | |
56 gpu::GPUInfo::GPUDevice input; | |
57 // Using the values from gpu/config/gpu_info_collector_unittest.cc::nvidia_gpu | |
58 const uint32_t vendor_id = 0x10de; | |
59 const uint32_t device_id = 0x0df8; | |
60 const std::string vendor_string = "vendor_string"; | |
61 const std::string device_string = "device_string"; | |
62 | |
63 input.vendor_id = vendor_id; | |
64 input.device_id = device_id; | |
65 input.vendor_string = vendor_string; | |
66 input.device_string = device_string; | |
67 EXPECT_FALSE(input.active); | |
Fady Samuel
2016/07/12 01:27:30
Just explicitly set this.
Alex Z.
2016/07/12 13:58:15
Done.
| |
68 | |
69 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | |
70 gpu::GPUInfo::GPUDevice output; | |
71 proxy->EchoGpuDevice(input, &output); | |
72 | |
73 EXPECT_EQ(vendor_id, output.vendor_id); | |
74 EXPECT_EQ(device_id, output.device_id); | |
75 EXPECT_FALSE(output.active); | |
76 EXPECT_TRUE(vendor_string.compare(output.vendor_string) == 0); | |
77 EXPECT_TRUE(device_string.compare(output.device_string) == 0); | |
78 } | |
79 | |
48 TEST_F(StructTraitsTest, Mailbox) { | 80 TEST_F(StructTraitsTest, Mailbox) { |
49 const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = { | 81 const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = { |
50 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, | 82 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, |
51 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7, | 83 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7, |
52 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7}; | 84 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7}; |
53 gpu::Mailbox input; | 85 gpu::Mailbox input; |
54 input.SetName(mailbox_name); | 86 input.SetName(mailbox_name); |
55 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 87 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
56 gpu::Mailbox output; | 88 gpu::Mailbox output; |
57 proxy->EchoMailbox(input, &output); | 89 proxy->EchoMailbox(input, &output); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 gpu::SyncToken output; | 133 gpu::SyncToken output; |
102 proxy->EchoSyncToken(input, &output); | 134 proxy->EchoSyncToken(input, &output); |
103 EXPECT_EQ(namespace_id, output.namespace_id()); | 135 EXPECT_EQ(namespace_id, output.namespace_id()); |
104 EXPECT_EQ(extra_data_field, output.extra_data_field()); | 136 EXPECT_EQ(extra_data_field, output.extra_data_field()); |
105 EXPECT_EQ(command_buffer_id, output.command_buffer_id()); | 137 EXPECT_EQ(command_buffer_id, output.command_buffer_id()); |
106 EXPECT_EQ(release_count, output.release_count()); | 138 EXPECT_EQ(release_count, output.release_count()); |
107 EXPECT_EQ(verified_flush, output.verified_flush()); | 139 EXPECT_EQ(verified_flush, output.verified_flush()); |
108 } | 140 } |
109 | 141 |
110 } // namespace gpu | 142 } // namespace gpu |
OLD | NEW |