Merge remote-tracking branch 'upstream/master' into Hats_Review

This commit is contained in:
wangchao582 2023-12-21 16:14:25 +08:00
commit 941648f235
44 changed files with 8018 additions and 50 deletions

View File

@ -80,6 +80,7 @@ DCStreamInfo streamInfo5;
DCCaptureInfo captureInfo2;
DCCaptureInfo captureInfo3;
DHBase dhBase;
DHBase dhBaseTest;
DCameraProvider cameraProvider;
DCameraBuffer buffer;
DCameraHDFEvent hdiEvent;
@ -138,12 +139,16 @@ void DCameraProviderTest::TearDown(void)
hdiCallback_ = nullptr;
camDev_ = nullptr;
stateListener_ = nullptr;
dhBase.deviceId_.clear();
dhBase.dhId_.clear();
}
HWTEST_F(DCameraProviderTest, SUB_DH_Dcamera_Hats_0100, TestSize.Level1)
{
int32_t ret = cameraProvider.EnableDCameraDevice(dhBase, testParam, hdiCallback_);
EXPECT_EQ(0, ret) << "EnableDCameraDevice fail";
dhBaseTest.deviceId_ = "";
dhBaseTest.dhId_ = testCameraDh;
int32_t ret = cameraProvider.EnableDCameraDevice(dhBaseTest, testParam, hdiCallback_);
EXPECT_EQ(2, ret) << "EnableDCameraDevice fail";
}
HWTEST_F(DCameraProviderTest, SUB_DH_Dcamera_Hats_0200, TestSize.Level1)
@ -233,7 +238,7 @@ HWTEST_F(DCameraProviderTest, SUB_DH_Dcamera_Hats_1300, TestSize.Level1)
HWTEST_F(DCameraProviderTest, SUB_DH_Dcamera_Hats_1400, TestSize.Level1)
{
int32_t ret = cameraProvider.Notify(dhBase, hdiEvent);
EXPECT_EQ(0, ret) << "Notify fail";
EXPECT_EQ(2, ret) << "Notify fail";
}
HWTEST_F(DCameraProviderTest, SUB_DH_Dcamera_Hats_1500, TestSize.Level1)
@ -264,7 +269,7 @@ HWTEST_F(DCameraProviderTest, SUB_DH_Dcamera_Hats_1800, TestSize.Level1)
HWTEST_F(DCameraProviderTest, SUB_DH_Dcamera_Hats_1900, TestSize.Level1)
{
int32_t ret = cameraProvider.DisableDCameraDevice(dhBase);
EXPECT_EQ(0, ret) << "DisableDCameraDevice fail";
EXPECT_EQ(2, ret) << "DisableDCameraDevice fail";
}
HWTEST_F(DCameraProviderTest, SUB_DH_Dcamera_Hats_2000, TestSize.Level1)

View File

@ -61,7 +61,7 @@ ohos_moduletest_suite("HatsHdfCamerabenchmarkTestV0") {
"drivers_interface_camera:libbuffer_producer_sequenceable_1.0",
"drivers_interface_camera:metadata",
"drivers_interface_display:libdisplay_composer_proxy_1.0",
"graphic_chipsetsdk:surface",
"graphic_surface:surface",
"samgr:samgr_proxy",
]

View File

@ -59,7 +59,7 @@ ohos_moduletest_suite("HatsHdfCamerabenchmarkTestV1") {
"drivers_interface_camera:libbuffer_producer_sequenceable_1.0",
"drivers_interface_camera:metadata",
"drivers_interface_display:libdisplay_composer_proxy_1.0",
"graphic_chipsetsdk:surface",
"graphic_surface:surface",
"samgr:samgr_proxy",
]

View File

