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

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

Issue 2133833002: gpu::GPUInfo::GPUDevice struct traits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change according to comments Created 4 years, 5 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/mailbox.typemap ('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>
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 input.active = false;
68 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
69 gpu::GPUInfo::GPUDevice output;
70 proxy->EchoGpuDevice(input, &output);
71
72 EXPECT_EQ(vendor_id, output.vendor_id);
73 EXPECT_EQ(device_id, output.device_id);
74 EXPECT_FALSE(output.active);
75 EXPECT_TRUE(vendor_string.compare(output.vendor_string) == 0);
76 EXPECT_TRUE(device_string.compare(output.device_string) == 0);
77 }
78
48 TEST_F(StructTraitsTest, Mailbox) { 79 TEST_F(StructTraitsTest, Mailbox) {
49 const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = { 80 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, 81 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, 82 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}; 83 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7};
53 gpu::Mailbox input; 84 gpu::Mailbox input;
54 input.SetName(mailbox_name); 85 input.SetName(mailbox_name);
55 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 86 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
56 gpu::Mailbox output; 87 gpu::Mailbox output;
57 proxy->EchoMailbox(input, &output); 88 proxy->EchoMailbox(input, &output);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 gpu::SyncToken output; 132 gpu::SyncToken output;
102 proxy->EchoSyncToken(input, &output); 133 proxy->EchoSyncToken(input, &output);
103 EXPECT_EQ(namespace_id, output.namespace_id()); 134 EXPECT_EQ(namespace_id, output.namespace_id());
104 EXPECT_EQ(extra_data_field, output.extra_data_field()); 135 EXPECT_EQ(extra_data_field, output.extra_data_field());
105 EXPECT_EQ(command_buffer_id, output.command_buffer_id()); 136 EXPECT_EQ(command_buffer_id, output.command_buffer_id());
106 EXPECT_EQ(release_count, output.release_count()); 137 EXPECT_EQ(release_count, output.release_count());
107 EXPECT_EQ(verified_flush, output.verified_flush()); 138 EXPECT_EQ(verified_flush, output.verified_flush());
108 } 139 }
109 140
110 } // namespace gpu 141 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/common/mailbox.typemap ('k') | gpu/ipc/common/traits_test_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698