提交 7e10cc31 编写于 作者: Y yaocui

Merge branch 'master' of https://gitee.com/yaocui_moring/xts_acts

......@@ -5,7 +5,7 @@
"test-timeout": "600000",
"bundle-name": "com.example.actsgetabilitystatestagetest",
"module-name": "entry",
"shell-timeout": "600000"
"shell-timeout": "10000"
},
"kits": [
{
......
......@@ -14,6 +14,10 @@
*/
import Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
function publishCallBackOne() {
console.log("====MainAbility2 Publish CallBack GetCurrentTopAbility");
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
......@@ -27,9 +31,15 @@ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index", null)
console.log("[Demo] MainAbility onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index", null);
windowStage.on('windowStageEvent', (data) => {
console.log(`ActsGetAbilityStatestAgeTest onWindwoStageMainAbilty2 is : ${JSON.stringify(data)}`);
if (data == 2 ) {
console.log(`ActsGetAbilityStatestAgeTest getWindowStageActiveMainAbility2 is sucess`);
commonEvent.publish("GetCurrentTopAbility", publishCallBackOne);
}
})
}
onWindowStageDestroy() {
......
......@@ -14,6 +14,11 @@
*/
import Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
function publishCallBackOne() {
console.log("====MainAbility3 Publish CallBack GetCurrentTopAbility");
}
export default class MainAbility3 extends Ability {
onCreate(want, launchParam) {
......@@ -27,9 +32,16 @@ export default class MainAbility3 extends Ability {
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility3 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index", null)
console.log("MainAbility3 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index", null);
globalThis.ability3Context = this.context;
windowStage.on('windowStageEvent', (data) => {
console.log(`ActsGetAbilityStatestAgeTest onWindwoStageMainAbilty3 is : ${JSON.stringify(data)}`);
if (data == 2 ) {
console.log(`ActsGetAbilityStatestAgeTest getWindowStageActiveMainAbility3 is sucess`);
commonEvent.publish("GetCurrentTopAbility", publishCallBackOne);
}
})
}
onWindowStageDestroy() {
......
......@@ -13,7 +13,11 @@
* limitations under the License.
*/
import Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
function publishCallBackOne() {
console.debug("====MainAbility4 Publish CallBack GetCurrentTopAbility");
}
export default class MainAbility4 extends Ability {
onCreate(want, launchParam) {
......@@ -27,10 +31,16 @@ export default class MainAbility4 extends Ability {
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility4 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index", null)
console.log("MainAbility4 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index", null);
globalThis.ability4Context = this.context;
//commonEvent.publish("ACTS_GetAppContext", PublishCallBackOne4);
windowStage.on('windowStageEvent', (data) => {
console.log(`ActsGetAbilityStatestAgeTest onWindwoStageMainAbilty4 is : ${JSON.stringify(data)}`);
if (data == 2 ) {
console.log(`ActsGetAbilityStatestAgeTest getWindowStageActiveMainAbility4 is sucess`);
commonEvent.publish("GetCurrentTopAbility", publishCallBackOne);
}
})
}
onWindowStageDestroy() {
......
......@@ -15,8 +15,11 @@
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
const START_ABILITY_TIMEOUT = 4000;
import commonEvent from "@ohos.commonEvent"
let subscriberInfo_MainAbility = {
events: ["GetCurrentTopAbility"],
};
export default function abilityTest() {
describe('ActsGetAbilityStateStageTest', function () {
......@@ -26,31 +29,44 @@ export default function abilityTest() {
* @tc.desc : Get the status of the Ability in the BACKGROUND state
*/
it('ACTS_GetAbilityState_0200', 0, async function (done) {
console.debug('====>start ACTS_GetAbilityState_0200====');
var flag = true;
var ability;
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
console.log('====>start ACTS_GetAbilityState_0200====');
let ability;
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let count = 0;
let subscriber;
function onAbilityForegroundCallback2(){
console.debug("====>onAbilityForegroundCallback2====");
abilityDelegator.getCurrentTopAbility((err, data)=>{
console.debug("====>getCurrentTopAbility_0200 err:" + JSON.stringify(err) + " data:" + JSON.stringify(data));
console.log("====>onAbilityForegroundCallback2====");
count ++;
if (count == 2) {
abilityDelegator.getCurrentTopAbility((err, data)=>{
console.log("====>getCurrentTopAbility_0200 err:" + JSON.stringify(err) + " data:" + JSON.stringify(data));
ability = data;
abilityDelegator.doAbilityBackground(ability, (err)=>{
console.debug("====>doAbilityBackground_0200 data:" + JSON.stringify(err));
console.log("====>doAbilityBackground_0200 data:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
})
})
}
}
function onAbilityBackgroundCallback2(){
console.debug("====>onAbilityBackgroundCallback2====");
var state = abilityDelegator.getAbilityState(ability);
console.debug("====>ACTS_GetAbilityState_0200 state:" + state);
console.log("====>onAbilityBackgroundCallback2====");
let state = abilityDelegator.getAbilityState(ability);
console.log("====>ACTS_GetAbilityState_0200 state:" + state);
expect(state).assertEqual(AbilityDelegatorRegistry.AbilityLifecycleState.BACKGROUND);
console.debug("====>ACTS_GetAbilityState_0200 end====");
flag=false;
done();
console.log("====>ACTS_GetAbilityState_0200 end====");
commonEvent.unsubscribe(subscriber, UnSubscribeCallback);
}
commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => {
console.log("ACTS_GetAbilityState_0200====>Create Subscriber====>");
subscriber = data;
await commonEvent.subscribe(subscriber, onAbilityForegroundCallback2);
})
function UnSubscribeCallback() {
console.log("ACTS_GetAbilityState_0200====>UnSubscribe CallBack====>");
done();
}
abilityDelegator.addAbilityMonitor(
{abilityName: 'MainAbility2',
......@@ -58,24 +74,15 @@ export default function abilityTest() {
onAbilityBackground:onAbilityBackgroundCallback2
}
).then(()=>{
console.debug("====>addAbilityMonitor_0200 finish====");
console.log("====>addAbilityMonitor_0200 finish====");
globalThis.abilityContext.startAbility(
{
bundleName: 'com.example.actsgetabilitystatestagetest',
abilityName: 'MainAbility2',
}, (err)=>{
console.debug("====>startAbility_0200 err:" + JSON.stringify(err));
console.log("====>startAbility_0200 err:" + JSON.stringify(err));
})
})
setTimeout(()=>{
if(flag==true){
console.debug("====>in timeout 0200====");
expect().assertFail();
done();
}
},START_ABILITY_TIMEOUT)
})
/*
......@@ -84,46 +91,54 @@ export default function abilityTest() {
* @tc.desc : Get the status of the Ability in the FOREGROUND state
*/
it('ACTS_GetAbilityState_0300', 0, async function (done) {
console.debug('====>start ACTS_GetAbilityState_0300====');
var flag = true;
var ability;
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
console.log('====>start ACTS_GetAbilityState_0300====');
let ability;
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let count = 0;
let subscriber;
function onAbilityForegroundCallback3(){
console.debug("====>onAbilityForegroundCallback3====");
abilityDelegator.getCurrentTopAbility((err, data)=>{
console.debug("====>getCurrentTopAbility_0300 err:" + JSON.stringify(err) + "data:" + JSON.stringify(data));
console.log("====>onAbilityForegroundCallback3====");
count++;
if (count == 2) {
abilityDelegator.getCurrentTopAbility((err, data)=>{
console.log("====>getCurrentTopAbility_0300 err:" + JSON.stringify(err) + "data:" + JSON.stringify(data));
ability = data;
var state = abilityDelegator.getAbilityState(ability);
console.debug("====>ACTS_GetAbilityState_0300 state:" + state);
let state = abilityDelegator.getAbilityState(ability);
console.log("====>ACTS_GetAbilityState_0300 state:" + state);
expect(state).assertEqual(AbilityDelegatorRegistry.AbilityLifecycleState.FOREGROUND);
expect(state != AbilityDelegatorRegistry.AbilityLifecycleState.CREATE).assertTrue()
expect(state != AbilityDelegatorRegistry.AbilityLifecycleState.DESTROY).assertTrue()
expect(state != AbilityDelegatorRegistry.AbilityLifecycleState.CREATE).assertTrue();
expect(state != AbilityDelegatorRegistry.AbilityLifecycleState.DESTROY).assertTrue();
abilityDelegator.doAbilityBackground(ability, (err)=>{
console.debug("====>doAbilityBackground_0300 data:" + JSON.stringify(err));
console.log("====>doAbilityBackground_0300 data:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ACTS_GetAbilityState_0300 end====");
flag=false;
done();
console.log("====>ACTS_GetAbilityState_0300 end====");
commonEvent.unsubscribe(subscriber, UnSubscribeCallback);
})
})
}
setTimeout(()=>{
if(flag==true){
console.debug("====>in timeout 0300====");
expect().assertFail();
done();
}
},START_ABILITY_TIMEOUT)
}
commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => {
console.log("ACTS_GetAbilityState_0300====>Create Subscriber====>");
subscriber = data;
await commonEvent.subscribe(subscriber, onAbilityForegroundCallback3);
})
function UnSubscribeCallback() {
console.log("ACTS_GetAbilityState_0300====>UnSubscribe CallBack====>");
done();
}
abilityDelegator.addAbilityMonitor(
{abilityName: 'MainAbility3',
onAbilityForeground:onAbilityForegroundCallback3}).then(()=>{
console.debug("====>addAbilityMonitor_0300 finish====");
console.log("====>addAbilityMonitor_0300 finish====");
globalThis.abilityContext.startAbility(
{
bundleName: 'com.example.actsgetabilitystatestagetest',
abilityName: 'MainAbility3',
}, (err)=>{
console.debug("====>startAbility_0300 err:" + JSON.stringify(err));
console.log("====>startAbility_0300 err:" + JSON.stringify(err));
})
})
})
......@@ -134,13 +149,13 @@ export default function abilityTest() {
* @tc.desc : Get the status of an inactive or nonexistent Ability
*/
it('ACTS_GetAbilityState_0500', 0, async function (done) {
console.debug('====>start ACTS_GetAbilityState_0500====');
var ability = Object.create(null);
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var state = abilityDelegator.getAbilityState(ability);
console.debug("====>ACTS_GetAppState_0500 state:" + state);
console.log('====>start ACTS_GetAbilityState_0500====');
let ability = Object.create(null);
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let state = abilityDelegator.getAbilityState(ability);
console.log("====>ACTS_GetAppState_0500 state:" + state);
expect(state).assertEqual(undefined);
console.debug("====>ACTS_GetAbilityState_0500 end====");
console.log("====>ACTS_GetAbilityState_0500 end====");
done();
})
......@@ -150,49 +165,56 @@ export default function abilityTest() {
* @tc.desc : Get the status of the Ability in the uninitialized state
*/
it('ACTS_GetAbilityState_0600', 0, async function (done) {
console.debug('====>start ACTS_GetAbilityState_0600====')
var flag = true;
var ability;
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
console.log('====>start ACTS_GetAbilityState_0600====');
let ability;
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let count = 0;
let subscriber;
function onAbilityForegroundCallback6(){
console.debug("====>onAbilityForegroundCallback6====");
abilityDelegator.getCurrentTopAbility((err, data)=>{
console.debug("====>getCurrentTopAbility_0600 err:" + JSON.stringify(err) + "data:" + JSON.stringify(data));
console.log("====>onAbilityForegroundCallback6====");
count++;
if (count == 2) {
abilityDelegator.getCurrentTopAbility((err, data)=>{
console.log("====>getCurrentTopAbility_0600 err:" + JSON.stringify(err) + "data:" + JSON.stringify(data));
ability = data;
globalThis.ability4Context.terminateSelf();
})
})
}
}
function onAbilityDestroyCallback6(){
console.debug("====>onAbilityDestroyCallback6====");
var state = abilityDelegator.getAbilityState(ability);
console.debug("====>ACTS_GetAbilityState_0600 data:" + state);
console.debug("====>UNINITIALIZED:"+ AbilityDelegatorRegistry.AbilityLifecycleState.UNINITIALIZED);
console.log("====>onAbilityDestroyCallback6====");
let state = abilityDelegator.getAbilityState(ability);
console.log("====>ACTS_GetAbilityState_0600 data:" + state);
console.log("====>UNINITIALIZED:"+ AbilityDelegatorRegistry.AbilityLifecycleState.UNINITIALIZED);
expect(state).assertEqual(AbilityDelegatorRegistry.AbilityLifecycleState.UNINITIALIZED);
console.debug("====>ACTS_GetAbilityState_0600 end====");
flag=false;
done();
console.log("====>ACTS_GetAbilityState_0600 end====");
commonEvent.unsubscribe(subscriber, UnSubscribeCallback);
}
setTimeout(()=>{
if(flag==true){
console.debug("====>in timeout 0600===");
expect().assertFail();
done();
}
},START_ABILITY_TIMEOUT)
commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => {
console.log("ACTS_GetAbilityState_0600====>Create Subscriber====>");
subscriber = data;
await commonEvent.subscribe(subscriber, onAbilityForegroundCallback6);
})
function UnSubscribeCallback() {
console.log("ACTS_GetAbilityState_0600====>UnSubscribe CallBack====>");
done();
}
abilityDelegator.addAbilityMonitor(
{abilityName: 'MainAbility4',
onAbilityForeground:onAbilityForegroundCallback6,
onAbilityDestroy:onAbilityDestroyCallback6}).then(()=>{
console.debug("====>addAbilityMonitor_0600 finish====");
console.log("====>addAbilityMonitor_0600 finish====");
globalThis.abilityContext.startAbility(
{
bundleName: 'com.example.actsgetabilitystatestagetest',
abilityName: 'MainAbility4',
}, (err)=>{
console.debug("====>startAbility_0600 err:" + JSON.stringify(err));
console.log("====>startAbility_0600 err:" + JSON.stringify(err));
})
})
})
})
}
\ No newline at end of file
......@@ -36,6 +36,13 @@ export default class MainAbility extends Ability {
globalThis.ability3Context = this.context
windowStage.setUIContent(this.context, "pages/index1", null)
windowStage.on('windowStageEvent', (data) => {
console.log(`ActsGetCurrentTopAbilityStagebTest onWindwoStage is : ${JSON.stringify(data)}`)
if (data == 2 ) {
console.log(`ActsGetCurrentTopAbilityStagebTest getWindowStageActive is sucess`)
commonEvent.publish("GetCurrentTopAbility", publishCallBackOne);
}
})
}
onWindowStageDestroy() {
......@@ -46,7 +53,6 @@ export default class MainAbility extends Ability {
onForeground() {
// Ability has brought to foreground
console.log("Ability1 onForeground")
commonEvent.publish("GetCurrentTopAbility", publishCallBackOne);
}
......
......@@ -28,6 +28,11 @@ var osAccountManager
const START_ABILITY_TIMEOUT = 10000;
console.debug("====>in Ability.test====>");
export default function abilityTest() {
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
console.debug("====>in function abilityTest====>");
describe('ActsInterfaceMultiUsersTest', function () {
// afterAll(function() {
......@@ -135,44 +140,20 @@ export default function abilityTest() {
* @tc.desc : Start an ability with the parameter startability with options failed.(promise)
*/
it('ACTS_startAbility_2200', 0, async function (done) {
let TAG = 'ACTS_startAbility_2200'
let Subscriber
function SubscribeCallBack (err, data) {
expect().assertFail();
console.debug(TAG + "====>0200 Subscribe CallBack data:====>" + JSON.stringify(data));
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
commonEvent.createSubscriber(subscriberInfo_MainAbility).then((data) => {
console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug(TAG + "====>start startAbility====>");
await globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
}, {
windowMode:0
}).then(()=>{
console.debug(TAG + "====>startAbility end====>");
})
})
})
function UnSubscribeCallback() {
console.debug(TAG + "====>UnSubscribeCallback====>");
let TAG = 'ACTS_startAbility_2200';
await globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
}, {
windowMode:0
}).then(()=>{
console.debug(TAG + "====>startAbility end====>");
}).catch((err) => {
console.info(TAG + 'ACTS_startAbility_2200 - error');
expect(err.code == 16000001).assertTrue();
done();
}
function timeout() {
console.debug(TAG + 'ACTS_startAbility_2200 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
})
})
/*
......@@ -238,45 +219,23 @@ export default function abilityTest() {
* @tc.desc : Start an ability with the parameter startability with options failed.(callback)
*/
it('ACTS_startAbility_2600', 0, async function (done) {
let TAG = 'ACTS_startAbility_2600'
let Subscriber
function SubscribeCallBack (err, data) {
expect().assertFail();
console.debug(TAG + "====>0200 Subscribe CallBack data:====>" + JSON.stringify(data));
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => {
console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
console.debug(TAG + "====>start startAbility====>");
let TAG = 'ACTS_startAbility_2600';
console.debug(TAG + "====>start startAbility====>");
try {
await globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
}, {
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
}, {
windowMode:0
},() => {
console.debug(TAG + "====>startAbility end====>" );
},(err) => {
console.info(TAG + "====>startAbility end====>" );
expect(err.code == 16000001).assertTrue();
done();
})
})
function UnSubscribeCallback() {
console.debug(TAG + "====>UnSubscribeCallback====>");
done();
}
function timeout() {
console.debug(TAG + 'ACTS_startAbility_2600 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
} catch (err) {
console.info(TAG + 'ACTS_startAbility_2600 - error');
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
})
/*
......@@ -427,24 +386,19 @@ export default function abilityTest() {
* @tc.desc : Starting mainability3 with startAbilityForResult failed.(promise)
*/
it('ACTS_StartAbilityForResult_0200', 0, async function (done) {
let TAG = 'ACTS_StartAbilityForResult_0200'
function timeout() {
console.debug(TAG + 'ACTS_startAbilityForResult_0200 - timeout');
done();
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
let TAG = 'ACTS_StartAbilityForResult_0200';
console.debug(TAG + "====>start startAbilityForResult====>");
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility3',
}, {
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility3',
}, {
windowMode:0
}).then((data)=>{
}).then((err, data)=>{
console.debug(TAG + "====>startAbilityForResult end====>");
expect().assertFail();
expect(data.resultCode).assertEqual(1)
expect(data.want.action).assertEqual('ACTION')
}).catch((err) => {
console.info(TAG + 'ACTS_startAbilityForResult_0200 - error');
expect(err.code == 16000001).assertTrue();
done();
})
})
......@@ -487,26 +441,23 @@ export default function abilityTest() {
* @tc.desc : Starting mainability3 with startAbilityForResult failed.(callback)
*/
it('ACTS_StartAbilityForResult_0400', 0, async function (done) {
let TAG = 'ACTS_StartAbilityForResult_0400'
function timeout() {
console.debug(TAG + 'ACTS_startAbilityForResult_0400 - timeout');
done();
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
let TAG = 'ACTS_StartAbilityForResult_0400';
console.debug(TAG + "====>start startAbilityForResult====>");
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility3',
}, {
windowMode:0
},(err,data)=>{
expect().assertFail();
console.debug(TAG + "====>startAbilityForResult end====>");
expect(data.resultCode).assertEqual(1)
expect(data.want.action).assertEqual('ACTION')
done();
})
try {
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility3',
}, {
windowMode:0
},(err, data)=>{
console.debug(TAG + "====>startAbilityForResult end====>");
expect(err.code == 16000001).assertTrue();
done();
})
} catch (err) {
console.info(TAG + 'ACTS_startAbilityForResult_0400 - error');
}
})
/*
......@@ -721,6 +672,7 @@ export default function abilityTest() {
* then terminateself ability and return result succeeded.(callback)
*/
it('ACTS_TerminateSelfWithResult_0300', 0, async function (done) {
await sleep(2000);
let TAG = 'ACTS_TerminateSelfWithResult_0300'
var flag = true
function timeout() {
......
......@@ -36,7 +36,20 @@ export default class TestAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
globalThis.onWindowStageActive = false;
let count = 0;
windowStage.setUIContent(this.context, 'MainAbility/pages/index', null)
windowStage.on('windowStageEvent', (data) => {
console.log(`ActsApiTest onWindwoStage is : ${JSON.stringify(data)}`)
if (data == 2 ) {
console.log(`ActsApiTest onWindwoStage count is : ${count}`)
count++;
if (count == 2) {
console.log(`ActsApiTest onWindwoStage count is : ${count}`)
globalThis.onWindowStageActive = true;
}
}
})
}
onWindowStageDestroy() {
......
......@@ -31,7 +31,18 @@ export default function abilityTest() {
describe('ActsChangeAbilityStagetest', function () {
beforeAll(async function (done) {
console.info('beforeAll called')
await sleep(2000)
let delay = 3000;
let start = new Date().getTime();
while (true) {
if (globalThis.onWindowStageActive) {
console.log(`ActsApiTest getWindwoStageActive is success`)
break;
}
if (new Date().getTime() - start > delay) {
console.log(`ActsApiTest getWindwoStageActive is failed`)
break;
}
}
await globalThis.abilitydelegator.getCurrentTopAbility().then((data) => {
mainability = data
done()
......
......@@ -82,7 +82,7 @@ export default function test() {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_0200 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
expect(data.data).assertEqual("check permission deny, need to request ohos.permission.REQUIRE_FORM.");
expect(data.data).assertEqual("check permission deny, need to request ohos.permission.REQUIRE_FORM or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS.");
commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallback("FMS_acquireForm_0200"));
console.info(`FMS_acquireForm_0200 end`);
done();
......
......@@ -19,8 +19,6 @@ group("non_concurrent") {
deps = [
"acts_systemappa_test:ActsSystemAppATest",
"acts_systemappone_rely_test:ActsSystemAppOneRelyHap",
"actsthirdappatest:ActsThirdAppATest",
"actsthirdapponerelytest:ActsThirdAppOneRelyHap",
]
}
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"bundle-name": "com.example.actsabilitypermissionthirdtest",
"module-name": "entry",
"shell-timeout": "300000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"power-shell setmode 602"
]
},
{
"type": "ShellKit",
"run-command": [
"remount"
]
},
{
"type": "ShellKit",
"run-command": [
"acm create -n 101 -t normal",
"acm switch -i 101"
],
"teardown-command": [
"acm delete -i 101"
]
},
{
"type": "ShellKit",
"run-command": [
"acm switch -i 100"
]
},
{
"type": "PushKit",
"push": [
"ActsThirdAppATest.hap->/data/app/ActsThirdAppATest.hap",
"ActsThirdAppOneRelyHap.hap->/data/app/ActsThirdAppOneRelyHap.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"bm install -u100 -p /data/app/ActsThirdAppATest.hap",
"bm install -u101 -p /data/app/ActsThirdAppOneRelyHap.hap"
],
"teardown-command": [
"bm uninstall -n com.example.actsabilitypermissionthirdtest"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/*.hap"
]
}
]
}
\ 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 AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
}
}
\ 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
function PublishCallBackOne1() {
console.debug("====>Publish CallBack ACTS_ThirdPartyAbilityPermission_0100_CommonEvent====>");
globalThis.ability2Context.terminateSelf();
console.debug("====>close this context====>")
}
export default class MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("MainAbility2 onCreate")
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility2 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index2", null)
globalThis.ability2Context = this.context;
commonEvent.publish("ACTS_ThirdPartyAbilityPermission_0100_Start_CommonEvent", PublishCallBackOne1);
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("MainAbility2 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility2 onForeground")
}
onBackground() {
// Ability has back to background
console.log("MainAbility2 onBackground")
}
};
/*
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import commonEvent from '@ohos.commonEvent'
var AbilityPermission1 = {
events: ["ACTS_ThirdPartyAbilityPermission_0100_Start_CommonEvent"]
}
var AbilityPermission3 = {
events: ["ACTS_ThirdPartyAbilityPermission_0300_Start_CommonEvent"]
}
var AbilityPermission6 = {
events: ["ACTS_ThirdPartyAbilityPermission_0600_Start_CommonEvent"]
}
const START_ABILITY_TIMEOUT = 3000;
export default function abilityPermissionTest() {
describe('ActsAbilityPermissionTest', function () {
var userA=100;
var userB=101;
/*
* @tc.number: ACTS_ThirdPartyAbilityPermission_0100
* @tc.name: In non-concurrent mode, if the target application is not the current user, it is forbidden to start
* @tc.desc: Start an ability that belongs to the current user with the current user
*/
it('ACTS_ThirdPartyAbilityPermission_0100', 0, async function (done) {
console.log("ACTS_ThirdPartyAbilityPermission_0100====>callback start====>")
var Subscriber;
var flag = true;
function SubscribeCallBack(err, data) {
console.debug("ACTS_ThirdPartyAbilityPermission_0100====>Subscribe CallBack data:" + JSON.stringify(data));
expect(data.event == 'ACTS_ThirdPartyAbilityPermission_0100_Start_CommonEvent').assertTrue()
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
commonEvent.createSubscriber(AbilityPermission1).then(async (data) => {
console.debug("ACTS_ThirdPartyAbilityPermission_0100====>Create Subscriber====>");
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility_100====>");
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.example.actsabilitypermissionthirdtest',
abilityName: 'MainAbility2'
}, userA, () => {
console.debug("====>startAbility end_100====>");
})
})
function UnSubscribeCallback() {
flag = false
console.debug("ACTS_ThirdPartyAbilityPermission_0100====>UnSubscribe CallBack====>"+flag);
done();
}
setTimeout(()=>{
if (flag == true) {
expect().assertFail();
console.debug('in ACTS_ThirdPartyAbilityPermission_0100====>timeout====>'+flag);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
}
console.debug('ACTS_ThirdPartyAbilityPermission_0100====>timeout====>');
}, START_ABILITY_TIMEOUT);
})
/*
* @tc.number: ACTS_ThirdPartyAbilityPermission_0300
* @tc.name: In non-concurrent mode, if the target application is not the current user, it is forbidden to start
* @tc.desc: Start an ability under user U101 with the current user
*/
it('ACTS_ThirdPartyAbilityPermission_0300', 0, async function (done) {
console.log("ACTS_ThirdPartyAbilityPermission_0300====>callback start====>")
var Subscriber
var flag = 0;
console.debug("====>get AccountManager finish====");
function SubscribeCallBack(err, data) {
console.debug("ACTS_ThirdPartyAbilityPermission_0300====>Subscribe CallBack data:" + JSON.stringify(data));
expect(data.event == 'ACTS_ThirdPartyAbilityPermission_0300_Start_CommonEvent').assertTrue()
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
}
commonEvent.createSubscriber(AbilityPermission3).then(async (data) => {
console.debug("ACTS_ThirdPartyAbilityPermission_0300====>Create Subscriber====>");
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility_0300====>");
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.example.actsthirdappuonehundredone',
abilityName: 'MainAbility'
}, userB ).then().catch((err) => {
console.debug("ACTS_ThirdPartyAbilityPermission_0300====>" + err)
console.debug("====>startAbility end_0300====>");
})
})
function UnSubscribeCallback() {
if(flag == 0) {
expect().assertFail();
}
console.debug("ACTS_ThirdPartyAbilityPermission_0300====>UnSubscribe CallBack====>");
done();
}
function timeout() {
console.debug('ACTS_ThirdPartyAbilityPermission_0300====>timeout====>');
if(flag == 0){
flag = 1;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
}
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
})
/*
* @tc.number: ACTS_ThirdPartyAbilityPermission_0600
* @tc.name: In non-concurrent mode, if the target application is not the current user, it is forbidden to start
* @tc.desc: Bind a U101 Ability with the current user
*/
it('ACTS_ThirdPartyAbilityPermission_0600', 0, async function (done) {
console.log("ACTS_ThirdPartyAbilityPermission_0600====>callback start====>")
let Subscriber
let connId
function onConnectCallbackC(element, remote) {
console.log('ACTS_ThirdPartyAbilityPermission_0600_Start_CommonEvent onConnectCallback====>'+
' element=' + JSON.stringify(element));
console.log('ACTS_ThirdPartyAbilityPermission_0600_Start_CommonEvent onConnectCallback====>'+
' remote=' + JSON.stringify(remote));
expect().assertFail();
}
function onDisconnectCallbackC(element) {
console.log('onDisconnectCallback====> element=' + JSON.stringify(element));
}
function onFailedCallbackC(code) {
console.log('onFailedCallback====> code=' + JSON.stringify(code))
}
function SubscribeCallBackF(err, data) {
console.debug("====>0600 Subscribe CallBack data:====>" + JSON.stringify(data));
}
function UnSubscribeCallbackF() {
console.debug("====>UnSubscribeCallback====>");
}
commonEvent.createSubscriber(AbilityPermission6).then(async (data) => {
console.debug("====>Create Subscriber====>");
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBackF);
})
console.debug("====>0600start connectAbility====>");
connId = await globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: 'com.example.actsthirdappuonehundredone',
abilityName: 'ServiceAbility',
action: "StartAbilityPromise"
}, userB, {
onConnect: onConnectCallbackC,
onDisconnect: onDisconnectCallbackC,
onFailed: onFailedCallbackC
})
console.debug("====>number is====>" + JSON.stringify(connId));
setTimeout(() =>{
console.debug('in ACTS_ThirdPartyAbilityPermission_0600_Start_CommonEvent timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallbackF)
done()
}, START_ABILITY_TIMEOUT);
})
})
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "entry_test_desc",
"value": "i am an entry for tv"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
},
{
"name": "MainAbility2_desc",
"value": "description"
},
{
"name": "MainAbility2_label",
"value": "label"
},
{
"name": "Service_desc",
"value": "description"
},
{
"name": "Service_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"src": [
"pages/index/index2",
"TestAbility/pages/index"
]
}
\ 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 AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
\ 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
function PublishCallBackOne3() {
console.debug("====>Publish CallBack ACTS_ThirdPartyAbilityPermission_0300_CommonEvent====>");
setTimeout(globalThis.abilityContext.terminateSelfWithResult(()=>{
console.debug("====>terminateSelfWithResult succese====>")
}),1000)
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
commonEvent.publish("ACTS_ThirdPartyAbilityPermission_0300_Start_CommonEvent", PublishCallBackOne3);
windowStage.setUIContent(this.context, "pages/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("MainAbility onBackground")
}
};
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
\ No newline at end of file
......@@ -22,6 +22,8 @@ ohos_js_hap_suite("ActsUiTest") {
ets2abc = true
certificate_profile = "//test/xts/acts/arkXtest/uitest/signature/auto_ohos_default_com.uitest.test.p7b"
hap_name = "ActsUiTest"
part_name = "arkXtest"
subsystem_name = "arkXtest"
}
ohos_js_assets("uitest_ets_assets") {
......
......@@ -166,6 +166,20 @@ export default function UiTest() {
expect(button2 != null).assertTrue()
await stopApplication('com.uitestScene.acts')
})
/*
* @tc.number: uiTest_10007
* @tc.name: testInWindow
* @tc.desc: scroll the mouse wheel at the specified location to specify the cell.
*/
it('testInWindow', 0, async function () {
await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
let driver = Driver.create()
await driver.delayMs(waitUiReadyMs)
let btn = await driver.findComponent(ON.inWindow('com.uitestScene.acts').text('next page'))
expect(btn != null).assertTrue()
await stopApplication('com.uitestScene.acts')
})
})
describe('UiTest_API8', function () {
......
......@@ -24,6 +24,8 @@ ohos_hap_assist_suite("ActsUiTestScene") {
testonly = true
certificate_profile = "//test/xts/acts/arkXtest/uitestScene/signature/auto_ohos_default_com.uitestScene.test.p7b"
hap_name = "ActsUiTestScene"
part_name = "arkXtest"
subsystem_name = "arkXtest"
}
ohos_js_assets("uitest_scene_ets_assets") {
......
# Copyright (C) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
......@@ -15,9 +15,21 @@ group("componentUxTest") {
testonly = true
if (is_standard_system) {
deps = [
"ace_ets_component_badge:ActsAcebadgeTest",
"ace_ets_component_button:ActsAceButtonTest",
"ace_ets_component_checkbox:ActsAceCheckboxTest",
"ace_ets_component_datapanel:ActsAceDatapanelTest",
"ace_ets_component_datepicker:ActsAceDatePickerTest",
"ace_ets_component_progress:ActsAceProgressTest",
"ace_ets_component_radio:ActsAceRadioTest",
"ace_ets_component_select:ActsAceSelectTest",
"ace_ets_component_sidebar:ActsAceSideBarTest",
"ace_ets_component_swiper:ActsAceSwiperTest",
"ace_ets_component_tabs:ActsAceTabsTest",
"ace_ets_component_text:ActsAceTextTest",
"ace_ets_component_textinput:ActsAceTextInputTest",
"ace_ets_component_textpicker:ActsAceTextPickerTest",
"ace_ets_component_timepicker:ActsAceTimePickerTest",
]
}
}
{
"app": {
"bundleName": "com.example.badgetest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string":[
{
"name":"app_name",
"value":"MyApplication"
}
]
}
\ No newline at end of file
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAcebadgeTest") {
hap_profile = "src/main/module.json"
js_build_mode = "debug"
deps = [
":ace_ets_component_badge_js_assets",
":ace_ets_component_badge_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAcebadgeTest"
part_name = "ace_engine"
subsystem_name = "arkui"
}
ohos_app_scope("ace_ets_component_badge_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("ace_ets_component_badge_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("ace_ets_component_badge_resources") {
sources = [ "src/main/resources" ]
deps = [ ":ace_ets_component_badge_profile" ]
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.badgetest",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 240000
},
"kits": [{
"test-file-name": [
"ActsAcebadgeTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602"
]
}
]
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import testsuite from '../test/List.test'
import Window from '@ohos.window'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import badgeTest from './badge'
export default function testsuite() {
badgeTest()
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"metadata": [{
"name": "ArkTSPartialUpdate",
"value": "true"
}],
"abilities": [
{
"name": "TestAbility",
"srcEntrance": "./ets/TestAbility/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"visible": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
]
}
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
},
{
"name": "Divider_color",
"value": "#000000"
},
{
"name": "badge_BorderColor",
"value": "#FFFD0000"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_test_desc",
"value": "test ability description"
},
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
},
{
"name": "Divider_width",
"value": "10px"
},
{
"name": "Divider_startMargin",
"value": "5px"
},
{
"name": "Divider_endMargin",
"value": "5px"
},
{
"name": "badge_Size_test",
"value": "7vp"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.buttontest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string":[
{
"name":"app_name",
"value":"MyApplication"
}
]
}
\ No newline at end of file
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAceButtonTest") {
hap_profile = "src/main/module.json"
js_build_mode = "debug"
deps = [
":ace_ets_component_button_js_assets",
":ace_ets_component_button_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAceButtonTest"
part_name = "ace_engine"
subsystem_name = "arkui"
}
ohos_app_scope("ace_ets_component_button_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("ace_ets_component_button_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("ace_ets_component_button_resources") {
sources = [ "src/main/resources" ]
deps = [ ":ace_ets_component_button_profile" ]
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.buttontest",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 240000
},
"kits": [{
"test-file-name": [
"ActsAceButtonTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602"
]
}
]
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import testsuite from '../test/List.test'
import Window from '@ohos.window'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//@ts-nocheck
import events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import hilog from '@ohos.hilog';
import testsuite from '../../test/List.test'
@Entry
@Component
struct textInputTest {
aboutToAppear(){
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
@State txtA: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtB: string = 'overflowTextOverlengthTextOverflow.Ellipsis';
@State txtC: string = 'overflowTextOverlengthTextOverflow.None';
@State txtD: string = 'overflowTextOverflow.Race';
@State txtE: string = 'overflowTextOverflow.MultilineClip';
@State txtF: string = 'overflowTextOverflow.MultilineEllipsis';
@State txtG: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtH: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtI: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtJ: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtK: string = 'overfloTextOverlengthTextOverflow.Clip';
@State txtL: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtM: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtN: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtO: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtP: string = 'overflowTextOverlengthTextOverflow.Clipe';
@State txtQ: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtR: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtS: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtT: string = 'overflowTextOverlengthTextOverflow.Clipe';
@State txtU: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtV: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtW: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtX: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtY: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtZ: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txta: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtb: string = 'overflowTextOverlengthTextOverflow.Clip';
@State txtc: string = 'overflowTextOverlength TextOverflow.Clip';
@State txtd: string = 'overflowTextOverlength TextOverflow.Clip';
@State widthLongSize: number = 300;
@State widthShortSize: number = 200;
@State colorInfo: string = "#f2eada";
private scroller: Scroller = new Scroller()
build() {
Column() {
Stack({ alignContent: Alignment.End }) {
Scroll(this.scroller) {
Flex({ direction: FlexDirection.Column }) {
Text('ArkUX_Stage_Button_LabelStyle_0100').fontSize(15).margin({top:20})
Button(this.txtA)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Clip,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy: TextHeightAdaptivePolicy.MaxLines,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic }
})
.key("ArkUX_Stage_Button_LabelStyle_0100")
Text('ArkUX_Stage_Button_LabelStyle_0200').fontSize(15).margin({top:20})
Button(this.txtB)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Clip,
maxLines: 3, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MaxLines,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_0200")
Text('ArkUX_Stage_Button_LabelStyle_0300').fontSize(15).margin({top:20})
Button(this.txtC)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Clip,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MinFontSize,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_0300")
Text('ArkUX_Stage_Button_LabelStyle_0400').fontSize(15).margin({top:20})
Button(this.txtD)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Clip,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MinFontSize,
font: { weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Normal } })
.key("ArkUX_Stage_Button_LabelStyle_0400")
Text('ArkUX_Stage_Button_LabelStyle_0500').fontSize(15).margin({top:20})
Button(this.txtE)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Clip,
maxLines: 3, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.LayoutConstraint,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_0500")
Text('ArkUX_Stage_Button_LabelStyle_0600').fontSize(15).margin({top:20})
Button(this.txtF)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Ellipsis,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MaxLines,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_0600")
Text('ArkUX_Stage_Button_LabelStyle_0700').fontSize(15).margin({top:20})
Button(this.txtG)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Ellipsis,
maxLines: 3, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MaxLines,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_0700")
Text('ArkUX_Stage_Button_LabelStyle_0800').fontSize(15).margin({top:20})
Button(this.txtH)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Ellipsis,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MinFontSize,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_0800")
Text('ArkUX_Stage_Button_LabelStyle_0900').fontSize(15).margin({top:20})
Button(this.txtI)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Ellipsis,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MinFontSize,
font: { weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Normal } })
.key("ArkUX_Stage_Button_LabelStyle_0900")
Text('ArkUX_Stage_Button_LabelStyle_1000').fontSize(15).margin({top:20})
Button(this.txtJ)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Ellipsis,
maxLines: 3, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.LayoutConstraint,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_1000")
Text('ArkUX_Stage_Button_LabelStyle_1100').fontSize(15).margin({top:20})
Button(this.txtK)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.None,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MaxLines,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_1100")
Text('ArkUX_Stage_Button_LabelStyle_1200').fontSize(15).margin({top:20})
Button(this.txtL)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.None,
maxLines: 3, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MaxLines,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_1200")
Text('ArkUX_Stage_Button_LabelStyle_1300').fontSize(15).margin({top:20})
Button(this.txtM)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.None,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MinFontSize,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_1300")
Text('ArkUX_Stage_Button_LabelStyle_1400').fontSize(15).margin({top:20})
Button(this.txtN)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.None,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MinFontSize,
font: { weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Normal } })
.key("ArkUX_Stage_Button_LabelStyle_1400")
Text('ArkUX_Stage_Button_LabelStyle_1500').fontSize(15).margin({top:20})
Button(this.txtO)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.None,
maxLines: 3, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.LayoutConstraint,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_1500")
Text('ArkUX_Stage_Button_LabelStyle_1600').fontSize(15).margin({top:20})
Button(this.txtP)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Ellipsis,
maxLines: 1 })
.key("ArkUX_Stage_Button_LabelStyle_1600")
Text('ArkUX_Stage_Button_LabelStyle_1700').fontSize(15).margin({top:20})
Button(this.txtQ)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Ellipsis,
minFontSize: 5 })
.key("ArkUX_Stage_Button_LabelStyle_1700")
Text('ArkUX_Stage_Button_LabelStyle_1800').fontSize(15).margin({top:20})
Button(this.txtR)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Ellipsis,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MaxLines
})
.key("ArkUX_Stage_Button_LabelStyle_1800")
Text('ArkUX_Stage_Button_LabelStyle_1900').fontSize(15).margin({top:20})
Button(this.txtS)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Ellipsis,
font: { size: 15, weight: FontWeight.Medium, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_1900")
Text('ArkUX_Stage_Button_LabelStyle_2000').fontSize(15).margin({top:20})
Button(this.txtT)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Ellipsis })
.key("ArkUX_Stage_Button_LabelStyle_2000")
Text('ArkUX_Stage_Button_LabelStyle_2100').fontSize(15).margin({top:20})
Button(this.txtU)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MaxLines,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_2100")
Text('ArkUX_Stage_Button_LabelStyle_2200').fontSize(15).margin({top:20})
Button(this.txtV)
.width(this.widthShortSize)
.key("ArkUX_Stage_Button_LabelStyle_2200")
Text('ArkUX_Stage_Button_LabelStyle_2300').fontSize(15).margin({top:20})
Button(this.txtW)
.width(this.widthLongSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Clip,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MaxLines,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_2300")
Text('ArkUX_Stage_Button_LabelStyle_2400').fontSize(15).margin({top:20})
Button(this.txtX)
.width(this.widthLongSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Ellipsis,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MaxLines,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_2400")
Text('ArkUX_Stage_Button_LabelStyle_2500').fontSize(15).margin({top:20})
Button(this.txtY)
.width(this.widthLongSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.None,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MaxLines,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_2500")
Text('ArkUX_Stage_Button_LabelStyle_2600').fontSize(15).margin({top:20})
Button(this.txtZ)
.width(this.widthLongSize)
.key("ArkUX_Stage_Button_LabelStyle_2600")
Text('ArkUX_Stage_Button_LabelStyle_2700').fontSize(15).margin({top:20})
Button(this.txta)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: null,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MaxLines,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_2700")
Text('ArkUX_Stage_Button_LabelStyle_2800').fontSize(15).margin({top:20})
Button(this.txtb)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: 0,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MaxLines,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_2800")
Text('ArkUX_Stage_Button_LabelStyle_2900').fontSize(15).margin({top:20})
Button(this.txtc,{ type: ButtonType.Capsule, stateEffect: false }).opacity(0.4)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Clip,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MaxLines,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_2900")
Text('ArkUX_Stage_Button_LabelStyle_3000').fontSize(15).margin({top:20})
Button(this.txtd)
.width(this.widthShortSize)
// @ts-ignore
.labelStyle({ overflow: TextOverflow.Race,
maxLines: 1, minFontSize: 5,
heightAdaptivePolicy:TextHeightAdaptivePolicy.MaxLines,
font: { size: 15, weight: FontWeight.Bolder, family: 'cursive', style: FontStyle.Italic } })
.key("ArkUX_Stage_Button_LabelStyle_3000")
}
}
.scrollBar(BarState.Off)
.scrollable(ScrollDirection.Vertical)
ScrollBar({ scroller: this.scroller, direction: ScrollBarDirection.Vertical, state: BarState.Auto })
}
}
.width('100%')
}
}
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import buttonTest from './button'
export default function testsuite() {
buttonTest()
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"metadata": [{
"name": "ArkTSPartialUpdate",
"value": "true"
}],
"abilities": [
{
"name": "TestAbility",
"srcEntrance": "./ets/TestAbility/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"visible": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
]
}
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
},
{
"name": "Divider_color",
"value": "#000000"
},
{
"name": "TextInput_Color",
"value": "#FFFD0000"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_test_desc",
"value": "test ability description"
},
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
},
{
"name": "Divider_width",
"value": "10px"
},
{
"name": "Divider_startMargin",
"value": "5px"
},
{
"name": "Divider_endMargin",
"value": "5px"
},
{
"name": "textInput_Size_test",
"value": "4"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.checkboxtest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string":[
{
"name":"app_name",
"value":"MyApplication"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAceCheckboxTest") {
hap_profile = "src/main/module.json"
js_build_mode = "debug"
deps = [
":ace_ets_component_checkbox_js_assets",
":ace_ets_component_checkbox_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAceCheckboxTest"
part_name = "ace_engine"
subsystem_name = "arkui"
}
ohos_app_scope("ace_ets_component_checkbox_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("ace_ets_component_checkbox_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("ace_ets_component_checkbox_resources") {
sources = [ "src/main/resources" ]
deps = [ ":ace_ets_component_checkbox_profile" ]
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.checkboxtest",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 240000
},
"kits": [{
"test-file-name": [
"ActsAceCheckboxTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602"
]
}
]
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import testsuite from '../test/List.test'
import Window from '@ohos.window'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../test/List.test'
@Entry
@Component
struct Index {
aboutToAppear() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
@State message: string = 'ArkUX XtsTest'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import checkBoxTest from './checkBox'
import checkBoxGroupTest from './checkBoxGroup'
export default function testsuite() {
checkBoxTest()
checkBoxGroupTest()
}
\ No newline at end of file
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
},
{
"name": "Divider_color",
"value": "#000000"
},
{
"name": "checkbox_Color",
"value": "#FFFD0000"
}
]
}
\ No newline at end of file
{
"src": [
"TestAbility/pages/Index",
"TestAbility/pages/CheckBox",
"TestAbility/pages/CheckBoxGroup"
]
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册