提交 e5729410 编写于 作者: Q qu-xianfei

add gn->hvigor

Signed-off-by: Nqu-xianfei <quxianfei@huawei.com>
上级 b76c111b
......@@ -12,11 +12,23 @@
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_app_suite("ActsCommonEventManagerTest") {
test_hap = true
testonly = true
ohos_js_hap_suite("ActsCommonEventManagerTest") {
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsCommonEventManagerTest"
subsystem_name = "notification"
part_name = "common_event_service"
certificate_profile = "./signature/openharmony_sx.p7b"
}
ohos_js_assets("hjs_demo_js_assets") {
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
......@@ -5,7 +5,7 @@
"test-timeout": "260000",
"shell-timeout": "260000",
"bundle-name": "com.example.actscommoneventmanager",
"package-name": "com.example.actscommoneventmanager_test"
"package-name": "com.example.actscommoneventmanager"
},
"kits": [
{
......
/**
* 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.
*/
// 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';
{
"app":{
"bundleName":"com.example.actscommoneventmanager",
"vendor":"example",
"version":{
"code":1,
"name":"1.0"
}
},
"deviceConfig":{
},
"module":{
"package":"com.example.actscommoneventmanager",
"name":".entry",
"mainAbility":".MainAbility",
"deviceType": [
"tablet",
"default"
],
"distro":{
"deliveryWithInstall":true,
"installationFree":false,
"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) 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 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
{
"app":{
"bundleName":"ohos.acts.storage.fileio",
"vendor":"example",
"version":{
"code":1000000,
"name":"1.0.0"
}
},
"deviceConfig":{
},
"module":{
"package":"ohos.acts.storage.fileio_test",
"name":".entry_test",
"mainAbility":".TestAbility",
"deviceType": [
"tablet",
"default"
],
"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
/*
* 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.fileio';
import fileIO from '@ohos.file.fs';
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 fd = fileio.openSync(fpath, 0o102, 0o666)
fileio.ftruncateSync(fd)
fileio.writeSync(fd, content)
fileio.fsyncSync(fd)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to prepareFile for ' + e)
return false
}
}
export function prepareEmptyFile(fpath) {
try {
let fd = fileio.openSync(fpath, 0o102, 0o777)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to prepareFile for ' + e)
return false
}
}
export function fileToReadOnly(fpath) {
try {
let fd = fileio.openSync(fpath, 0o1)
fileio.fchmodSync(fd, 0o444)
fileio.fsyncSync(fd)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to fileToReadOnly for ' + e);
return false
}
}
export function fileToWriteOnly(fpath) {
try {
let fd = fileio.openSync(fpath, 0o2)
fileio.fchmodSync(fd, 0o222)
fileio.fsyncSync(fd)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to fileToWriteOnly ' + 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;
}
export function forceRemoveDir(path, num) {
for (let i = num; i >= 0; i--) {
if (i < num) {
path = path.replace(`/d${i}`, "");
}
fileio.rmdirSync(path);
}
}
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;
}
function isBoolean(val) {
return typeof val == 'boolean';
}
function isInclude(error, message) {
return error.toString().indexOf(message) != -1;
}
export {
fileio,
fileIO,
isIntNum,
isBigInt,
isString,
isBoolean,
isInclude,
describe,
it,
expect
};
\ 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 fileIOTest from './FileIO.test.js'
import fileIOTestDir from './FileIODir.test.js'
import fileIOTestDirent from './FileIODirent.test.js'
import fileIOTestStat from './FileIOStat.test.js'
import fileIOTestStream from './FileIOStream.test.js'
import fileioDirClose from './module_fileio/class_dir/close.test.js'
import fileioDirListfile from './module_fileio/class_dir/listfile.test.js'
import fileioDirRead from './module_fileio/class_dir/read.test.js'
import fileioDirent from './module_fileio/class_dirent/all.test.js'
import fileioStream from './module_fileio/class_stream/all.test.js'
import fileioRandomAccessFileClose from './module_fileio/class_randomAccessFile/close.test.js'
import fileioRandomAccessFileRead from './module_fileio/class_randomAccessFile/read.test.js'
import fileioRandomAccessFileSetFilePointer from './module_fileio/class_randomAccessFile/setFilePointer.test.js'
import fileioRandomAccessFileWrite from './module_fileio/class_randomAccessFile/write.test.js'
import fileioStreamClose from './module_fileio/class_stream/close.test.js'
import fileioStreamFlush from './module_fileio/class_stream/flush.test.js'
import fileioStreamRead from './module_fileio/class_stream/read.test.js'
import fileioStreamWrite from './module_fileio/class_stream/write.test.js'
import fileioCreateWatcher from './module_fileio/class_watcher/createWatcher.test.js'
import fileioAccess from './module_fileio/members/access.test.js'
import fileioChmod from './module_fileio/members/chmod.test.js'
import fileioChown from './module_fileio/members/chown.test.js'
import fileioClose from './module_fileio/members/close.test.js'
import fileioCopyfile from './module_fileio/members/copyFile.test.js'
import fileioCreateRandomAccessFile from './module_fileio/members/createRandomAccessFile.test.js'
import fileioCreateStream from './module_fileio/members/createStream.test.js'
import fileioFchmod from './module_fileio/members/fchmod.test.js'
import fileioFchown from './module_fileio/members/fchown.test.js'
import fileioFdatasync from './module_fileio/members/fdatasync.test.js'
import fileioFdOpenStream from './module_fileio/members/fdopenStream.test.js'
import fileioFstat from './module_fileio/members/fstat.test.js'
import fileioFsync from './module_fileio/members/fsync.test.js'
import fileioFtruncate from './module_fileio/members/ftruncate.test.js'
import fileioHash from './module_fileio/members/hash.test.js'
import fileioLchown from './module_fileio/members/lchown.test.js'
import fileioLseek from './module_fileio/members/lseek.test.js'
import fileioLstat from './module_fileio/members/lstat.test.js'
import fileioMkdirRmdir from './module_fileio/members/mkdir_rmdir.test.js'
import fileioMkdtemp from './module_fileio/members/mkdtemp.test.js'
import fileioOpen from './module_fileio/members/open.test.js'
import fileioOpendirClose from './module_fileio/members/opendir_close.test.js'
import fileioOpenClose from './module_fileio/members/open_close.test.js'
import fileioPosixFallocate from './module_fileio/members/posix_fallocate.test.js'
import fileioRead from './module_fileio/members/read.test.js'
import fileioReadtext from './module_fileio/members/readtext.test.js'
import fileioRename from './module_fileio/members/rename.test.js'
import fileioRmdir from './module_fileio/members/rmdir.test.js'
import fileioStat from './module_fileio/members/stat.test.js'
import fileioSymlink from './module_fileio/members/symlink.test.js'
import fileioTruncate from './module_fileio/members/truncate.test.js'
import fileioUnlink from './module_fileio/members/unlink.test.js'
import fileioWrite from './module_fileio/members/write.test.js'
export default function testsuite() {
fileIOTest()
fileIOTestDir()
fileIOTestDirent()
fileIOTestStat()
fileIOTestStream()
fileioDirClose()
fileioDirListfile()
fileioDirRead()
fileioDirent()
fileioStream()
fileioRandomAccessFileClose()
fileioRandomAccessFileRead()
fileioRandomAccessFileSetFilePointer()
fileioRandomAccessFileWrite()
fileioStreamClose()
fileioStreamFlush()
fileioStreamRead()
fileioStreamWrite()
fileioCreateWatcher()
fileioAccess()
fileioChmod()
fileioChown()
fileioClose()
fileioCopyfile()
fileioCreateRandomAccessFile()
fileioCreateStream()
fileioFchmod()
fileioFchown()
fileioFdatasync()
fileioFdOpenStream()
fileioFstat()
fileioFsync()
fileioFtruncate()
fileioHash()
fileioLchown()
fileioLseek()
fileioLstat()
fileioMkdirRmdir()
fileioMkdtemp()
fileioOpen()
fileioOpendirClose()
fileioOpenClose()
fileioPosixFallocate()
fileioRead()
fileioReadtext()
fileioRename()
fileioRmdir()
fileioStat()
fileioSymlink()
fileioTruncate()
fileioUnlink()
fileioWrite()
}
/*
* 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 fileioRandomAccessFileClose() {
describe('fileio_randomAccessFile_close', function () {
/**
* @tc.number SUB_STORAGE_FILEIO_RANDOMACCESSFILE_CLOSE_SYNC_0000
* @tc.name fileio_randomaccessfile_close_sync_000
* @tc.desc Test closeSync() interface. Close the RandomAccessFile object.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_randomaccessfile_close_sync_000', 0, async function () {
let fpath = await nextFileName('fileio_randomaccessfile_close_sync_000');
try {
let randomaccessfile = fileio.createRandomAccessFileSync(fpath, 0, 0o102);
randomaccessfile.closeSync();
fileio.unlinkSync(fpath);
} catch(err) {
console.info('fileio_randomaccessfile_close_sync_000 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_STORAGE_FILEIO_RANDOMACCESSFILE_CLOSE_SYNC_0100
* @tc.name fileio_randomaccessfile_close_sync_001
* @tc.desc Test closeSync() interface. Parameter mismatch.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_randomaccessfile_close_sync_001', 0, async function () {
let fpath = await nextFileName('fileio_randomaccessfile_close_sync_001');
let randomaccessfile = fileio.createRandomAccessFileSync(fpath, 0, 0o102);
try {
randomaccessfile.closeSync(1);
expect(false).assertTrue();
} catch(err) {
console.info('fileio_randomaccessfile_close_sync_001 has failed for ' + err);
expect(err.message == "Number of arguments unmatched").assertTrue();
randomaccessfile.closeSync();
fileio.unlinkSync(fpath);
}
});
})
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册