提交 ead6ddd2 编写于 作者: J jiyong

jiyong@huawei.com

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