mock_objects.cc
Go to the documentation of this file.
1 // Copyright 2021 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
16 
17 #include <memory>
18 
19 #include "absl/memory/memory.h"
20 
21 namespace grpc_binder {
22 
24 
26  ON_CALL(*this, ReadBinder).WillByDefault([](std::unique_ptr<Binder>* binder) {
27  *binder = absl::make_unique<MockBinder>();
28  return absl::OkStatus();
29  });
30  ON_CALL(*this, ReadInt32).WillByDefault(Return(absl::OkStatus()));
31  ON_CALL(*this, ReadByteArray).WillByDefault(Return(absl::OkStatus()));
32  ON_CALL(*this, ReadString).WillByDefault(Return(absl::OkStatus()));
33 }
34 
36  ON_CALL(*this, WriteInt32).WillByDefault(Return(absl::OkStatus()));
37  ON_CALL(*this, WriteBinder).WillByDefault(Return(absl::OkStatus()));
38  ON_CALL(*this, WriteString).WillByDefault(Return(absl::OkStatus()));
39  ON_CALL(*this, WriteByteArray).WillByDefault(Return(absl::OkStatus()));
40 }
41 
43  ON_CALL(*this, PrepareTransaction).WillByDefault(Return(absl::OkStatus()));
44  ON_CALL(*this, Transact).WillByDefault(Return(absl::OkStatus()));
45  ON_CALL(*this, GetWritableParcel).WillByDefault(Return(&mock_input_));
47  .WillByDefault(
48  [this](grpc_core::RefCountedPtr<WireReader> /*wire_reader_ref*/,
50  return absl::make_unique<MockTransactionReceiver>(
52  });
53 }
54 
55 } // namespace grpc_binder
grpc_binder::Binder::ConstructTxReceiver
virtual std::unique_ptr< TransactionReceiver > ConstructTxReceiver(grpc_core::RefCountedPtr< WireReader > wire_reader_ref, TransactionReceiver::OnTransactCb transact_cb) const =0
grpc_binder::BinderTransportTxCode::SETUP_TRANSPORT
@ SETUP_TRANSPORT
grpc_binder::MockBinder::mock_input_
MockWritableParcel mock_input_
Definition: mock_objects.h:70
testing::Return
internal::ReturnAction< R > Return(R value)
Definition: bloaty/third_party/googletest/googlemock/include/gmock/gmock-actions.h:1004
grpc_binder
Definition: connection_id_generator.cc:45
mock_objects.h
absl::OkStatus
Status OkStatus()
Definition: third_party/abseil-cpp/absl/status/status.h:882
grpc_binder::WritableParcel::WriteString
virtual absl::Status WriteString(absl::string_view s)=0
grpc_core::RefCountedPtr
Definition: ref_counted_ptr.h:35
grpc_binder::ReadableParcel::ReadBinder
virtual absl::Status ReadBinder(std::unique_ptr< Binder > *data)=0
grpc_binder::Binder::GetWritableParcel
virtual WritableParcel * GetWritableParcel() const =0
grpc_binder::ReadableParcel::ReadByteArray
virtual absl::Status ReadByteArray(std::string *data)=0
ON_CALL
#define ON_CALL(obj, call)
grpc_binder::TransactionReceiver::OnTransactCb
std::function< absl::Status(transaction_code_t, ReadableParcel *, int uid)> OnTransactCb
Definition: binder.h:80
grpc_binder::WritableParcel::WriteInt32
virtual absl::Status WriteInt32(int32_t data)=0
grpc_binder::WritableParcel::WriteBinder
virtual absl::Status WriteBinder(HasRawBinder *binder)=0
grpc_binder::ReadableParcel::ReadString
virtual absl::Status ReadString(std::string *str)=0
grpc_binder::MockBinder::MockBinder
MockBinder()
Definition: mock_objects.cc:42
grpc_binder::ReadableParcel::ReadInt32
virtual absl::Status ReadInt32(int32_t *data)=0
grpc_binder::WritableParcel::WriteByteArray
virtual absl::Status WriteByteArray(const int8_t *buffer, int32_t length)=0
grpc_binder::MockReadableParcel::MockReadableParcel
MockReadableParcel()
Definition: mock_objects.cc:25
grpc_binder::MockBinder::mock_output_
MockReadableParcel mock_output_
Definition: mock_objects.h:71
grpc_binder::Binder::Transact
virtual absl::Status Transact(BinderTransportTxCode tx_code)=0
grpc_binder::Binder::PrepareTransaction
virtual absl::Status PrepareTransaction()=0
cb
OPENSSL_EXPORT pem_password_cb * cb
Definition: pem.h:351
grpc_binder::MockWritableParcel::MockWritableParcel
MockWritableParcel()
Definition: mock_objects.cc:35


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:40