提交 636c1e4a 编写于 作者: Y yaocui

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

......@@ -16,10 +16,6 @@ import("//test/xts/tools/build/suite.gni")
group("serviceability") {
testonly = true
if (is_standard_system) {
deps = [
"actsserviceabilityclienttest:ActsServiceAbilityClientTest",
"actsserviceabilityserverrelyhap:ActsServiceAbilityServerRelyHap",
"actsserviceabilityserversecondrelyhap:ActsServiceAbilityServerSecondRelyHap",
]
deps = [ "actsserviceabilityclienttest:ActsServiceAbilityClientTest" ]
}
}
......@@ -11,9 +11,7 @@
"kits": [
{
"test-file-name": [
"ActsServiceAbilityClientTest.hap",
"ActsServiceAbilityServerRelyHap.hap",
"ActsServiceAbilityServerSecondRelyHap.hap"
"ActsServiceAbilityClientTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
......
......@@ -63,6 +63,24 @@
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"srcPath": "ServiceAbility1",
"name": ".ServiceAbility1",
"icon": "$media:icon",
"srcLanguage": "js",
"description": "$string:description_serviceability",
"visible": true,
"type": "service"
},
{
"srcPath": "ServiceAbility2",
"name": ".ServiceAbility2",
"icon": "$media:icon",
"srcLanguage": "js",
"description": "$string:description_serviceability",
"visible": true,
"type": "service"
}
],
"js": [
......
......@@ -15,8 +15,8 @@
import rpc from "@ohos.rpc";
import particleAbility from '@ohos.ability.particleAbility'
import commonEvent from '@ohos.commonEvent'
var serversecond_bundleName = "com.amsst.stserviceabilityserversecond";
var serversecond_abilityName = "com.amsst.stserviceabilityserversecond.ServiceAbility";
var serversecond_bundleName = "com.amsst.stserviceabilityclient";
var serversecond_abilityName = "com.amsst.stserviceabilityclient.ServiceAbility2";
var mConnIdJs;
class StubTest extends rpc.RemoteObject {
constructor(des) {
......
......@@ -15,8 +15,8 @@
import rpc from "@ohos.rpc";
import particleAbility from '@ohos.ability.particleAbility'
import commonEvent from '@ohos.commonEvent'
var server_bundleName = "com.amsst.stserviceabilityserver";
var server_abilityName = "com.amsst.stserviceabilityserver.ServiceAbility";
var server_bundleName = "com.amsst.stserviceabilityclient";
var server_abilityName = "com.amsst.stserviceabilityclient.ServiceAbility1";
var mConnIdJs;
class StubTest extends rpc.RemoteObject {
constructor(des) {
......
......@@ -19,8 +19,8 @@ import rpc from "@ohos.rpc";
import { describe, afterEach, it, expect } from '@ohos/hypium'
export default function ActsStServiceAbilityTest() {
describe('ActsStServiceAbilityTest', function () {
let bundleName = "com.amsst.stserviceabilityserver";
let abilityName = "com.amsst.stserviceabilityserver.ServiceAbility";
let bundleName = "com.amsst.stserviceabilityclient";
let abilityName = "com.amsst.stserviceabilityclient.ServiceAbility1";
let subscriber0100;
let CommonEventSubscribeInfo0100 = {
......
......@@ -23,6 +23,10 @@
{
"name": "TestAbility_label",
"value": "label"
},
{
"name": "description_serviceability",
"value": "hap sample empty service"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.amsst.stserviceabilityserver",
"vendor": "test",
"version": {
"code": 1000110,
"name": "1.1.1"
},
"apiVersion": {
"compatible": 8,
"target": 9
}
},
"deviceConfig": {},
"module": {
"package": "com.amsst.stserviceabilityserver",
"name": ".MyApplication",
"mainAbility": ".MainAbility",
"srcPath": "",
"deviceType": [
"default",
"tablet"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"formsEnabled": false,
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"srcPath": "ServiceAbility",
"name": ".ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability",
"visible": true,
"type": "service"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index",
"pages/second"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"name": "com.ohos.screenlock.DataAbilityShellProvider.PROVIDER"
}
]
}
}
/*
* 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'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("jws onCreate");
}
onDestroy() {
console.log("jws onDestroy");
}
onWindowStageCreate(windowStage) {
console.log("jws onWindowStageCreate");
}
onWindowStageDestroy() {
console.log("jws onWindowStageDestroy");
}
onForeground() {
console.log("jws onForeground");
}
onBackground() {
console.log("jws onBackground");
}
call(){
}
}
\ 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 {Core} from '@ohos/hypium'
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('onShow finish')
const core = Core.getInstance()
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
core.execute()
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "ServiceExtAbility"
},
{
"name": "description_mainability",
"value": "eTS_Empty Ability"
},
{
"name": "description_serviceability",
"value": "hap sample empty service"
},
{
"name": "description_dataability",
"value": "hap sample empty provider"
},
{
"name": "description_mainability2",
"value": "eTS_Empty Ability"
},
{
"name": "entry_MainAbility2",
"value": "entry_MainAbility2"
},
{
"name": "description_testdataability",
"value": "hap sample empty provider"
},
{
"name": "permreason_dataability",
"value": "request dataability premission"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsServiceAbilityServerSecondRelyHap") {
hap_name = "ActsServiceAbilityServerSecondRelyHap"
js_build_mode = "debug"
hap_profile = "entry/src/main/config.json"
testonly = true
deps = [
":serviceability_resources",
":serviceability_ts_assets",
]
certificate_profile = "signature/openharmony_sx.p7b"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_js_assets("serviceability_ts_assets") {
source_dir = "entry/src/main/ets"
hap_profile = "entry/src/main/config.json"
ets2abc = true
}
ohos_resources("serviceability_resources") {
sources = [ "entry/src/main/resources" ]
hap_profile = "entry/src/main/config.json"
}
{
"app": {
"bundleName": "com.amsst.stserviceabilityserversecond",
"vendor": "test",
"version": {
"code": 1000110,
"name": "1.1.1"
},
"apiVersion": {
"compatible": 8,
"target": 9
}
},
"deviceConfig": {},
"module": {
"package": "com.amsst.stserviceabilityserversecond",
"name": ".MyApplication",
"mainAbility": ".MainAbility",
"srcPath": "",
"deviceType": [
"default",
"tablet"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"formsEnabled": false,
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"srcPath": "ServiceAbility",
"name": ".ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability",
"visible": true,
"type": "service"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index",
"pages/second"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"name": "com.ohos.screenlock.DataAbilityShellProvider.PROVIDER"
}
]
}
}
/*
* 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
import Ability from '@ohos.app.ability.UIAbility'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("jws onCreate");
}
onDestroy() {
console.log("jws onDestroy");
}
onWindowStageCreate(windowStage) {
console.log("jws onWindowStageCreate");
}
onWindowStageDestroy() {
console.log("jws onWindowStageDestroy");
}
onForeground() {
console.log("jws onForeground");
}
onBackground() {
console.log("jws onBackground");
}
call(){
}
}
\ 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.
*/
export default {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ 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 {Core} from '@ohos/hypium'
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('onShow finish')
const core = Core.getInstance()
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
core.execute()
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "ServiceExtAbility"
},
{
"name": "description_mainability",
"value": "eTS_Empty Ability"
},
{
"name": "description_serviceability",
"value": "hap sample empty service"
},
{
"name": "description_dataability",
"value": "hap sample empty provider"
},
{
"name": "description_mainability2",
"value": "eTS_Empty Ability"
},
{
"name": "entry_MainAbility2",
"value": "entry_MainAbility2"
},
{
"name": "description_testdataability",
"value": "hap sample empty provider"
},
{
"name": "permreason_dataability",
"value": "request dataability premission"
}
]
}
\ No newline at end of file
......@@ -29,6 +29,7 @@ group("arkui") {
"ace_ets_test:ActsAceEtsTest",
"ace_ets_third_test:ActsAceEtsThirdTest",
"ace_ets_web_dev:ActsAceWebDevTest",
"ace_ets_web_dev_four:ActsAceWebDevFourTest",
"ace_ets_web_dev_three:ActsAceWebDevThreeTest",
"ace_ets_web_dev_two:ActsAceWebDevTwoTest",
"ace_ets_xcomponent:ActsAceXComponentEtsTest",
......
......@@ -166,14 +166,12 @@ export default function GridItemJsunit() {
it('GridJsunit_0500', 0, async function (done) {
// Verify the columnsTemplate of Grid component
console.info('[GridJsunit_0500] START');
let gridItem1 = CommonFunc.getComponentRect('gridItem1');
let left1 = gridItem1.left
let gridItem2 = CommonFunc.getComponentRect('gridItem1');
let right1 = gridItem2.right
let gridItem1 = CommonFunc.getComponentRect('0');
let right1 = gridItem1.right;
await CommonFunc.sleep(1000);
let gridItem3 = CommonFunc.getComponentRect('3');
let right2 = gridItem3.right
expect(right2 - left1 - 4 * 6).assertEqual((right1 - left1) * 5);
let gridItem3 = CommonFunc.getComponentRect('1');
let left3 = gridItem3.left;
expect(left3 - right1).assertEqual(vp2px(4));
console.info('[GridJsunit_0500] END');
done();
});
......@@ -183,12 +181,10 @@ export default function GridItemJsunit() {
console.info('[GridJsunit_0600] START');
await CommonFunc.sleep(1000);
let gridItem1 = CommonFunc.getComponentRect('0');
let top1 = gridItem1.top
let gridItem2 = CommonFunc.getComponentRect('gridItem3');
let top2 = gridItem2.top
let gridItem3 = CommonFunc.getComponentRect('gridItem3');
let bottom2 = gridItem3.bottom
expect((bottom2 - top2) * 4 + 7.5).assertEqual(bottom2 - top1 - 5 * 3);
let bottom1 = gridItem1.bottom;
let gridItem3 = CommonFunc.getComponentRect('4');
let top3 = gridItem3.top;
expect(top3 - bottom1).assertEqual(vp2px(5));
console.info('[GridJsunit_0600] END');
done();
});
......@@ -199,10 +195,10 @@ export default function GridItemJsunit() {
await CommonFunc.sleep(1000);
let driver = await UiDriver.create()
let gridItem1 = CommonFunc.getComponentRect('gridItem1');
let right1 = gridItem1.right
let right1 = gridItem1.right;
let gridItem2 = CommonFunc.getComponentRect('0');
let left1 = gridItem2.left
expect(left1 - right1).assertEqual(6);
let left1 = gridItem2.left;
expect(left1 - right1).assertEqual(vp2px(4));
console.info('[GridJsunit_0700] END');
done();
});
......@@ -216,10 +212,10 @@ export default function GridItemJsunit() {
await CommonFunc.sleep(1000);
let driver = await UiDriver.create()
let gridItem1 = CommonFunc.getComponentRect('gridItem1');
let bottom1 = gridItem1.bottom
let bottom1 = gridItem1.bottom;
let gridItem2 = CommonFunc.getComponentRect('gridItem3');
let top1 = gridItem2.top
expect(top1 - bottom1).assertEqual(7.5);
let top1 = gridItem2.top;
expect(top1 - bottom1).assertEqual(vp2px(5));
console.info('[GridJsunit_0800] END');
done();
});
......
......@@ -57,7 +57,11 @@ export default function GridRowJsunit() {
expect(obj.$attrs.columns).assertEqual('4');
expect(obj.$attrs.breakpoints).assertEqual('4');
expect(obj.$attrs.direction).assertEqual('4');
expect(obj.$attrs.gutter).assertEqual('<7.500000, 15.000000');
// fix the vp2px
let x = vp2px(5).toFixed(6);
let y = vp2px(10).toFixed(6);
let str = '<' + x + ', '+y;
expect(obj.$attrs.gutter).assertEqual(str);
console.info('[GridRowJsunit_0100] END');
done();
});
......@@ -65,13 +69,15 @@ export default function GridRowJsunit() {
it('GridRowJsunit_0200', 0, async function (done) {
// Modify the properties of component GridRow
console.info('[GridRowJsunit_0200] START');
globalThis.value.message.notify({name:'columns',value:12})
globalThis.value.message.notify({name:'columns',value:'12'})
await CommonFunc.sleep(2000);
globalThis.value.message.notify({name:'gutter',value:{ x: 12, y: 27}})
globalThis.value.message.notify({name:'gutter',value:'x: 7.5, y: 15'})
await CommonFunc.sleep(2000);
globalThis.value.message.notify({name:'breakpoints',value:{ value: ["200vp", "400vp", "600vp"], reference: BreakpointsReference.ComponentSize }})
globalThis.value.message.notify({name:'breakpoints',value:'12'})
await CommonFunc.sleep(2000);
globalThis.value.message.notify({name:'grDirection',value:GridRowDirection.RowReverse })
globalThis.value.message.notify({name:'grDirection',value:'12'})
await CommonFunc.sleep(2000);
globalThis.value.message.notify({name:'currentBp',value:'sm'})
await CommonFunc.sleep(2000);
// Get the propoties value of the GridRow component
......@@ -83,9 +89,12 @@ export default function GridRowJsunit() {
console.info("[GridRowJsunit_0200] direction: " + JSON.stringify(obj.$attrs.direction));
console.info("[GridRowJsunit_0200] gutter: " + JSON.stringify(obj.$attrs.gutter));
expect(obj.$attrs.columns).assertEqual('12');
expect(obj.$attrs.gutter).assertEqual('<18.000000, 40.500000');
expect(obj.$attrs.breakpoints).assertEqual('12');
expect(obj.$attrs.direction).assertEqual('12');
let x = vp2px(5).toFixed(6);
let y = vp2px(10).toFixed(6);
let str = '<' + x + ', '+y;
expect(obj.$attrs.gutter).assertEqual(str);
console.info('[GridRowJsunit_0200] END');
done();
});
......@@ -113,9 +122,12 @@ export default function GridRowJsunit() {
console.info("[GridRowJsunit_0300] direction: " + JSON.stringify(obj.$attrs.direction));
console.info("[GridRowJsunit_0300] gutter: " + JSON.stringify(obj.$attrs.gutter));
expect(obj.$attrs.columns).assertEqual('12');
expect(obj.$attrs.gutter).assertEqual('<18.000000, 40.500000');
expect(obj.$attrs.breakpoints).assertEqual('12');
expect(obj.$attrs.direction).assertEqual('12');
let x = vp2px(5).toFixed(6);
let y = vp2px(10).toFixed(6);
let str = '<' + x + ', '+y;
expect(obj.$attrs.gutter).assertEqual(str);
console.info('[GridRowJsunit_0300] END');
done();
});
......@@ -126,8 +138,14 @@ export default function GridRowJsunit() {
let strJson = getInspectorByKey('gridRow_default');
let obj = JSON.parse(strJson);
console.info("[GridRowJsunit_0400] component obj is: " + JSON.stringify(obj));
console.info("[GridRowJsunit_0400] columns: " + JSON.stringify(obj.$attrs.columns));
console.info("[GridRowJsunit_0400] breakpoints: " + JSON.stringify(obj.$attrs.breakpoints));
console.info("[GridRowJsunit_0400] direction: " + JSON.stringify(obj.$attrs.direction));
console.info("[GridRowJsunit_0400] gutter: " + JSON.stringify(obj.$attrs.gutter));
expect(obj.$attrs.columns).assertEqual('12');
expect(obj.$attrs.gutter).assertEqual('<0.000000, 0.000000');
expect(obj.$attrs.breakpoints).assertEqual('12');
expect(obj.$attrs.direction).assertEqual('12');
console.info('[GridRowJsunit_0400] END');
done();
});
......
......@@ -81,7 +81,7 @@ export default function flex_AlignContent_SpaceBetween_TextOffsetTest() {
expect(fourthText.bottom).assertEqual(flexContainer.bottom); //行首贴边行尾溢出
expect(Math.round(thirdText.top - secondText.bottom)).assertEqual(Math.round(fourthText.top - thirdText.bottom));
expect(Math.round(thirdText.top - secondText.bottom)).assertEqual(distanceBefore);
expect(Math.round(thirdText.top - secondText.bottom)).assertEqual(Math.round(distanceBefore));
console.info('[SUB_ACE_FLEXALIGNCONTENT_SPACEBETWEEN_1000] END');//其余组件行间距相等,未改变
done();
});
......
......@@ -110,7 +110,7 @@ export default function AlignCenter_AddLayoutWeight() {
expect(Center_AddLayoutWeight_013.right).assertEqual(Center_AddLayoutWeight_01.right);
let oneWidth = Math.round(Center_AddLayoutWeight_011.right - Center_AddLayoutWeight_011.left);
let twoWidth = Math.round(Center_AddLayoutWeight_012.right - Center_AddLayoutWeight_012.left);
expect(twoWidth / oneWidth).assertEqual(2);
expect(Math.round(twoWidth / oneWidth)).assertEqual(2);
expect(twoWidth + oneWidth).assertEqual(vp2px(350));
expect(Math.round(Center_AddLayoutWeight_013.right - Center_AddLayoutWeight_013.left)).assertEqual(vp2px(150));
expect(Math.round(Center_AddLayoutWeight_011.bottom - Center_AddLayoutWeight_011.top)).assertEqual(vp2px(50));
......
......@@ -110,7 +110,7 @@ export default function AlignEnd_AddLayoutWeight() {
expect(End_AddLayoutWeight_013.right).assertEqual(End_AddLayoutWeight_01.right);
let oneWidth = Math.round(End_AddLayoutWeight_011.right - End_AddLayoutWeight_011.left);
let twoWidth = Math.round(End_AddLayoutWeight_012.right - End_AddLayoutWeight_012.left);
expect(twoWidth / oneWidth).assertEqual(2);
expect(Math.round(twoWidth / oneWidth)).assertEqual(2);
expect(twoWidth + oneWidth).assertEqual(vp2px(350));
expect(Math.round(End_AddLayoutWeight_013.right - End_AddLayoutWeight_013.left)).assertEqual(vp2px(150));
expect(Math.round(End_AddLayoutWeight_011.bottom - End_AddLayoutWeight_011.top)).assertEqual(vp2px(50));
......
......@@ -74,9 +74,9 @@ export default function AlignEnd_AddPadding() {
expect(Math.round(End_AddPadding_011.bottom - End_AddPadding_011.top)).assertEqual(vp2px(50));
expect(Math.round(End_AddPadding_012.bottom - End_AddPadding_012.top)).assertEqual(vp2px(100));
expect(Math.round(End_AddPadding_013.bottom - End_AddPadding_013.top)).assertEqual(vp2px(150));
expect(Math.round(End_AddPadding_011.right - End_AddPadding_011.left)).assertEqual(vp2px(440/3));
expect(Math.round(End_AddPadding_012.right - End_AddPadding_012.left)).assertEqual(vp2px(440/3));
expect(Math.round(End_AddPadding_013.right - End_AddPadding_013.left)).assertEqual(vp2px(440/3));
expect(Math.round(End_AddPadding_011.right - End_AddPadding_011.left)).assertEqual(Math.round(vp2px(440/3)));
expect(Math.round(End_AddPadding_012.right - End_AddPadding_012.left)).assertEqual(Math.round(vp2px(440/3)));
expect(Math.round(End_AddPadding_013.right - End_AddPadding_013.left)).assertEqual(Math.round(vp2px(440/3)));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_END_TEST_0300] END');
done();
});
......
......@@ -77,9 +77,9 @@ export default function AlignSpaceEvenly_AddAllSpace() {
expect(Math.round(SpaceEvenly_AddAllSpace_011.bottom - SpaceEvenly_AddAllSpace_011.top)).assertEqual(vp2px(50));
expect(Math.round(SpaceEvenly_AddAllSpace_012.bottom - SpaceEvenly_AddAllSpace_012.top)).assertEqual(vp2px(100));
expect(Math.round(SpaceEvenly_AddAllSpace_013.bottom - SpaceEvenly_AddAllSpace_013.top)).assertEqual(vp2px(150));
expect(Math.round(SpaceEvenly_AddAllSpace_011.right - SpaceEvenly_AddAllSpace_011.left)).assertEqual(vp2px(440/3));
expect(Math.round(SpaceEvenly_AddAllSpace_012.right - SpaceEvenly_AddAllSpace_012.left)).assertEqual(vp2px(440/3));
expect(Math.round(SpaceEvenly_AddAllSpace_013.right - SpaceEvenly_AddAllSpace_013.left)).assertEqual(vp2px(440/3));
expect(Math.round(SpaceEvenly_AddAllSpace_011.right - SpaceEvenly_AddAllSpace_011.left)).assertEqual(Math.round(vp2px(440/3)));
expect(Math.round(SpaceEvenly_AddAllSpace_012.right - SpaceEvenly_AddAllSpace_012.left)).assertEqual(Math.round(vp2px(440/3)));
expect(Math.round(SpaceEvenly_AddAllSpace_013.right - SpaceEvenly_AddAllSpace_013.left)).assertEqual(Math.round(vp2px(440/3)));
console.info('[SUB_ACE_FLEX_JUSTIFYCONTENT_FLEXALIGN_SPACEEVENLY_TEST_0600] END');
done();
});
......
......@@ -122,7 +122,7 @@ export default function AlignSpaceEvenly_AddLayoutWeight() {
.assertEqual(vp2px(150));
let oneWidth = Math.round(SpaceEvenly_AddLayoutWeight_011.right - SpaceEvenly_AddLayoutWeight_011.left);
let twoWidth = Math.round(SpaceEvenly_AddLayoutWeight_012.right - SpaceEvenly_AddLayoutWeight_012.left);
expect(twoWidth / oneWidth).assertEqual(2);
expect(Math.round(twoWidth / oneWidth)).assertEqual(2);
expect(twoWidth + oneWidth).assertEqual(vp2px(350));
expect(Math.round(SpaceEvenly_AddLayoutWeight_013.right - SpaceEvenly_AddLayoutWeight_013.left)).
assertEqual(vp2px(150));
......
......@@ -110,7 +110,7 @@ export default function AlignStart_AddLayoutWeight() {
expect(Start_AddLayoutWeight_013.right).assertEqual(Start_AddLayoutWeight_01.right);
let oneWidth = Math.round(Start_AddLayoutWeight_011.right - Start_AddLayoutWeight_011.left);
let twoWidth = Math.round(Start_AddLayoutWeight_012.right - Start_AddLayoutWeight_012.left);
expect(twoWidth / oneWidth).assertEqual(2);
expect(Math.round(twoWidth / oneWidth)).assertEqual(2);
expect(twoWidth + oneWidth).assertEqual(vp2px(350));
expect(Math.round(Start_AddLayoutWeight_013.right - Start_AddLayoutWeight_013.left)).assertEqual(vp2px(150));
expect(Math.round(Start_AddLayoutWeight_011.bottom - Start_AddLayoutWeight_011.top)).assertEqual(vp2px(50));
......
{
"app": {
"bundleName": "com.open.harmony.acewebfourtest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"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":"ohosProject"
}
]
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# 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
......@@ -13,28 +13,29 @@
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsServiceAbilityServerRelyHap") {
hap_name = "ActsServiceAbilityServerRelyHap"
ohos_js_hap_suite("ActsAceWebDevFourTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
hap_profile = "entry/src/main/config.json"
testonly = true
deps = [
":serviceability_resources",
":serviceability_ts_assets",
":ace_ets_web_dev_js_assets",
":ace_ets_web_dev_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
subsystem_name = "ability"
part_name = "ability_runtime"
hap_name = "ActsAceWebDevFourTest"
}
ohos_js_assets("serviceability_ts_assets") {
ohos_app_scope("ace_ets_web_dev_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("ace_ets_web_dev_js_assets") {
source_dir = "entry/src/main/ets"
hap_profile = "entry/src/main/config.json"
ets2abc = true
}
ohos_resources("serviceability_resources") {
ohos_resources("ace_ets_web_dev_resources") {
sources = [ "entry/src/main/resources" ]
hap_profile = "entry/src/main/config.json"
deps = [ ":ace_ets_web_dev_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "com.open.harmony.acewebfourtest",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [{
"test-file-name": [
"ActsAceWebDevFourTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602"
]
}
]
}
\ No newline at end of file
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
import Ability from '@ohos.app.ability.UIAbility'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage)
globalThis.windowStage = windowStage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "MainAbility/pages/web", null)
}
onWindowStageDestroy() {
//Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
};
/*
* Copyright (c) 2021~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 events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
import fileio from '@ohos.fileio';
import prompt from '@system.prompt';
let loadedUrl;
@Entry
@Component
struct Index {
controller: web_webview.WebviewController = new web_webview.WebviewController();
@State outputStr: string = ''
@State playing: boolean = false
@State str:string="emitOnLoadIntercept"
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
};
events_emitter.on(valueChangeEvent,this.valueChangeCallBack);
}
private valueChangeCallBack=(eventData)=>{
console.info("web page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
aboutToAppear(){
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build(){
Column(){
Row(){
Button("web click").key('webcomponent').onClick(async ()=>{
console.info("key==>"+this.str)
switch(this.str){
case "emitOnLoadIntercept":{
this.controller.loadUrl("https://www.baidu.com/")
break;
}
default:
console.info("can not match case")
}
})
}
Web({src:"www.example.com",controller:this.controller})
.onLoadIntercept((event) => {
console.log('url:' + event.data.getRequestUrl())
Utils.emitEvent(event.data.getRequestUrl(),2)
console.log('isMainFrame:' + event.data.isMainFrame())
console.log('isRedirect:' + event.data.isRedirect())
console.log('isRequestGesture:' + event.data.isRequestGesture())
return false
})
.onErrorReceive((event) => {
console.log('getErrorInfo:' + event.error.getErrorInfo())
Utils.emitEvent(event.error.getErrorInfo(),3)
})
}
}
}
\ 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 events_emitter from '@ohos.events.emitter';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
function Uint8ArrayToString(dataArray) {
var dataString = ''
for (var i = 0; i < dataArray.length; i++) {
dataString += String.fromCharCode(dataArray[i])
}
return dataString
}
function ParseX509CertInfo(x509CertArray) {
let res: string = 'getCertificate success: len = ' + x509CertArray.length;
for (let i = 0; i < x509CertArray.length; i++) {
res += ', index = ' + i + ', issuer name = '
+ Uint8ArrayToString(x509CertArray[i].getIssuerName().data) + ', subject name = '
+ Uint8ArrayToString(x509CertArray[i].getSubjectName().data) + ', valid start = '
+ x509CertArray[i].getNotBeforeTime()
+ ', valid end = ' + x509CertArray[i].getNotAfterTime()
}
return res
}
@Entry
@Component
struct Second {
@State outputStr: string = ''
webviewCtl: web_webview.WebviewController = new web_webview.WebviewController();
@State str:string="emitGetCertificate"
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
};
events_emitter.on(valueChangeEvent,this.valueChangeCallBack);
}
private valueChangeCallBack=(eventData)=>{
console.info("web page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
build(){
Column(){
Row(){
Button("web click").key('webcomponenttwo').onClick(async ()=>{
console.info("key==>"+this.str);
switch(this.str){
case "emitGetCertificate":{
this.webviewCtl.loadUrl('https://www.baidu.com')
try {
this.webviewCtl.getCertificate().then(x509CertArray => {
this.outputStr = ParseX509CertInfo(x509CertArray);
console.info('11111111111111'+this.outputStr)
Utils.emitEvent(this.outputStr,4)
})
} catch (error) {
this.outputStr = 'getCertificate failed: ' + error.code + ", errMsg: " + error.message;
}
break;
}
default:
console.info("can not match case");
}
})
}
Web({ src: 'https://www.example.com', controller: this.webviewCtl })
.fileAccess(true)
.javaScriptAccess(true)
.domStorageAccess(true)
.onlineImageAccess(true)
.onPageEnd((e) => {
this.outputStr = 'onPageEnd : url = ' + e.url
})
}
}
}
\ 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 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() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ 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.
*/
export default {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
/*
* 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 webJsunit from './WebJsunit.test'
import webTwoJsunit from './WebTwoJsunit.test'
export default function testsuite() {
webJsunit()
webTwoJsunit()
}
\ 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 events_emitter from '@ohos.events.emitter';
import { expect } from "@ohos/hypium";
export default class Utils {
static sleep(time){
return new Promise((resolve,reject)=>{
setTimeout(()=>{
resolve("ok")
},time)
}).then(()=>{
console.info(`sleep ${time} over...`)
})
}
static registerEvent(testCaseName,expectedValue,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.ACTION).assertEqual(expectedValue);
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static emitEvent(actualValue,eventId){
try {
let backData = {
data: {
"ACTION": actualValue
}
}
let backEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
console.info("webFlag start to emit action state");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("webFlag emit action state err: " + JSON.stringify(err));
}
}
static registerEventTwo(testCaseName,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.actualValue).assertLarger(backData.data.expectedValue-100);
expect(backData.data.actualValue).assertLess(backData.data.expectedValue-(-100));
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static emitEventTwo(expectedValue,actualValue,eventId){
try {
let backData = {
data: {
"expectedValue":expectedValue,
"actualValue":actualValue
}
}
let backEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
console.info("webFlag start to emit action state");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("webFlag emit action state err: " + JSON.stringify(err));
}
}
static registerContainEvent(testCaseName,expectedValue,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.ACTION).assertContain(expectedValue);
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static commitKey(emitKey){
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
}
static registerLargerEvent(testCaseName,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.actualValue).assertLarger(backData.data.expectedValue);
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
}
\ 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.
*/
// @ts-nocheck
import { describe, beforeEach, afterEach, it, expect } from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
let emitKey = "emitOnLoadIntercept";
export default function webJsunit() {
describe('ActsAceWebDevTest', function () {
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("web beforeEach start");
done();
})
afterEach(async function (done) {
console.info("web afterEach start:"+emitKey);
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_002
*tc.name OnLoadIntercept *tc.desic Injects the JavaScript object into window and invoke the function in window
*/
it('OnLoadIntercept',0,async function(done){
emitKey="emitOnLoadIntercept";
Utils.registerEvent("OnLoadIntercept","https://www.baidu.com/",2,done);
sendEventByKey('webcomponent',10,'');
})
})
}
/*
* 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.
*/
// @ts-nocheck
import { describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import router from '@system.router';
import Utils from './Utils.ets';
let emitKey = "emitGetCertificate";
export default function webTwoJsunit() {
describe('overviewTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webTwo',
}
try {
router.clear();
let pages = router.getState();
console.info("get webTwo state success " + JSON.stringify(pages));
if (!("webTwo" == pages.name)) {
console.info("get webTwo state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webTwo page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webTwo page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("web beforeEach start");
done();
})
afterEach(async function (done) {
console.info("web afterEach start:"+emitKey);
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_001
*tc.name GetCertificate
*tc.desic Sets allow the Web access overview mode
*/
it('GetCertificate',0,async function(done){
emitKey="emitOverviewModeAccessFalse";
Utils.registerEvent("GetCertificate","getCertificate success: len = 0",4,done);
sendEventByKey('webcomponenttwo',10,'');
})
})
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"tablet",
"default",
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"metadata": [
{
"name": "ArkTSPartialUpdate",
"value": "false"
}
],
"abilities": [{
"name": "com.example.myapplication.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}]
}],
"requestPermissions": [
{
"name": "ohos.permission.LOCATION"
},
{
"name": "ohos.permission.INTERNET"
}
]
}
}
\ No newline at end of file
{
"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"
}
]
}
{
"src": [
"MainAbility/pages/web",
"MainAbility/pages/webTwo"
]
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>music</title>
</head>
<body>
<audio src="../base/media/gequ.mp3" loop="loop" controls="controls" autoplay="autoplay"></audio>
</body>
</html>
......@@ -925,6 +925,35 @@ describe('ActsAbilityTest', function () {
done();
})
it('TaskPoolTestClass062', 0, async function (done) {
async function func(value1, value2) {
"use concurrent"
let result = await new Promise((resolve, reject) => {
let value = value1 + value2;
resolve(value);
})
return result;
}
var result = await taskpool.execute(func, 10, 20);
expect(result).assertEqual(30);
done();
})
it('TaskPoolTestClass063', 0, async function (done) {
async function func(value1, value2) {
"use concurrent"
let result = await new Promise((resolve, reject) => {
let value = value1 + value2;
resolve(value);
})
return result;
}
var task = new taskpool.Task(func, 10, 20);
var result = await taskpool.execute(task);
expect(result).assertEqual(30);
done();
})
/**
* @tc.number : TaskPoolTestClass049
* @tc.name : Async Function Cancel task
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册