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_skeleton.h" 22 23 namespace OHOS { 24 25 class TestService : public TestServiceStub { 26 public: 27 TestService(); 28 ~TestService(); 29 static int Instantiate(); 30 int TestSyncTransaction(int data, 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 void 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 void TestAsyncDumpService() override; 47 int TestNestingSend(int sendCode, int &replyCode) override; 48 int TestAccessTokenID(int32_t ftoken_expected) override; 49 int TestAccessTokenID64(uint64_t token_expected, uint64_t ftoken_expected) override; 50 int TestMessageParcelAppend(MessageParcel &dst, MessageParcel &src) override; 51 int TestMessageParcelAppendWithIpc(MessageParcel &dst, MessageParcel &src, 52 MessageParcel &reply, bool withObject) override; 53 private: 54 int testFd_; 55 static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "TestService" }; 56 }; 57 } // namespace OHOS 58 #endif // OHOS_IPC_TEST_SERVICE_H