提交 50e6e4cc 编写于 作者: O openharmony_ci 提交者: Gitee

!478 ACE用例修改

Merge pull request !478 from jiyong/master
...@@ -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;
res++; let promise1 = new Promise((resolve, reject) => {
console.info('testClearInterval res = ' + res); intervalID = setInterval(function () {
}, 100); res++;
await setTimeout(function () { console.info('testClearInterval res = ' + res);
console.info('[clearInterval] start'); resolve();
clearInterval(intervalID); }, 100);
console.info('[clearInterval] end'); });
}, 600); let promise2 = new Promise((resolve, reject) => {
await setTimeout(function () { setTimeout(function () {
console.info('[clearInterval] start');
clearInterval(intervalID);
console.info('[clearInterval] end');
resolve();
}, 600);
});
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 pages = router.getState(); let promise2 = new Promise((resolve, reject) => {
console.info("[router.push] getState" + JSON.stringify(pages)); setTimeout(() => {
expect("pages/routerPush/").assertEqual(pages.path); let pages = router.getState();
console.info("[router.push] getLength:" + router.getLength()); console.info("[router.push] getState" + JSON.stringify(pages));
expect("2").assertEqual(router.getLength()); expect("pages/routerPush/").assertEqual(pages.path);
console.info('testRouterPush SUCCESS'); console.info("[router.push] getLength:" + router.getLength());
router.back(); expect("2").assertEqual(router.getLength());
console.info('testRouterPush END'); console.info('testRouterPush SUCCESS');
done(); resolve();
}, 1000); }, 500);
});
await promise1.then(() => {
return promise2;
});
await backToIndex();
console.info('testRouterPush END');
done();
}); });
/** /**
...@@ -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 pages = router.getState(); let promise2 = new Promise((resolve, reject) => {
console.info("testRouterPushNotExist getState" + JSON.stringify(pages)); setTimeout(() => {
expect("pages/index/").assertEqual(pages.path); let pages = router.getState();
console.info("testRouterPushNotExist getLength:" + router.getLength()); console.info("testRouterPushNotExist getState" + JSON.stringify(pages));
expect("1").assertEqual(router.getLength()); expect("pages/index/").assertEqual(pages.path);
console.info('testRouterPushNotExist END'); console.info("testRouterPushNotExist getLength:" + router.getLength());
done(); expect("1").assertEqual(router.getLength());
}, 1000); console.info('testRouterPushNotExist success');
resolve();
}, 500);
});
await promise1.then(() => {
return promise2;
});
console.info('testRouterPushNotExist END');
done();
}); });
/** /**
...@@ -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(() => { });
router.replace({ let promise2 = new Promise((resolve, reject) => {
uri: 'pages/routerReplace/index' setTimeout(() => {
}); router.replace({
}, 1000); uri: 'pages/routerReplace/index'
await setTimeout(() => { });
let pages = router.getState(); resolve();
console.info("[router.replace] getState" + JSON.stringify(pages)); }, 500);
expect("pages/routerReplace/").assertEqual(pages.path); });
console.info("[router.replace] getLength:" + router.getLength()); let promise3 = new Promise((resolve, reject) => {
expect("2").assertEqual(router.getLength()); setTimeout(() => {
console.info('testRouterReplace SUCCESS'); let pages = router.getState();
router.back(); console.info("[router.replace] getState" + JSON.stringify(pages));
console.info('testRouterReplace END'); expect("pages/routerReplace/").assertEqual(pages.path);
done(); console.info("[router.replace] getLength:" + router.getLength());
}, 1500); 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 () { ...@@ -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(() => { });
router.back({ let promise2 = new Promise((resolve, reject) => {
uri: 'pages/index/index' setTimeout(() => {
}); router.back({
}, 1000); uri: 'pages/index/index'
await setTimeout(() => { });
let pages = router.getState(); resolve();
console.info("[router.back] getState" + JSON.stringify(pages)); }, 500);
expect("pages/index/").assertEqual(pages.path); });
console.info("[router.back] getLength:" + router.getLength()); let promise3 = new Promise((resolve, reject) => {
expect("1").assertEqual(router.getLength()); setTimeout(() => {
console.info('testRouterBack END'); let pages = router.getState();
done(); console.info("[router.back] getState" + JSON.stringify(pages));
}, 1500); 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 () { ...@@ -228,67 +295,83 @@ 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(() => { });
console.info("testRouterLength getLength:" + router.getLength()); let promise2 = new Promise((resolve, reject) => {
expect("2").assertEqual(router.getLength()); setTimeout(() => {
console.info('testRouterPush SUCCESS'); console.info("testRouterLength getLength:" + router.getLength());
router.back(); expect("2").assertEqual(router.getLength());
console.info('testRouterPush END'); console.info('testRouterLength SUCCESS');
done(); resolve();
}, 1000); }, 500);
});
await promise1.then(() => {
return promise2;
});
await backToIndex();
console.info('testRouterLength END');
done();
}); });
/** /**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0710 * @tc.number SUB_ACE_BASICABILITY_JS_API_0800
* @tc.name testRouterMaxLength * @tc.name testRouterGetState
* @tc.desc Test the max number of the page stack is 32. * @tc.desc Get the status information of the current page.
*/ */
it('testRouterMaxLength', 0, async function (done) { it('testRouterGetState', 0, async function (done) {
console.info('testRouterLength START'); console.info('testRouterGetState 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);
await setTimeout(() => { await setTimeout(() => {
console.info("testRouterMaxLength getLength:" + router.getLength()); let page = router.getState();
expect("32").assertEqual(router.getLength()); console.info('[router.getState] index: ' + page.index);
console.info('testRouterMaxLength SUCCESS'); console.info('[router.getState] name: ' + page.name);
router.back({ console.info('[router.getState] path: ' + page.path);
uri: 'pages/index/index' expect(page.index).assertEqual('1');
}); expect(page.name).assertEqual('index');
console.info('testRouterMaxLength END'); expect(page.path).assertEqual('pages/index/');
console.info('testRouterGetState END');
done(); done();
}, (1000 * 18)); }, 500);
}); });
/** /**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0800 * @tc.number SUB_ACE_BASICABILITY_JS_API_0710
* @tc.name testRouterGetState * @tc.name testRouterMaxLength
* @tc.desc Get the status information of the current page. * @tc.desc Test the max number of the page stack is 32.
*/ */
it('testRouterGetState', 0, function () { it('testRouterMaxLength', 0, async function (done) {
console.info('testRouterGetState START'); console.info('testRouterMaxLength START');
let page = router.getState(); let intervalID = -1;
console.info('[router.getState] index: ' + page.index); let promise1 = new Promise((resolve, reject) => {
console.info('[router.getState] name: ' + page.name); intervalID = setInterval(function () {
console.info('[router.getState] path: ' + page.path); router.push({
expect(page.index).assertEqual('1'); uri: 'pages/routerPush/index'
expect(page.name).assertEqual('index'); });
expect(page.path).assertEqual('pages/index/'); console.info('testRouterMaxLength router.getLength:' + router.getLength());
console.info('testRouterGetState END'); 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.
先完成此消息的编辑!
想要评论请 注册