1 /* 2 * Copyright (C) 2021 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_IPC_TEST_SERVICE_H 17 #define OHOS_IPC_TEST_SERVICE_H 18 19 #include "hilog/log.h" 20 #include "log_tags.h" 21 #include "test_service_stub.h" 22 23 namespace OHOS { 24 25 class TestService : public TestServiceStub { 26 public: 27 TestService(bool serialInvokeFlag = false); 28 ~TestService(); 29 static int Instantiate(bool isEnableSerialInvokeFlag); 30 int TestSyncTransaction(int value, int &rep, int delayTime = 0) override; 31 int TestAsyncTransaction(int data, int timeout = 0) override; 32 int TestAsyncCallbackTrans(int data, int &reply, int timeout) override; 33 int TestPingService(const std::u16string &serviceName) override; 34 int TestGetFileDescriptor() override; 35 int TestStringTransaction(const std::string& data) override; 36 int TestZtraceTransaction(std::string& send, std::string& reply, int len) override; 37 int TestDumpService() override; 38 int TestRawDataTransaction(int length, int &reply) override; 39 int TestRawDataReply(int length) override; 40 sptr<IFoo> TestGetFooService() override; 41 int Dump(int fd, const std::vector<std::u16string>& args) override; 42 int TestCallingUidPid() override; 43 int TestFlushAsyncCalls(int count, int length) override; 44 int TestMultipleProcesses(int data, int &rep, int delayTime) override; 45 std::u16string TestAshmem(sptr<Ashmem> ashmem, int32_t contentSize) override; 46 int TestNestingSend(int sendCode, int &replyCode) override; 47 int TestAccessTokenID(int32_t ftoken_expected) override; 48 int TestAccessTokenID64(uint64_t token_expected, uint64_t ftoken_expected) override; 49 int TestMessageParcelAppend(MessageParcel &dst, MessageParcel &src) override; 50 int TestMessageParcelAppendWithIpc(MessageParcel &dst, MessageParcel &src, 51 MessageParcel &reply, bool withObject) override; 52 int TestEnableSerialInvokeFlag() override; 53 int TestRegisterRemoteStub(const char *descriptor, const sptr<IRemoteObject> object) override; 54 int TestUnRegisterRemoteStub(const char *descriptor) override; 55 sptr<IRemoteObject> TestQueryRemoteProxy(const char *descriptor) override; 56 int TestSendTooManyRequest(int data, int &reply) override; 57 int TestMultiThreadSendRequest(int data, int &reply) override; 58 private: 59 int testFd_; 60 std::mutex remoteObjectsMutex_; 61 std::map<std::string, sptr<IRemoteObject>> remoteObjects_; 62 static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_TEST, "TestService" }; 63 }; 64 } // namespace OHOS 65 #endif // OHOS_IPC_TEST_SERVICE_H 66