未验证 提交 fa36c881 编写于 作者: O openharmony_ci 提交者: Gitee

回退 'Pull Request !9049 : 【gn 切hvigor】PART4_FA_storage'

上级 9f629aa7
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (C) 2022 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
......@@ -13,11 +13,23 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_app_suite("storagefileiov9_js_test") {
test_hap = true
testonly = true
ohos_js_hap_suite("storagefileiov9_js_test") {
hap_profile = "./src/main/config.json"
deps = [
":storagefileiov9_js_assets",
":storagefileiov9_js_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsStorageFileIoV9JSTest"
subsystem_name = "filemanagement"
part_name = "file_api"
certificate_profile = "./signature/openharmony_sx.p7b"
}
ohos_js_assets("storagefileiov9_js_assets") {
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("storagefileiov9_js_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for storage filefs Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"shell-timeout": "600000",
"bundle-name": "ohos.acts.storage.fileiov9",
"package-name": "ohos.acts.storage.fileiov9_test"
},
"kits": [
{
"test-file-name": ["ActsStorageFileIoV9JSTest.hap"],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
{
"description": "Configuration for storage filefs Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"shell-timeout": "600000",
"bundle-name": "ohos.acts.storage.fileiov9",
"package-name": "ohos.acts.storage.fileiov9"
},
"kits": [
{
"test-file-name": ["ActsStorageFileIoV9JSTest.hap"],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
/**
* 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.
*/
{
"app": {
"signingConfigs": [
],
"compileSdkVersion": 10,
"compatibleSdkVersion": 10,
"products": [
{
"name": "default",
"signingConfig": "default"
}
]
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}
\ No newline at end of file
/**
* 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.
*/
{
"apiType": 'faMode',
"buildOption": {
},
"targets": [
{
"name": "default",
},
{
"name": "ohosTest",
}
]
}
\ No newline at end of file
/**
* 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.
*/
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
export { legacyHapTasks } from '@ohos/hvigor-ohos-plugin';
/**
* 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.
*/
{
"license": "",
"devDependencies": {},
"author": "",
"name": "entry",
"description": "Please describe the basic information.",
"main": "",
"version": "1.0.0",
"dependencies": {}
}
{
"app":{
"bundleName":"ohos.acts.storage.fileiov9",
"vendor":"example",
"version":{
"code":1000000,
"name":"1.0.0"
}
},
"deviceConfig":{
},
"module":{
"package":"ohos.acts.storage.fileiov9",
"name":".entry",
"mainAbility":".MainAbility",
"deviceType":[
"default",
"tablet"
],
"distro":{
"deliveryWithInstall":true,
"installationFree":true,
"moduleName":"entry",
"moduleType":"entry"
},
"abilities":[
{
"description":"$string:MainAbility_desc",
"formsEnabled":false,
"icon":"$media:icon",
"label":"$string:MainAbility_label",
"launchType":"standard",
"name":".MainAbility",
"orientation":"unspecified",
"skills":[
{
"actions":[
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
],
"srcLanguage":"js",
"srcPath":"MainAbility",
"type":"page",
"visible":true
}
],
"js":[
{
"name":".MainAbility",
"pages":[
"pages/index/index"
],
"window":{
"autoDesignWidth":false,
"designWidth":720
}
}
]
}
}
\ No newline at end of file
/**
* 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 hilog from '@ohos.hilog';
export default {
onCreate() {
hilog.info(0x0000, 'testTag', '%{public}s', 'Application onCreate');
},
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'Application onDestroy');
},
}
/*
* Copyright (c) 2022 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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.title {
font-size: 40px;
color: #000000;
opacity: 0.9;
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFFFFF;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url("/common/images/Wallpaper.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.title {
font-size: 100px;
color: #FFFFFF;
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
/*
* Copyright (c) 2022 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.
*/
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/**
* 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
{
"app":{
"bundleName":"ohos.acts.storage.fileiov9",
"vendor":"example",
"version":{
"code":1000000,
"name":"1.0.0"
}
},
"deviceConfig":{
},
"module":{
"package":"ohos.acts.storage.fileiov9_test",
"name":".entry_test",
"mainAbility":".TestAbility",
"deviceType":[
"default",
"tablet"
],
"testRunner":{
"name":"OpenHarmonyTestRunner",
"srcPath":"TestRunner"
},
"distro":{
"deliveryWithInstall":true,
"installationFree":true,
"moduleName":"entry_test",
"moduleType":"feature"
},
"abilities":[
{
"description":"$string:TestAbility_desc",
"formsEnabled":false,
"icon":"$media:icon",
"label":"$string:TestAbility_label",
"launchType":"standard",
"name":".TestAbility",
"orientation":"unspecified",
"skills":[
{
"actions":[
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
],
"srcLanguage":"js",
"srcPath":"TestAbility",
"type":"page",
"visible":true
}
],
"js":[
{
"name":".TestAbility",
"pages":[
"pages/index/index"
],
"window":{
"autoDesignWidth":false,
"designWidth":720
}
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "storagefilefsjstest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
/**
* 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.
*/
{
"hvigorVersion": "2.0.0",
"dependencies": {
"@ohos/hvigor-ohos-plugin": "2.0.0"
}
}
/**
* 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.
*/
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
export { legacyAppTasks } from '@ohos/hvigor-ohos-plugin';
\ No newline at end of file
# 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.
#!/bin/bash
# ----------------------------------------------------------------------------
# Hvigor startup script, version 1.0.0
#
# Required ENV vars:
# ------------------
# NODE_HOME - location of a Node home dir
# or
# Add /usr/local/nodejs/bin to the PATH environment variable
# ----------------------------------------------------------------------------
HVIGOR_APP_HOME=$(dirname $(readlink -f $0))
HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js
warn() {
echo ""
echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
}
error() {
echo ""
echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
}
fail() {
error "$@"
exit 1
}
# Determine node to start hvigor wrapper script
if [ -n "${NODE_HOME}" ];then
EXECUTABLE_NODE="${NODE_HOME}/bin/node"
if [ ! -x "$EXECUTABLE_NODE" ];then
fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed"
fi
else
EXECUTABLE_NODE="node"
which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path"
fi
# Check hvigor wrapper script
if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then
fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}"
fi
# start hvigor-wrapper script
exec "${EXECUTABLE_NODE}" \
"${HVIGOR_WRAPPER_SCRIPT}" "$@"
@rem Copyright (C) 2023 Huawei Device Co., Ltd.
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Hvigor startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js
set NODE_EXE=node.exe
goto start
:start
@rem Find node.exe
if defined NODE_HOME goto findNodeFromNodeHome
%NODE_EXE% --version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
echo.
echo Please set the NODE_HOME variable in your environment to match the
echo location of your NodeJs installation.
goto fail
:findNodeFromNodeHome
set NODE_HOME=%NODE_HOME:"=%
set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE%
if exist "%NODE_EXE_PATH%" goto execute
echo.
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
echo.
echo Please set the NODE_HOME variable in your environment to match the
echo location of your NodeJs installation.
goto fail
:execute
@rem Execute hvigor
"%NODE_EXE%" %WRAPPER_MODULE_PATH% %*
:fail
exit /b 1
/**
* 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.
*/
{
"license": "",
"devDependencies": {
"@ohos/hypium": "1.0.6"
},
"author": "",
"name": "myapplication454434",
"description": "Please describe the basic information.",
"main": "",
"version": "1.0.0",
"dependencies": {}
}
{
"app": {
"bundleName": "ohos.acts.storage.fileiov9",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.storage.fileiov9",
"name": ".entry",
"deviceType": [
"default",
"tablet"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
/*
* Copyright (C) 2022 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.
*/
export default {
onCreate() {
console.info('ohos.acts.storage.fileio onCreate');
},
onDestroy() {
console.info('ohos.acts.storage.fileio onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
{
"strings": {
"hello": "Hello",
"world": "Test"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
{
"strings": {
"hello": "您好",
"world": "测试"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
/*
* Copyright (C) 2022 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 app from '@system.app'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ''
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
},
}
/**
* 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 hilog from '@ohos.hilog';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
export default {
onCreate() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestApplication onCreate');
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestApplication onDestroy');
}
};
/*
* Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 Huawei Device Co., Ltd.
/*
* Copyright (c) 2022 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
......@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
......@@ -20,6 +21,3 @@ export default {
this.title = this.$t('strings.world');
}
}
/**
* Copyright (c) 2023 Huawei Device Co., Ltd.
/*
* Copyright (c) 2022 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
......@@ -12,30 +12,48 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare');
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', data.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', data.exitCode ?? '');
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
\ No newline at end of file
};
/**
* 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 fileIO from '@ohos.file.fs';
import util from '@ohos.util';
import featureAbility from '@ohos.ability.featureAbility';
export const FILE_CONTENT = 'hello world';
import {
describe, it, expect
}
from '@ohos/hypium'
export function prepareFile(fpath, content) {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE)
fileIO.truncateSync(file.fd)
fileIO.writeSync(file.fd, content)
fileIO.fsyncSync(file.fd)
fileIO.closeSync(file)
return true
}
catch (e) {
console.log('Failed to prepareFile for ' + e)
return false
}
}
export function prepare200MFile(fpath) {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE)
fileIO.truncateSync(file.fd)
let bf = new ArrayBuffer(1024 * 1024 * 20);
for (let i = 0; i < 10; i++) {
let position = bf.byteLength * i;
let writeLen = fileIO.writeSync(file.fd, bf, { offset: 0, length: bf.byteLength, position: position, encoding: 'utf-8' });
}
fileIO.fsyncSync(file.fd)
fileIO.closeSync(file)
return true
}
catch (e) {
console.log('Failed to prepare200MFile for ' + e)
return false
}
}
export async function nextFileName(testName) {
let context = featureAbility.getContext();
let data = await context.getCacheDir();
let BASE_PATH = data + '/';
return BASE_PATH + testName + '_' + randomString(testName.length);
}
export async function fileName(testName) {
let context = featureAbility.getContext();
let data = await context.getFilesDir();
let BASE_PATH = data + '/';
return BASE_PATH + testName + '_' + randomString(testName.length);
}
export function randomString(num) {
let len= num;
var $chars = 'aaaabbbbcccc';
var maxPos = $chars.length;
var pwd = '';
for (var i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
}
function isIntNum(val) {
return typeof val === 'number' && val % 1 === 0;
}
function isBigInt(val) {
return typeof val === 'bigint';
}
function isString(str) {
return (typeof str == 'string') && str.constructor == String;
}
export {
fileIO,
isIntNum,
isBigInt,
isString,
describe,
it,
expect,
util
/*
* 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 fileIO from '@ohos.file.fs';
import util from '@ohos.util';
import featureAbility from '@ohos.ability.featureAbility';
export const FILE_CONTENT = 'hello world';
import {
describe, it, expect
}
from '@ohos/hypium'
export function prepareFile(fpath, content) {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE)
fileIO.truncateSync(file.fd)
fileIO.writeSync(file.fd, content)
fileIO.fsyncSync(file.fd)
fileIO.closeSync(file)
return true
}
catch (e) {
console.log('Failed to prepareFile for ' + e)
return false
}
}
export function prepare200MFile(fpath) {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE)
fileIO.truncateSync(file.fd)
let bf = new ArrayBuffer(1024 * 1024 * 20);
for (let i = 0; i < 10; i++) {
let position = bf.byteLength * i;
let writeLen = fileIO.writeSync(file.fd, bf, { offset: 0, length: bf.byteLength, position: position, encoding: 'utf-8' });
}
fileIO.fsyncSync(file.fd)
fileIO.closeSync(file)
return true
}
catch (e) {
console.log('Failed to prepare200MFile for ' + e)
return false
}
}
export async function nextFileName(testName) {
let context = featureAbility.getContext();
let data = await context.getCacheDir();
let BASE_PATH = data + '/';
return BASE_PATH + testName + '_' + randomString(testName.length);
}
export async function fileName(testName) {
let context = featureAbility.getContext();
let data = await context.getFilesDir();
let BASE_PATH = data + '/';
return BASE_PATH + testName + '_' + randomString(testName.length);
}
export function randomString(num) {
let len= num;
var $chars = 'aaaabbbbcccc';
var maxPos = $chars.length;
var pwd = '';
for (var i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
}
function isIntNum(val) {
return typeof val === 'number' && val % 1 === 0;
}
function isBigInt(val) {
return typeof val === 'bigint';
}
function isString(str) {
return (typeof str == 'string') && str.constructor == String;
}
export {
fileIO,
isIntNum,
isBigInt,
isString,
describe,
it,
expect,
util
};
\ No newline at end of file
/**
* 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 fileIOAccess from './members/access.test.js'
import fileIOClose from './members/close.test.js'
import fileIOCopyDir from './members/copyDir.test'
import fileIOCopyfile from './members/copyFile.test.js'
import fileIOCreateStream from './members/createStream.test.js'
import fileIOFdatasync from './members/fdatasync.test.js'
import fileIOFdOpenStream from './members/fdopenStream.test.js'
import fileIOFileLock from './members/fileLock.test.js'
import fileIOFsync from './members/fsync.test.js'
import fileIOHash from './members/hash.test.js'
import fileIOListfile from './members/listFile.test.js'
import fileIOLstat from './members/lstat.test.js'
import fileIOMkdir from './members/mkdir.test.js'
import fileIOMkdtemp from './members/mkdtemp.test.js'
import fileIOMoveDir from './members/moveDir.test.js'
import fileIOMoveFile from './members/moveFile.test.js'
import fileIOOpen from './members/open.test.js'
import fileIORead from './members/read.test.js'
import fileIOReadtext from './members/readtext.test.js'
import fileIORename from './members/rename.test.js'
import fileIORmdir from './members/rmdir.test'
import fileIOStat from './members/stat.test.js'
import fileIOStreamClose from './class_stream/close.test.js'
import fileIOStreamFlush from './class_stream/flush.test.js'
import fileIOStreamRead from './class_stream/read.test.js'
import fileIOStreamWrite from './class_stream/write.test.js'
import fileIOSymlink from './members/symlink.test.js'
import fileIOTruncate from './members/truncate.test.js'
import fileIOUnlink from './members/unlink.test.js'
import fileIOWrite from './members/write.test.js'
import fileIORW from './members/filerw.test.js'
export default function testsuite() {
fileIOAccess()
fileIOClose()
fileIOCopyDir()
fileIOCopyfile()
fileIOCreateStream()
fileIOFdatasync()
fileIOFdOpenStream()
fileIOFileLock()
fileIOFsync()
fileIOHash()
fileIOListfile()
fileIOLstat()
fileIOMkdir()
fileIOMkdtemp()
fileIOMoveDir()
fileIOMoveFile()
fileIOOpen()
fileIORead()
fileIOReadtext()
fileIORename()
fileIORmdir()
fileIOStat()
fileIOStreamClose()
fileIOStreamFlush()
fileIOStreamRead()
fileIOStreamWrite()
fileIOSymlink()
fileIOTruncate()
fileIOUnlink()
fileIOWrite()
fileIORW()
}
/*
* 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 fileIOAccess from './members/access.test.js'
import fileIOClose from './members/close.test.js'
import fileIOCopyDir from './members/copyDir.test'
import fileIOCopyfile from './members/copyFile.test.js'
import fileIOCreateStream from './members/createStream.test.js'
import fileIOFdatasync from './members/fdatasync.test.js'
import fileIOFdOpenStream from './members/fdopenStream.test.js'
import fileIOFileLock from './members/fileLock.test.js'
import fileIOFsync from './members/fsync.test.js'
import fileIOHash from './members/hash.test.js'
import fileIOListfile from './members/listFile.test.js'
import fileIOLstat from './members/lstat.test.js'
import fileIOMkdir from './members/mkdir.test.js'
import fileIOMkdtemp from './members/mkdtemp.test.js'
import fileIOMoveDir from './members/moveDir.test.js'
import fileIOMoveFile from './members/moveFile.test.js'
import fileIOOpen from './members/open.test.js'
import fileIORead from './members/read.test.js'
import fileIOReadtext from './members/readtext.test.js'
import fileIORename from './members/rename.test.js'
import fileIORmdir from './members/rmdir.test'
import fileIOStat from './members/stat.test.js'
import fileIOStreamClose from './class_stream/close.test.js'
import fileIOStreamFlush from './class_stream/flush.test.js'
import fileIOStreamRead from './class_stream/read.test.js'
import fileIOStreamWrite from './class_stream/write.test.js'
import fileIOSymlink from './members/symlink.test.js'
import fileIOTruncate from './members/truncate.test.js'
import fileIOUnlink from './members/unlink.test.js'
import fileIOWrite from './members/write.test.js'
import fileIORW from './members/filerw.test.js'
export default function testsuite() {
fileIOAccess()
fileIOClose()
fileIOCopyDir()
fileIOCopyfile()
fileIOCreateStream()
fileIOFdatasync()
fileIOFdOpenStream()
fileIOFileLock()
fileIOFsync()
fileIOHash()
fileIOListfile()
fileIOLstat()
fileIOMkdir()
fileIOMkdtemp()
fileIOMoveDir()
fileIOMoveFile()
fileIOOpen()
fileIORead()
fileIOReadtext()
fileIORename()
fileIORmdir()
fileIOStat()
fileIOStreamClose()
fileIOStreamFlush()
fileIOStreamRead()
fileIOStreamWrite()
fileIOSymlink()
fileIOTruncate()
fileIOUnlink()
fileIOWrite()
fileIORW()
}
/**
* 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 {
fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect,
} from '../Common';
export default function fileIOStreamClose() {
describe('fileIO_fs_stream_close', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0000
* @tc.name fileIO_test_stream_close_sync_000
* @tc.desc Test the closeSync() interface of class Stream.
* Open a file stream, close file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_stream_close_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_close_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_stream_close_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0100
* @tc.name fileIO_test_stream_close_sync_001
* @tc.desc Test the closeSync() interface of class Stream.
* Invalid parameter, don't requrie any parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_stream_close_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_close_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let sr = fileIO.createStreamSync(fpath, 'r');
try {
expect(sr !== null).assertTrue();
sr.closeSync(1);
expect(false).assertTrue();
} catch (e) {
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_close_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0200
* @tc.name fileIO_test_stream_close_sync_002
* @tc.desc Test the closeSync() interface of class Stream.
* The file stream has been closed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_stream_close_sync_002', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_close_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let sr = fileIO.createStreamSync(fpath, 'r');
try {
expect(sr !== null).assertTrue();
sr.closeSync();
sr.closeSync();
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_close_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
}
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0000
* @tc.name fileIO_test_stream_close_async_000
* @tc.desc Test the close() interface of class Stream. Promise.
* Open a file stream, close file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
* @tc.require
*/
it('fileIO_test_stream_close_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_close_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
await sr.close();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_stream_close_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0100
* @tc.name fileIO_test_stream_close_async_001
* @tc.desc Test the close() interface of class Stream. Callback.
* Open a file stream, close file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
* @tc.require
*/
it('fileIO_test_stream_close_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_close_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
sr.close((err) => {
if (err) {
console.log('fileIO_test_stream_close_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
fileIO.unlinkSync(fpath);
})
done();
} catch (e) {
console.log('fileIO_test_stream_close_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0200
* @tc.name fileIO_test_stream_close_async_002
* @tc.desc Test the close() interface of class Stream. Promise.
* The file stream has been closed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_stream_close_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_close_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
await sr.close();
await sr.close();
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_close_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0300
* @tc.name fileIO_test_stream_close_async_003
* @tc.desc Test the close() interface of class Stream. Promise.
* Invalid parameter, don't requrie any parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_stream_close_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_close_async_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
await sr.close(1);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_close_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
})
}
/*
* 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 {
fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect,
} from '../Common';
export default function fileIOStreamClose() {
describe('fileIO_fs_stream_close', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0000
* @tc.name fileIO_test_stream_close_sync_000
* @tc.desc Test the closeSync() interface of class Stream.
* Open a file stream, close file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_stream_close_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_close_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_stream_close_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0100
* @tc.name fileIO_test_stream_close_sync_001
* @tc.desc Test the closeSync() interface of class Stream.
* Invalid parameter, don't requrie any parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_stream_close_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_close_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let sr = fileIO.createStreamSync(fpath, 'r');
try {
expect(sr !== null).assertTrue();
sr.closeSync(1);
expect(false).assertTrue();
} catch (e) {
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_close_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0200
* @tc.name fileIO_test_stream_close_sync_002
* @tc.desc Test the closeSync() interface of class Stream.
* The file stream has been closed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_stream_close_sync_002', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_close_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let sr = fileIO.createStreamSync(fpath, 'r');
try {
expect(sr !== null).assertTrue();
sr.closeSync();
sr.closeSync();
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_close_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
}
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0000
* @tc.name fileIO_test_stream_close_async_000
* @tc.desc Test the close() interface of class Stream. Promise.
* Open a file stream, close file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
* @tc.require
*/
it('fileIO_test_stream_close_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_close_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
await sr.close();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_stream_close_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0100
* @tc.name fileIO_test_stream_close_async_001
* @tc.desc Test the close() interface of class Stream. Callback.
* Open a file stream, close file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
* @tc.require
*/
it('fileIO_test_stream_close_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_close_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
sr.close((err) => {
if (err) {
console.log('fileIO_test_stream_close_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
fileIO.unlinkSync(fpath);
})
done();
} catch (e) {
console.log('fileIO_test_stream_close_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0200
* @tc.name fileIO_test_stream_close_async_002
* @tc.desc Test the close() interface of class Stream. Promise.
* The file stream has been closed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_stream_close_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_close_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
await sr.close();
await sr.close();
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_close_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0300
* @tc.name fileIO_test_stream_close_async_003
* @tc.desc Test the close() interface of class Stream. Promise.
* Invalid parameter, don't requrie any parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_stream_close_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_close_async_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
await sr.close(1);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_close_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
})
}
/**
* 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 {
fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect,
} from '../Common';
export default function fileIOStreamFlush() {
describe('fileIO_fs_stream_flush', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_SYNC_0000
* @tc.name fileIO_test_stream_flush_sync_000
* @tc.desc Test the flushSync() interface of class Stream.
* Refresh file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_stream_flush_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_flush_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sr.flushSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_stream_flush_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_SYNC_0100
* @tc.name fileIO_test_stream_flush_sync_001
* @tc.desc Test the flushSync() interface of class Stream.
* Invalid parameter, don't requrie any parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_stream_flush_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_flush_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let sr = fileIO.createStreamSync(fpath, 'r+');
try {
expect(sr !== null).assertTrue();
sr.flushSync(1);
expect(false).assertTrue();
} catch (e) {
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_flush_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0000
* @tc.name fileIO_test_stream_flush_async_000
* @tc.desc Test the flush() interface of class Stream. Promise.then().catch()
* Refresh the file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_stream_flush_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_flush_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = await fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sr.flush().then(() => {
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
}).catch((err) => {
console.log('fileIO_test_stream_flush_async_000 error package' + JSON.stringify(err));
expect(false).assertTrue();
});
} catch (e) {
console.log('fileIO_test_stream_flush_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0100
* @tc.name fileIO_test_stream_flush_async_001
* @tc.desc Test the flush() interface of class Stream. Callback.
* Refresh the file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
* @tc.require
*/
it('fileIO_test_stream_flush_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_flush_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = await fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sr.flush((err) => {
if (err) {
console.log('fileIO_test_stream_flush_async_001 error package' + JSON.stringify(err));
expect(false).assertTrue();
}
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
})
} catch (e) {
console.log('fileIO_test_stream_flush_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0100
* @tc.name fileIO_test_stream_flush_async_002
* @tc.desc Test the flush() interface of class Stream. Promise.
* Refresh the file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_stream_flush_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_flush_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let sr = fileIO.createStreamSync(fpath, 'r+');
try {
expect(sr !== null).assertTrue();
await sr.flush(1);
expect(false).assertTrue();
} catch (e) {
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_flush_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
});
}
/*
* 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 {
fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect,
} from '../Common';
export default function fileIOStreamFlush() {
describe('fileIO_fs_stream_flush', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_SYNC_0000
* @tc.name fileIO_test_stream_flush_sync_000
* @tc.desc Test the flushSync() interface of class Stream.
* Refresh file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_stream_flush_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_flush_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sr.flushSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_stream_flush_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_SYNC_0100
* @tc.name fileIO_test_stream_flush_sync_001
* @tc.desc Test the flushSync() interface of class Stream.
* Invalid parameter, don't requrie any parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_stream_flush_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_flush_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let sr = fileIO.createStreamSync(fpath, 'r+');
try {
expect(sr !== null).assertTrue();
sr.flushSync(1);
expect(false).assertTrue();
} catch (e) {
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_flush_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0000
* @tc.name fileIO_test_stream_flush_async_000
* @tc.desc Test the flush() interface of class Stream. Promise.then().catch()
* Refresh the file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_stream_flush_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_flush_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = await fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sr.flush().then(() => {
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
}).catch((err) => {
console.log('fileIO_test_stream_flush_async_000 error package' + JSON.stringify(err));
expect(false).assertTrue();
});
} catch (e) {
console.log('fileIO_test_stream_flush_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0100
* @tc.name fileIO_test_stream_flush_async_001
* @tc.desc Test the flush() interface of class Stream. Callback.
* Refresh the file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
* @tc.require
*/
it('fileIO_test_stream_flush_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_flush_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let sr = await fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sr.flush((err) => {
if (err) {
console.log('fileIO_test_stream_flush_async_001 error package' + JSON.stringify(err));
expect(false).assertTrue();
}
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
})
} catch (e) {
console.log('fileIO_test_stream_flush_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0100
* @tc.name fileIO_test_stream_flush_async_002
* @tc.desc Test the flush() interface of class Stream. Promise.
* Refresh the file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_stream_flush_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_flush_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let sr = fileIO.createStreamSync(fpath, 'r+');
try {
expect(sr !== null).assertTrue();
await sr.flush(1);
expect(false).assertTrue();
} catch (e) {
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_flush_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
});
}
/*
* 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 {
fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, describe, it, expect,
} from '../Common';
export default function fileIOAccess() {
describe('fileIO_fs_access', function () {
/**
* @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0000
* @tc.name fileIO_test_access_sync_000
* @tc.desc Test accessSync() interface.
* This interface shall work properly in normal case.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_access_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_access_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
expect(fileIO.accessSync(fpath)).assertTrue();
let file = fileIO.openSync(fpath);
expect(isIntNum(file.fd)).assertTrue();
let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(readlen == FILE_CONTENT.length).assertTrue();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_access_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0100
* @tc.name fileIO_test_access_sync_001
* @tc.desc Test accessSync() interface.
* The test file is not exist.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_access_sync_001');
try {
let ret = fileIO.accessSync(fpath);
expect(ret === false).assertTrue();
} catch (e) {
console.log('fileIO_test_access_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0200
* @tc.name fileIO_test_access_sync_002
* @tc.desc Test accessSync() interface.
* The test file path is illegal.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_sync_002', 0, async function () {
try {
expect(fileIO.accessSync(-1)).assertTrue();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_access_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0000
* @tc.name fileIO_test_access_async_000
* @tc.desc Test access() interface. Promise.
* Use promise to test that the file is exist. Sync method reads data from file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_access_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ret = await fileIO.access(fpath);
expect(ret === true).assertTrue();
let file = fileIO.openSync(fpath);
expect(isIntNum(file.fd)).assertTrue();
let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(readlen == FILE_CONTENT.length).assertTrue();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_access_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0100
* @tc.name fileIO_test_access_async_001
* @tc.desc Test access() interface. Callback.
* Use callback to test that the file is exist. Sync method reads data from file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_access_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.access(fpath, (err, ret) => {
if (err) {
console.log('fileIO_test_access_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(ret === true).assertTrue();
let file = fileIO.openSync(fpath);
expect(isIntNum(file.fd)).assertTrue();
let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(readlen == FILE_CONTENT.length).assertTrue();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
});
done();
} catch (e) {
console.log('fileIO_test_access_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0200
* @tc.name fileIO_test_access_async_002
* @tc.desc Test access() interface. Promise.
* Async test file does not exist.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_access_async_002');
try {
let ret = await fileIO.access(fpath);
expect(ret === false).assertTrue();
done();
} catch (e) {
console.log('fileIO_test_access_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0300
* @tc.name fileIO_test_access_async_003
* @tc.desc Test access() interface. Callback.
* Async test file does not exist.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_access_async_002');
try {
fileIO.access(fpath, (err, ret) => {
if (err) {
console.log('fileIO_test_access_async_003 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(ret === false).assertTrue();
done();
});
} catch (e) {
console.log('fileIO_test_access_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0400
* @tc.name fileIO_test_access_async_004
* @tc.desc Test access() interface. Promise.
* Invalid path parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_004', 0, async function (done) {
try {
await fileIO.access(-1);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_access_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0500
* @tc.name fileIO_test_access_async_005
* @tc.desc Test access() interface. Callback.
* Invalid path parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_005', 0, async function (done) {
try {
fileIO.access(-1, (err) => {
expect(false).assertTrue();
});
} catch (e) {
console.log('fileIO_test_access_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
});
}
/*
* 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 {
fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, describe, it, expect,
} from '../Common';
export default function fileIOAccess() {
describe('fileIO_fs_access', function () {
/**
* @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0000
* @tc.name fileIO_test_access_sync_000
* @tc.desc Test accessSync() interface.
* This interface shall work properly in normal case.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_access_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_access_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
expect(fileIO.accessSync(fpath)).assertTrue();
let file = fileIO.openSync(fpath);
expect(isIntNum(file.fd)).assertTrue();
let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(readlen == FILE_CONTENT.length).assertTrue();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_access_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0100
* @tc.name fileIO_test_access_sync_001
* @tc.desc Test accessSync() interface.
* The test file is not exist.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_access_sync_001');
try {
let ret = fileIO.accessSync(fpath);
expect(ret === false).assertTrue();
} catch (e) {
console.log('fileIO_test_access_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0200
* @tc.name fileIO_test_access_sync_002
* @tc.desc Test accessSync() interface.
* The test file path is illegal.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_sync_002', 0, async function () {
try {
expect(fileIO.accessSync(-1)).assertTrue();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_access_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0000
* @tc.name fileIO_test_access_async_000
* @tc.desc Test access() interface. Promise.
* Use promise to test that the file is exist. Sync method reads data from file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_access_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ret = await fileIO.access(fpath);
expect(ret === true).assertTrue();
let file = fileIO.openSync(fpath);
expect(isIntNum(file.fd)).assertTrue();
let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(readlen == FILE_CONTENT.length).assertTrue();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_access_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0100
* @tc.name fileIO_test_access_async_001
* @tc.desc Test access() interface. Callback.
* Use callback to test that the file is exist. Sync method reads data from file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_access_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.access(fpath, (err, ret) => {
if (err) {
console.log('fileIO_test_access_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(ret === true).assertTrue();
let file = fileIO.openSync(fpath);
expect(isIntNum(file.fd)).assertTrue();
let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(readlen == FILE_CONTENT.length).assertTrue();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
});
done();
} catch (e) {
console.log('fileIO_test_access_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0200
* @tc.name fileIO_test_access_async_002
* @tc.desc Test access() interface. Promise.
* Async test file does not exist.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_access_async_002');
try {
let ret = await fileIO.access(fpath);
expect(ret === false).assertTrue();
done();
} catch (e) {
console.log('fileIO_test_access_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0300
* @tc.name fileIO_test_access_async_003
* @tc.desc Test access() interface. Callback.
* Async test file does not exist.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_access_async_002');
try {
fileIO.access(fpath, (err, ret) => {
if (err) {
console.log('fileIO_test_access_async_003 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(ret === false).assertTrue();
done();
});
} catch (e) {
console.log('fileIO_test_access_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0400
* @tc.name fileIO_test_access_async_004
* @tc.desc Test access() interface. Promise.
* Invalid path parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_004', 0, async function (done) {
try {
await fileIO.access(-1);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_access_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0500
* @tc.name fileIO_test_access_async_005
* @tc.desc Test access() interface. Callback.
* Invalid path parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_005', 0, async function (done) {
try {
fileIO.access(-1, (err) => {
expect(false).assertTrue();
});
} catch (e) {
console.log('fileIO_test_access_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
});
}
/*
* 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 { fileIO, nextFileName, describe, it, expect } from '../Common';
export default function fileIOMkdtemp() {
describe('fileIO_fs_mkdtemp', function () {
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_SYNC_0000
* @tc.name fileIO_test_mkdtemp_sync_000
* @tc.desc Test mkdtempSync() interface.
* Create a temporary directory, verify the normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_mkdtemp_sync_000', 0, async function () {
let dpath = await nextFileName('fileIO_test_mkdtemp_sync_000');
try {
dpath = dpath + 'XXXXXX';
let res = fileIO.mkdtempSync(dpath);
expect(fileIO.accessSync(res)).assertTrue();
fileIO.rmdirSync(res);
} catch (e) {
console.log('fileIO_test_mkdtemp_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_SYNC_0100
* @tc.name fileIO_test_mkdtemp_sync_001
* @tc.desc Test mkdtempSync() interface.
* The directory should end in XXXXXX.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_sync_001', 0, async function () {
let dpath = await nextFileName('fileIO_test_mkdtemp_sync_000');
try {
fileIO.mkdtempSync(dpath);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_mkdtemp_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_SYNC_0200
* @tc.name fileIO_test_mkdtemp_sync_002
* @tc.desc Test mkdtempSync() interface.
* Missing parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_sync_002', 0, async function () {
try {
fileIO.mkdtempSync();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_mkdtemp_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0000
* @tc.name fileIO_test_mkdtemp_async_000
* @tc.desc Test mkdtemp() interface. Promise.
* Create a temporary directory, verify the normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_000', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_mkdtemp_async_000');
try {
dpath = dpath + 'XXXXXX';
let res = await fileIO.mkdtemp(dpath);
expect(fileIO.accessSync(res)).assertTrue();
fileIO.rmdirSync(res);
done();
} catch (e) {
console.log('fileIO_test_mkdtemp_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0100
* @tc.name fileIO_test_mkdtemp_async_001
* @tc.desc Test mkdtemp() interface. Callback.
* Create a temporary directory, verify the normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_001', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_mkdtemp_async_001');
try {
dpath = dpath + 'XXXXXX';
fileIO.mkdtemp(dpath, (err, res) => {
if (err) {
console.log('fileIO_test_mkdtemp_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(fileIO.accessSync(res)).assertTrue();
fileIO.rmdirSync(res);
done();
});
} catch (e) {
console.log('fileIO_test_mkdtemp_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0200
* @tc.name fileIO_test_mkdtemp_async_002
* @tc.desc Test mkdtemp() interface. Promise.
* The directory should end in XXXXXX.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_002', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_mkdtemp_async_002');
try {
await fileIO.mkdtemp(dpath);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_mkdtemp_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0300
* @tc.name fileIO_test_mkdtemp_async_003
* @tc.desc Test mkdtemp() interface. Callback.
* The directory should end in XXXXXX.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_003', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_mkdtemp_async_003');
try {
fileIO.mkdtemp(dpath, (err) => {
if (err) {
console.log('fileIO_test_mkdtemp_async_003 error package: ' + JSON.stringify(err));
expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_test_mkdtemp_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0400
* @tc.name fileIO_test_mkdtemp_async_004
* @tc.desc Test mkdtemp() interface. Promise.
* Missing parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_004', 0, async function (done) {
try {
await fileIO.mkdtemp();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_mkdtemp_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
});
}
/*
* 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 { fileIO, nextFileName, describe, it, expect } from '../Common';
export default function fileIOMkdtemp() {
describe('fileIO_fs_mkdtemp', function () {
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_SYNC_0000
* @tc.name fileIO_test_mkdtemp_sync_000
* @tc.desc Test mkdtempSync() interface.
* Create a temporary directory, verify the normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_mkdtemp_sync_000', 0, async function () {
let dpath = await nextFileName('fileIO_test_mkdtemp_sync_000');
try {
dpath = dpath + 'XXXXXX';
let res = fileIO.mkdtempSync(dpath);
expect(fileIO.accessSync(res)).assertTrue();
fileIO.rmdirSync(res);
} catch (e) {
console.log('fileIO_test_mkdtemp_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_SYNC_0100
* @tc.name fileIO_test_mkdtemp_sync_001
* @tc.desc Test mkdtempSync() interface.
* The directory should end in XXXXXX.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_sync_001', 0, async function () {
let dpath = await nextFileName('fileIO_test_mkdtemp_sync_000');
try {
fileIO.mkdtempSync(dpath);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_mkdtemp_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_SYNC_0200
* @tc.name fileIO_test_mkdtemp_sync_002
* @tc.desc Test mkdtempSync() interface.
* Missing parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_sync_002', 0, async function () {
try {
fileIO.mkdtempSync();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_mkdtemp_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0000
* @tc.name fileIO_test_mkdtemp_async_000
* @tc.desc Test mkdtemp() interface. Promise.
* Create a temporary directory, verify the normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_000', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_mkdtemp_async_000');
try {
dpath = dpath + 'XXXXXX';
let res = await fileIO.mkdtemp(dpath);
expect(fileIO.accessSync(res)).assertTrue();
fileIO.rmdirSync(res);
done();
} catch (e) {
console.log('fileIO_test_mkdtemp_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0100
* @tc.name fileIO_test_mkdtemp_async_001
* @tc.desc Test mkdtemp() interface. Callback.
* Create a temporary directory, verify the normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_001', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_mkdtemp_async_001');
try {
dpath = dpath + 'XXXXXX';
fileIO.mkdtemp(dpath, (err, res) => {
if (err) {
console.log('fileIO_test_mkdtemp_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(fileIO.accessSync(res)).assertTrue();
fileIO.rmdirSync(res);
done();
});
} catch (e) {
console.log('fileIO_test_mkdtemp_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0200
* @tc.name fileIO_test_mkdtemp_async_002
* @tc.desc Test mkdtemp() interface. Promise.
* The directory should end in XXXXXX.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_002', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_mkdtemp_async_002');
try {
await fileIO.mkdtemp(dpath);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_mkdtemp_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0300
* @tc.name fileIO_test_mkdtemp_async_003
* @tc.desc Test mkdtemp() interface. Callback.
* The directory should end in XXXXXX.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_003', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_mkdtemp_async_003');
try {
fileIO.mkdtemp(dpath, (err) => {
if (err) {
console.log('fileIO_test_mkdtemp_async_003 error package: ' + JSON.stringify(err));
expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_test_mkdtemp_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0400
* @tc.name fileIO_test_mkdtemp_async_004
* @tc.desc Test mkdtemp() interface. Promise.
* Missing parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_004', 0, async function (done) {
try {
await fileIO.mkdtemp();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_mkdtemp_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
});
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
/**
* 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.
*/
{
"apiType": 'faMode',
"buildOption": {
},
"targets": [
{
"name": "default",
},
{
"name": "ohosTest",
}
]
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册