100600bfbSopenharmony_ci/* 200600bfbSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 300600bfbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 400600bfbSopenharmony_ci * you may not use this file except in compliance with the License. 500600bfbSopenharmony_ci * You may obtain a copy of the License at 600600bfbSopenharmony_ci * 700600bfbSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 800600bfbSopenharmony_ci * 900600bfbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1000600bfbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1100600bfbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1200600bfbSopenharmony_ci * See the License for the specific language governing permissions and 1300600bfbSopenharmony_ci * limitations under the License. 1400600bfbSopenharmony_ci */ 1500600bfbSopenharmony_ci#include <gtest/gtest.h> 1600600bfbSopenharmony_ci#include <message_parcel.h> 1700600bfbSopenharmony_ci#include "dump_broker_cpu_stub.h" 1800600bfbSopenharmony_ci#include "dump_cpu_data.h" 1900600bfbSopenharmony_ci#include "hidumper_cpu_service_ipc_interface_code.h" 2000600bfbSopenharmony_ciusing namespace std; 2100600bfbSopenharmony_ciusing namespace testing::ext; 2200600bfbSopenharmony_ciusing namespace OHOS; 2300600bfbSopenharmony_ciusing namespace OHOS::HiviewDFX; 2400600bfbSopenharmony_cinamespace OHOS { 2500600bfbSopenharmony_cinamespace HiviewDFX { 2600600bfbSopenharmony_ciclass HidumperCpuZidlTest : public testing::Test { 2700600bfbSopenharmony_cipublic: 2800600bfbSopenharmony_ci static void SetUpTestCase(void); 2900600bfbSopenharmony_ci static void TearDownTestCase(void); 3000600bfbSopenharmony_ci void SetUp(); 3100600bfbSopenharmony_ci void TearDown(); 3200600bfbSopenharmony_ci}; 3300600bfbSopenharmony_ci 3400600bfbSopenharmony_ciclass TestDumpBrokerCpuStub : public DumpBrokerCpuStub { 3500600bfbSopenharmony_cipublic: 3600600bfbSopenharmony_ci TestDumpBrokerCpuStub() {}; 3700600bfbSopenharmony_ci virtual ~TestDumpBrokerCpuStub() {}; 3800600bfbSopenharmony_ci int32_t Request(DumpCpuData &dumpCpuData) 3900600bfbSopenharmony_ci { 4000600bfbSopenharmony_ci return 0; 4100600bfbSopenharmony_ci } 4200600bfbSopenharmony_ci int32_t GetCpuUsageByPid(int32_t pid, double &cpuUsage) 4300600bfbSopenharmony_ci { 4400600bfbSopenharmony_ci return 0; 4500600bfbSopenharmony_ci } 4600600bfbSopenharmony_ci}; 4700600bfbSopenharmony_ci 4800600bfbSopenharmony_civoid HidumperCpuZidlTest::SetUpTestCase(void) 4900600bfbSopenharmony_ci{ 5000600bfbSopenharmony_ci} 5100600bfbSopenharmony_ci 5200600bfbSopenharmony_civoid HidumperCpuZidlTest::TearDownTestCase(void) 5300600bfbSopenharmony_ci{ 5400600bfbSopenharmony_ci} 5500600bfbSopenharmony_ci 5600600bfbSopenharmony_civoid HidumperCpuZidlTest::SetUp(void) 5700600bfbSopenharmony_ci{ 5800600bfbSopenharmony_ci} 5900600bfbSopenharmony_ci 6000600bfbSopenharmony_civoid HidumperCpuZidlTest::TearDown(void) 6100600bfbSopenharmony_ci{ 6200600bfbSopenharmony_ci} 6300600bfbSopenharmony_ci 6400600bfbSopenharmony_ci/** 6500600bfbSopenharmony_ci * @tc.name: HidumperCpuZidlTest001 6600600bfbSopenharmony_ci * @tc.desc: Test cpu service stub. 6700600bfbSopenharmony_ci * @tc.type: FUNC 6800600bfbSopenharmony_ci */ 6900600bfbSopenharmony_ciHWTEST_F(HidumperCpuZidlTest, HidumperCpuZidlTest001, TestSize.Level3) 7000600bfbSopenharmony_ci{ 7100600bfbSopenharmony_ci DumpBrokerCpuStub* stub = new(std::nothrow) TestDumpBrokerCpuStub(); 7200600bfbSopenharmony_ci MessageParcel data, reply; 7300600bfbSopenharmony_ci MessageOption option; 7400600bfbSopenharmony_ci int ret = stub->OnRemoteRequest(static_cast<uint32_t>(HidumperCpuServiceInterfaceCode::DUMP_REQUEST_CPUINFO), 7500600bfbSopenharmony_ci data, reply, option); 7600600bfbSopenharmony_ci ASSERT_TRUE(ret != 0); 7700600bfbSopenharmony_ci stub->OnRemoteRequest(static_cast<uint32_t>(HidumperCpuServiceInterfaceCode::DUMP_USAGE_ONLY), 7800600bfbSopenharmony_ci data, reply, option); 7900600bfbSopenharmony_ci ret = stub->DumpCpuUsageOnly(data, reply); 8000600bfbSopenharmony_ci ASSERT_TRUE(ret != 0); 8100600bfbSopenharmony_ci} 8200600bfbSopenharmony_ci} // namespace HiviewDFX 8300600bfbSopenharmony_ci} // namespace OHOS