提交 ead6ddd2 编写于 作者: J jiyong

jiyong@huawei.com

Signed-off-by: Njiyong <jiyong@huawei.com>
上级 c2129dee
......@@ -9,31 +9,56 @@
},
"deviceConfig": {},
"module": {
"package": "com.example.aceceshi",
"name": ".MyApplication",
"mainAbility": "com.example.aceceshi.MainAbility",
"deviceType": [
"liteWearable",
"smartVision"
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"name": "default",
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.aceceshi.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"name": "decc.testkit.runner.JsEntryAbility",
"label": "$string:entry_MainAbility",
"type": "page"
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"name": "default",
"pages": [
"pages/index/index",
"pages/routerPush/index",
"pages/routerReplace/index"
]
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
......
export default {
onCreate() {
console.info("Application onCreate");
console.info('AceApplication onCreate');
},
onDestroy() {
console.info("Application onDestroy");
console.info('AceApplication onDestroy');
}
};
.container {
width: 454px;
height: 454px;
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
width: 200px;
font-size: 30px;
text-align: center;
font-size: 40px;
color: #000000;
opacity: 0.9;
}
......@@ -12,33 +12,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file'
import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index'
import {Core, ExpectExtend} from 'deccjsunit/index'
export default {
data: {
title: ""
},
onInit() {
console.info('[test page log] index onInit')
this.title = this.$t('strings.world');
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
const reportExtend = new ReportExtend(file)
core.addService('expect', expectExtend)
core.addService('report', reportExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onShow() {
console.info('onShow finish')
console.info('[test page log] index onShow')
},
onReady() {
onHide() {
console.info('[test page log] index onHide')
},
}
......@@ -16,10 +16,10 @@ export default {
data: {
title: "router push test"
},
onInit() {
},
onShow() {
console.info('[test page log] routerPush onShow');
},
onReady() {
onHide() {
console.info('[test page log] routerPush ohHide');
},
}
......@@ -16,10 +16,10 @@ export default {
data: {
title: "router replace test"
},
onInit() {
},
onShow() {
console.info('[test page log] routerReplace onShow');
},
onReady() {
onHide() {
console.info('[test page log] routerReplace ohHide');
},
}
......@@ -34,6 +34,26 @@ describe('basicabilityapi', function () {
afterAll(function () {
});
async function backToIndex(){
let backToIndexPromise = new Promise((resolve, reject) => {
setTimeout(() => {
router.back({
uri: 'pages/index/index'
});
resolve();
}, 500);
});
let clearPromise = new Promise((resolve, reject) => {
setTimeout(() => {
router.clear();
resolve();
}, 500);
});
await backToIndexPromise.then(() => {
return clearPromise;
});
}
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0100
* @tc.name testClearInterval
......@@ -42,21 +62,28 @@ describe('basicabilityapi', function () {
it('testClearInterval', 0, async function(done) {
console.info('testClearInterval START');
let res = 0;
let intervalID = await setInterval(function () {
res++;
console.info('testClearInterval res = ' + res);
}, 100);
await setTimeout(function () {
console.info('[clearInterval] start');
clearInterval(intervalID);
console.info('[clearInterval] end');
}, 600);
await setTimeout(function () {
let intervalID = -1;
let promise1 = new Promise((resolve, reject) => {
intervalID = setInterval(function () {
res++;
console.info('testClearInterval res = ' + res);
resolve();
}, 100);
});
let promise2 = new Promise((resolve, reject) => {
setTimeout(function () {
console.info('[clearInterval] start');
clearInterval(intervalID);
console.info('[clearInterval] end');
resolve();
}, 600);
});
Promise.all([promise1, promise2]).then(() => {
console.info('testClearInterval finally');
expect(5).assertEqual(res);
console.info('testClearInterval END');
done();
}, 1000);
});
});
/**
......@@ -83,22 +110,29 @@ describe('basicabilityapi', function () {
*/
it('testRouterPush', 0, async function (done) {
console.info('testRouterPush START');
await setTimeout(() => {
let promise1 = new Promise((resolve, reject) => {
router.push({
uri: 'pages/routerPush/index'
});
}, 500);
await setTimeout(() => {
let pages = router.getState();
console.info("[router.push] getState" + JSON.stringify(pages));
expect("pages/routerPush/").assertEqual(pages.path);
console.info("[router.push] getLength:" + router.getLength());
expect("2").assertEqual(router.getLength());
console.info('testRouterPush SUCCESS');
router.back();
console.info('testRouterPush END');
done();
}, 1000);
resolve();
});
let promise2 = new Promise((resolve, reject) => {
setTimeout(() => {
let pages = router.getState();
console.info("[router.push] getState" + JSON.stringify(pages));
expect("pages/routerPush/").assertEqual(pages.path);
console.info("[router.push] getLength:" + router.getLength());
expect("2").assertEqual(router.getLength());
console.info('testRouterPush SUCCESS');
resolve();
}, 500);
});
await promise1.then(() => {
return promise2;
});
await backToIndex();
console.info('testRouterPush END');
done();
});
/**
......@@ -108,20 +142,28 @@ describe('basicabilityapi', function () {
*/
it('testRouterPushNotExist', 0, async function (done) {
console.info('testRouterPushNotExist START');
await setTimeout(() => {
let promise1 = new Promise((resolve, reject) => {
router.push({
uri: 'pages/routerNotExist/index'
});
}, 500);
await setTimeout(() => {
let pages = router.getState();
console.info("testRouterPushNotExist getState" + JSON.stringify(pages));
expect("pages/index/").assertEqual(pages.path);
console.info("testRouterPushNotExist getLength:" + router.getLength());
expect("1").assertEqual(router.getLength());
console.info('testRouterPushNotExist END');
done();
}, 1000);
resolve();
});
let promise2 = new Promise((resolve, reject) => {
setTimeout(() => {
let pages = router.getState();
console.info("testRouterPushNotExist getState" + JSON.stringify(pages));
expect("pages/index/").assertEqual(pages.path);
console.info("testRouterPushNotExist getLength:" + router.getLength());
expect("1").assertEqual(router.getLength());
console.info('testRouterPushNotExist success');
resolve();
}, 500);
});
await promise1.then(() => {
return promise2;
});
console.info('testRouterPushNotExist END');
done();
});
/**
......@@ -131,27 +173,39 @@ describe('basicabilityapi', function () {
*/
it('testRouterReplace', 0, async function (done) {
console.info('testRouterReplace START');
await setTimeout(() => {
let promise1 = new Promise((resolve, reject) => {
router.push({
uri: 'pages/routerPush/index'
});
}, 500);
await setTimeout(() => {
router.replace({
uri: 'pages/routerReplace/index'
});
}, 1000);
await setTimeout(() => {
let pages = router.getState();
console.info("[router.replace] getState" + JSON.stringify(pages));
expect("pages/routerReplace/").assertEqual(pages.path);
console.info("[router.replace] getLength:" + router.getLength());
expect("2").assertEqual(router.getLength());
console.info('testRouterReplace SUCCESS');
router.back();
console.info('testRouterReplace END');
done();
}, 1500);
resolve();
});
let promise2 = new Promise((resolve, reject) => {
setTimeout(() => {
router.replace({
uri: 'pages/routerReplace/index'
});
resolve();
}, 500);
});
let promise3 = new Promise((resolve, reject) => {
setTimeout(() => {
let pages = router.getState();
console.info("[router.replace] getState" + JSON.stringify(pages));
expect("pages/routerReplace/").assertEqual(pages.path);
console.info("[router.replace] getLength:" + router.getLength());
expect("2").assertEqual(router.getLength());
console.info('testRouterReplace SUCCESS');
resolve();
}, 1000);
});
await promise1.then(() => {
return promise2;
}).then(() => {
return promise3;
});
await backToIndex();
console.info('testRouterReplace END');
done();
});
/**
......@@ -184,25 +238,38 @@ describe('basicabilityapi', function () {
*/
it('testRouterBack', 0, async function (done) {
console.info('testRouterBack START');
await setTimeout(() => {
let promise1 = new Promise((resolve, reject) => {
router.push({
uri: 'pages/routerPush/index'
});
}, 500);
await setTimeout(() => {
router.back({
uri: 'pages/index/index'
});
}, 1000);
await setTimeout(() => {
let pages = router.getState();
console.info("[router.back] getState" + JSON.stringify(pages));
expect("pages/index/").assertEqual(pages.path);
console.info("[router.back] getLength:" + router.getLength());
expect("1").assertEqual(router.getLength());
console.info('testRouterBack END');
done();
}, 1500);
resolve();
});
let promise2 = new Promise((resolve, reject) => {
setTimeout(() => {
router.back({
uri: 'pages/index/index'
});
resolve();
}, 500);
});
let promise3 = new Promise((resolve, reject) => {
setTimeout(() => {
let pages = router.getState();
console.info("[router.back] getState" + JSON.stringify(pages));
expect("pages/index/").assertEqual(pages.path);
console.info("[router.back] getLength:" + router.getLength());
expect("1").assertEqual(router.getLength());
console.info('testRouterBack SUCCESS');
resolve();
}, 1000);
});
await promise1.then(() => {
return promise2;
}).then(() => {
return promise3;
});
console.info('testRouterBack END');
done();
});
/**
......@@ -228,67 +295,83 @@ describe('basicabilityapi', function () {
let size = router.getLength();
console.info('[router.getLength] pages stack size = ' + size);
expect(size).assertEqual('1');
await setTimeout(() => {
let promise1 = new Promise((resolve, reject) => {
router.push({
uri: 'pages/routerPush/index'
});
}, 500);
await setTimeout(() => {
console.info("testRouterLength getLength:" + router.getLength());
expect("2").assertEqual(router.getLength());
console.info('testRouterPush SUCCESS');
router.back();
console.info('testRouterPush END');
done();
}, 1000);
resolve();
});
let promise2 = new Promise((resolve, reject) => {
setTimeout(() => {
console.info("testRouterLength getLength:" + router.getLength());
expect("2").assertEqual(router.getLength());
console.info('testRouterLength SUCCESS');
resolve();
}, 500);
});
await promise1.then(() => {
return promise2;
});
await backToIndex();
console.info('testRouterLength END');
done();
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0710
* @tc.name testRouterMaxLength
* @tc.desc Test the max number of the page stack is 32.
* @tc.number SUB_ACE_BASICABILITY_JS_API_0800
* @tc.name testRouterGetState
* @tc.desc Get the status information of the current page.
*/
it('testRouterMaxLength', 0, async function (done) {
console.info('testRouterLength START');
let intervalID = await setInterval(async function () {
await router.push({
uri: 'pages/routerPush/index'
});
await router.push({
uri: 'pages/routerReplace/index'
});
console.info('testRouterMaxLength router.getLength:' + router.getLength());
}, 500);
await setTimeout(() => {
clearInterval(intervalID);
}, 1000 * 17);
it('testRouterGetState', 0, async function (done) {
console.info('testRouterGetState START');
await setTimeout(() => {
console.info("testRouterMaxLength getLength:" + router.getLength());
expect("32").assertEqual(router.getLength());
console.info('testRouterMaxLength SUCCESS');
router.back({
uri: 'pages/index/index'
});
console.info('testRouterMaxLength END');
let page = router.getState();
console.info('[router.getState] index: ' + page.index);
console.info('[router.getState] name: ' + page.name);
console.info('[router.getState] path: ' + page.path);
expect(page.index).assertEqual('1');
expect(page.name).assertEqual('index');
expect(page.path).assertEqual('pages/index/');
console.info('testRouterGetState END');
done();
}, (1000 * 18));
}, 500);
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0800
* @tc.name testRouterGetState
* @tc.desc Get the status information of the current page.
* @tc.number SUB_ACE_BASICABILITY_JS_API_0710
* @tc.name testRouterMaxLength
* @tc.desc Test the max number of the page stack is 32.
*/
it('testRouterGetState', 0, function () {
console.info('testRouterGetState START');
let page = router.getState();
console.info('[router.getState] index: ' + page.index);
console.info('[router.getState] name: ' + page.name);
console.info('[router.getState] path: ' + page.path);
expect(page.index).assertEqual('1');
expect(page.name).assertEqual('index');
expect(page.path).assertEqual('pages/index/');
console.info('testRouterGetState END');
it('testRouterMaxLength', 0, async function (done) {
console.info('testRouterMaxLength START');
let intervalID = -1;
let promise1 = new Promise((resolve, reject) => {
intervalID = setInterval(function () {
router.push({
uri: 'pages/routerPush/index'
});
console.info('testRouterMaxLength router.getLength:' + router.getLength());
resolve();
}, 100);
});
let promise2 = new Promise((resolve, reject) => {
setTimeout(function () {
console.info('testRouterMaxLength[clearInterval] start');
clearInterval(intervalID);
console.info('testRouterMaxLength[clearInterval] end');
resolve();
}, 500 * 34);
});
Promise.all([promise1, promise2]).then(() => {
setTimeout(async () => {
console.info("testRouterMaxLength getLength:" + router.getLength());
expect("32").assertEqual(router.getLength());
console.info('testRouterMaxLength success');
await backToIndex();
console.info('testRouterMaxLength END');
done();
}, 500);
});
});
/**
......@@ -414,7 +497,7 @@ describe('basicabilityapi', function () {
let res = 0;
let intervalID = setInterval(function () {
res++;
}, 1000);
}, 100);
await setTimeout(function () {
expect(9).assertEqual(res);
console.info('testSetInterval SUCCESS');
......
......@@ -3,6 +3,10 @@
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "mainability_description",
"value": "JS_Empty Ability"
}
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册