20 #include <gtest/gtest.h>
22 #include "absl/memory/memory.h"
38 TEST(WireWriterTest, RpcCall) {
43 auto mock_binder = absl::make_unique<MockBinder>();
46 ON_CALL(mock_binder_ref, GetWritableParcel)
47 .WillByDefault(
Return(&mock_writable_parcel));
61 int sequence_number = 0;
67 EXPECT_CALL(mock_writable_parcel, WriteInt32(sequence_number));
71 auto tx = std::make_unique<Transaction>(
kFirstCallId,
true);
86 const std::vector<std::pair<std::string, std::string>> kMetadata = {
91 {
"another-key",
"another-value"},
95 EXPECT_CALL(mock_writable_parcel, WriteInt32(kMetadata.size()));
97 for (
const auto&
md : kMetadata) {
98 ExpectWriteByteArray(
md.first);
99 ExpectWriteByteArray(
md.second);
107 tx->SetPrefix(kMetadata);
108 tx->SetMethodRef(
"/example/method/ref");
116 EXPECT_CALL(mock_writable_parcel, WriteInt32(sequence_number));
118 ExpectWriteByteArray(
"data");
121 auto tx = std::make_unique<Transaction>(
kFirstCallId,
true);
131 EXPECT_CALL(mock_writable_parcel, WriteInt32(sequence_number));
135 auto tx = std::make_unique<Transaction>(
kFirstCallId,
true);
146 EXPECT_CALL(mock_writable_parcel, WriteInt32(sequence_number));
151 const std::vector<std::pair<std::string, std::string>> kMetadata = {
156 {
"another-key",
"another-value"},
160 EXPECT_CALL(mock_writable_parcel, WriteInt32(kMetadata.size()));
162 for (
const auto&
md : kMetadata) {
163 ExpectWriteByteArray(
md.first);
164 ExpectWriteByteArray(
md.second);
168 ExpectWriteByteArray(
"");
172 auto tx = std::make_unique<Transaction>(
kFirstCallId,
true);
175 tx->SetPrefix(kMetadata);
176 tx->SetMethodRef(
"/example/method/ref");
206 ExpectWriteByteArray(
"a");
221 mock_writable_parcel,
244 ExpectWriteByteArray(
"a");
253 tx->SetMethodRef(
"123");
265 int main(
int argc,
char** argv) {