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