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

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

Issue 2030173002: Simplify StructTraits tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comments 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
« no previous file with comments | « cc/ipc/traits_test_service.mojom ('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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/run_loop.h"
7 #include "gpu/ipc/common/traits_test_service.mojom.h" 6 #include "gpu/ipc/common/traits_test_service.mojom.h"
8 #include "mojo/public/cpp/bindings/binding_set.h" 7 #include "mojo/public/cpp/bindings/binding_set.h"
9 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
10 9
11 namespace gpu { 10 namespace gpu {
12 11
13 namespace { 12 namespace {
14 13
15 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { 14 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
16 public: 15 public:
(...skipping 16 matching lines...) Expand all
33 callback.Run(r); 32 callback.Run(r);
34 } 33 }
35 34
36 void EchoSyncToken(const SyncToken& s, 35 void EchoSyncToken(const SyncToken& s,
37 const EchoSyncTokenCallback& callback) override { 36 const EchoSyncTokenCallback& callback) override {
38 callback.Run(s); 37 callback.Run(s);
39 } 38 }
40 39
41 base::MessageLoop loop_; 40 base::MessageLoop loop_;
42 mojo::BindingSet<TraitsTestService> traits_test_bindings_; 41 mojo::BindingSet<TraitsTestService> traits_test_bindings_;
42
43 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest);
43 }; 44 };
44 45
45 } // namespace 46 } // namespace
46 47
47 TEST_F(StructTraitsTest, Mailbox) { 48 TEST_F(StructTraitsTest, Mailbox) {
48 const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = { 49 const 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 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 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 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 gpu::Mailbox input;
53 input.SetName(mailbox_name); 54 input.SetName(mailbox_name);
54 base::RunLoop loop;
55 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 55 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
56 proxy->EchoMailbox(input, [&mailbox_name, &loop](const Mailbox& pass) { 56 gpu::Mailbox output;
57 gpu::Mailbox test_mailbox; 57 proxy->EchoMailbox(input, &output);
58 test_mailbox.SetName(mailbox_name); 58 gpu::Mailbox test_mailbox;
59 EXPECT_EQ(test_mailbox, pass); 59 test_mailbox.SetName(mailbox_name);
60 loop.Quit(); 60 EXPECT_EQ(test_mailbox, output);
61 });
62 loop.Run();
63 } 61 }
64 62
65 TEST_F(StructTraitsTest, MailboxHolder) { 63 TEST_F(StructTraitsTest, MailboxHolder) {
66 gpu::MailboxHolder input; 64 gpu::MailboxHolder input;
67 const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = { 65 const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = {
68 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 66 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9,
69 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7, 67 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7,
70 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};
71 gpu::Mailbox mailbox; 69 gpu::Mailbox mailbox;
72 mailbox.SetName(mailbox_name); 70 mailbox.SetName(mailbox_name);
73 const gpu::CommandBufferNamespace namespace_id = gpu::IN_PROCESS; 71 const gpu::CommandBufferNamespace namespace_id = gpu::IN_PROCESS;
74 const int32_t extra_data_field = 0xbeefbeef; 72 const int32_t extra_data_field = 0xbeefbeef;
75 const gpu::CommandBufferId command_buffer_id( 73 const gpu::CommandBufferId command_buffer_id(
76 gpu::CommandBufferId::FromUnsafeValue(0xdeadbeef)); 74 gpu::CommandBufferId::FromUnsafeValue(0xdeadbeef));
77 const uint64_t release_count = 0xdeadbeefdeadL; 75 const uint64_t release_count = 0xdeadbeefdeadL;
78 const gpu::SyncToken sync_token(namespace_id, extra_data_field, 76 const gpu::SyncToken sync_token(namespace_id, extra_data_field,
79 command_buffer_id, release_count); 77 command_buffer_id, release_count);
80 const uint32_t texture_target = 1337; 78 const uint32_t texture_target = 1337;
81 input.mailbox = mailbox; 79 input.mailbox = mailbox;
82 input.sync_token = sync_token; 80 input.sync_token = sync_token;
83 input.texture_target = texture_target; 81 input.texture_target = texture_target;
84 82
85 base::RunLoop loop;
86 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 83 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
87 proxy->EchoMailboxHolder(input, [mailbox, sync_token, texture_target, 84 gpu::MailboxHolder output;
88 &loop](const MailboxHolder& pass) { 85 proxy->EchoMailboxHolder(input, &output);
89 EXPECT_EQ(mailbox, pass.mailbox); 86 EXPECT_EQ(mailbox, output.mailbox);
90 EXPECT_EQ(sync_token, pass.sync_token); 87 EXPECT_EQ(sync_token, output.sync_token);
91 EXPECT_EQ(texture_target, pass.texture_target); 88 EXPECT_EQ(texture_target, output.texture_target);
92 loop.Quit();
93 });
94 } 89 }
95 90
96 TEST_F(StructTraitsTest, SyncToken) { 91 TEST_F(StructTraitsTest, SyncToken) {
97 const gpu::CommandBufferNamespace namespace_id = gpu::IN_PROCESS; 92 const gpu::CommandBufferNamespace namespace_id = gpu::IN_PROCESS;
98 const int32_t extra_data_field = 0xbeefbeef; 93 const int32_t extra_data_field = 0xbeefbeef;
99 const gpu::CommandBufferId command_buffer_id( 94 const gpu::CommandBufferId command_buffer_id(
100 gpu::CommandBufferId::FromUnsafeValue(0xdeadbeef)); 95 gpu::CommandBufferId::FromUnsafeValue(0xdeadbeef));
101 const uint64_t release_count = 0xdeadbeefdead; 96 const uint64_t release_count = 0xdeadbeefdead;
102 const bool verified_flush = false; 97 const bool verified_flush = false;
103 gpu::SyncToken input(namespace_id, extra_data_field, command_buffer_id, 98 gpu::SyncToken input(namespace_id, extra_data_field, command_buffer_id,
104 release_count); 99 release_count);
105 base::RunLoop loop;
106 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 100 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
107 proxy->EchoSyncToken( 101 gpu::SyncToken output;
108 input, [namespace_id, extra_data_field, command_buffer_id, release_count, 102 proxy->EchoSyncToken(input, &output);
109 verified_flush, &loop](const SyncToken& pass) { 103 EXPECT_EQ(namespace_id, output.namespace_id());
110 EXPECT_EQ(namespace_id, pass.namespace_id()); 104 EXPECT_EQ(extra_data_field, output.extra_data_field());
111 EXPECT_EQ(extra_data_field, pass.extra_data_field()); 105 EXPECT_EQ(command_buffer_id, output.command_buffer_id());
112 EXPECT_EQ(command_buffer_id, pass.command_buffer_id()); 106 EXPECT_EQ(release_count, output.release_count());
113 EXPECT_EQ(release_count, pass.release_count()); 107 EXPECT_EQ(verified_flush, output.verified_flush());
114 EXPECT_EQ(verified_flush, pass.verified_flush());
115 loop.Quit();
116 });
117 loop.Run();
118 } 108 }
119 109
120 } // namespace gpu 110 } // namespace gpu
OLDNEW
« no previous file with comments | « cc/ipc/traits_test_service.mojom ('k') | gpu/ipc/common/traits_test_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698