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

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

Issue 2019833002: Implement StructTraits for various cc and gpu types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix DEPS file Created 4 years, 6 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/message_loop/message_loop.h"
6 #include "base/run_loop.h"
7 #include "gpu/ipc/common/traits_test_service.mojom.h"
8 #include "mojo/public/cpp/bindings/binding_set.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace gpu {
12
13 namespace {
14
15 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
16 public:
17 StructTraitsTest() {}
18
19 protected:
20 mojom::TraitsTestServicePtr GetTraitsTestProxy() {
21 return traits_test_bindings_.CreateInterfacePtrAndBind(this);
22 }
23
24 private:
25 // TraitsTestService:
26 void EchoMailbox(const Mailbox& m,
27 const EchoMailboxCallback& callback) override {
28 callback.Run(m);
29 }
30
31 void EchoMailboxHolder(const MailboxHolder& r,
32 const EchoMailboxHolderCallback& callback) override {
33 callback.Run(r);
34 }
35
36 void EchoSyncToken(const SyncToken& s,
37 const EchoSyncTokenCallback& callback) override {
38 callback.Run(s);
39 }
40
41 base::MessageLoop loop_;
42 mojo::BindingSet<TraitsTestService> traits_test_bindings_;
43 };
44
45 } // namespace
46
47 TEST_F(StructTraitsTest, Mailbox) {
48 int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = {
49 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9,
50 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7,
51 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7};
52 gpu::Mailbox input;
53 input.SetName(mailbox_name);
54 base::RunLoop loop;
55 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
56 proxy->EchoMailbox(input, [&](const Mailbox& pass) {
57 EXPECT_EQ(input, pass);
58 loop.Quit();
59 });
60 loop.Run();
61 }
62
63 TEST_F(StructTraitsTest, MailboxHolder) {
64 gpu::MailboxHolder input;
65 int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = {
66 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9,
67 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7,
68 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7};
69 input.mailbox.SetName(mailbox_name);
70 const gpu::CommandBufferNamespace command_buffer_namespace = gpu::IN_PROCESS;
71 const int32_t extra_data_field = 0xbeefbeef;
72 const gpu::CommandBufferId command_buffer_id(
73 gpu::CommandBufferId::FromUnsafeValue(0xdeadbeef));
74 const uint64_t release_count = 0xdeadbeefdead;
75 input.sync_token = gpu::SyncToken(command_buffer_namespace, extra_data_field,
76 command_buffer_id, release_count);
77 input.texture_target = 1337;
78 base::RunLoop loop;
79 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
80 proxy->EchoMailboxHolder(input, [&](const MailboxHolder& pass) {
81 EXPECT_EQ(input.mailbox, pass.mailbox);
82 EXPECT_EQ(input.sync_token, pass.sync_token);
83 EXPECT_EQ(input.texture_target, pass.texture_target);
84 loop.Quit();
85 });
86 }
87
88 TEST_F(StructTraitsTest, SyncToken) {
89 const gpu::CommandBufferNamespace command_buffer_namespace = gpu::IN_PROCESS;
90 const int32_t extra_data_field = 0xbeefbeef;
91 const gpu::CommandBufferId command_buffer_id(
92 gpu::CommandBufferId::FromUnsafeValue(0xdeadbeef));
93 const uint64_t release_count = 0xdeadbeefdead;
94 gpu::SyncToken input(command_buffer_namespace, extra_data_field,
95 command_buffer_id, release_count);
96 base::RunLoop loop;
97 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
98 proxy->EchoSyncToken(input, [&](const SyncToken& pass) {
99 EXPECT_EQ(input.namespace_id(), pass.namespace_id());
100 EXPECT_EQ(input.command_buffer_id(), pass.command_buffer_id());
101 EXPECT_EQ(input.release_count(), pass.release_count());
102 EXPECT_EQ(input.extra_data_field(), pass.extra_data_field());
103 EXPECT_EQ(input.verified_flush(), pass.verified_flush());
104 loop.Quit();
105 });
106 loop.Run();
107 }
108
109 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698