未验证 提交 22019388 编写于 作者: O openharmony_ci 提交者: Gitee

!7697 多模子系统pointer 5条case添加canIUse判断调用

Merge pull request !7697 from 岳鑫瑶/monthly_20221018
/* /*
* Copyright (c) 2022 Huawei Device Co., Ltd. * Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import pointer from '@ohos.multimodalInput.pointer' import pointer from '@ohos.multimodalInput.pointer'
import window from '@ohos.window' import window from '@ohos.window'
...@@ -65,32 +65,40 @@ export default function Pointer_test() { ...@@ -65,32 +65,40 @@ export default function Pointer_test() {
it('Pointer_PointerVisibleTest_002', 0, async function (done) { it('Pointer_PointerVisibleTest_002', 0, async function (done) {
console.info(`Pointer_PointerVisibleTest_002 enter`); console.info(`Pointer_PointerVisibleTest_002 enter`);
try { var result = canIUse("SystemCapability.MultimodalInput.Input.Pointer");
await pointer.setPointerVisible(true).then(data => { console.info('Pointer_PointerVisibleTest_002 segregate result=' + result);
console.info(`Pointer_PointerVisibleTest_002 success_1, data=${JSON.stringify(data)}`); if (result) {
expect(true).assertTrue(); try {
}).catch((err) => { await pointer.setPointerVisible(true).then(data => {
console.info(`Pointer_PointerVisibleTest_002 failed, err=${JSON.stringify(err)}`); console.info(`Pointer_PointerVisibleTest_002 success_1, data=${JSON.stringify(data)}`);
expect(false).assertTrue(); expect(true).assertTrue();
}); }).catch((err) => {
} catch (error) {
console.info(`Pointer_PointerVisibleTest_002 error`);
expect(false).assertTrue();
}
try {
pointer.isPointerVisible((err, data) => {
if (err) {
console.info(`Pointer_PointerVisibleTest_002 failed, err=${JSON.stringify(err)}`); console.info(`Pointer_PointerVisibleTest_002 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue(); expect(false).assertTrue();
} else { });
console.info(`Pointer_PointerVisibleTest_002 success_2, data=${JSON.stringify(data)}`); } catch (error) {
expect(data == true).assertTrue(); console.info(`Pointer_PointerVisibleTest_002 error`);
done(); expect(false).assertTrue();
} }
}); try {
} catch (error) { pointer.isPointerVisible((err, data) => {
console.info(`Pointer_PointerVisibleTest_002 error`); if (err) {
expect(false).assertTrue(); console.info(`Pointer_PointerVisibleTest_002 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue();
} else {
console.info(`Pointer_PointerVisibleTest_002 success_2, data=${JSON.stringify(data)}`);
expect(data == true).assertTrue();
done();
}
});
} catch (error) {
console.info(`Pointer_PointerVisibleTest_002 error`);
expect(false).assertTrue();
}
} else {
expect(true).assertTrue();
console.info('Pointer_PointerVisibleTest_002 SystemCapability.MultimodalInput.Input.Pointer segregate');
done();
} }
console.info(`Pointer_PointerVisibleTest_002 exit`); console.info(`Pointer_PointerVisibleTest_002 exit`);
}) })
...@@ -122,21 +130,28 @@ export default function Pointer_test() { ...@@ -122,21 +130,28 @@ export default function Pointer_test() {
}) })
}) })
} }
window.getTopWindow(async (err, data) => { var result = canIUse("SystemCapability.MultimodalInput.Input.Pointer");
console.info(`case:SetPointerStyle_001 enter`); console.info('Pointer_SetPointerStyle_001 segregate result=' + result);
var windowClass = data; if (result) {
if (err && err.code != 0) { window.getTopWindow(async (err, data) => {
console.info(`case:SetPointerStyle_001,getTopWindow failed, err=${JSON.stringify(err)}`); console.info(`case:SetPointerStyle_001 enter`);
return; var windowClass = data;
} if (err && err.code != 0) {
console.info(`case:SetPointerStyle_001 ===========`); console.info(`case:SetPointerStyle_001,getTopWindow failed, err=${JSON.stringify(err)}`);
await getPropertiesPromise(data); return;
console.info(`case:SetPointerStyle_001 exit`); }
console.info(`case:SetPointerStyle_001 ===========`);
await getPropertiesPromise(data);
console.info(`case:SetPointerStyle_001 exit`);
done();
})
} else {
expect(true).assertTrue();
console.info('Pointer_SetPointerStyle_001 SystemCapability.MultimodalInput.Input.Pointer segregate');
done(); done();
}) }
}) })
it('Pointer_SetPointerStyle_002', 0, async function (done) { it('Pointer_SetPointerStyle_002', 0, async function (done) {
console.info(`SetPointerStyle_002 enter`); console.info(`SetPointerStyle_002 enter`);
function getPropertiesPromise(windowClass) { function getPropertiesPromise(windowClass) {
...@@ -166,18 +181,26 @@ export default function Pointer_test() { ...@@ -166,18 +181,26 @@ export default function Pointer_test() {
}) })
}) })
} }
window.getTopWindow(async (err, data) => { var result = canIUse("SystemCapability.MultimodalInput.Input.Pointer");
console.info(`case:SetPointerStyle_002 enter`); console.info('Pointer_SetPointerStyle_002 segregate result=' + result);
var windowClass = data; if (result) {
if (err && err.code != 0) { window.getTopWindow(async (err, data) => {
console.info(`case:SetPointerStyle_002,getTopWindow failed, err=${JSON.stringify(err)}`); console.info(`case:SetPointerStyle_002 enter`);
return; var windowClass = data;
} if (err && err.code != 0) {
console.info(`case:SetPointerStyle_002 ===========`); console.info(`case:SetPointerStyle_002,getTopWindow failed, err=${JSON.stringify(err)}`);
await getPropertiesPromise(data); return;
console.info(`case:SetPointerStyle_002 exit`); }
console.info(`case:SetPointerStyle_002 ===========`);
await getPropertiesPromise(data);
console.info(`case:SetPointerStyle_002 exit`);
done();
})
} else {
expect(true).assertTrue();
console.info('Pointer_SetPointerStyle_002 SystemCapability.MultimodalInput.Input.Pointer segregate');
done(); done();
}) }
}) })
it('Pointer_GetPointerStyle_001', 0, async function (done) { it('Pointer_GetPointerStyle_001', 0, async function (done) {
...@@ -207,18 +230,26 @@ export default function Pointer_test() { ...@@ -207,18 +230,26 @@ export default function Pointer_test() {
}) })
}) })
} }
window.getTopWindow(async (err, data) => { var result = canIUse("SystemCapability.MultimodalInput.Input.Pointer");
console.info(`case:GetPointerStyle_001 enter`); console.info('Pointer_GetPointerStyle_001 segregate result=' + result);
var windowClass = data; if (result) {
if (err && err.code != 0) { window.getTopWindow(async (err, data) => {
console.info(`case:GetPointerStyle_001,getTopWindow failed, err=${JSON.stringify(err)}`); console.info(`case:GetPointerStyle_001 enter`);
return; var windowClass = data;
} if (err && err.code != 0) {
console.info(`case:GetPointerStyle_001 ===========`); console.info(`case:GetPointerStyle_001,getTopWindow failed, err=${JSON.stringify(err)}`);
await getPropertiesPromise(data); return;
console.info(`case:GetPointerStyle_001 exit`); }
console.info(`case:GetPointerStyle_001 ===========`);
await getPropertiesPromise(data);
console.info(`case:GetPointerStyle_001 exit`);
done();
})
} else {
expect(true).assertTrue();
console.info('Pointer_GetPointerStyle_001 SystemCapability.MultimodalInput.Input.Pointer segregate');
done(); done();
}) }
}) })
it('Pointer_GetPointerStyle_002', 0, async function (done) { it('Pointer_GetPointerStyle_002', 0, async function (done) {
...@@ -251,19 +282,27 @@ export default function Pointer_test() { ...@@ -251,19 +282,27 @@ export default function Pointer_test() {
}) })
}) })
} }
window.getTopWindow(async (err, data) => { var result = canIUse("SystemCapability.MultimodalInput.Input.Pointer");
console.info(`case:GetPointerStyle_002 enter`); console.info('Pointer_GetPointerStyle_002 segregate result=' + result);
var windowClass = data; if (result) {
if (err && err.code != 0) { window.getTopWindow(async (err, data) => {
console.info(`case:GetPointerStyle_002,getTopWindow failed, err=${JSON.stringify(err)}`); console.info(`case:GetPointerStyle_002 enter`);
var windowClass = data;
if (err && err.code != 0) {
console.info(`case:GetPointerStyle_002,getTopWindow failed, err=${JSON.stringify(err)}`);
done();
return;
}
console.info(`case:GetPointerStyle_002 ===========`);
await getPropertiesPromise(data);
console.info(`case:GetPointerStyle_002 exit`);
done(); done();
return; })
} } else {
console.info(`case:GetPointerStyle_002 ===========`); expect(true).assertTrue();
await getPropertiesPromise(data); console.info('Pointer_GetPointerStyle_002 SystemCapability.MultimodalInput.Input.Pointer segregate');
console.info(`case:GetPointerStyle_002 exit`);
done(); done();
}) }
}) })
it('Pointer_PointerStyle_test', 0, function () { it('Pointer_PointerStyle_test', 0, function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册