@ -78,7 +78,7 @@ ohos_moduletest_suite("HatsHdfCameraBufferTest") {
"drivers_peripheral_camera:peripheral_camera_buffer_manager",
"drivers_peripheral_camera:peripheral_camera_device_manager",
"drivers_peripheral_camera:peripheral_camera_pipeline_core",
"graphic_chipsetsdk:surface",
"graphic_surface:surface",
"hdf_core:libhdf_host",
"hdf_core:libhdf_ipc_adapter",
"hdf_core:libhdf_utils",

View File

@ -87,7 +87,7 @@ ohos_moduletest_suite("HatsHdfCameraPipelineTest") {
"drivers_peripheral_camera:peripheral_camera_buffer_manager",
"drivers_peripheral_camera:peripheral_camera_device_manager",
"drivers_peripheral_camera:peripheral_camera_pipeline_core",
"graphic_chipsetsdk:surface",
"graphic_surface:surface",
"hdf_core:libhdf_host",
"hdf_core:libhdf_ipc_adapter",
"hdf_core:libhdf_utils",

View File

@ -95,7 +95,7 @@ ohos_moduletest_suite("HatsHdfCameraTest") {
"drivers_peripheral_camera:peripheral_camera_buffer_manager",
"drivers_peripheral_camera:peripheral_camera_device_manager",
"drivers_peripheral_camera:peripheral_camera_pipeline_core",
"graphic_chipsetsdk:surface",
"graphic_surface:surface",
"hdf_core:libhdf_host",
"hdf_core:libhdf_ipc_adapter",
"hdf_core:libhdf_utils",

View File

@ -59,7 +59,7 @@ ohos_moduletest_suite("HatsHdfCameraMgTestv0") {
"drivers_interface_camera:libcamera_proxy_1.0",
"drivers_interface_camera:metadata",
"drivers_interface_display:libdisplay_composer_proxy_1.0",
"graphic_chipsetsdk:surface",
"graphic_surface:surface",
"samgr:samgr_proxy",
]

View File

@ -52,7 +52,7 @@ ohos_moduletest_suite("HatsHdfCameraMgTestv1") {
"drivers_interface_camera:libcamera_proxy_1.1",
"drivers_interface_camera:metadata",
"drivers_interface_display:libdisplay_composer_proxy_1.0",
"graphic_chipsetsdk:surface",
"graphic_surface:surface",
"samgr:samgr_proxy",
]

View File

@ -58,7 +58,7 @@ ohos_moduletest_suite("HatsHdfCameraMgv0AdditionalTest") {
"drivers_interface_camera:libcamera_proxy_1.0",
"drivers_interface_camera:metadata",
"drivers_interface_display:libdisplay_composer_proxy_1.0",
"graphic_chipsetsdk:surface",
"graphic_surface:surface",
"samgr:samgr_proxy",
]

View File

@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
base_root = "../../../../../../../"
import("//build/ohos.gni")
@ -52,7 +52,7 @@ ohos_moduletest_suite("HatsHdfCameraMgv1AdditionalTest") {
"drivers_interface_camera:libcamera_proxy_1.1",
"drivers_interface_camera:metadata",
"drivers_interface_display:libdisplay_composer_proxy_1.0",
"graphic_chipsetsdk:surface",
"graphic_surface:surface",
"samgr:samgr_proxy",
]

View File

@ -42,7 +42,7 @@ ohos_moduletest_suite("HatsHdfCodecBenchmarkTest") {
"drivers_interface_display:libdisplay_buffer_hdi_impl",
"drivers_interface_display:libdisplay_composer_hdi_impl",
"drivers_peripheral_codec:libcodec_hdi_omx_client",
"graphic_chipsetsdk:buffer_handle",
"graphic_surface:buffer_handle",
"hdf_core:libhdf_host",
"hdf_core:libhdf_ipc_adapter",
"hdf_core:libhdf_utils",

View File

@ -44,7 +44,7 @@ ohos_moduletest_suite("HatsHdfCodecBenchmarkAdditionalTest") {
"drivers_interface_display:libdisplay_buffer_hdi_impl",
"drivers_interface_display:libdisplay_composer_hdi_impl",
"drivers_peripheral_codec:libcodec_hdi_omx_client",
"graphic_chipsetsdk:buffer_handle",
"graphic_surface:buffer_handle",
"hdf_core:libhdf_host",
"hdf_core:libhdf_ipc_adapter",
"hdf_core:libhdf_utils",

View File

@ -32,7 +32,7 @@ ohos_moduletest_suite("HatsHdfImageCodecTest") {
"drivers_interface_display:display_composer_idl_headers",
"drivers_interface_display:libdisplay_buffer_hdi_impl",
"drivers_interface_display:libdisplay_composer_hdi_impl",
"graphic_chipsetsdk:buffer_handle",
"graphic_surface:buffer_handle",
"hdf_core:libhdf_host",
"hdf_core:libhdf_ipc_adapter",
"hdf_core:libhdf_utils",

View File

@ -32,7 +32,7 @@ ohos_moduletest_suite("HatsHdfImageCodecAdditionalTest") {
"drivers_interface_display:display_composer_idl_headers",
"drivers_interface_display:libdisplay_buffer_hdi_impl",
"drivers_interface_display:libdisplay_composer_hdi_impl",
"graphic_chipsetsdk:buffer_handle",
"graphic_surface:buffer_handle",
"hdf_core:libhdf_host",
"hdf_core:libhdf_ipc_adapter",
"hdf_core:libhdf_utils",

View File

@ -35,7 +35,7 @@ ohos_moduletest_suite("HatsHdfOmxCodecTest") {
"drivers_interface_display:libdisplay_buffer_hdi_impl",
"drivers_interface_display:libdisplay_composer_hdi_impl",
"drivers_peripheral_codec:libcodec_hdi_omx_client",
"graphic_chipsetsdk:buffer_handle",
"graphic_surface:buffer_handle",
"hdf_core:libhdf_host",
"hdf_core:libhdf_ipc_adapter",
"hdf_core:libhdf_utils",

View File

@ -32,7 +32,7 @@ ohos_moduletest_suite("HatsHdfOmxCodecAdditionalTest") {
"drivers_interface_display:libdisplay_buffer_hdi_impl",
"drivers_interface_display:libdisplay_composer_hdi_impl",
"drivers_peripheral_codec:libcodec_hdi_omx_client",
"graphic_chipsetsdk:buffer_handle",
"graphic_surface:buffer_handle",
"hdf_core:libhdf_host",
"hdf_core:libhdf_ipc_adapter",
"hdf_core:libhdf_utils",

View File

@ -37,7 +37,7 @@ ohos_moduletest_suite("HatsHdfV1CodecTest") {
"c_utils:utils",
"drivers_peripheral_codec:libcodec_client",
"drivers_peripheral_display:hdi_gralloc_client",
"graphic_chipsetsdk:buffer_handle",
"graphic_surface:buffer_handle",
"hdf_core:libhdf_host",
"hdf_core:libhdf_ipc_adapter",
"hdf_core:libhdf_utils",

View File

@ -31,7 +31,7 @@ ohos_moduletest_suite("HatsHdfDisplayBufferMtAdditionalTest") {
"drivers_interface_display:libdisplay_buffer_hdi_impl",
"drivers_interface_display:libdisplay_composer_hdi_impl",
"googletest:gtest",
"graphic_chipsetsdk:buffer_handle",
"graphic_surface:buffer_handle",
"hdf_core:libhdf_utils",
"hilog:libhilog",
"ipc:ipc_core",

View File

@ -14,20 +14,30 @@
import("//build/ohos_var.gni")
import("//build/test.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")
import("//test/xts/hats/build.gni")
import("//test/xts/tools/build/suite.gni")
group("HatsHdfUsbTest") {
testonly = true
deps = [
"autoFunctionTest:HatsHdfUsbAutoFunctionTest",
# "deviceTest:HatsHdfUsbDeviceTest",
# "functionTest:HatsHdfUsbFunctionTest",
# "requestTest:HatsHdfUsbRequestTest",
# "transferTest:HatsHdfUsbTransferTest",
# "usbdBenchmarkTest:HatsHdfUsbBenchmarkDeviceTest",
# "usbdBenchmarkTest:HatsHdfUsbBenchmarkFunctionTest",
# "usbdBenchmarkTest:HatsHdfUsbBenchmarkRequestTest",
# "usbdBenchmarkTest:HatsHdfUsbBenchmarkTransferTest",
# "mtpTest:HatsHdfUsbFnMtpTest",
]
if (hats_rich == false) {
deps = [
"autoFunctionTest:HatsHdfUsbAutoFunctionTest",
# "deviceTest:HatsHdfUsbDeviceTest",
# "functionTest:HatsHdfUsbFunctionTest",
# "mtpTest:HatsHdfUsbFnMtpTest",
# "requestTest:HatsHdfUsbRequestTest",
"requestTest_additional:HatsHdfUsbRequestAdditionalTest",
# "transferTest:HatsHdfUsbTransferTest",
"transferTest_additional:HatsHdfUsbTransferAdditionalTest",
# "usbdBenchmarkTest:HatsHdfUsbBenchmarkDeviceTest",
# "usbdBenchmarkTest:HatsHdfUsbBenchmarkFunctionTest",
# "usbdBenchmarkTest:HatsHdfUsbBenchmarkRequestTest",
# "usbdBenchmarkTest:HatsHdfUsbBenchmarkTransferTest",
]
} else {
deps = [ "autoFunctionTest:HatsHdfUsbAutoFunctionTest" ]
}
}

View File

@ -0,0 +1,54 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos_var.gni")
import("//test/xts/tools/build/suite.gni")
module_output_path = "hdf/usb"
ohos_moduletest_suite("HatsHdfUsbRequestAdditionalTest") {
module_out_path = module_output_path
sources = [
"../UsbSubscriberTest/UsbSubscriberTest.cpp",
"./common/usbd_interface_test.cpp",
"./common/usbd_request_test.cpp",
]
configs = [ ":hdf_usb_additional" ]
deps = [ "//third_party/googletest:gtest_main" ]
external_deps = [
"ability_base:want",
"bundle_framework:appexecfwk_base",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"drivers_interface_usb:libusb_proxy_1.0",
"eventhandler:libeventhandler",
"hdf_core:libhdf_host",
"hdf_core:libhdf_utils",
"hilog:libhilog",
"ipc:ipc_single",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
subsystem_name = "xts"
part_name = "hats"
}
config("hdf_usb_additional") {
include_dirs = [
"include",
"../UsbSubscriberTest",
]
}

View File

@ -0,0 +1,18 @@
{
"kits": [
{
"push": [
"HatsHdfUsbRequestAdditionalTest->/data/local/tmp/HatsHdfUsbRequestAdditionalTest"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "HatsHdfUsbRequestAdditionalTest",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for HatsHdfUsbRequestAdditionalTest Tests"
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,61 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef USBD_REQUEST_TEST_H
#define USBD_REQUEST_TEST_H
#include <gtest/gtest.h>
#include "UsbSubscriberTest.h"
#include "v1_0/iusbd_subscriber.h"
#include "v1_0/usb_types.h"
#include "v1_0/iusbd_bulk_callback.h"
using OHOS::HDI::Usb::V1_0::UsbDev;
/**
* Used to signify direction of data for USBEndpoint is IN, device to host
*/
const int32_t USB_ENDPOINT_DIR_IN = 0x80;
/**
* Used to signify direction of data for USBEndpoint is OUT, host to device
*/
const int32_t USB_ENDPOINT_DIR_OUT = 0;
namespace {
class UsbdRequestTestAdditional : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
static UsbDev dev_;
static OHOS::sptr<OHOS::USB::UsbSubscriberTest> subscriber_;
};
class UsbdBulkCallbackTest : public OHOS::HDI::Usb::V1_0::IUsbdBulkCallback {
public:
UsbdBulkCallbackTest() = default;
~UsbdBulkCallbackTest() = default;
int32_t OnBulkWriteCallback(int32_t status, int32_t actLength) override
{
return 0;
};
int32_t OnBulkReadCallback(int32_t status, int32_t actLength) override
{
return 0;
};
};
}
#endif // USBD_REQUEST_TEST_H

View File

@ -0,0 +1,53 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos_var.gni")
import("//test/xts/tools/build/suite.gni")
module_output_path = "hdf/usb"
ohos_moduletest_suite("HatsHdfUsbTransferAdditionalTest") {
module_out_path = module_output_path
sources = [
"../UsbSubscriberTest/UsbSubscriberTest.cpp",
"./common/usbd_transfer_test.cpp",
]
configs = [ ":hdf_usb_additional" ]
deps = [ "//third_party/googletest:gtest_main" ]
external_deps = [
"ability_base:want",
"bundle_framework:appexecfwk_base",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"drivers_interface_usb:libusb_proxy_1.0",
"eventhandler:libeventhandler",
"hdf_core:libhdf_host",
"hdf_core:libhdf_utils",
"hilog:libhilog",
"ipc:ipc_single",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
subsystem_name = "xts"
part_name = "hats"
}
config("hdf_usb_additional") {
include_dirs = [
"include",
"../UsbSubscriberTest",
]
}

View File

@ -0,0 +1,18 @@
{
"kits": [
{
"push": [
"HatsHdfUsbTransferAdditionalTest->/data/local/tmp/HatsHdfUsbTransferAdditionalTest"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "HatsHdfUsbTransferAdditionalTest",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for HatsHdfUsbTransferAdditionalTest Tests"
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,65 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef USBD_TRANSFER_TEST_H
#define USBD_TRANSFER_TEST_H
#include <gtest/gtest.h>
#include "UsbSubscriberTest.h"
#include "v1_0/iusbd_subscriber.h"
#include "v1_0/usb_types.h"
#include "v1_0/iusbd_bulk_callback.h"
using OHOS::HDI::Usb::V1_0::UsbDev;
#define USB_DDK_REQ_GET_DESCRIPTOR 0x06
#define USB_DDK_REQ_GET_CONFIGURATION 0x08
#define USB_DDK_REQ_GET_INTERFACE 0x0A
#define USB_DDK_REQ_SYNCH_FRAME 0x0C
const int32_t USB_ENDPOINT_DIR_IN = 0x80;
const int32_t USB_ENDPOINT_DIR_OUT = 0;
typedef enum {
USB_REQUEST_TARGET_DEVICE,
USB_REQUEST_TARGET_INTERFACE,
USB_REQUEST_TARGET_ENDPOINT,
USB_REQUEST_TARGET_OTHER,
} UsbRequestTargetType;
namespace {
class UsbdTransferTestAdditional : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
static UsbDev dev_;
static OHOS::sptr<OHOS::USB::UsbSubscriberTest> subscriber_;
};
class UsbdBulkCallbackTest : public OHOS::HDI::Usb::V1_0::IUsbdBulkCallback {
public:
UsbdBulkCallbackTest() = default;
~UsbdBulkCallbackTest() = default;
int32_t OnBulkWriteCallback(int32_t status, int32_t actLength) override
{
return 0;
};
int32_t OnBulkReadCallback(int32_t status, int32_t actLength) override
{
return 0;
};
};
}
#endif // USBD_TRANSFER_TEST_H

View File

@ -28,9 +28,9 @@ using namespace OHOS::HDI::Vibrator::V1_1;
using namespace testing::ext;
namespace {
const std::string DEVICETYPE_KEY = "const.product.devicetype";
const std::string DEVICETYPE_TYPE = "phone";
sptr<IVibratorInterface> g_vibratorInterface = nullptr;
HapticCapacity g_hapticCapacity;
sptr<V1_2::IVibratorInterface> g_vibratorInterface = nullptr;
const std::vector<std::string> g_effect{"haptic.log_press.light","haptic.slide.light","haptic.threshold","haptic.long_press.medium","haptic.fail","haptic.common.notice1","haptic.common.success","haptic.charging","haptic.long_press.heavy"};
}
@ -45,7 +45,7 @@ public:
void HatsHdfVibratorImplTest::SetUpTestCase()
{
g_vibratorInterface = IVibratorInterface::Get();
g_vibratorInterface = V1_2::IVibratorInterface::Get();
}
void HatsHdfVibratorImplTest::TearDownTestCase()
{
@ -75,7 +75,7 @@ HWTEST_F(HatsHdfVibratorImplTest, SUB_Vibrator_HDI_CheckVibratorInstanceIsEmpty_
HWTEST_F(HatsHdfVibratorImplTest, SUB_Vibrator_HDI_EnableCompositeEffectTest_0010, Function | MediumTest | Level1)
{
ASSERT_NE(nullptr, g_vibratorInterface);
if (OHOS::system::GetParameter(PHONE_KEY, "") == PHONE_TYPE) {
if (g_hapticCapacity.isSupportPresetMapping) {
PrimitiveEffect primitiveEffect1 { 0, 60007, 0};
PrimitiveEffect primitiveEffect2 { 1000, 60007, 0};
PrimitiveEffect primitiveEffect3 { 1000, 60007, 0};
@ -109,7 +109,7 @@ HWTEST_F(HatsHdfVibratorImplTest, SUB_Vibrator_HDI_EnableCompositeEffectTest_001
HWTEST_F(HatsHdfVibratorImplTest, SUB_Vibrator_HDI_EnableCompositeEffectTest_0020, Function | MediumTest | Level1)
{
ASSERT_NE(nullptr, g_vibratorInterface);
if (OHOS::system::GetParameter(DEVICETYPE_KEY, "") == PHONE_TYPE) {
if (g_hapticCapacity.isSupportPresetMapping) {
PrimitiveEffect primitiveEffect1 { 0, 60007, 0};
PrimitiveEffect primitiveEffect2 { 1000, 60007, 0};
PrimitiveEffect primitiveEffect3 { 1000, 60007, 0};
@ -175,7 +175,7 @@ HWTEST_F(HatsHdfVibratorImplTest, SUB_Vibrator_HDI_GetEffectInfoTest_0020, Funct
HWTEST_F(HatsHdfVibratorImplTest, SUB_Vibrator_HDI_IsVibratorRunningTest_0010, Function | MediumTest | Level1)
{
ASSERT_NE(nullptr, g_vibratorInterface);
if (OHOS::system::GetParameter(DEVICETYPE_KEY, "") == PHONE_TYPE) {
if (g_hapticCapacity.isSupportPresetMapping) {
PrimitiveEffect primitiveEffect1 { 0, 60007, 0};
PrimitiveEffect primitiveEffect2 { 1000, 60007, 0};
PrimitiveEffect primitiveEffect3 { 1000, 60007, 0};

View File

@ -25,8 +25,6 @@ using namespace OHOS::HDI::Vibrator::V1_1;
using namespace testing::ext;
namespace {
const std::string DEVICETYPE_KEY = "const.product.devicetype";
const std::string DEVICETYPE_TYPE = "phone";
sptr<IVibratorInterface> g_vibratorInterface = nullptr;
}

View File

@ -38,8 +38,6 @@ namespace {
std::string g_timeSequence = "haptic.clock.timer";
std::string g_builtIn = "haptic.default.effect";
std::string g_arbitraryStr = "arbitraryString";
const std::string DEVICETYPE_KEY = "const.product.devicetype";
const std::string DEVICETYPE_TYPE = "phone";
sptr<IVibratorInterface> g_vibratorInterface = nullptr;
class vibratorBenchmarkTest : public benchmark::Fixture {

View File

@ -12,9 +12,17 @@
# limitations under the License.
import("//build/ohos_var.gni")
import("//test/xts/hats/build.gni")
import("//test/xts/tools/build/suite.gni")
group("HatsPowermgrPowerTest") {
testonly = true
deps = [ "hdi_power:HatsPowermgrPowerTest" ]
if (hats_rich == false) {
deps = [
"hdi_power:HatsPowermgrPowerTest",
"hdi_power_additional:HatsPowermgrPowerAdditionalTest",
]
} else {
deps = [ "hdi_power:HatsPowermgrPowerTest" ]
}
}

View File

@ -0,0 +1,34 @@
# Copyright (c) 2022 - 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos_var.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")
import("//test/xts/tools/build/suite.gni")
ohos_moduletest_suite("HatsPowermgrPowerAdditionalTest") {
module_out_path = "powermgr/power"
sources = [ "./common/hdi_power_test.cpp" ]
deps = [ "//third_party/googletest:gtest_main" ]
external_deps = [
"c_utils:utils",
"drivers_interface_power:libpower_proxy_1.1",
"hdf_core:libhdf_utils",
"hilog:libhilog",
"ipc:ipc_single",
]
subsystem_name = "xts"
part_name = "hats"
}

View File

@ -0,0 +1,18 @@
{
"kits": [
{
"push": [
"HatsPowermgrPowerAdditionalTest->/data/local/tmp/HatsPowermgrPowerAdditionalTest"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "HatsPowermgrPowerAdditionalTest",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for HatsPowermgrPowerAdditionalTest Tests"
}

File diff suppressed because it is too large Load Diff

View File

@ -12,9 +12,17 @@
# limitations under the License.
import("//build/ohos_var.gni")
import("//test/xts/hats/build.gni")
import("//test/xts/tools/build/suite.gni")
group("HatsPowermgrThermalTest") {
testonly = true
deps = [ "hdi_thermal:HatsPowermgrThermalTest" ]
if (hats_rich == false) {
deps = [
"hdi_thermal:HatsPowermgrThermalTest",
"hdi_thermal_additional:HatsPowermgrThermalAdditionalTest",
]
} else {
deps = [ "hdi_thermal:HatsPowermgrThermalTest" ]
}
}

View File

@ -0,0 +1,36 @@
# Copyright (c) 2022 - 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos_var.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")
import("//test/xts/tools/build/suite.gni")
ohos_moduletest_suite("HatsPowermgrThermalAdditionalTest") {
module_out_path = "powermgr/thermal"
sources = [ "./common/HDIThermalTest.cpp" ]
deps = [ "//third_party/googletest:gtest_main" ]
external_deps = [
"c_utils:utils",
"drivers_interface_thermal:libthermal_proxy_1.1",
"drivers_interface_thermal:thermal_idl_headers",
"hdf_core:libhdf_utils",
"hilog:libhilog",
"init:libbeget_proxy",
"ipc:ipc_single",
]
subsystem_name = "xts"
part_name = "hats"
}

View File

@ -0,0 +1,18 @@
{
"kits": [
{
"push": [
"HatsPowermgrThermalAdditionalTest->/data/local/tmp/HatsPowermgrThermalAdditionalTest"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "HatsPowermgrThermalAdditionalTest",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for HatsPowermgrThermalAdditionalTest Tests"
}

View File

@ -0,0 +1,449 @@
/*
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cmath>
#include <cstdio>
#include <fcntl.h>
#include <functional>
#include <gtest/gtest.h>
#include <mutex>
#include <securec.h>
#include <unistd.h>
#include "hdf_base.h"
#include "osal_time.h"
#include "v1_1/ifan_callback.h"
#include "v1_1/ithermal_callback.h"
#include "v1_1/ithermal_interface.h"
#include "v1_1/thermal_types.h"
using namespace OHOS::HDI;
using namespace OHOS::HDI::Thermal::V1_1;
using namespace testing::ext;
namespace {
class ThermalCallbackMock : public IThermalCallback {
public:
virtual ~ThermalCallbackMock() {}
using ThermalEventCallback = std::function<int32_t(const HdfThermalCallbackInfo &event)>;
static int32_t RegisterThermalEvent(const ThermalEventCallback &eventCb)
{
(void)eventCb;
return 0;
}
int32_t OnThermalDataEvent(const HdfThermalCallbackInfo &event) override
{
(void)event;
return 0;
}
};
class FanCallbackMock : public IFanCallback {
public:
virtual ~FanCallbackMock() {}
using FanEventCallback = std::function<int32_t(const HdfThermalCallbackInfo &event)>;
static int32_t RegisterFanEvent(const FanEventCallback &eventCb)
{
(void)eventCb;
return 0;
}
int32_t OnFanDataEvent(const HdfThermalCallbackInfo &event) override
{
(void)event;
return 0;
}
};
sptr<IThermalInterface> g_thermalInterface = nullptr;
sptr<IThermalCallback> g_callback = new ThermalCallbackMock();
sptr<IFanCallback> g_fanCallback = new FanCallbackMock();
std::mutex g_mutex;
class HdfThermalHdiTestAdditional : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
};
void HdfThermalHdiTestAdditional::SetUpTestCase() { g_thermalInterface = IThermalInterface::Get(true); }
void HdfThermalHdiTestAdditional::TearDownTestCase() {}
void HdfThermalHdiTestAdditional::SetUp() {}
void HdfThermalHdiTestAdditional::TearDown() {}
} // namespace
namespace {
/**
* @tc.number SUB_Powermgr_Thermal_SetCpuFreq_0200
* @tc.name testSetCpuFreq001
* @tc.desc Reliability of function(SetCpuFreq)
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetCpuFreq001, Function | MediumTest | Level1)
{
int32_t cpuFreq = 1994100;
int32_t ret = 0;
int i = 0;
for (i = 0; i < 1000; i++) {
ret |= g_thermalInterface->SetCpuFreq(cpuFreq);
}
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_SetCpuFreq_0300
* @tc.name testSetCpuFreq002
* @tc.desc Test parameters with abnormal input
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetCpuFreq002, Function | MediumTest | Level2)
{
int32_t cpuFreq = -1;
int32_t ret = g_thermalInterface->SetCpuFreq(cpuFreq);
EXPECT_NE(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_SetCpuFreq_0400
* @tc.name testSetCpuFreq003
* @tc.desc Test input param
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetCpuFreq003, Function | MediumTest | Level1)
{
int32_t cpuFreq = 0x7fffffff;
int32_t ret = g_thermalInterface->SetCpuFreq(cpuFreq);
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_SetCpuFreq_0500
* @tc.name testSetCpuFreq004
* @tc.desc Test input param
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetCpuFreq004, Function | MediumTest | Level1)
{
int32_t cpuFreq = 1024;
int32_t ret = g_thermalInterface->SetCpuFreq(cpuFreq);
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_SetCpuFreq_0600
* @tc.name testSetCpuFreq005
* @tc.desc Test parameters with abnormal input
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetCpuFreq005, Function | MediumTest | Level2)
{
int32_t cpuFreq = 0;
int32_t ret = g_thermalInterface->SetCpuFreq(cpuFreq);
EXPECT_NE(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_SetGpuFreq_0200
* @tc.name testSetGpuFreq001
* @tc.desc Reliability of function(SetGpuFreq)
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetGpuFreq001, Function | MediumTest | Level1)
{
int32_t gpuFreq = 1994100;
int32_t ret = 0;
int i = 0;
for (i = 0; i < 1000; i++) {
ret |= g_thermalInterface->SetGpuFreq(gpuFreq);
}
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_SetGpuFreq_0300
* @tc.name testSetGpuFreq002
* @tc.desc Test parameters with abnormal input
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetGpuFreq002, Function | MediumTest | Level2)
{
int32_t gpuFreq = -1;
int32_t ret = g_thermalInterface->SetGpuFreq(gpuFreq);
EXPECT_NE(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_SetGpuFreq_0400
* @tc.name testSetGpuFreq003
* @tc.desc Test input param
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetGpuFreq003, Function | MediumTest | Level1)
{
int32_t gpuFreq = 0x7fffffff;
int32_t ret = g_thermalInterface->SetGpuFreq(gpuFreq);
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_SetGpuFreq_0500
* @tc.name testSetGpuFreq004
* @tc.desc Test input param
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetGpuFreq004, Function | MediumTest | Level1)
{
int32_t gpuFreq = 1024;
int32_t ret = g_thermalInterface->SetGpuFreq(gpuFreq);
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_SetGpuFreq_0600
* @tc.name testSetGpuFreq005
* @tc.desc Test parameters with abnormal input
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetGpuFreq005, Function | MediumTest | Level2)
{
int32_t gpuFreq = 0;
int32_t ret = g_thermalInterface->SetGpuFreq(gpuFreq);
EXPECT_NE(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_SetBatteryCurrent_0200
* @tc.name testSetBatteryCurrent001
* @tc.desc Reliability of function(SetBatteryCurrent)
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetBatteryCurrent001, Function | MediumTest | Level1)
{
int32_t ret = 0;
int32_t batteryCurrent = 1000;
int i = 0;
for (i = 0; i < 1000; i++) {
ret |= g_thermalInterface->SetBatteryCurrent(batteryCurrent);
}
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_SetBatteryCurrent_0300
* @tc.name testSetBatteryCurrent002
* @tc.desc Test parameters with abnormal input
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetBatteryCurrent002, Function | MediumTest | Level2)
{
int32_t ret = 0;
int32_t batteryCurrent = -1;
ret = g_thermalInterface->SetBatteryCurrent(batteryCurrent);
EXPECT_NE(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_SetBatteryCurrent_0400
* @tc.name testSetBatteryCurrent003
* @tc.desc Test input param
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetBatteryCurrent003, Function | MediumTest | Level1)
{
int32_t ret = 0;
int32_t batteryCurrent = 0x7fffffff;
ret = g_thermalInterface->SetBatteryCurrent(batteryCurrent);
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_SetBatteryCurrent_0500
* @tc.name testSetBatteryCurrent004
* @tc.desc Test input param
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetBatteryCurrent004, Function | MediumTest | Level1)
{
int32_t ret = 0;
int32_t batteryCurrent = 1024;
ret = g_thermalInterface->SetBatteryCurrent(batteryCurrent);
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_SetBatteryCurrent_0600
* @tc.name testSetBatteryCurrent005
* @tc.desc Test input param
*/
HWTEST_F(HdfThermalHdiTestAdditional, testSetBatteryCurrent005, Function | MediumTest | Level2)
{
int32_t ret = 0;
int32_t batteryCurrent = 0;
ret = g_thermalInterface->SetBatteryCurrent(batteryCurrent);
EXPECT_NE(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_GetThermalZoneInfo_0200
* @tc.name testGetThermalZoneInfo001
* @tc.desc Reliability of function(GetThermalZoneInfo)
*/
HWTEST_F(HdfThermalHdiTestAdditional, testGetThermalZoneInfo001, Function | MediumTest | Level1)
{
HdfThermalCallbackInfo event;
int i = 0;
int32_t ret = 0;
for (i = 0; i < 1000; i++) {
ret |= g_thermalInterface->GetThermalZoneInfo(event);
}
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_IsolateCpu_0200
* @tc.name testIsolateCpu001
* @tc.desc Reliability of function(IsolateCpu)
*/
HWTEST_F(HdfThermalHdiTestAdditional, testIsolateCpu001, Function | MediumTest | Level1)
{
int i = 0;
int32_t isolateNum = 2;
int32_t ret = 0;
for (i = 0; i < 1000; i++) {
ret |= g_thermalInterface->IsolateCpu(isolateNum);
}
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_IsolateCpu_0300
* @tc.name testIsolateCpu002
* @tc.desc Test parameters with abnormal input
*/
HWTEST_F(HdfThermalHdiTestAdditional, testIsolateCpu002, Function | MediumTest | Level2)
{
int32_t isolateNum = -1;
int32_t ret = g_thermalInterface->IsolateCpu(isolateNum);
EXPECT_NE(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_IsolateCpu_0400
* @tc.name testIsolateCpu003
* @tc.desc Test parameters with abnormal input
*/
HWTEST_F(HdfThermalHdiTestAdditional, testIsolateCpu003, Function | MediumTest | Level2)
{
int32_t isolateNum = 0;
int32_t ret = g_thermalInterface->IsolateCpu(isolateNum);
EXPECT_NE(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_IsolateCpu_0500
* @tc.name testIsolateCpu004
* @tc.desc Test input param
*/
HWTEST_F(HdfThermalHdiTestAdditional, testIsolateCpu004, Function | MediumTest | Level1)
{
int32_t isolateNum = 0x7fffffff;
int32_t ret = g_thermalInterface->IsolateCpu(isolateNum);
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_IsolateCpu_0600
* @tc.name testIsolateCpu005
* @tc.desc Test input param
*/
HWTEST_F(HdfThermalHdiTestAdditional, testIsolateCpu005, Function | MediumTest | Level1)
{
int32_t isolateNum = 3;
int32_t ret = g_thermalInterface->IsolateCpu(isolateNum);
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_Register_0200
* @tc.name testRegister001
* @tc.desc Reliability of function(Register)
*/
HWTEST_F(HdfThermalHdiTestAdditional, testRegister001, Function | MediumTest | Level1)
{
int i = 0;
int32_t ret = 0;
for (i = 0; i < 1000; i++) {
ret |= g_thermalInterface->Register(g_callback);
g_thermalInterface->Unregister();
}
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_Register_0200
* @tc.name testRegister002
* @tc.desc Test parameters with abnormal input
*/
HWTEST_F(HdfThermalHdiTestAdditional, testRegister002, Function | MediumTest | Level2)
{
int32_t ret;
ret = g_thermalInterface->Register(nullptr);
EXPECT_NE(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_Unregister_0200
* @tc.name testUnregister001
* @tc.desc Reliability of function(Unregister)
*/
HWTEST_F(HdfThermalHdiTestAdditional, testUnregister001, Function | MediumTest | Level1)
{
int i = 0;
int32_t ret = 0;
for (i = 0; i < 1000; i++) {
g_thermalInterface->Register(g_callback);
ret |= g_thermalInterface->Unregister();
}
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_Unregister_0300
* @tc.name testUnregister002
* @tc.desc Test parameters with abnormal input
*/
HWTEST_F(HdfThermalHdiTestAdditional, testUnregister002, Function | MediumTest | Level2)
{
int32_t ret = g_thermalInterface->Unregister();
EXPECT_NE(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_RegisterFanCallback_0200
* @tc.name testRegisterFanCallback001
* @tc.desc Reliability of function(RegisterFanCallback)
*/
HWTEST_F(HdfThermalHdiTestAdditional, testRegisterFanCallback001, Function | MediumTest | Level1)
{
int i = 0;
int32_t ret = 0;
for (i = 0; i < 1000; i++) {
ret |= g_thermalInterface->RegisterFanCallback(g_fanCallback);
g_thermalInterface->UnregisterFanCallback();
}
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_RegisterFanCallback_0300
* @tc.name testRegisterFanCallback002
* @tc.desc Test parameters with abnormal input
*/
HWTEST_F(HdfThermalHdiTestAdditional, testRegisterFanCallback002, Function | MediumTest | Level2)
{
int32_t ret = g_thermalInterface->RegisterFanCallback(nullptr);
EXPECT_NE(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_UnregisterFanCallback_0200
* @tc.name testUnregisterFanCallback001
* @tc.desc Test input param
*/
HWTEST_F(HdfThermalHdiTestAdditional, testUnregisterFanCallback001, Function | MediumTest | Level1)
{
int i = 0;
int32_t ret = 0;
for (i = 0; i < 1000; i++) {
g_thermalInterface->RegisterFanCallback(g_fanCallback);
ret |= g_thermalInterface->UnregisterFanCallback();
}
EXPECT_EQ(0, ret);
}
/**
* @tc.number SUB_Powermgr_Thermal_UnregisterFanCallback_0300
* @tc.name testUnregisterFanCallback002
* @tc.desc Test parameters with abnormal input
*/
HWTEST_F(HdfThermalHdiTestAdditional, testUnregisterFanCallback002, Function | MediumTest | Level2)
{
int32_t ret = g_thermalInterface->UnregisterFanCallback();
EXPECT_NE(0, ret);
}
} // namespace

View File

@ -20,6 +20,9 @@ group("startup") {
#"partitionslot:HatsStartupPartitionSlotTest"
]
} else {
deps = [ "partitionslot:HatsStartupPartitionSlotTest" ]
deps = [
"partitionslot:HatsStartupPartitionSlotTest",
"partitionslot_additional:HatsStartupPartitionSlotAdditionalTest",
]
}
}

View File

@ -0,0 +1,45 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/config/features.gni")
import("//build/ohos_var.gni")
import("//build/test.gni")
import("//test/xts/tools/build/suite.gni")
ohos_moduletest_suite("HatsStartupPartitionSlotAdditionalTest") {
module_out_path = "startup/partitionslot"
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
include_dirs = [
"./include",
"//third_party/googletest/googletest/include/gtest",
]
sources = [ "./src/partitionslot_test.cpp" ]
deps = [ "//third_party/googletest:gtest_main" ]
external_deps = [
"c_utils:utils",
"drivers_interface_partitionslot:libpartitionslot_proxy_1.0",
"hdf_core:libhdf_host",
"hdf_core:libhdf_ipc_adapter",
"hdf_core:libhdf_utils",
"hdf_core:libhdi",
"hilog:libhilog",
]
}

View File

@ -0,0 +1,18 @@
{
"kits": [
{
"push": [
"HatsStartupPartitionSlotAdditionalTest->/data/local/tmp/HatsStartupPartitionSlotAdditionalTest"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "HatsStartupPartitionSlotAdditionalTest",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for HatsStartupPartitionSlotAdditionalTest Tests"
}

View File

@ -0,0 +1,260 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "hdf_log.h"
#include "idevmgr_hdi.h"
#include "v1_0/ipartition_slot.h"
#include <gtest/gtest.h>
#include <osal_mem.h>
#include <unistd.h>
using namespace testing;
using namespace testing::ext;
using namespace OHOS::HDI::Partitionslot::V1_0;
using OHOS::HDI::DeviceManager::V1_0::IDeviceManager;
class StartupPartitionSlotTestAdditional : public testing::Test {
public:
static void SetUpTestCase()
{
auto devmgr = IDeviceManager::Get();
if (devmgr != nullptr) {
devmgr->LoadDevice("partition_slot_service");
} else {
std::cout << "Get devmgr failed" << std::endl;
}
}
static void TearDownTestCase()
{
auto devmgr = IDeviceManager::Get();
if (devmgr != nullptr) {
devmgr->UnloadDevice("partition_slot_service");
} else {
std::cout << "Get devmgr failed" << std::endl;
}
}
void SetUp() {}
void TearDown() {}
};
/**
* @tc.number: SUB_Startup_PartitionSlot_GetCurrentSlot_0100
* @tc.name: testPartitionSlotGetCurrentSlot001
* @tc.desc: GetCurrentSlot, numOfSlots is 1, currentSlo is 0
*/
HWTEST_F(StartupPartitionSlotTestAdditional, testPartitionSlotGetCurrentSlot001, Function | MediumTest | Level1)
{
std::cout << "begin get currentslot by service" << std::endl;
int numOfSlots = 1;
int currentSlot = 0;
for (int i = 0; i < 100; i++) {
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->GetCurrentSlot(currentSlot, numOfSlots) == 0);
}
}
/**
* @tc.number: SUB_Startup_PartitionSlot_GetCurrentSlot_0200
* @tc.name: testPartitionSlotGetCurrentSlot002
* @tc.desc: GetCurrentSlot, numOfSlots is 0, currentSlo is 1
*/
HWTEST_F(StartupPartitionSlotTestAdditional, testPartitionSlotGetCurrentSlot002, Function | MediumTest | Level1)
{
std::cout << "begin get currentslot by service" << std::endl;
int numOfSlots = 0;
int currentSlot = 1;
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->GetCurrentSlot(currentSlot, numOfSlots) == 0);
}
/**
* @tc.number: SUB_Startup_PartitionSlot_GetCurrentSlot_0300
* @tc.name: testPartitionSlotGetCurrentSlot003
* @tc.desc: GetCurrentSlot, numOfSlots is 1, currentSlo is -1
*/
HWTEST_F(StartupPartitionSlotTestAdditional, testPartitionSlotGetCurrentSlot003, Function | MediumTest | Level1)
{
std::cout << "begin get currentslot by service" << std::endl;
int numOfSlots = 1;
int currentSlot = -1;
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->GetCurrentSlot(currentSlot, numOfSlots) == 0);
}
/**
* @tc.number: SUB_Startup_PartitionSlot_GetCurrentSlot_0400
* @tc.name: testPartitionSlotGetCurrentSlot004
* @tc.desc: GetCurrentSlot, numOfSlots is 2, currentSlo is -1
*/
HWTEST_F(StartupPartitionSlotTestAdditional, testPartitionSlotGetCurrentSlot004, Function | MediumTest | Level1)
{
std::cout << "begin get currentslot by service" << std::endl;
int numOfSlots = 2;
int currentSlot = -1;
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->GetCurrentSlot(currentSlot, numOfSlots) == 0);
}
/**
* @tc.number: SUB_Startup_PartitionSlot_GetCurrentSlot_0500
* @tc.name: testPartitionSlotGetCurrentSlot005
* @tc.desc: GetCurrentSlot, numOfSlots is 2, currentSlo is 1
*/
HWTEST_F(StartupPartitionSlotTestAdditional, testPartitionSlotGetCurrentSlot005, Function | MediumTest | Level1)
{
std::cout << "begin get currentslot by service" << std::endl;
int numOfSlots = 2;
int currentSlot = 1;
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->GetCurrentSlot(currentSlot, numOfSlots) == 0);
}
/**
* @tc.number: SUB_Startup_PartitionSlot_GetCurrentSlot_0600
* @tc.name: testPartitionSlotGetCurrentSlot006
* @tc.desc: GetCurrentSlot, numOfSlots is 3, currentSlo is -1
*/
HWTEST_F(StartupPartitionSlotTestAdditional, testPartitionSlotGetCurrentSlot006, Function | MediumTest | Level1)
{
std::cout << "begin get currentslot by service" << std::endl;
int numOfSlots = 3;
int currentSlot = -1;
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->GetCurrentSlot(currentSlot, numOfSlots) == 0);
}
/**
* @tc.number: SUB_Startup_PartitionSlot_GetCurrentSlot_0700
* @tc.name: testPartitionSlotGetCurrentSlot007
* @tc.desc: GetCurrentSlot, numOfSlots is 3, currentSlo is 1
*/
HWTEST_F(StartupPartitionSlotTestAdditional, testPartitionSlotGetCurrentSlot007, Function | MediumTest | Level1)
{
std::cout << "begin get currentslot by service" << std::endl;
int numOfSlots = 3;
int currentSlot = 1;
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->GetCurrentSlot(currentSlot, numOfSlots) == 0);
}
/**
* @tc.number: SUB_Startup_PartitionSlot_GetCurrentSlot_0800
* @tc.name: testPartitionSlotGetCurrentSlot008
* @tc.desc: GetCurrentSlot, numOfSlots is 3, currentSlo is 2
*/
HWTEST_F(StartupPartitionSlotTestAdditional, testPartitionSlotGetCurrentSlot008, Function | MediumTest | Level1)
{
std::cout << "begin get currentslot by service" << std::endl;
int numOfSlots = 3;
int currentSlot = 2;
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->GetCurrentSlot(currentSlot, numOfSlots) == 0);
}
/**
* @tc.number: SUB_Startup_PartitionSlot_GetCurrentSlot_0900
* @tc.name: testPartitionSlotGetCurrentSlot009
* @tc.desc: GetCurrentSlot, numOfSlots is 2, currentSlo is 3
*/
HWTEST_F(StartupPartitionSlotTestAdditional, testPartitionSlotGetCurrentSlot009, Function | MediumTest | Level1)
{
std::cout << "begin get currentslot by service" << std::endl;
int numOfSlots = 2;
int currentSlot = 3;
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->GetCurrentSlot(currentSlot, numOfSlots) == 0);
}
/**
* @tc.number: SUB_Startup_PartitionSlot_GetSlotSuffix_0100
* @tc.name: testPartitionSlotGetSlotSuffix001
* @tc.desc: GetSlotSuffix, slot is 2147483647
*/
HWTEST_F(StartupPartitionSlotTestAdditional, testPartitionSlotGetSlotSuffix001, Function | MediumTest | Level1)
{
std::cout << "begin get suffix by service" << std::endl;
std::string suffix = "";
int slot = 2147483647;
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->GetSlotSuffix(slot, suffix) == 0);
}
/**
* @tc.number: SUB_Startup_PartitionSlot_GetSlotSuffix_0200
* @tc.name: testPartitionSlotGetSlotSuffix002
* @tc.desc: GetSlotSuffix, slot is -2147483648
*/
HWTEST_F(StartupPartitionSlotTestAdditional, testPartitionSlotGetSlotSuffix002, Function | MediumTest | Level1)
{
std::cout << "begin get suffix by service" << std::endl;
std::string suffix = "";
int slot = -2147483648;
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->GetSlotSuffix(slot, suffix) == 0);
}
/**
* @tc.number: SUB_Startup_PartitionSlot_GetSlotSuffix_0300
* @tc.name: testPartitionSlotGetSlotSuffix003
* @tc.desc: GetSlotSuffix, stability test
*/
HWTEST_F(StartupPartitionSlotTestAdditional, testPartitionSlotGetSlotSuffix003, Function | MediumTest | Level1)
{
std::cout << "begin get suffix by service" << std::endl;
std::string suffix = "";
int slot = 2;
for (int i = 0; i < 100; i++) {
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->GetSlotSuffix(slot, suffix) == 0);
}
}
/**
* @tc.number: SUB_Startup_PartitionSlot_SetActiveSlot_0200
* @tc.name: testPartitionSlotSetActiveSlot002
* @tc.desc: SetActiveSlot, slot is -2147483648
*/
HWTEST_F(StartupPartitionSlotTestAdditional, testPartitionSlotSetActiveSlot002, Function | MediumTest | Level1)
{
std::cout << "begin set active slot by service" << std::endl;
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->SetActiveSlot(-2147483648) != 0);
}
/**
* @tc.number: SUB_Startup_PartitionSlot_SetSlotUnbootable_0200
* @tc.name: testPartitionSlotSetSlotUnbootable002
* @tc.desc: SetSlotUnbootable, slot is -2147483648
*/
HWTEST_F(StartupPartitionSlotTestAdditional, testPartitionSlotSetSlotUnbootable002, Function | MediumTest | Level1)
{
std::cout << "begin set unbootable slot by service" << std::endl;
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
ASSERT_TRUE(partitionslot != nullptr);
ASSERT_TRUE(partitionslot->SetSlotUnbootable(-2147483648) != 0);
}

View File

@ -54,8 +54,7 @@ ohos_moduletest_suite("HatsUserIamFaceAuthTest") {
"c_utils:utils",
"drivers_interface_camera:libbuffer_producer_sequenceable_1.0",
"drivers_interface_face_auth:face_auth_idl_headers",
"graphic_2d:surface",
"graphic_chipsetsdk:surface",
"graphic_surface:surface",
"hilog:libhilog",
"ipc:ipc_core",
]