提交 0fe6018e 编写于 作者: W weiyufeng 提交者: caochuan

XTS Split 0812

 fix mediaLibrary_fileKey and mediaLibrary_fileAsset
Signed-off-by: Ncaochuan <caochuan@huawei.com>
上级 0a8a4f45
...@@ -37,6 +37,8 @@ group("multimedia") { ...@@ -37,6 +37,8 @@ group("multimedia") {
"media/media_js_standard/videoPlayer:video_player_js_hap", "media/media_js_standard/videoPlayer:video_player_js_hap",
"medialibrary/mediaLibrary_album:mediaLibrary_album_hap", "medialibrary/mediaLibrary_album:mediaLibrary_album_hap",
"medialibrary/mediaLibrary_favorite:mediaLibrary_favorite_hap", "medialibrary/mediaLibrary_favorite:mediaLibrary_favorite_hap",
"medialibrary/mediaLibrary_fileAsset:mediaLibrary_fileAsset_hap",
"medialibrary/mediaLibrary_fileKey:mediaLibrary_fileKey_hap",
"medialibrary/mediaLibrary_fileResult:mediaLibrary_fileResult_hap", "medialibrary/mediaLibrary_fileResult:mediaLibrary_fileResult_hap",
"medialibrary/mediaLibrary_js_standard:mediaLibrary_js_hap", "medialibrary/mediaLibrary_js_standard:mediaLibrary_js_hap",
] ]
......
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import mediaLibrary from '@ohos.multimedia.mediaLibrary'; import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
import bundle from '@ohos.bundle'; import bundle from '@ohos.bundle';
const presetsCount = { const presetsCount = {
ActsMediaLibraryAlbum: { assetsCount: 19, albumsCount: 7 }, ActsMediaLibraryAlbum: { assetsCount: 19, albumsCount: 7 },
ActsMediaLibraryFavorite: { assetsCount: 32, albumsCount: 6 }, ActsMediaLibraryFavorite: { assetsCount: 32, albumsCount: 6 },
//ActsMediaLibraryAlbumFileResultPro test case create 1 album 5 assets //ActsMediaLibraryAlbumFileResultPro test case create 1 album 5 assets
ActsMediaLibraryAlbumFileResultPro: { assetsCount: 123, albumsCount: 6 }, ActsMediaLibraryAlbumFileResultPro: { assetsCount: 123, albumsCount: 6 },
//ActsMediaLibraryAlbumFileResultCb test case create 1 album 5 assets //ActsMediaLibraryAlbumFileResultCb test case create 1 album 5 assets
ActsMediaLibraryAlbumFileResultCb: { assetsCount: 118, albumsCount: 5 }, ActsMediaLibraryAlbumFileResultCb: { assetsCount: 118, albumsCount: 5 },
} ActsMediaLibraryFileKey: { assetsCount: 4, albumsCount: 4 },
ActsMediaLibraryFileAsset: { assetsCount: 4, albumsCount: 4 },
const IMAGE_TYPE = mediaLibrary.MediaType.IMAGE; ActsMediaLibraryFile: { assetsCount: 4, albumsCount: 4 },
const VIDEO_TYPE = mediaLibrary.MediaType.VIDEO; }
const AUDIO_TYPE = mediaLibrary.MediaType.AUDIO;
const FILE_TYPE = mediaLibrary.MediaType.FILE; const IMAGE_TYPE = mediaLibrary.MediaType.IMAGE;
const VIDEO_TYPE = mediaLibrary.MediaType.VIDEO;
const FILEKEY = mediaLibrary.FileKey; const AUDIO_TYPE = mediaLibrary.MediaType.AUDIO;
const { RELATIVE_PATH, ALBUM_NAME, MEDIA_TYPE } = FILEKEY const FILE_TYPE = mediaLibrary.MediaType.FILE;
const sleep = async function sleep(times = 10) {
await new Promise(res => setTimeout(res, times)); const FILEKEY = mediaLibrary.FileKey;
} const { RELATIVE_PATH, ALBUM_NAME, MEDIA_TYPE } = FILEKEY
const sleep = async function sleep(times = 10) {
const allFetchOp = function (others = {}) { await new Promise(res => setTimeout(res, times));
return { }
selections: '',
selectionArgs: [], const allFetchOp = function (others = {}) {
...others return {
}; selections: '',
} selectionArgs: [],
...others
const fetchOps = function (path, type, others = {}) { };
return { }
selections: FILEKEY.RELATIVE_PATH + '= ? AND ' + FILEKEY.MEDIA_TYPE + '=?',
selectionArgs: [path, type.toString()], const fetchOps = function (path, type, others = {}) {
...others return {
}; selections: FILEKEY.RELATIVE_PATH + '= ? AND ' + FILEKEY.MEDIA_TYPE + '=?',
} selectionArgs: [path, type.toString()],
const nameFetchOps = function (path, title, type) { ...others
return { };
selections: FILEKEY.RELATIVE_PATH + '= ? AND ' + FILEKEY.TITLE + '= ? AND ' + FILEKEY.MEDIA_TYPE + '=?', }
selectionArgs: [path, title, type.toString()], const nameFetchOps = function (path, title, type) {
}; return {
} selections: FILEKEY.RELATIVE_PATH + '= ? AND ' + FILEKEY.TITLE + '= ? AND ' + FILEKEY.MEDIA_TYPE + '=?',
selectionArgs: [path, title, type.toString()],
const idFetchOps = function (albumId) { };
return { }
selections: FILEKEY.ALBUM_ID + '= ?',
selectionArgs: [albumId + ''], const idFetchOps = function (albumId) {
}; return {
} selections: FILEKEY.ALBUM_ID + '= ?',
selectionArgs: [albumId + ''],
const albumFetchOps = function (path, albumName, type, others = { order: FILEKEY.DATE_ADDED + " DESC", }) { };
return { }
selections: RELATIVE_PATH + '= ? AND ' + ALBUM_NAME + '= ? AND ' + MEDIA_TYPE + '= ?',
selectionArgs: [path, albumName, type.toString()], const albumFetchOps = function (path, albumName, type, others = { order: FILEKEY.DATE_ADDED + " DESC", }) {
...others return {
}; selections: RELATIVE_PATH + '= ? AND ' + ALBUM_NAME + '= ? AND ' + MEDIA_TYPE + '= ?',
} selectionArgs: [path, albumName, type.toString()],
...others
// albums of two resource types };
const albumTwoTypesFetchOps = function (paths, albumName, types, others = { order: FILEKEY.DATE_ADDED + " DESC", }) { }
try {
let ops = { // albums of two resource types
selections: '(' + RELATIVE_PATH + '= ? or ' + const albumTwoTypesFetchOps = function (paths, albumName, types, others = { order: FILEKEY.DATE_ADDED + " DESC", }) {
RELATIVE_PATH + '= ? ) AND ' + try {
ALBUM_NAME + '= ? AND (' + let ops = {
MEDIA_TYPE + '= ? or ' + selections: '(' + RELATIVE_PATH + '= ? or ' +
MEDIA_TYPE + '= ?)', RELATIVE_PATH + '= ? ) AND ' +
selectionArgs: [paths[0], paths[1], albumName, types[0].toString(), types[1].toString()], ALBUM_NAME + '= ? AND (' +
...others MEDIA_TYPE + '= ? or ' +
}; MEDIA_TYPE + '= ?)',
return ops selectionArgs: [paths[0], paths[1], albumName, types[0].toString(), types[1].toString()],
} catch (error) { ...others
console.info(`albumTwoTypesFetchOps :: error: ${error}`); };
} return ops
} } catch (error) {
console.info(`albumTwoTypesFetchOps :: error: ${error}`);
// albums of three resource types }
const albumThreeTypesFetchOps = function (paths, albumName, types, others = { order: FILEKEY.DATE_ADDED, }) { }
try {
let ops = { // albums of three resource types
selections: '(' + RELATIVE_PATH + '= ? or ' + const albumThreeTypesFetchOps = function (paths, albumName, types, others = { order: FILEKEY.DATE_ADDED, }) {
RELATIVE_PATH + '= ? or ' + try {
RELATIVE_PATH + '= ? ) AND ' + let ops = {
ALBUM_NAME + '= ? AND (' + selections: '(' + RELATIVE_PATH + '= ? or ' +
MEDIA_TYPE + '= ? or ' + RELATIVE_PATH + '= ? or ' +
MEDIA_TYPE + '= ? or ' + RELATIVE_PATH + '= ? ) AND ' +
MEDIA_TYPE + '= ?)', ALBUM_NAME + '= ? AND (' +
selectionArgs: [paths[0], paths[1], paths[2], albumName, MEDIA_TYPE + '= ? or ' +
types[0].toString(), types[1].toString(), types[2].toString()], MEDIA_TYPE + '= ? or ' +
...others MEDIA_TYPE + '= ?)',
}; selectionArgs: [paths[0], paths[1], paths[2], albumName,
return ops types[0].toString(), types[1].toString(), types[2].toString()],
} catch (error) { ...others
console.info(`albumThreeTypesFetchOps :: error: ${error}`); };
} return ops
} } catch (error) {
console.info(`albumThreeTypesFetchOps :: error: ${error}`);
const checkPresetsAssets = async function (media, hapName) { }
console.info('checkPresetsAssets start') }
let albumList = await media.getAlbums(allFetchOp());
let albumsCount = albumList.length; const checkPresetsAssets = async function (media, hapName) {
let fetchFileResult = await media.getFileAssets(allFetchOp()); console.info('checkPresetsAssets start')
let assetsCount = await fetchFileResult.getCount(); let albumList = await media.getAlbums(allFetchOp());
console.info(`${hapName}:: assetsCount: ${assetsCount}`); let albumsCount = albumList.length;
console.info(`${hapName}:: albumsCount: ${albumsCount}`); let fetchFileResult = await media.getFileAssets(allFetchOp());
console.info(`${hapName}:: presetsassetsCount: ${presetsCount[hapName].assetsCount}`); let assetsCount = await fetchFileResult.getCount();
console.info(`${hapName}:: presetsalbumsCount: ${presetsCount[hapName].albumsCount}`); console.info(`${hapName}:: assetsCount: ${assetsCount}`);
console.info('checkPresetsAssets end') console.info(`${hapName}:: albumsCount: ${albumsCount}`);
} console.info(`${hapName}:: presetsassetsCount: ${presetsCount[hapName].assetsCount}`);
console.info(`${hapName}:: presetsalbumsCount: ${presetsCount[hapName].albumsCount}`);
const checkAssetsCount = async function (done, testNum, fetchFileResult, expectCount) { console.info('checkPresetsAssets end')
if (!fetchFileResult) { }
console.info(`${testNum}:: fetchFileResult error:`);
return false const checkAssetsCount = async function (done, testNum, fetchFileResult, expectCount) {
} if (!fetchFileResult) {
let count = await fetchFileResult.getCount(); console.info(`${testNum}:: fetchFileResult error:`);
if (count != expectCount) { expect(false).assertTrue();
console.info(`${testNum}:: count: ${count}`); done();
console.info(`${testNum}:: expectCount: ${expectCount}`); return false
expect(count).assertEqual(expectCount); }
done(); let count = await fetchFileResult.getCount();
} if (count != expectCount) {
return count == expectCount; console.info(`${testNum}:: count: ${count}`);
} console.info(`${testNum}:: expectCount: ${expectCount}`);
expect(count).assertEqual(expectCount);
const checkAlbumsCount = function (done, testNum, albumList, expectCount) { done();
if (!Array.isArray(albumList)) { }
console.info(`${testNum}:: albumList error:`); return count == expectCount;
return false }
}
let albumsCount = albumList.length; const checkAlbumsCount = function (done, testNum, albumList, expectCount) {
if (albumsCount != expectCount) { if (!Array.isArray(albumList)) {
console.info(`${testNum}:: albumsCount: ${albumsCount}`); console.info(`${testNum}:: albumList error:`);
console.info(`${testNum}:: expectCount: ${expectCount}`); expect(false).assertTrue();
console.info(`${testNum} failed:: albums length error`); done();
expect(albumsCount).assertEqual(expectCount); return false
done(); }
} let albumsCount = albumList.length;
return albumsCount == expectCount; if (albumsCount != expectCount) {
} console.info(`${testNum}:: albumsCount: ${albumsCount}`);
console.info(`${testNum}:: expectCount: ${expectCount}`);
const getPermission = async function (name = 'ohos.acts.multimedia.mediaLibrary') { console.info(`${testNum} failed:: albums length error`);
console.info('getPermission start', name) expect(albumsCount).assertEqual(expectCount);
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.mediaLibrary', 0, 100); done();
let tokenID = appInfo.accessTokenId; }
let atManager = abilityAccessCtrl.createAtManager(); return albumsCount == expectCount;
let result1 = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.MEDIA_LOCATION", 1); }
let result2 = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.READ_MEDIA", 1);
let result3 = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.WRITE_MEDIA", 1); const getPermission = async function (name = 'ohos.acts.multimedia.mediaLibrary') {
let isGranted1 = await atManager.verifyAccessToken(tokenID, "ohos.permission.MEDIA_LOCATION"); console.info('getPermission start', name)
let isGranted2 = await atManager.verifyAccessToken(tokenID, "ohos.permission.READ_MEDIA"); let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.mediaLibrary', 0, 100);
let isGranted3 = await atManager.verifyAccessToken(tokenID, "ohos.permission.WRITE_MEDIA"); let tokenID = appInfo.accessTokenId;
if (!(result1 == 0 && result2 == 0 && result3 == 0) || !(isGranted1 == 0 && isGranted2 == 0 && isGranted3 == 0)) { let atManager = abilityAccessCtrl.createAtManager();
console.info('getPermission failed') let result1 = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.MEDIA_LOCATION", 1);
} let result2 = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.READ_MEDIA", 1);
console.info('getPermission end') let result3 = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.WRITE_MEDIA", 1);
} let isGranted1 = await atManager.verifyAccessToken(tokenID, "ohos.permission.MEDIA_LOCATION");
let isGranted2 = await atManager.verifyAccessToken(tokenID, "ohos.permission.READ_MEDIA");
const MODIFY_ERROR_CODE_01 = '-1000'; let isGranted3 = await atManager.verifyAccessToken(tokenID, "ohos.permission.WRITE_MEDIA");
export { if (!(result1 == 0 && result2 == 0 && result3 == 0) || !(isGranted1 == 0 && isGranted2 == 0 && isGranted3 == 0)) {
getPermission, console.info('getPermission failed')
IMAGE_TYPE, }
VIDEO_TYPE, console.info('getPermission end')
AUDIO_TYPE, }
FILE_TYPE,
const MODIFY_ERROR_CODE_01 = '-1000';
FILEKEY,
const isNum = function (value) {
sleep, return typeof value === 'number' && !isNaN(value);
}
allFetchOp, export {
fetchOps, getPermission,
nameFetchOps, IMAGE_TYPE,
idFetchOps, VIDEO_TYPE,
albumFetchOps, AUDIO_TYPE,
albumTwoTypesFetchOps, FILE_TYPE,
albumThreeTypesFetchOps, FILEKEY,
sleep,
checkPresetsAssets, allFetchOp,
checkAssetsCount, fetchOps,
checkAlbumsCount, nameFetchOps,
MODIFY_ERROR_CODE_01, idFetchOps,
} albumFetchOps,
albumTwoTypesFetchOps,
albumThreeTypesFetchOps,
checkPresetsAssets,
checkAssetsCount,
checkAlbumsCount,
MODIFY_ERROR_CODE_01,
isNum,
}
{ {
"app":{ "app":{
"bundleName":"ohos.acts.multimedia.mediaLibrary", "bundleName":"ohos.acts.multimedia.mediaLibrary",
"vendor":"huawei", "vendor":"huawei",
"versionCode":1000000, "versionCode":1000000,
"versionName":"1.0.0", "versionName":"1.0.0",
"debug":false, "debug":false,
"icon":"$media:icon", "icon":"$media:icon",
"label":"$string:entry_MainAbility", "label":"$string:entry_MainAbility",
"description":"$string:mainability_description", "description":"$string:mainability_description",
"distributedNotificationEnabled":true, "distributedNotificationEnabled":true,
"keepAlive":true, "keepAlive":true,
"singleUser":true, "singleUser":true,
"minAPIVersion":8, "minAPIVersion":8,
"targetAPIVersion":8, "targetAPIVersion":8,
"car":{ "car":{
"apiCompatibleVersion":8, "apiCompatibleVersion":8,
"singleUser":false "singleUser":false
} }
} }
} }
{ {
"string": [ "string": [
{ {
"name": "entry_MainAbility", "name": "entry_MainAbility",
"value": "MediaLibraryJSTestMain" "value": "MediaLibraryJSTestMain"
}, },
{ {
"name": "mainability_description", "name": "mainability_description",
"value": "MediaLibraryJSTestMain Ability" "value": "MediaLibraryJSTestMain Ability"
} }
] ]
} }
\ No newline at end of file
文件模式从 100644 更改为 100755
{ {
"description": "Configuration for mediaLibrary Tests", "description": "Configuration for mediaLibrary Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "300000", "test-timeout": "300000",
"package": "ohos.acts.multimedia.mediaLibrary", "package": "ohos.acts.multimedia.mediaLibrary",
"shell-timeout": "600000" "shell-timeout": "600000"
}, },
"kits": [ "kits": [
{ {
"type": "ShellKit", "type": "ShellKit",
"pre-push": [ "pre-push": [
], ],
"run-command": [ "run-command": [
"rm -rf /storage/media/100/local/files/*", "rm -rf /storage/media/100/local/files/*",
"rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*",
"mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios}", "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios}",
"mkdir -p /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata" "mkdir -p /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata"
] ]
}, },
{ {
"type": "PushKit", "type": "PushKit",
"pre-push": [ "pre-push": [
], ],
"push": [ "push": [
"./resource/medialibrary/01.jpg ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata", "./resource/medialibrary/01.jpg ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.mp3 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata", "./resource/medialibrary/01.mp3 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.mp4 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata" "./resource/medialibrary/01.mp4 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata"
] ]
}, },
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"mkdir -pv /storage/media/100/local/files/Pictures/{Static,DynamicPro1,DynamicPro2,DynamicCb1,DynamicCb2}", "mkdir -pv /storage/media/100/local/files/Pictures/{Static,DynamicPro1,DynamicPro2,DynamicCb1,DynamicCb2}",
"mkdir -pv /storage/media/100/local/files/Videos/Static", "mkdir -pv /storage/media/100/local/files/Videos/Static",
"mkdir -pv /storage/media/100/local/files/Audios/Static", "mkdir -pv /storage/media/100/local/files/Audios/Static",
"for d in Static; do for i in $$(seq 5); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;", "for d in Static; do for i in $$(seq 5); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in Static; do for i in $$(seq 5); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;", "for d in Static; do for i in $$(seq 5); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
"for d in Static; do for i in $$(seq 5); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;", "for d in Static; do for i in $$(seq 5); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
"for d in DynamicPro1 DynamicPro2 DynamicCb1 DynamicCb2; do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/$$d ;done;", "for d in DynamicPro1 DynamicPro2 DynamicCb1 DynamicCb2; do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/$$d ;done;",
"chmod -R 777 /storage/media/100/local/files/*", "chmod -R 777 /storage/media/100/local/files/*",
"chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*",
"hilog -Q pidoff", "hilog -Q pidoff",
"hilog -p off", "hilog -p off",
"hilog -b D -D 0xD002B70", "hilog -b D -D 0xD002B70",
"aa start -a com.ohos.photos.MainAbility -b com.ohos.photos", "scanner_demo",
"sleep 10", "sleep 10"
"cem publish -e usual.event.SCREEN_OFF", ],
"sleep 10" "teardown-command":[
],
"teardown-command":[ ]
},
] {
}, "test-file-name": [
{ "ActsMediaLibraryAlbum.hap"
"test-file-name": [ ],
"ActsMediaLibraryAlbum.hap" "type": "AppInstallKit",
], "cleanup-apps": true
"type": "AppInstallKit", }
"cleanup-apps": true ]
}
]
} }
\ No newline at end of file
import AbilityStage from "@ohos.application.AbilityStage" import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage { export default class MyAbilityStage extends AbilityStage {
onCreate() { onCreate() {
console.log("[Demo] MyAbilityStage onCreate") console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1; globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context; globalThis.stageContext = this.context;
} }
} }
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
onCreate(want,launchParam){ onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability // Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate") console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want; globalThis.abilityWant = want;
} }
onDestroy() { onDestroy() {
// Ability is destroying, release resources for this ability // Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy") console.log("[Demo] MainAbility onDestroy")
} }
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate") console.log("[Demo] MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null) windowStage.setUIContent(this.context, "pages/index/index", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
//Main window is destroyed, release UI related resources //Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy") console.log("[Demo] MainAbility onWindowStageDestroy")
} }
onForeground() { onForeground() {
// Ability has brought to foreground // Ability has brought to foreground
console.log("[Demo] MainAbility onForeground") console.log("[Demo] MainAbility onForeground")
} }
onBackground() { onBackground() {
// Ability has back to background // Ability has back to background
console.log("[Demo] MainAbility onBackground") console.log("[Demo] MainAbility onBackground")
} }
}; };
\ No newline at end of file
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import file from '@system.file'; import file from '@system.file';
import { Core, ExpectExtend, InstrumentLog, ReportExtend } from "deccjsunit/index" import { Core, ExpectExtend, InstrumentLog, ReportExtend } from "deccjsunit/index"
import testsuite from "../../test/List.test.ets" import testsuite from "../../test/List.test.ets"
import { getPermission } from "../../../../../../../common"
@Entry
@Entry @Component
@Component struct Index {
struct Index {
aboutToAppear(){
aboutToAppear(){ console.info("start run testcase!!!!")
getPermission() const core = Core.getInstance()
console.info("start run testcase!!!!") const expectExtend = new ExpectExtend({
const core = Core.getInstance() 'id': 'extend'
const expectExtend = new ExpectExtend({ })
'id': 'extend' core.addService('expect', expectExtend)
}) const reportExtend = new ReportExtend(file)
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file) core.addService('report', reportExtend)
core.init()
core.addService('report', reportExtend) core.subscribeEvent('task', reportExtend)
core.init() const configService = core.getDefaultService('config')
core.subscribeEvent('task', reportExtend) console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
const configService = core.getDefaultService('config') globalThis.abilityWant.parameters.timeout = 70000;
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) configService.setConfig(globalThis.abilityWant.parameters)
globalThis.abilityWant.parameters.timeout = 70000; console.info('testsuite()---->')
configService.setConfig(globalThis.abilityWant.parameters) testsuite(globalThis.abilityContext)
console.info('testsuite()---->') core.execute()
testsuite(globalThis.abilityContext) console.info('core.execute()---->')
core.execute() }
console.info('core.execute()---->')
} build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
build() { Text('Hello World')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { .fontSize(50)
Text('Hello World') .fontWeight(FontWeight.Bold)
.fontSize(50) Button() {
.fontWeight(FontWeight.Bold) Text('next page')
Button() { .fontSize(25)
Text('next page') .fontWeight(FontWeight.Bold)
.fontSize(25) }.type(ButtonType.Capsule)
.fontWeight(FontWeight.Bold) .margin({
}.type(ButtonType.Capsule) top: 20
.margin({ })
top: 20 .backgroundColor('#0D9FFB')
}) .onClick(() => {
.backgroundColor('#0D9FFB')
.onClick(() => { })
}
}) .width('100%')
} .height('100%')
.width('100%') }
.height('100%')
}
} }
\ No newline at end of file
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import router from '@system.router'; import router from '@system.router';
@Entry @Entry
@Component @Component
struct Second { struct Second {
private content: string = "Second Page" private content: string = "Second Page"
build() { build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`) Text(`${this.content}`)
.fontSize(50) .fontSize(50)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button() { Button() {
Text('back to index') Text('back to index')
.fontSize(20) .fontSize(20)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule) }.type(ButtonType.Capsule)
.margin({ .margin({
top: 20 top: 20
}) })
.backgroundColor('#0D9FFB') .backgroundColor('#0D9FFB')
.onClick(() => { .onClick(() => {
router.back() router.back()
}) })
} }
.width('100%') .width('100%')
.height('100%') .height('100%')
} }
} }
\ No newline at end of file
/* /*
* Copyright (c) 2022 Huawei Device Co., Ltd. * Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import albumGetFileAssetsCallbackTest from './albumGetFileAssetsCallback.test.ets' import albumGetFileAssetsCallbackTest from './albumGetFileAssetsCallback.test.ets'
import albumGetFileAssetsPromiseTest from './albumGetFileAssetsPromise.test.ets' import albumGetFileAssetsPromiseTest from './albumGetFileAssetsPromise.test.ets'
import albumTestCallBackTest from './albumTestCallBack.test.ets' import albumTestCallBackTest from './albumTestCallBack.test.ets'
import albumTestPromiseTest from './albumTestPromise.test.ets' import albumTestPromiseTest from './albumTestPromise.test.ets'
export default function testsuite(abilityContext) { export default function testsuite(abilityContext) {
albumGetFileAssetsCallbackTest(abilityContext) albumGetFileAssetsCallbackTest(abilityContext)
albumGetFileAssetsPromiseTest(abilityContext) albumGetFileAssetsPromiseTest(abilityContext)
albumTestPromiseTest(abilityContext) albumTestPromiseTest(abilityContext)
albumTestCallBackTest(abilityContext) albumTestCallBackTest(abilityContext)
} }
{ {
"module": { "module": {
"name": "phone", "name": "phone",
"type": "entry", "type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts", "srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:mainability_description", "description": "$string:mainability_description",
"mainElement": "MainAbility", "mainElement": "MainAbility",
"deviceTypes": [ "deviceTypes": [
"phone" "phone"
], ],
"deliveryWithInstall": true, "deliveryWithInstall": true,
"installationFree": false, "installationFree": false,
"uiSyntax": "ets", "uiSyntax": "ets",
"pages": "$profile:main_pages", "pages": "$profile:main_pages",
"abilities": [ "abilities": [
{ {
"name": "ohos.acts.multimedia.mediaLibrary.MainAbility", "name": "ohos.acts.multimedia.mediaLibrary.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts", "srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:mainability_description", "description": "$string:mainability_description",
"icon": "$media:icon", "icon": "$media:icon",
"label": "$string:entry_MainAbility", "label": "$string:entry_MainAbility",
"visible": true, "visible": true,
"orientation": "portrait", "orientation": "portrait",
"skills": [ "skills": [
{ {
"actions": [ "actions": [
"action.system.home" "action.system.home"
], ],
"entities":[ "entities":[
"entity.system.home" "entity.system.home"
] ]
} }
] ]
} }
], ],
"requestPermissions": [ "requestPermissions": [
{ {
"name": "ohos.permission.GET_BUNDLE_INFO", "name": "ohos.permission.GET_BUNDLE_INFO",
"reason": "use ohos.permission.GET_BUNDLE_INFO" "reason": "use ohos.permission.GET_BUNDLE_INFO"
}, },
{ {
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
}, },
{ {
"name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
}, },
{ {
"name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
}, },
{ {
"name": "ohos.permission.MEDIA_LOCATION", "name": "ohos.permission.MEDIA_LOCATION",
"reason":"use ohos.permission.MEDIA_LOCATION" "reason":"use ohos.permission.MEDIA_LOCATION"
}, },
{ {
"name": "ohos.permission.READ_MEDIA", "name": "ohos.permission.READ_MEDIA",
"reason":"use ohos.permission.READ_MEDIA" "reason":"use ohos.permission.READ_MEDIA"
}, },
{ {
"name": "ohos.permission.WRITE_MEDIA", "name": "ohos.permission.WRITE_MEDIA",
"reason":"use ohos.permission.WRITE_MEDIA" "reason":"use ohos.permission.WRITE_MEDIA"
} }
] ]
} }
} }
{ {
"string": [ "string": [
{ {
"name": "entry_MainAbility", "name": "entry_MainAbility",
"value": "MediaLibraryJSTestMain" "value": "MediaLibraryJSTestMain"
}, },
{ {
"name": "mainability_description", "name": "mainability_description",
"value": "MediaLibraryJSTestMain Ability" "value": "MediaLibraryJSTestMain Ability"
} }
] ]
} }
\ No newline at end of file
{ {
"src": [ "src": [
"pages/index/index", "pages/index/index",
"pages/second/second" "pages/second/second"
] ]
} }
\ No newline at end of file
{ {
"app":{ "app":{
"bundleName":"ohos.acts.multimedia.mediaLibrary", "bundleName":"ohos.acts.multimedia.mediaLibrary",
"vendor":"huawei", "vendor":"huawei",
"versionCode":1000000, "versionCode":1000000,
"versionName":"1.0.0", "versionName":"1.0.0",
"debug":false, "debug":false,
"icon":"$media:icon", "icon":"$media:icon",
"label":"$string:entry_MainAbility", "label":"$string:entry_MainAbility",
"description":"$string:mainability_description", "description":"$string:mainability_description",
"distributedNotificationEnabled":true, "distributedNotificationEnabled":true,
"keepAlive":true, "keepAlive":true,
"singleUser":true, "singleUser":true,
"minAPIVersion":8, "minAPIVersion":8,
"targetAPIVersion":8, "targetAPIVersion":8,
"car":{ "car":{
"apiCompatibleVersion":8, "apiCompatibleVersion":8,
"singleUser":false "singleUser":false
} }
} }
} }
{ {
"string": [ "string": [
{ {
"name": "entry_MainAbility", "name": "entry_MainAbility",
"value": "MediaLibraryJSTestMain" "value": "MediaLibraryJSTestMain"
}, },
{ {
"name": "mainability_description", "name": "mainability_description",
"value": "MediaLibraryJSTestMain Ability" "value": "MediaLibraryJSTestMain Ability"
} }
] ]
} }
\ No newline at end of file
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
......
{ {
"description": "Configuration for mediaLibrary Tests", "description": "Configuration for mediaLibrary Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "300000", "test-timeout": "300000",
"package": "ohos.acts.multimedia.mediaLibrary", "package": "ohos.acts.multimedia.mediaLibrary",
"shell-timeout": "600000" "shell-timeout": "600000"
}, },
"kits": [ "kits": [
{ {
"type": "ShellKit", "type": "ShellKit",
"pre-push": [ "pre-push": [
], ],
"run-command": [ "run-command": [
"rm -rf /storage/media/100/local/files/*", "rm -rf /storage/media/100/local/files/*",
"rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*",
"mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}", "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}",
"mkdir -p /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata" "mkdir -p /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata"
] ]
}, },
{ {
"type": "PushKit", "type": "PushKit",
"pre-push": [ "pre-push": [
], ],
"push": [ "push": [
"./resource/medialibrary/01.jpg ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata", "./resource/medialibrary/01.jpg ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.mp3 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata", "./resource/medialibrary/01.mp3 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.mp4 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata", "./resource/medialibrary/01.mp4 ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata",
"./resource/medialibrary/01.dat ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata" "./resource/medialibrary/01.dat ->/data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata"
] ]
}, },
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"mkdir -pv /storage/media/100/local/files/Pictures/{StaticPro,StaticCb}", "mkdir -pv /storage/media/100/local/files/Pictures/{StaticPro,StaticCb}",
"mkdir -pv /storage/media/100/local/files/Videos/{StaticPro,StaticCb}", "mkdir -pv /storage/media/100/local/files/Videos/{StaticPro,StaticCb}",
"mkdir -pv /storage/media/100/local/files/Audios/{StaticPro,StaticCb}", "mkdir -pv /storage/media/100/local/files/Audios/{StaticPro,StaticCb}",
"mkdir -pv /storage/media/100/local/files/Documents/{StaticPro,StaticCb}", "mkdir -pv /storage/media/100/local/files/Documents/{StaticPro,StaticCb}",
"for d in {StaticPro,StaticCb}; do for i in $$(seq 4); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;", "for d in {StaticPro,StaticCb}; do for i in $$(seq 4); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in {StaticPro,StaticCb}; do for i in $$(seq 4); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;", "for d in {StaticPro,StaticCb}; do for i in $$(seq 4); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
"for d in {StaticPro,StaticCb}; do for i in $$(seq 4); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;", "for d in {StaticPro,StaticCb}; do for i in $$(seq 4); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
"for d in {StaticPro,StaticCb}; do for i in $$(seq 4); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;", "for d in {StaticPro,StaticCb}; do for i in $$(seq 4); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;",
"chmod -R 777 /storage/media/100/local/files/*", "chmod -R 777 /storage/media/100/local/files/*",
"chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*",
"hilog -Q pidoff", "hilog -Q pidoff",
"hilog -p off", "hilog -p off",
"hilog -b D -D 0xD002B70", "hilog -b D -D 0xD002B70",
"aa start -a com.ohos.photos.MainAbility -b com.ohos.photos", "scanner_demo",
"sleep 10", "sleep 10"
"cem publish -e usual.event.SCREEN_OFF", ]
"sleep 10" },
] {
}, "test-file-name": [
{ "ActsMediaLibraryFavorite.hap"
"test-file-name": [ ],
"ActsMediaLibraryFavorite.hap" "type": "AppInstallKit",
], "cleanup-apps": true
"type": "AppInstallKit", }
"cleanup-apps": true ]
}
]
} }
\ No newline at end of file
import AbilityStage from "@ohos.application.AbilityStage" import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage { export default class MyAbilityStage extends AbilityStage {
onCreate() { onCreate() {
console.log("[Demo] MyAbilityStage onCreate") console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1; globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context; globalThis.stageContext = this.context;
} }
} }
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
onCreate(want,launchParam){ onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability // Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate") console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want; globalThis.abilityWant = want;
} }
onDestroy() { onDestroy() {
// Ability is destroying, release resources for this ability // Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy") console.log("[Demo] MainAbility onDestroy")
} }
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate") console.log("[Demo] MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null) windowStage.setUIContent(this.context, "pages/index/index", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
//Main window is destroyed, release UI related resources //Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy") console.log("[Demo] MainAbility onWindowStageDestroy")
} }
onForeground() { onForeground() {
// Ability has brought to foreground // Ability has brought to foreground
console.log("[Demo] MainAbility onForeground") console.log("[Demo] MainAbility onForeground")
} }
onBackground() { onBackground() {
// Ability has back to background // Ability has back to background
console.log("[Demo] MainAbility onBackground") console.log("[Demo] MainAbility onBackground")
} }
}; };
\ No newline at end of file
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import file from '@system.file'; import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from "../../test/List.test.ets" import testsuite from "../../test/List.test.ets"
import { getPermission } from "../../../../../../../common"
@Entry
@Entry @Component
@Component struct Index {
struct Index {
aboutToAppear(){
aboutToAppear(){ console.info("start run testcase!!!!")
getPermission() const core = Core.getInstance()
console.info("start run testcase!!!!") const expectExtend = new ExpectExtend({
const core = Core.getInstance() 'id': 'extend'
const expectExtend = new ExpectExtend({ })
'id': 'extend' core.addService('expect', expectExtend)
}) const reportExtend = new ReportExtend(file)
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file) core.addService('report', reportExtend)
core.init()
core.addService('report', reportExtend) core.subscribeEvent('task', reportExtend)
core.init() const configService = core.getDefaultService('config')
core.subscribeEvent('task', reportExtend) console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
const configService = core.getDefaultService('config') globalThis.abilityWant.parameters.timeout = 70000;
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) configService.setConfig(globalThis.abilityWant.parameters)
globalThis.abilityWant.parameters.timeout = 70000; console.info('testsuite()---->')
configService.setConfig(globalThis.abilityWant.parameters) testsuite(globalThis.abilityContext)
console.info('testsuite()---->') core.execute()
testsuite(globalThis.abilityContext) console.info('core.execute()---->')
core.execute() }
console.info('core.execute()---->')
} build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
build() { Text('Hello World')
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { .fontSize(50)
Text('Hello World') .fontWeight(FontWeight.Bold)
.fontSize(50) Button() {
.fontWeight(FontWeight.Bold) Text('next page')
Button() { .fontSize(25)
Text('next page') .fontWeight(FontWeight.Bold)
.fontSize(25) }.type(ButtonType.Capsule)
.fontWeight(FontWeight.Bold) .margin({
}.type(ButtonType.Capsule) top: 20
.margin({ })
top: 20 .backgroundColor('#0D9FFB')
}) .onClick(() => {
.backgroundColor('#0D9FFB')
.onClick(() => { })
}
}) .width('100%')
} .height('100%')
.width('100%') }
.height('100%')
}
} }
\ No newline at end of file
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import router from '@system.router'; import router from '@system.router';
@Entry @Entry
@Component @Component
struct Second { struct Second {
private content: string = "Second Page" private content: string = "Second Page"
build() { build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`) Text(`${this.content}`)
.fontSize(50) .fontSize(50)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button() { Button() {
Text('back to index') Text('back to index')
.fontSize(20) .fontSize(20)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule) }.type(ButtonType.Capsule)
.margin({ .margin({
top: 20 top: 20
}) })
.backgroundColor('#0D9FFB') .backgroundColor('#0D9FFB')
.onClick(() => { .onClick(() => {
router.back() router.back()
}) })
} }
.width('100%') .width('100%')
.height('100%') .height('100%')
} }
} }
\ No newline at end of file
/* /*
* Copyright (c) 2022 Huawei Device Co., Ltd. * Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import favoriteTestPromise from './favoriteTestPromise.test.ets' import favoriteTestPromise from './favoriteTestPromise.test.ets'
import favoriteTestCallback from './favoriteTestCallback.test.ets' import favoriteTestCallback from './favoriteTestCallback.test.ets'
export default function testsuite(abilityContext) { export default function testsuite(abilityContext) {
favoriteTestPromise(abilityContext) favoriteTestCallback(abilityContext)
favoriteTestCallback(abilityContext) favoriteTestPromise(abilityContext)
} }
{ {
"src": [ "src": [
"pages/index/index", "pages/index/index",
"pages/second/second" "pages/second/second"
] ]
} }
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册