提交 6321402d 编写于 作者: W wangqing 提交者: wanggang

add test cases

Signed-off-by: Nwangqing <wangqing@kaihongdigi.com>
上级 c778d2dc
......@@ -9,16 +9,16 @@
# 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.
# limitations under the License.
group("ace") {
testonly = true
deps = [
"ace_ets_component:AceEtsComponentTest",
"ace_ets_component:AceEtsComponentTest",
"ace_ets_standard:ActsAceEtsStTest",
"ace_ets_test:ActsAceEtsTest",
"ace_ets_third_test:ActsAceEtsThirdTest",
"ace_standard:ace_standard_test",
"ace_standard_video:ace_standard_video_test"
]
}
......@@ -62,9 +62,6 @@
<video id="disabledPropFalse"
disabled="false">
</video>
<video id="disabledPropNone"
disabled="">
</video>
<text class="sub-title">
通用属性 -- focusable
......@@ -75,9 +72,6 @@
<video id="focusablePropFalse"
focusable="false">
</video>
<video id="focusablePropNone"
focusable="">
</video>
<text class="sub-title">
通用属性 -- data-*
......@@ -118,9 +112,6 @@
<video id="showPropFalse"
show="false">
</video>
<video id="showPropNone"
show="">
</video>
</div>
<div style="background-color: #000000; width: 2px; height: 100%;">
......@@ -138,9 +129,6 @@
<video id="mutedPropTrue"
muted="true">
</video>
<video id="mutedPropNone"
muted="">
</video>
<text class="sub-title">
视频路径属性 -- src
......@@ -161,9 +149,6 @@
<video id="autoplayPropTrue"
autoplay="true">
</video>
<video id="autoplayPropNone"
autoplay="">
</video>
<text class="sub-title">
预览海报属性 -- poster
......@@ -184,9 +169,6 @@
<video id="controlsPropTrue"
controls="true">
</video>
<video id="controlsPropNone"
controls="">
</video>
<text class="sub-title">
重头循环属性 -- loop
......
......@@ -27,10 +27,8 @@ export default {
refPropNone : null,
disabledPropTrue : null,
disabledPropFalse : null,
disabledPropNone : null,
focusablePropTrue : null,
focusablePropFalse : null,
focusablePropNone : null,
dataProp : null,
dataPropNone : null,
forPropNull : null,
......@@ -41,20 +39,16 @@ export default {
ifPropNone : null,
showPropTrue : null,
showPropFalse : null,
showPropNone : null,
mutedPropFalse : null,
mutedPropTrue : null,
mutedPropNone : null,
srcProp : null,
srcPropNone : null,
autoplayPropFalse : null,
autoplayPropTrue : null,
autoplayPropNone : null,
posterProp : null,
posterPropNone : null,
controlsPropFalse : null,
controlsPropTrue : null,
controlsPropNone : null,
loopPropFalse : null,
loopPropTrue : null,
loopPropNone : null,
......@@ -79,10 +73,8 @@ export default {
refPropNone : this.refPropNone,
disabledPropTrue : this.disabledPropTrue,
disabledPropFalse : this.disabledPropFalse,
disabledPropNone : this.disabledPropNone,
focusablePropTrue : this.focusablePropTrue,
focusablePropFalse : this.focusablePropFalse,
focusablePropNone : this.focusablePropNone,
dataProp : this.dataProp,
dataPropNone : this.dataPropNone,
forPropNull : this.forPropNull,
......@@ -91,20 +83,16 @@ export default {
ifPropTrue : this.ifPropTrue,
showPropTrue : this.showPropTrue,
showPropFalse : this.showPropFalse,
showPropNone : this.showPropNone,
mutedPropFalse : this.mutedPropFalse,
mutedPropTrue : this.mutedPropTrue,
mutedPropNone : this.mutedPropNone,
srcProp : this.srcProp,
srcPropNone : this.srcPropNone,
autoplayPropFalse : this.autoplayPropFalse,
autoplayPropTrue : this.autoplayPropTrue,
autoplayPropNone : this.autoplayPropNone,
posterProp : this.posterProp,
posterPropNone : this.posterPropNone,
controlsPropFalse : this.controlsPropFalse,
controlsPropTrue : this.controlsPropTrue,
controlsPropNone : this.controlsPropNone,
loopPropFalse : this.loopPropFalse,
loopPropTrue : this.loopPropTrue,
loopPropNone : this.loopPropNone,
......@@ -128,10 +116,8 @@ export default {
this.refPropNone = this.$element("refPropNone").getInspector()
this.disabledPropTrue = this.$element("disabledPropTrue").getInspector()
this.disabledPropFalse = this.$element("disabledPropFalse").getInspector()
this.disabledPropNone = this.$element("disabledPropNone").getInspector()
this.focusablePropTrue = this.$element("focusablePropTrue").getInspector()
this.focusablePropFalse = this.$element("focusablePropFalse").getInspector()
this.focusablePropNone = this.$element("focusablePropNone").getInspector()
this.dataProp = this.$element("dataProp").getInspector()
this.dataPropNone = this.$element("dataPropNone").getInspector()
this.forPropNull = this.$element("forPropNull").getInspector()
......@@ -140,20 +126,16 @@ export default {
this.ifPropTrue = this.$element("ifPropTrue").getInspector()
this.showPropTrue = this.$element("showPropTrue").getInspector()
this.showPropFalse = this.$element("showPropFalse").getInspector()
this.showPropNone = this.$element("showPropNone").getInspector()
this.mutedPropFalse = this.$element("mutedPropFalse").getInspector()
this.mutedPropTrue = this.$element("mutedPropTrue").getInspector()
this.mutedPropNone = this.$element("mutedPropNone").getInspector()
this.srcProp = this.$element("srcProp").getInspector()
this.srcPropNone = this.$element("srcPropNone").getInspector()
this.autoplayPropFalse = this.$element("autoplayPropFalse").getInspector()
this.autoplayPropTrue = this.$element("autoplayPropTrue").getInspector()
this.autoplayPropNone = this.$element("autoplayPropNone").getInspector()
this.posterProp = this.$element("posterProp").getInspector()
this.posterPropNone = this.$element("posterPropNone").getInspector()
this.controlsPropFalse = this.$element("controlsPropFalse").getInspector()
this.controlsPropTrue = this.$element("controlsPropTrue").getInspector()
this.controlsPropNone = this.$element("controlsPropNone").getInspector()
this.loopPropFalse = this.$element("loopPropFalse").getInspector()
this.loopPropTrue = this.$element("loopPropTrue").getInspector()
this.loopPropNone = this.$element("loopPropNone").getInspector()
......
......@@ -964,29 +964,6 @@ describe('aceJsTest', function () {
done();
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testVideoComponent
* @tc.desc ACE
*/
it('testVideoComponent', 0, async function (done) {
let result;
let options = {
uri: 'pages/video/router/index'
}
try {
result = router.push(options)
console.info("push video page success " + JSON.stringify(result));
} catch (err) {
console.error("push video page error " + JSON.stringify(result));
}
await sleep(5000)
let pages = router.getState();
console.info("[router.video] getState" + JSON.stringify(pages));
expect("pages/video/router/").assertEqual(pages.path);
done();
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testGridContainerComponent
......
......@@ -238,25 +238,6 @@ describe('videoPropsJsTest', function () {
done();
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testVideoDisabledPropNone
* @tc.desc ACE
*/
it('testVideoDisabledPropNone', 0, async function (done) {
console.info('testVideoDisabledPropNone START');
console.info("[videoProps] get globalThis.value is: " + JSON.stringify(globalThis.value));
let obj = JSON.parse(globalThis.value.disabledPropNone);
console.info("[videoProps] get inspector value is: " + JSON.stringify(obj));
console.info("[videoProps] get inspector attrs value is: " + JSON.stringify(obj.$attrs));
expect(obj.$type).assertEqual('video')
expect(obj.$attrs.id).assertEqual('disabledPropNone')
expect(obj.$attrs.disabled).assertEqual('false')
done();
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testVideoFocusablePropTrue
......@@ -295,25 +276,6 @@ describe('videoPropsJsTest', function () {
done();
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testVideoFocusablePropNone
* @tc.desc ACE
*/
it('testVideoFocusablePropNone', 0, async function (done) {
console.info('testVideoFocusablePropNone START');
console.info("[videoProps] get globalThis.value is: " + JSON.stringify(globalThis.value));
let obj = JSON.parse(globalThis.value.focusablePropNone);
console.info("[videoProps] get inspector value is: " + JSON.stringify(obj));
console.info("[videoProps] get inspector attrs value is: " + JSON.stringify(obj.$attrs));
expect(obj.$type).assertEqual('video')
expect(obj.$attrs.id).assertEqual('focusablePropNone')
expect(obj.$attrs.focusable).assertEqual('false')
done();
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testVideoDataProp
......@@ -665,26 +627,6 @@ describe('videoPropsJsTest', function () {
done();
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testVideoShowPropNone
* @tc.desc ACE
*/
it('testVideoShowPropNone', 0, async function (done) {
console.info('testVideoShowPropNone START');
console.info("[videoProps] get globalThis.value is: " + JSON.stringify(globalThis.value));
let obj = JSON.parse(globalThis.value.showPropNone);
console.info("[videoProps] get inspector value is: " + JSON.stringify(obj));
console.info("[videoProps] get inspector attrs value is: " + JSON.stringify(obj.$attrs));
expect(obj.$type).assertEqual('video')
expect(obj.$attrs.id).assertEqual('showPropNone')
expect(obj.$attrs.show).assertEqual('true')
console.info("[videoProps] get show value is: " + JSON.stringify(obj.$attrs.show));
done();
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testVideoMutedPropFalse
......@@ -725,26 +667,6 @@ describe('videoPropsJsTest', function () {
done();
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testVideoMutedPropNone
* @tc.desc ACE
*/
it('testVideoMutedPropNone', 0, async function (done) {
console.info('testVideoMutedPropNone START');
console.info("[videoProps] get globalThis.value is: " + JSON.stringify(globalThis.value));
let obj = JSON.parse(globalThis.value.mutedPropNone);
console.info("[videoProps] get inspector value is: " + JSON.stringify(obj));
console.info("[videoProps] get inspector attrs value is: " + JSON.stringify(obj.$attrs));
expect(obj.$type).assertEqual('video')
expect(obj.$attrs.id).assertEqual('mutedPropNone')
expect(obj.$attrs.muted).assertEqual('false')
console.info("[videoProps] get muted value is: " + JSON.stringify(obj.$attrs.muted));
done();
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testVideoSrcProp
......@@ -825,26 +747,6 @@ describe('videoPropsJsTest', function () {
done();
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testVideoAutoplayPropNone
* @tc.desc ACE
*/
it('testVideoAutoplayPropNone', 0, async function (done) {
console.info('testVideoAutoplayPropNone START');
console.info("[videoProps] get globalThis.value is: " + JSON.stringify(globalThis.value));
let obj = JSON.parse(globalThis.value.autoplayPropNone);
console.info("[videoProps] get inspector value is: " + JSON.stringify(obj));
console.info("[videoProps] get inspector attrs value is: " + JSON.stringify(obj.$attrs));
expect(obj.$type).assertEqual('video')
expect(obj.$attrs.id).assertEqual('autoplayPropNone')
expect(obj.$attrs.autoplay).assertEqual('false')
console.info("[videoProps] get autoplay value is: " + JSON.stringify(obj.$attrs.autoplay));
done();
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testVideoPosterProp
......@@ -925,26 +827,6 @@ describe('videoPropsJsTest', function () {
done();
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testVideoControlsPropNone
* @tc.desc ACE
*/
it('testVideoControlsPropNone', 0, async function (done) {
console.info('testVideoControlsPropNone START');
console.info("[videoProps] get globalThis.value is: " + JSON.stringify(globalThis.value));
let obj = JSON.parse(globalThis.value.controlsPropNone);
console.info("[videoProps] get inspector value is: " + JSON.stringify(obj));
console.info("[videoProps] get inspector attrs value is: " + JSON.stringify(obj.$attrs));
expect(obj.$type).assertEqual('video')
expect(obj.$attrs.id).assertEqual('controlsPropNone')
expect(obj.$attrs.controls).assertEqual('true')
console.info("[videoProps] get controls value is: " + JSON.stringify(obj.$attrs.controls));
done();
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testVideoLoopPropFalse
......
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ace_standard_video_test") {
hap_profile = "./src/main/config.json"
deps = [
":ace_js_assets",
":ace_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAceStandardVideoTest"
}
ohos_js_assets("ace_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("ace_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for acevideo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "250000",
"package": "com.example.acevideo",
"shell-timeout": "250000"
},
"kits": [
{
"test-file-name": [
"ActsAceStandardVideoTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.acevideo",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "com.example.acevideo",
"name": ".MyApplication",
"mainAbility": "com.example.acevideo.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.acevideo.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard",
"visible": true,
"configChanges": ["orientation"]
}
],
"js": [
{
"pages": [
"pages/index/index",
"pages/routerPush/index",
"pages/routerReplace/index",
"pages/video/router/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
}
\ 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 40px;
color: #000000;
opacity: 0.9;
}
<!--/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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.
*/-->
<div class="container">
<text class="title">
Hello {{ title }}
</text>
</div>
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
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'
})
core.addService('expect', expectExtend)
core.init()
require('../../test/List.test')
core.execute()
},
onShow() {
console.info('[test page log] index onShow')
},
onHide() {
console.info('[test page log] index onHide')
},
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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.
*/
.container {
width: 454px;
height: 454px;
justify-content: center;
align-items: center;
}
.title {
width: 200px;
font-size: 30px;
text-align: center;
}
<!--/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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.
*/-->
<div class="container">
<text class="title">
{{ title }}
</text>
</div>
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 {
data: {
title: "router push test"
},
onShow() {
console.info('[test page log] routerPush onShow');
},
onHide() {
console.info('[test page log] routerPush ohHide');
},
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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.
*/
.container {
width: 454px;
height: 454px;
justify-content: center;
align-items: center;
}
.title {
width: 200px;
font-size: 30px;
text-align: center;
}
<!--/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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.
*/-->
<div class="container">
<text class="title">
{{ title }}
</text>
</div>
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 {
data: {
title: "router replace test"
},
onShow() {
console.info('[test page log] routerReplace onShow');
},
onHide() {
console.info('[test page log] routerReplace ohHide');
},
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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.
*/
.container {
flex-direction:row;
width:100%;
height:100%;
padding: 1px;
}
.sub-container{
flex-direction: column;
height: 100%;
flex-weight: 1;
}
.title{
width: 100%;
height: 50px;
font-size: 18px;
margin: 2px;
padding: 2px;
font-weight: bold;
text-align: center;
}
.title-style-2{
height: 30px;
}
.sub-title{
width: 100%;
height: 50px;
font-size: 14px;
text-align: left;
margin: 2px;
padding: 2px;
}
.sub-title-2{
height: 20px;
}
.sub-title-3{
font-size: 12px;
}
.style1{
width: 100%;
height: 100%;
min-width: 25px;
min-height: 10px;
max-width: 300px;
max-height: 100px;
padding-left: 5px;
padding-top: 5px;
padding-right: 5px;
padding-bottom: 5px;
margin-left: 5px;
margin-top: 5px;
margin-right: 5px;
margin-bottom: 5px;
border-left-style: solid;
border-right-style: dashed;
border-top-style: dashed;
border-bottom-style: dotted;
border-left-width: 1px;
border-right-width: 2px;
border-top-width: 2px;
border-bottom-width: 1px;
border-left-color: #ff0000;
border-right-color: #00ff00;
border-top-color: #0000ff;
border-bottom-color: #fff000;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 15px;
border-top-left-radius: 8px;
border-top-right-radius: 12px;
background: linear-gradient(pink,#fff000);
box-shadow: 2px 4px 6px 8px #888888;
opacity: 0.5;
display: flex;
visibility: visible;
align-self: center;
image-fill: #000fff;
clip-path: margin-box;
}
.style2{
width: 300px;
height: 100px;
padding-start: 10px;
padding-end: 15px;
margin-start: 5px;
margin-end: 10px;
border-style: dotted;
border-width: 2px;
border-color:#000000;
border-radius:5px;
background-color:#ffaa00;
mask-image: url('common/images/icon.png');
mask-size: cover;
mask-position: center;
}
.style3{
width: 100%;
height: 100px;
padding: 10px;
margin: 5px;
border-left: 1px solid #000000;
border-right: 2px dashed #00ff00;
border-top: 1.5px dotted #0000ff;
border-bottom: 2.5px dotted #fff000;
background-image:url('common/images/image.png');
background-size:cover;
background-repeat: repeat-x;
background-position: center;
flex:1;
flex-grow: 2;
flex-shrink: 1;
}
.style4{
width: 100%;
height: 15%;
padding: 10px;
margin: 5px;
border: 2px solid #000000;
}
.contain1{
width: 100%;
}
.style5{
width: 90%;
height: 60px;
background-color: yellow;
border-image-source: url('/common/images/image.png');
border-image-slice: 1px 2px 3px 4px;
border-image-width: 2px 3px 4px 5px;
border-image-outset: 3px 4px 5px 6px;
border-image-repeat: repeat;
}
.style6{
width: 100px;
height: 70px;
position: absolute;
left: 10px;
top: 70px;
bottom: 5px;
right: 10px;
background-color: pink;
border-image: url('common/images/icon.png') 1px 2px 3px 4px 2px 3px 4px 5px 3px 4px 5px 6px round;
}
.style7 {
width: 100px;
height: 100px;
border: 1px solid #000000;
object-fit: fill;
}
.color-primary {
background-color: mediumpurple;
}
.color-warning {
background-color: pink;
}
.color-success {
background-color: cornflowerblue;
}
.grid-child {
width: 100%;
border-radius: 2px;
}
.grid-left-top {
width: 20px;
height: 20px;
border-radius: 10px;
border: 1px solid plum;
background: linear-gradient(pink, purple);
box-shadow: 0px 0px 1px 1px pink;
grid-row-start: 0;
grid-column-start: 0;
grid-row-end: 0;
grid-column-end: 0;
}
.grid-left-bottom {
width: 20px;
height: 20px;
border-radius: 5px;
border: 1px solid plum;
background: linear-gradient(pink, #00aaee);
box-shadow: 0px 0px 1px 1px pink;
grid-row-start: 1;
grid-column-start: 0;
grid-row-end: 1;
grid-column-end: 0;
}
.grid-right-top {
width: 20px;
height: 20px;
border-radius: 3px;
border: 1px dotted plum;
background: linear-gradient(mediumpurple, #00aaee);
box-shadow: 0px 0px 1px 1px pink;
grid-row-start: 0;
grid-column-start: 1;
grid-row-end: 0;
grid-column-end: 1;
}
.grid-right-bottom {
width: 20px;
height: 20px;
border-radius: 5px;
border: 1px dotted plum;
background: linear-gradient(pink, mediumpurple);
box-shadow: 0px 0px 2px 2px pink;
grid-row-start: 1;
grid-column-start: 1;
grid-row-end: 1;
grid-column-end: 1;
}
.event-container{
flex-direction: column;
flex-weight: 1;
}
.event1{
width: 90%;
flex-weight: 1;
background-color: yellow;
}
.event2{
width: 90%;
flex-weight: 1;
background-color: red;
}
.event3{
width: 90%;
flex-weight: 1;
background-color: #ad4e2a;
}
.event4{
flex-direction: row;
width: 90%;
flex-weight: 1;
}
.event5{
flex-direction: column;
width: 100%;
height: 90px;
}
.prop-container{
flex-direction: column;
}
#prop1 {
height: 20px;
background-color: mediumslateblue;
width: 100%;
margin: 5px;
}
.prop2 {
height: 20px;
background-color: pink;
width: 100%;
margin: 5px;
}
.prop3 {
height: 20px;
background-color: darkseagreen;
width: 100%;
margin: 5px;
}
.prop4 {
height: 50px;
background-color: darkseagreen;
width: 100%;
margin: 5px;
}
.prop5 {
height: 50px;
background-color: darkseagreen;
width: 100%;
margin: 5px;
}
.atom-container{
flex-direction: column;
}
.function-container{
flex-direction: column;
}
.function1{
background-color: #ff0000;
width: 90%;
height: 45px;
}
.function2{
background-color: #00ff00;
width: 90%;
height: 45px;
}
.function3{
background-color: #0000ff;
width: 90%;
height: 45px;
}
.function4{
flex-direction: row;
width: 90%;
height: 45px;
}
.function5{
flex-direction: row;
width: 90%;
height: 45px;
}
.function6{
flex-direction: row;
width: 90%;
height: 45px;
}
.function7{
flex-direction: row;
width: 90%;
height: 45px;
}
.function8{
flex-direction: row;
width: 90%;
height: 45px;
}
.function9{
flex-direction: row;
width: 90%;
height: 45px;
}
\ No newline at end of file
<!--/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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.
*/-->
<div class="container">
<div class="sub-container">
<text class="title">
通用样式
</text>
<text class="sub-title">
video通用样式1
</text>
<video src="/common/images/video.mp4" id="style1" class="style1">
</video>
<text class="sub-title">
video通用样式2
</text>
<video src="/common/images/video.mp4" id="style2" class="style2">
</video>
<text class="sub-title">
video通用样式3
</text>
<video src="/common/images/video.mp4" id="style3" class="style3">
</video>
<text class="sub-title">
video通用样式4
</text>
<video src="/common/images/video.mp4" id="style4" class="style4">
</video>
<text class="sub-title">
div通用样式5
</text>
<div class="contain1" style="height: 300px;">
<video src="/common/images/video.mp4" id="style5" class="style5">
</video>
<video src="/common/images/video.mp4" id="style6" class="style6">
</video>
</div>
<text class="sub-title">
video特有样式
</text>
<video src="/common/images/video.mp4" id="style7" class="style7">
</video>
</div>
<div style="background-color: #000000; width: 2px; height: 100%;">
</div>
<div class="sub-container">
<div class="prop-container">
<text class="title title-style-2">
通用属性
</text>
<text class="sub-title sub-title-2">
video通用属性1
</text>
<video id="prop1" class="prop1"
disabled = "true" data-name ="prop1" click-effect="spring-medium">
</video>
<text class="sub-title sub-title-2">
video通用属性2
</text>
<video class="prop2" ref ="prop2" id="prop2"
disabled = "false" data-name ="prop2" click-effect="spring-large">
</video>
<text class="sub-title sub-title-2">
video通用属性3
</text>
<video style="color: #679855; margin: 5px;" class="prop3" id="prop3">
</video>
<text class="sub-title sub-title-2">
video特有属性
</text>
<video src="/common/images/video.mp4" class="prop4" id="prop4"
muted="true" autoplay="true" poster="/common/images/image.png"
controls="true" loop="true" starttime="2" direction="auto"
speed="1.5">
</video>
<video src="/common/images/video.mp4" class="prop5" id="prop5"
muted="false" autoplay="false" controls="false" loop="false"
starttime="3" direction="vertical" speed="1.0">
</video>
</div>
<div style="background-color: #000000; width: 100%; height: 2px;">
</div>
<div class="event-container" >
<text class="title title-style-2">
通用事件
</text>
<text class="sub-title sub-title-2">
video通用事件1
</text>
<video src="/common/images/video.mp4" class ="event1" ontouchstart="touchStart"
ontouchmove="touchMove" ontouchend="touchEnd" ontouchcancel="touchCancel">
</video>
<text class="sub-title sub-title-2">
video通用事件2
</text>
<video src="/common/images/video.mp4" class ="event2" onclick="click"
ondoubleclick="doubleClick" onlongpress="longPress" onfocus="focus"
onblur="blur" onkey="key" onswipe="swipe" onattached="attached"
ondetached="detached">
</video>
<text class="sub-title sub-title-2">
video通用事件3
</text>
<video src="/common/images/video.mp4" class ="event3" onpinchstart="pinchStart"
onpinchupdate="pinchUpdate"
onpinchend="pinchEnd" onpinchcancel="pinchCancel"
ondragstart="dragStart" ondrag="drag"
ondragend="dragEnd" ondragenter="dragEnter"
ondragover="dragOver" ondragleave="dragLeave"
ondrop="drop"
onaccessibility="onAccessibility">
</video>
<text class="sub-title sub-title-2">
video特有事件1
</text>
<video src="/common/images/video.mp4" class ="event4" onprepared="prepared"
onstart="start" onpause="pause" onfinish="finish" onerror="error"
onseeking="seeking" onseeked="seeked" ontimeupdate="timeupdate"
onfullscreenchange="fullscreenchange" onstop="stop">
</video>
</div>
</div>
<div style="background-color: #000000; width: 2px; height: 100%;">
</div>
<div class="sub-container">
<div class="atom-container">
<text class="title title-style-2">
特有方法
</text>
<text class="sub-title sub-title-2 sub-title-3">
video特有方法1
</text>
<video src="/common/images/video.mp4" id="function4" class="function4" ontouchstart="functionTest4">
</video>
<text class="sub-title sub-title-2 sub-title-3">
video特有方法2
</text>
<video src="/common/images/video.mp4" id="function5" class="function5" ontouchstart="functionTest5">
</video>
<text class="sub-title sub-title-2 sub-title-3">
video特有方法3
</text>
<video src="/common/images/video.mp4" id="function6" class="function6" ontouchstart="functionTest6">
</video>
<text class="sub-title sub-title-2 sub-title-3">
video特有方法4
</text>
<video src="/common/images/video.mp4" id="function7" class="function7" ontouchstart="functionTest7">
</video>
<text class="sub-title sub-title-2 sub-title-3">
video特有方法5
</text>
<video src="/common/images/video.mp4" id="function8" class="function8" ontouchstart="functionTest8">
</video>
<text class="sub-title sub-title-2 sub-title-3">
video特有方法6
</text>
<video src="/common/images/video.mp4" id="function9" class="function9" ontouchstart="functionTest9">
</video>
</div>
<div style="background-color: #000000; width: 100%; height: 2px;">
</div>
<div class="function-container">
<text class="title title-style-2">
通用方法
</text>
<text class="sub-title sub-title-2 sub-title-3">
video通用方法1
</text>
<video src="/common/images/video.mp4" id="function1" class="function1" ontouchstart="functionTest1">
</video>
<text class="sub-title sub-title-2 sub-title-3">
div通用方法2
</text>
<video src="/common/images/video.mp4" id="function2" class="function2" ontouchstart="functionTest2">
</video>
<text class="sub-title sub-title-2 sub-title-3">
div通用方法3
</text>
<video src="/common/images/video.mp4" id="function3" class="function3" ontouchstart="functionTest3">
</video>
</div>
</div>
</div>
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 prompt from '@system.prompt';
var options = {
duration: 1500,
easing: 'friction',
delay: 100,
fill: 'forwards',
iterations: 2,
direction: 'normal',
};
var frames = [
{
transform: {
translate: '-120px',
rotate:'10deg',
scale:0.2,
skew:'40deg'
},
opacity: 0.1,
offset: 0.0,
width: '40%',
height:'20px',
backgroundColor:'#ff0000',
backgroundPosition:'10px 20px',
transformOrigin:'left top'
},
{
transform: {
translateX: '0px',
translateY: '5px',
rotateX:'10deg',
rotateY:'10deg',
scaleX:0.5,
scaleY:0.7,
skewX:'22deg',
skewY:'30deg'
},
opacity: 0.6,
offset: 2.0,
width: '60%',
height:'30px',
backgroundColor:'#ff00ff',
backgroundPosition:'15px 25px',
transformOrigin:'center top'
},
{
transform: {
translateX: '100px',
translateY: '0px',
translateZ: '20px',
rotateX:'0deg',
rotateY:'0deg',
rotateZ:'30deg',
scaleX:1,
scaleY:1,
scaleZ:2,
skewX:'0',
skewY:'0',
skewZ:'30deg'
},
opacity: 1,
offset: 0.0,
width: '100%',
height:'30px',
backgroundColor:'#ffff00',
backgroundPosition:'0px',
transformOrigin:'center center'
},
];
export default {
onShow(){
// 通用属性
var prop1 = this.$element('prop1');
var name1 = prop1.dataSet.name
var prop2 = this.$refs.prop2;
var name2 = prop2.dataSet.name
prompt.showToast({
message: 'prop1--' + name1 + '\nprop2--' + name2
});
},
touchStart(event){
var globalX = event.touches[0].globalX
var globalY = event.touches[0].globalY
var localX = event.touches[0].localX
var localY = event.touches[0].localY
var size = event.touches[0].size
var force = event.touches[0].force
var changeGlobalX = event.changedTouches[0].globalX
var changeGlobalY = event.changedTouches[0].globalY
var changeLocalX = event.changedTouches[0].localX
var changeLocalY = event.changedTouches[0].localY
var changeSize = event.changedTouches[0].size
var changeForce = event.changedTouches[0].force
var message = 'globalX--' + globalX + ',globalY--' + globalY +
',localX--' + localX + ',localY--' + localY + ',size--' + size + ',force--' + force +
',changeGlobalX--' + changeGlobalX + ',changeGlobalY--' + changeGlobalY +
',changeLocalX--' + changeLocalX + ',changeLocalY--' + changeLocalY +
',changeSize--' + changeSize + ',changeForce--' + changeForce;
prompt.showToast({
message: 'touchstart:\n' + message
});
},
touchMove(event){
var globalX = event.touches[0].globalX
var globalY = event.touches[0].globalY
var localX = event.touches[0].localX
var localY = event.touches[0].localY
var size = event.touches[0].size
var force = event.touches[0].force
var changeGlobalX = event.changedTouches[0].globalX
var changeGlobalY = event.changedTouches[0].globalY
var changeLocalX = event.changedTouches[0].localX
var changeLocalY = event.changedTouches[0].localY
var changeSize = event.changedTouches[0].size
var changeForce = event.changedTouches[0].force
var message = 'globalX--' + globalX + ',globalY--' + globalY +
',localX--' + localX + ',localY--' + localY + ',size--' + size + ',force--' + force +
',changeGlobalX--' + changeGlobalX + ',changeGlobalY--' + changeGlobalY +
',changeLocalX--' + changeLocalX + ',changeLocalY--' + changeLocalY +
',changeSize--' + changeSize + ',changeForce--' + changeForce;
prompt.showToast({
message: 'touchMove:\n' +message
});
},
touchEnd(event){
var globalX = event.touches[0].globalX
var globalY = event.touches[0].globalY
var localX = event.touches[0].localX
var localY = event.touches[0].localY
var size = event.touches[0].size
var force = event.touches[0].force
var changeGlobalX = event.changedTouches[0].globalX
var changeGlobalY = event.changedTouches[0].globalY
var changeLocalX = event.changedTouches[0].localX
var changeLocalY = event.changedTouches[0].localY
var changeSize = event.changedTouches[0].size
var changeForce = event.changedTouches[0].force
var message = 'globalX--' + globalX + ',globalY--' + globalY +
',localX--' + localX + ',localY--' + localY + ',size--' + size + ',force--' + force +
',changeGlobalX--' + changeGlobalX + ',changeGlobalY--' + changeGlobalY +
',changeLocalX--' + changeLocalX + ',changeLocalY--' + changeLocalY +
',changeSize--' + changeSize + ',changeForce--' + changeForce;
prompt.showToast({
message: 'touchEnd:\n' +message
});
},
touchCancel(event){
var globalX = event.touches[0].globalX
var globalY = event.touches[0].globalY
var localX = event.touches[0].localX
var localY = event.touches[0].localY
var size = event.touches[0].size
var force = event.touches[0].force
var changeGlobalX = event.changedTouches[0].globalX
var changeGlobalY = event.changedTouches[0].globalY
var changeLocalX = event.changedTouches[0].localX
var changeLocalY = event.changedTouches[0].localY
var changeSize = event.changedTouches[0].size
var changeForce = event.changedTouches[0].force
var message = 'globalX--' + globalX + ',globalY--' + globalY +
',localX--' + localX + ',localY--' + localY + ',size--' + size + ',force--' + force +
',changeGlobalX--' + changeGlobalX + ',changeGlobalY--' + changeGlobalY +
',changeLocalX--' + changeLocalX + ',changeLocalY--' + changeLocalY +
',changeSize--' + changeSize + ',changeForce--' + changeForce;
prompt.showToast({
message: 'touchCancel:\n' +message
});
},
click(){
prompt.showToast({
message: 'click'
});
},
doubleClick(){
prompt.showToast({
message: 'doubleClick'
});
},
longPress(){
prompt.showToast({
message: 'longPress'
});
},
focus(){
prompt.showToast({
message: 'focus'
});
},
blur(){
prompt.showToast({
message: 'blur'
});
},
key(event){
var code = event.code;
var action = event.action;
var repeatCount = event.repeatCount;
var timestampStart = event.timestampStart;
var message = 'code--' + code + ',action--' + action +
',repeatCount--' + repeatCount + ',timestampStart--' + timestampStart;
prompt.showToast({
message: 'key:\n' + message
});
},
swipe(event){
var direction = event.direction;
var distance = event.distance;
var message = 'direction--' + direction + ',distance--' + distance;
prompt.showToast({
message: 'swipe:\n' + message
});
},
attached(){
prompt.showToast({
message: 'attached'
});
},
detached(){
prompt.showToast({
message: 'detached'
});
},
pinchStart(event){
var scale = event.scale
var pinchCenterX = event.pinchCenterX
var pinchCenterY = event.pinchCenterY
var message = 'scale--' + scale + ',pinchCenterX--' + pinchCenterX +
',pinchCenterY--' + pinchCenterY;
prompt.showToast({
message: 'pinchStart:\n' + message
});
},
pinchUpdate(event){
var scale = event.scale
var pinchCenterX = event.pinchCenterX
var pinchCenterY = event.pinchCenterY
var message = 'scale--' + scale + ',pinchCenterX--' + pinchCenterX +
',pinchCenterY--' + pinchCenterY;
prompt.showToast({
message: 'pinchUpdate:\n' + message
});
},
pinchEnd(event){
var scale = event.scale
var pinchCenterX = event.pinchCenterX
var pinchCenterY = event.pinchCenterY
var message = 'scale--' + scale + ',pinchCenterX--' + pinchCenterX +
',pinchCenterY--' + pinchCenterY;
prompt.showToast({
message: 'pinchUpdate:\n' + message
});
},
pinchCancel(event){
var scale = event.scale
var pinchCenterX = event.pinchCenterX
var pinchCenterY = event.pinchCenterY
var message = 'scale--' + scale + ',pinchCenterX--' + pinchCenterX +
',pinchCenterY--' + pinchCenterY;
prompt.showToast({
message: 'pinchCancel:\n' + message
});
},
dragStart(event){
var type = event.type
var globalX = event.globalX
var globalY = event.globalY
var timestamp = event.timestamp
var message = 'type--' + type + ',globalX--' + globalX +
',globalY--' + globalY + ',timestamp--' + timestamp;
prompt.showToast({
message: 'dragStart:\n' + message
});
},
drag(event){
var type = event.type
var globalX = event.globalX
var globalY = event.globalY
var timestamp = event.timestamp
var message = 'type--' + type + ',globalX--' + globalX +
',globalY--' + globalY + ',timestamp--' + timestamp;
prompt.showToast({
message: 'drag:\n' + message
});
},
dragEnd(event){
var type = event.type
var globalX = event.globalX
var globalY = event.globalY
var timestamp = event.timestamp
var message = 'type--' + type + ',globalX--' + globalX +
',globalY--' + globalY + ',timestamp--' + timestamp;
prompt.showToast({
message: 'dragEnd:\n' + message
});
},
dragEnter(event){
var type = event.type
var globalX = event.globalX
var globalY = event.globalY
var timestamp = event.timestamp
var message = 'type--' + type + ',globalX--' + globalX +
',globalY--' + globalY + ',timestamp--' + timestamp;
prompt.showToast({
message: 'dragEnter:\n' + message
});
},
dragOver(event){
var type = event.type
var globalX = event.globalX
var globalY = event.globalY
var timestamp = event.timestamp
var message = 'type--' + type + ',globalX--' + globalX +
',globalY--' + globalY + ',timestamp--' + timestamp;
prompt.showToast({
message: 'dragOver:\n' + message
});
},
dragLeave(event){
var type = event.type
var globalX = event.globalX
var globalY = event.globalY
var timestamp = event.timestamp
var message = 'type--' + type + ',globalX--' + globalX +
',globalY--' + globalY + ',timestamp--' + timestamp;
prompt.showToast({
message: 'dragLeave:\n' + message
});
},
drop(event){
var type = event.type
var globalX = event.globalX
var globalY = event.globalY
var timestamp = event.timestamp
var message = 'type--' + type + ',globalX--' + globalX +
',globalY--' + globalY + ',timestamp--' + timestamp;
prompt.showToast({
message: 'drop:\n' + message
});
},
functionTest1(event){
var function1 = this.$element('function1');
function1.focus(true)
var rect = function1.getBoundingClientRect();
var width = rect.width;
var height = rect.height;
var left = rect.left;
var top = rect.top;
var message = 'width--' + width + ',height--' + height +
',left--' + left + ',top--' + top;
prompt.showToast({
message: 'function1 rect:\n' + message
});
},
functionTest2(event){
var function2 = this.$element('function2');
let observer = function2.createIntersectionObserver({
ratios: [0.2, 0], // number
});
observer.observe((isVisible, ratio)=> {
console.info('this element is ' + isVisible + 'ratio is ' + ratio)
prompt.showToast({
message: 'function2 observer:\n' + 'isVisible--' + isVisible + ',ratio--' + ratio
});
})
observer.unobserve()
},
functionTest3(event){
var function3 = this.$element('function3');
var animation = function3.animate(frames, options);
animation.play()
animation.onfinish = function(){
prompt.showToast({
message: 'The animation is finished.'
});
};
animation.oncancel = function(){
prompt.showToast({
message: 'The animation is canceled.'
});
};
animation.onrepeat = function(){
prompt.showToast({
message: 'The animation is repeated.'
});
};
setTimeout(() => {
animation.reverse()
}, 500)
setTimeout(() => {
animation.pause()
}, 1000)
setTimeout(() => {
animation.cancel()
}, 1500)
},
functionTest4(){
var function4 = this.$element('function4');
function4.start();
prompt.showToast({
message: 'function4 video start.'
});
},
functionTest5(){
var function5 = this.$element('function5');
function5.pause();
prompt.showToast({
message: 'function5 video pause.'
})
},
functionTest6(){
var function6 = this.$element('function6');
function6.setCurrentTime({
currenttime: 2
});
prompt.showToast({
message: 'function6 video setCurrentTime.'
})
},
functionTest7(){
var function7 = this.$element('function7');
function7.requestFullscreen({
screenOrientation : "default"
});
prompt.showToast({
message: 'function7 video requestFullscreen.'
})
},
functionTest8(){
var function8 = this.$element('function8');
function8.exitFullscreen();
prompt.showToast({
message: 'function8 video exitFullscreen.'
})
},
functionTest9(){
var function9 = this.$element('function9');
function9.stop();
prompt.showToast({
message: 'function9 video stop.'
})
},
reachStart(){
prompt.showToast({
message: 'reachStart'
});
},
reachEnd(){
prompt.showToast({
message: 'reachEnd'
});
},
reachTop(){
prompt.showToast({
message: 'reachTop'
});
},
reachBottom(){
prompt.showToast({
message: 'reachBottom'
});
},
prepared() {
prompt.showToast({
message: 'prepared'
});
},
start() {
prompt.showToast({
message: 'start'
});
},
pause() {
prompt.showToast({
message: 'pause'
});
},
finish() {
prompt.showToast({
message: 'finish'
});
},
error() {
prompt.showToast({
message: 'error'
});
},
seeking() {
prompt.showToast({
message: 'seeking'
});
},
seeked() {
prompt.showToast({
message: 'seeked'
});
},
timeupdate() {
prompt.showToast({
message: 'timeupdate'
});
},
fullscreenchange() {
prompt.showToast({
message: 'fullscreenchange'
});
},
stop() {
prompt.showToast({
message: 'stop'
});
},
onAccessibility() {
prompt.showToast({
message: 'onAccessibility'
});
}
}
/*
* 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.
*/
require('./basicabilityapi.test.js')
require('./mediaquery.test.js')
require('./commonComponentJsApi.test.js')
/*
* 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 configuration from '@system.configuration';
import prompt from '@system.prompt';
import router from '@system.router';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
describe('basicabilityapi', function () {
let testResult;
let testResultFail;
let test;
beforeAll(function () {
testResult = true;
testResultFail = false;
test = "success"
});
beforeEach(function () {
});
afterEach(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
* @tc.desc Cancel the repetitive timing tasks previously set by setInterval.
*/
it('testClearInterval', 0, async function(done) {
console.info('testClearInterval START');
let res = 0;
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();
});
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0200
* @tc.name testConsole
* @tc.desc Print a text message.
*/
it('testConsole', 0, function () {
console.info('testConsole START');
const versionCode = 1.1;
console.info('[console.info] versionCode: ' + versionCode);
console.debug('[console.debug] versionCode: ' + versionCode);
console.log('[console.log] versionCode: ' + versionCode);
console.warn('[console.warn] versionCode: ' + versionCode);
console.error('[console.error] versionCode: ' + versionCode);
expect(test).assertEqual('success');
console.info('testConsole END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0300
* @tc.name testRouterPush
* @tc.desc Go to the specified page of the application.
*/
it('testRouterPush', 0, async function (done) {
console.info('testRouterPush START');
let options = {
uri : 'pages/routerPush/index'
}
let promise1 = new Promise((resolve, reject) => {
router.push(options);
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();
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0310
* @tc.name testRouterPushNotExist
* @tc.desc Test push not exist page.
*/
it('testRouterPushNotExist', 0, async function (done) {
console.info('testRouterPushNotExist START');
let promise1 = new Promise((resolve, reject) => {
router.push({
uri: 'pages/routerNotExist/index'
});
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();
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0400
* @tc.name testRouterReplace
* @tc.desc Replace the current page with a page in the application, and destroy the replaced page.
*/
it('testRouterReplace', 0, async function (done) {
//测试框架不允许index页面直接替换,需要先跳转到其他页面再替换
console.info('testRouterReplace START');
let options = {
uri : 'pages/routerPush/index'
}
let promise1 = new Promise((resolve, reject) => {
router.push(options);
resolve();
});
let repleasePage = {
uri : 'pages/routerReplace/index'
}
let promise2 = new Promise((resolve, reject) => {
setTimeout(() => {
router.replace(repleasePage);
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();
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0410
* @tc.name testRouterReplaceNotExist
* @tc.desc Test replace not exist page.
*/
it('testRouterReplaceNotExist', 0, async function (done) {
console.info('testRouterReplaceNotExist START');
await setTimeout(() => {
router.replace({
uri: 'pages/routerNotExist/index'
});
}, 500);
await setTimeout(() => {
let pages = router.getState();
console.info("testRouterReplaceNotExist getState" + JSON.stringify(pages));
expect("pages/index/").assertEqual(pages.path);
console.info("testRouterReplaceNotExist getLength:" + router.getLength());
expect("1").assertEqual(router.getLength());
console.info('testRouterReplaceNotExist END');
done();
}, 1000);
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0500
* @tc.name testRouterBack
* @tc.desc Return to the previous page or the specified page.
*/
it('testRouterBack', 0, async function (done) {
console.info('testRouterBack START');
let promise1 = new Promise((resolve, reject) => {
router.push({
uri: 'pages/routerPush/index'
});
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();
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0600
* @tc.name testRouterClear
* @tc.desc Clear all historical pages in the page stack, and only keep the current page as the top page.
*/
it('testRouterClear', 0, function () {
console.info('testRouterClear START');
router.clear();
console.info("[router.clear] router.getLength:" + router.getLength());
expect("1").assertEqual(router.getLength());
console.info('testRouterClear END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0700
* @tc.name testRouterLength
* @tc.desc Get the number of pages currently in the page stack.
*/
it('testRouterLength', 0, async function (done) {
console.info('testRouterLength START');
let size = router.getLength();
console.info('[router.getLength] pages stack size = ' + size);
expect(size).assertEqual('1');
let options = {
uri : 'pages/routerPush/index'
}
let promise1 = new Promise((resolve, reject) => {
router.push(options);
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_0800
* @tc.name testRouterGetState
* @tc.desc Get the status information of the current page.
*/
it('testRouterGetState', 0, async function (done) {
console.info('testRouterGetState START');
await setTimeout(() => {
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();
}, 500);
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0900
* @tc.name testPromptShowToast
* @tc.desc Show text pop-up window.
*/
it('testPromptShowToast', 0, function () {
console.info('testPromptShowToast START');
const delay = 5000;
prompt.showToast({
message: 'message',
duration: delay,
});
expect(test).assertEqual('success');
console.info('[prompt.showToast] success');
console.info('testPromptShowToast END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1000
* @tc.name testPromptDialog
* @tc.desc Display the dialog box in the page.
*/
it('testPromptDialog', 0, function () {
console.info('testPromptDialog START')
prompt.showDialog({
title: 'dialog showDialog test',
message: 'message of dialog',
buttons: [
{
text: 'OK',
color: '#0000ff',
index: 0
}
],
success: function (ret) {
console.info("[prompt.showDialog] ret.index " + ret.index);
expect(testResult).toBeTrue();
},
cancel: function () {
console.log('[prompt.showDialog] dialog cancel callback');
expect(testResultFail).toBeTrue();
},
complete: function () {
console.log('[prompt.showDialog] complete');
}
});
console.info('testPromptDialog END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1100
* @tc.name testConfigurationGetLocale
* @tc.desc Get the current language and region of the app. Synchronize with the language and region.
*/
it('testConfigurationGetLocale', 0, function () {
console.info('testConfigurationGetLocale START');
const localeInfo = configuration.getLocale();
console.info("[configuration.getLocale] localeInfo: " + JSON.stringify(localeInfo));
console.info("[configuration.getLocale] language: " + localeInfo.language);
console.info("[configuration.getLocale] countryOrRegion: " + localeInfo.countryOrRegion);
console.info("[configuration.getLocale] dir: " + localeInfo.dir);
expect(localeInfo.language).assertEqual('zh');
expect(localeInfo.dir).assertEqual('ltr');
console.info('testConfigurationGetLocale END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1200
* @tc.name testSetTimeout
* @tc.desc Set up a timer that executes a function or a specified piece of code after the timer expires.
*/
it('testSetTimeout', 0, async function (done) {
console.info('testSetTimeout START');
let start_time = new Date().getTime();
const delay = 200;
await setTimeout(function (v1, v2) {
let end_time = new Date().getTime();
console.info("[settimeout] start_time: " + start_time);
console.info("[settimeout] end_time: " + end_time);
console.info('[settimeout] delay: ' + (end_time - start_time));
console.info('[settimeout] v1: ' + v1);
console.info('[settimeout] v2: ' + v2);
expect('test').assertEqual(v1);
expect('message').assertEqual(v2);
expect(end_time - start_time >= delay).assertTrue();
console.info('testSetTimeout END');
done();
}, delay, 'test', 'message');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1300
* @tc.name testClearTimeout
* @tc.desc The timer previously established by calling setTimeout() is cancelled.
*/
it('testClearTimeout', 0, async function (done) {
console.info('testClearTimeout START');
let res = 0;
let timeoutID = setTimeout(function () {
res++;
}, 700);
await setTimeout(function () {
console.info('testClearTimeout delay 0.5s')
clearTimeout(timeoutID);
console.info("[clearTimeout] success");
}, 500);
await setTimeout(function () {
expect(0).assertEqual(res);
console.info('testClearTimeout END');
done();
}, 1000);
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1400
* @tc.name testSetInterval
* @tc.desc Call a function or execute a code segment repeatedly, with a fixed time delay between each call.
*/
it('testSetInterval', 0, async function (done) {
console.info('testSetInterval START');
let res = 0;
let intervalID = setInterval(function () {
res++;
}, 100);
await setTimeout(function () {
expect(9).assertEqual(res);
console.info('testSetInterval SUCCESS');
clearInterval(intervalID);
console.info('testSetInterval END');
done();
}, 1000);
});
});
/*
* 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';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
describe('aceJsTest', function () {
async function sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
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;
});
}
/**
* run after testcase
*/
afterEach(async function () {
console.info('[aceJsTest] after each called')
await backToIndex();
await sleep(5000)
});
/**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100
* @tc.name testVideoComponent
* @tc.desc ACE
*/
it('testVideoComponent', 0, async function (done) {
let result;
let options = {
uri: 'pages/video/router/index'
}
try {
result = router.push(options)
console.info("push video page success " + JSON.stringify(result));
} catch (err) {
console.error("push video page error " + JSON.stringify(result));
}
await sleep(5000)
let pages = router.getState();
console.info("[router.video] getState" + JSON.stringify(pages));
expect("pages/video/router/").assertEqual(pages.path);
done();
});
});
/*
* 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 {describe,beforeAll,beforeEach,afterEach,afterAll,it,expect}from 'deccjsunit/index'
import mediaquery from '@system.mediaquery';
describe('mediaquery', function() {
let testResult;
let test;
beforeAll(function() {
testResult = false;
test="success"
});
it('addListener', 0, function() {
console.info('MediaQuery addListener start');
var mMediaQueryList = mediaquery.matchMedia('(min-height:0)');
// mMediaQueryList.onreadystatechange = function(){
function minWidthMatch(e){
if(e.matches){
//do something
expect(e.matches).assertEqual(true);
console.info('MediaQuery addListener success');
expect(test).assertEqual('success');
}
else{
expect(e.matches).assertEqual(true);
console.info('MediaQuery addListener fail');
expect(test).assertEqual('fail');
}
}
mMediaQueryList.addListener(minWidthMatch)
console.info('MediaQuery addListener end');
// }
});
it('matchMedia', 0, function() {
console.info('matchMedia start');
var mMediaQueryList = mediaquery.matchMedia('(min-height:0)');
var med = mMediaQueryList.media
console.info("media:"+med)
mMediaQueryList.onchange = function(){
console.info('MediaQuery detonate onchange')
}
function minWidthMatch(e){
if(e.matches){
console.info("MediaQuery matches:"+e.matches)
console.info("MediaQuery onchangeMessage:"+e.onchange)
console.info('MediaQuery matchMedia success');
expect(test).assertEqual('success');
}
else{
console.info('MediaQuery matchMedia fail');
expect(test).assertEqual('fail');
}
console.info('MediaQuery matchMedia end');
}
mMediaQueryList.addListener(minWidthMatch);
});
it('orientation', 0, function() {
console.info('orientation test start');
var mMediaQueryList = mediaquery.matchMedia('(orientation:landscape)');
var med = mMediaQueryList.media
console.info("orientation onchangeMessage:"+mMediaQueryList.onchange)
function orientationMatch(e){
if(e.matches){
//do something
console.info("MediaQuery orientation matches:"+e.matches)
console.info('MediaQuery orientation success');
expect(test).assertEqual('success');
}
else{
console.info('MediaQuery orientation fail');
expect(test).assertEqual('fail');
}
}
mMediaQueryList.addListener(orientationMatch)
console.info('MediaQuery orientation test end')
});
it('rmeoveListener', 0, function() {
console.info('rmeoveListener start');
var mMediaQueryList = mediaquery.matchMedia('(max-width:466)');
function maxWidthMatch(e){
if(e.matches){
//do something
console.info('MediaQuery rmeoveListener success');
expect(test).assertEqual('success');
}
else{
console.info('MediaQuery rmeoveListener fail');
expect(test).assertEqual('fail');
}
}
mMediaQueryList.addListener(maxWidthMatch)
mMediaQueryList.removeListener(maxWidthMatch)
console.info('MediaQuery removeListener end')
});
it('maxHeight', 0, function() {
console.info('maxHeight start');
var mMediaQueryList = mediaquery.matchMedia('(max-width:10000)');
// mMediaQueryList.onreadystatechange = function(){
function maxHeightMatch(e){
if(e.matches){
//do something
console.info('MediaQuery maxHeight success');
expect(test).assertEqual('success');
}
else{
console.info('MediaQuery maxHeight fail');
expect(test).assertEqual('fail');
}
}
// }
mMediaQueryList.addListener(maxHeightMatch)
console.info('MediaQuery maxHeight end')
});
it('deviceType', 0, function() {
console.info('deviceType start');
var mMediaQueryList = mediaquery.matchMedia('(deviceType:phone)');
function deviceTypeMatch(e){
if(e.matches){
//do something
console.info('MediaQuery deviceType success');
expect(test).assertEqual('success');
}
else{
console.info('MediaQuery deviceType fail');
expect(test).assertEqual('fail');
}
}
mMediaQueryList.addListener(deviceTypeMatch)
console.info('MediaQuery deviceType end')
});
it('logicOnly', 0, function() {
console.info('MediaQuery logicOnly start');
var mMediaQueryList = mediaquery.matchMedia('only screen and(deviceType:phone)and(max-height:100000)');
// mMediaQueryList.onreadystatechange = function(){
function logicOnlyMatch(e){
if(e.matches){
//do something
console.info('MediaQuery logicOnly success');
expect(test).assertEqual('success');
}
else{
console.info('MediaQuery logicOnly fail');
expect(test).assertEqual('fail');
}
}
mMediaQueryList.addListener(logicOnlyMatch)
console.info('MediaQuery logicOnly end')
//}
});
it('logicNot', 0, function() {
console.info('logicOnly start');
var mMediaQueryList = mediaquery.matchMedia('not screen and(deviceType:tv)');
// mMediaQueryList.onreadystatechange = function(){
function logicNotMatch(e){
if(e.matches){
//do something
console.info('MediaQuery logicNot success');
expect(test).assertEqual('success');
}
else{
console.info('MediaQuery logicNot fail');
expect(test).assertEqual('fail');
}
}
mMediaQueryList.addListener(logicNotMatch)
console.info('MediaQuery logicNot end')
//}
});
it('logicAnd', 0, function() {
console.info('MediaQuery logicAnd start');
var mMediaQueryList = mediaquery.matchMedia('screen and(deviceType:phone)');
function logicAndMatch(e){
if(e.matches){
//do something
expect(e.matches).assertEqual(true)
console.info('MediaQuery logicAnd success');
expect(test).assertEqual('success');
}
else{
expect(e.matches).assertEqual(true)
console.info('MediaQuery logicAnd fail');
expect(test).assertEqual('fail');
}
}
mMediaQueryList.addListener(logicAndMatch)
console.info('MediaQuery logicAnd end')
});
it('logicComma', 0, function() {
console.info('MediaQuery logicComma start');
var mMediaQueryList = mediaquery.matchMedia('screen and(min-height:0),(round-screen:true)');
function logicCommaMatch(e){
if(e.matches){
//do something
expect(e.matches).assertEqual(true)
console.info('MediaQuery logicComma success');
expect(test).assertEqual('success');
}
else{
expect(e.matches).assertEqual(true)
console.info('MediaQuery logicComma fail');
expect(test).assertEqual('fail');
}
}
mMediaQueryList.addListener(logicCommaMatch)
console.info('MediaQuery logicComma end')
});
it('logicOr', 0, function() {
console.info('MediaQuery logicOr start');
var mMediaQueryList = mediaquery.matchMedia('screen and(max-device-height:2000)or(round-screen:true)');
function logicOrMatch(e){
if(e.matches){
//do something
expect(e.matches).assertEqual(true)
console.info('MediaQuery logicOr success');
expect(test).assertEqual('success');
}
else{
expect(e.matches).assertEqual(true)
console.info('MediaQuery logicOr fail');
expect(test).assertEqual('fail');
}
}
mMediaQueryList.addListener(logicOrMatch)
console.info('MediaQuery logicOr end')
});
it('logic1', 0, function() {
console.info('MediaQuery logic>= start');
var mMediaQueryList = mediaquery.matchMedia('screen and(height>=0)');
function logicOrMatch(e){
if(e.matches){
//do something
expect(e.matches).assertEqual(true)
console.info('MediaQuery logic>= success');
expect(test).assertEqual('success');
}
else{
expect(e.matches).assertEqual(true)
console.info('MediaQuery logic>= fail');
expect(test).assertEqual('fail');
}
}
mMediaQueryList.addListener(logicOrMatch)
console.info('MediaQuery logic>= end')
})
});
\ No newline at end of file
{
"string": [
{
"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.
先完成此消息的编辑!
想要评论请 注册