1 /* 2 * Copyright (C) 2024 Huawei Device Co., Ltd. 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 */ 15 16 #ifndef OHOS_TEST_SERVICE_PROXY_H 17 #define OHOS_TEST_SERVICE_PROXY_H 18 19 #include "test_service_base.h" 20 21 namespace OHOS { 22 class TestServiceProxy : public IRemoteProxy<ITestService> { 23 public: 24 explicit TestServiceProxy(const sptr<IRemoteObject> &impl); 25 ~TestServiceProxy() = default; 26 int TestSyncTransaction(int value, int &reply, int delayTime = 0) override; 27 int TestAsyncTransaction(int data, int timeout = 0) override; 28 int TestAsyncCallbackTrans(int data, int &reply, int timeout = 0) override; 29 int TestPingService(const std::u16string &serviceName) override; 30 int TestGetFileDescriptor() override; 31 int TestStringTransaction(const std::string &data) override; 32 int TestZtraceTransaction(std::string &send, std::string &reply, int len) override; 33 int TestDumpService() override; 34 int TestRawDataTransaction(int length, int &reply) override; 35 int TestRawDataReply(int length) override; 36 sptr<IFoo> TestGetFooService() override; 37 int TestCallingUidPid() override; 38 int TestFlushAsyncCalls(int count, int length) override; 39 int TestMultipleProcesses(int data, int &rep, int delayTime) override; 40 std::u16string TestAshmem(sptr<Ashmem> ashmem, int32_t contentSize) override; 41 int TestNestingSend(int sendCode, int &replyCode) override; 42 int TestAccessTokenID(int32_t ftoken_expected) override; 43 int TestAccessTokenID64(uint64_t token_expected, uint64_t ftoken_expected) override; 44 int TestMessageParcelAppend(MessageParcel &dst, MessageParcel &src) override; 45 int TestMessageParcelAppendWithIpc(MessageParcel &dst, MessageParcel &src, 46 MessageParcel &reply, bool withObject) override; 47 int TestEnableSerialInvokeFlag() override; 48 49 int TestRegisterRemoteStub(const char *descriptor, const sptr<IRemoteObject> object) override; 50 int TestUnRegisterRemoteStub(const char *descriptor) override; 51 sptr<IRemoteObject> TestQueryRemoteProxy(const char *descriptor) override; 52 int TestSendTooManyRequest(int data, int &reply) override; 53 int TestMultiThreadSendRequest(int data, int &reply) override; 54 55 private: 56 static inline BrokerDelegator<TestServiceProxy> delegator_; 57 bool CheckTokenSelf(uint64_t token, uint64_t tokenSelf, uint64_t ftoken, uint64_t ftoken_expected); 58 bool CheckSetFirstToken(uint64_t ftoken_expected); 59 bool CheckSetSelfToken(uint64_t token_expected); 60 static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_TEST, "TestServiceProxy" }; 61 }; 62 63 } // namespace OHOS 64 #endif // OHOS_TEST_SERVICE_PROXY_H 65