From dfe56c7c1c17b4530d8f05d2dee911187ded397b Mon Sep 17 00:00:00 2001 From: Mupceet Date: Thu, 15 Sep 2022 12:42:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E4=BE=8B=E7=BC=96?= =?UTF-8?q?=E5=8F=B7=E5=8F=8A=E9=97=AE=E9=A2=98=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mupceet --- .../entry/src/main/ets/test/Ability.test.ets | 1 - .../src/main/ets/MainAbility/pages/index.ets | 340 ++++++++++-------- .../ServiceExtAbility/ServiceExtAbility.ts | 61 ---- .../ets/test/CaptionConfiguration.test.ets | 231 ++++++------ .../entry/src/main/module.json | 15 - 5 files changed, 288 insertions(+), 360 deletions(-) delete mode 100644 barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts diff --git a/barrierfree/accessibletest/actsabilitylisttest/entry/src/main/ets/test/Ability.test.ets b/barrierfree/accessibletest/actsabilitylisttest/entry/src/main/ets/test/Ability.test.ets index 4f29b3064..70340ca88 100644 --- a/barrierfree/accessibletest/actsabilitylisttest/entry/src/main/ets/test/Ability.test.ets +++ b/barrierfree/accessibletest/actsabilitylisttest/entry/src/main/ets/test/Ability.test.ets @@ -38,7 +38,6 @@ export default function abilityTest() { prompt.showToast({ message: 'CASE All End' }) - disableAll(LOG_PREFIX + ' disableAll ') done() }) /** diff --git a/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/ets/MainAbility/pages/index.ets b/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/ets/MainAbility/pages/index.ets index ca9e1d814..e3323ba17 100644 --- a/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/ets/MainAbility/pages/index.ets @@ -23,19 +23,15 @@ const LOG: string = "[xtsLog]"; const CaptionConfiguration_0010 = () => { const caseName = "CaptionConfiguration_0010" const logTag = LOG + caseName; - let captionsManager = accessibility.getCaptionsManager(); - if (!captionsManager) { - console.info(logTag + "captionsManager is undefined"); - return; - } - let before = captionsManager.enabled; - console.info(logTag + "captionsManager before modification. enabled=" + before); - captionsManager.enabled = !captionsManager.enabled; - let after = captionsManager.enabled; - console.info(logTag + "captionsManager after modification. enabled=" + after); - if (before != after) { - commonEventPublishOnTargetChangeExtra(caseName); - } + config.captions.get().then((res) => { + console.info(logTag + "Config before modification. enabled=" + res); + config.captions.set(!res).then(() => { + console.info(logTag + "Config after modification. enabled=" + !res); + commonEventPublishOnTargetChangeExtra(caseName); + }).catch((err) => { + console.info(logTag + "caption set err=" + JSON.stringify(err)); + }); + }); } const printCaptionsManagerStyle = (logTag, captionsManager) => { @@ -78,206 +74,234 @@ const foreachList = (currValue, array) => { const CaptionConfiguration_0020 = () => { const caseName = "CaptionConfiguration_0020" const logTag = LOG + caseName; - let captionsManager = accessibility.getCaptionsManager(); - if (!captionsManager) { - console.info(logTag + "captionsManager is undefined"); - return; - } - const before = printCaptionsManagerStyle(logTag + "captionsManager before modification. style=", captionsManager); - captionsManager.style.fontFamily = foreachList(captionsManager.style.fontFamily, ['default', 'monospacedSerif', 'serif', - 'monospacedSansSerif', 'sansSerif', 'casual', 'cursive', 'smallCapitals']); - const after = printCaptionsManagerStyle(logTag + "captionsManager after modification. style=", captionsManager); - if (before != after) { - commonEventPublishOnTargetChangeExtra(caseName); - } - + config.captionsStyle.get().then((res) => { + if (!res) { + console.info(logTag + "captionsStyle is undefined"); + return; + } + var captionsStyle = res; + printCaptionStyle(logTag + "captionsStyle before modification. style=", JSON.stringify(res)); + captionsStyle.fontFamily = foreachList(res.fontFamily, ['default', 'monospacedSerif', 'serif', + 'monospacedSansSerif', 'sansSerif', 'casual', 'cursive', 'smallCapitals']); + printCaptionStyle(logTag + "captionsStyle after modification. style=", JSON.stringify(captionsStyle)); + config.captionsStyle.set(captionsStyle).then(() => { + commonEventPublishOnTargetChangeExtra(caseName); + }).catch((err) => { + console.info(logTag + "captionsStyle fontFamily set err=" + JSON.stringify(err)); + }); + }) }; const CaptionConfiguration_0030 = () => { const caseName = "CaptionConfiguration_0030" const logTag = LOG + caseName; - let captionsManager = accessibility.getCaptionsManager(); - if (!captionsManager) { - console.info(logTag + "captionsManager is undefined"); - return; - } - let before = (captionsManager.enabled); - console.info(logTag + "captionsManager before modification. enabled=" + before); - captionsManager.enabled = !captionsManager.enabled; - let after = captionsManager.enabled; - console.info(logTag + "captionsManager after modification. enabled=" + after); - if (before != after) { - commonEventPublishOnTargetChangeExtra(caseName); - } + config.captions.get().then((res) => { + console.info(logTag + "Config before modification. enabled=" + res); + config.captions.set(!res).then(() => { + console.info(logTag + "Config after modification. enabled=" + !res); + commonEventPublishOnTargetChangeExtra(caseName); + }).catch((err) => { + console.info(logTag + "caption set err=" + JSON.stringify(err)); + }); + }); } const CaptionConfiguration_0040 = () => { const caseName = "CaptionConfiguration_0040" const logTag = LOG + caseName; - let captionsManager = accessibility.getCaptionsManager(); - if (!captionsManager) { - console.info(logTag + "captionsManager is undefined"); - return; - } - const before = printCaptionsManagerStyle(logTag + "captionsManager before modification. style=", captionsManager); - captionsManager.style.fontFamily = foreachList(captionsManager.style.fontFamily, ['default', 'monospacedSerif', 'serif', - 'monospacedSansSerif', 'sansSerif', 'casual', 'cursive', 'smallCapitals']); - const after = printCaptionsManagerStyle(logTag + "captionsManager after modification. style=", captionsManager); - if (before != after) { - commonEventPublishOnTargetChangeExtra(caseName); - } + config.captionsStyle.get().then((res) => { + if (!res) { + console.info(logTag + "captionsStyle is undefined"); + return; + } + var captionsStyle = res; + printCaptionStyle(logTag + "captionsStyle before modification. style=", JSON.stringify(res)); + captionsStyle.fontFamily = foreachList(res.fontFamily, ['default', 'monospacedSerif', 'serif', + 'monospacedSansSerif', 'sansSerif', 'casual', 'cursive', 'smallCapitals']); + printCaptionStyle(logTag + "captionsStyle after modification. style=", JSON.stringify(captionsStyle)); + config.captionsStyle.set(captionsStyle).then(() => { + commonEventPublishOnTargetChangeExtra(caseName); + }).catch((err) => { + console.info(logTag + "captionsStyle fontFamily set err=" + JSON.stringify(err)); + }); + }) }; const CaptionConfiguration_0050 = () => { const caseName = "CaptionConfiguration_0050" const logTag = LOG + caseName; - let captionsManager = accessibility.getCaptionsManager(); - if (!captionsManager) { - console.info(logTag + "captionsManager is undefined"); - return; - } - const before = printCaptionsManagerStyle(logTag + "captionsManager before modification. style=", captionsManager); - captionsManager.style.fontFamily = foreachList(captionsManager.style.fontFamily, ['default', 'monospacedSerif', 'serif', - 'monospacedSansSerif', 'sansSerif', 'casual', 'cursive', 'smallCapitals']); - const after = printCaptionsManagerStyle(logTag + "captionsManager after modification. style=", captionsManager); - if (before != after) { - commonEventPublishOnTargetChangeExtra(caseName); - } + config.captionsStyle.get().then((res) => { + if (!res) { + console.info(logTag + "captionsStyle is undefined"); + return; + } + var captionsStyle = res; + printCaptionStyle(logTag + "captionsStyle before modification. style=", JSON.stringify(res)); + captionsStyle.fontFamily = foreachList(res.fontFamily, ['default', 'monospacedSerif', 'serif', + 'monospacedSansSerif', 'sansSerif', 'casual', 'cursive', 'smallCapitals']); + printCaptionStyle(logTag + "captionsStyle after modification. style=", JSON.stringify(captionsStyle)); + config.captionsStyle.set(captionsStyle).then(() => { + commonEventPublishOnTargetChangeExtra(caseName); + }).catch((err) => { + console.info(logTag + "captionsStyle fontFamily set err=" + JSON.stringify(err)); + }); + }) }; const CaptionConfiguration_0060 = () => { const caseName = "CaptionConfiguration_0060" const logTag = LOG + caseName; - let captionsManager = accessibility.getCaptionsManager(); - if (!captionsManager) { - console.info(logTag + "captionsManager is undefined"); - return; - } - const before = printCaptionsManagerStyle(logTag + "captionsManager before modification. style=", captionsManager); - captionsManager.style.fontScale = (captionsManager.style.fontScale ?? 0) + 1; - const after = printCaptionsManagerStyle(logTag + "captionsManager after modification. style=", captionsManager); - if (before != after) { - commonEventPublishOnTargetChangeExtra(caseName); - } + config.captionsStyle.get().then((res) => { + if (!res) { + console.info(logTag + "captionsStyle is undefined"); + return; + } + var captionsStyle = res; + printCaptionStyle(logTag + "captionsStyle before modification. style=", JSON.stringify(res)); + captionsStyle.fontScale = (res.fontScale ?? 0) + 1; + printCaptionStyle(logTag + "captionsStyle after modification. style=", JSON.stringify(captionsStyle)); + config.captionsStyle.set(captionsStyle).then(() => { + commonEventPublishOnTargetChangeExtra(caseName); + }).catch((err) => { + console.info(logTag + "captionsStyle fontFamily set err=" + JSON.stringify(err)); + }); + }) }; const CaptionConfiguration_0070 = () => { const caseName = "CaptionConfiguration_0070" const logTag = LOG + caseName; - let captionsManager = accessibility.getCaptionsManager(); - if (!captionsManager) { - console.info(logTag + "captionsManager is undefined"); - return; - } - const before = printCaptionsManagerStyle(logTag + "captionsManager before modification. style=", captionsManager); - captionsManager.style.fontColor = foreachList(captionsManager.style.fontColor, ['red', 'yellow', 'blue', '#ff0000ff', '##ff000000', 'black', 'white']); - const after = printCaptionsManagerStyle(logTag + "captionsManager after modification. style=", captionsManager); - if (before != after) { - commonEventPublishOnTargetChangeExtra(caseName); - } + config.captionsStyle.get().then((res) => { + if (!res) { + console.info(logTag + "captionsStyle is undefined"); + return; + } + var captionsStyle = res; + printCaptionStyle(logTag + "captionsStyle before modification. style=", JSON.stringify(res)); + captionsStyle.fontColor = foreachList(res.fontColor, ['red', 'yellow', 'blue', '#FFFFFF', '#000000', 'black', 'white']); + printCaptionStyle(logTag + "captionsStyle after modification. style=", JSON.stringify(captionsStyle)); + config.captionsStyle.set(captionsStyle).then(() => { + commonEventPublishOnTargetChangeExtra(caseName); + }).catch((err) => { + console.info(logTag + "captionsStyle fontFamily set err=" + JSON.stringify(err)); + }); + }) }; const CaptionConfiguration_0080 = () => { const caseName = "CaptionConfiguration_0080" const logTag = LOG + caseName; - let captionsManager = accessibility.getCaptionsManager(); - if (!captionsManager) { - console.info(logTag + "captionsManager is undefined"); - return; - } - const before = printCaptionsManagerStyle(logTag + "captionsManager before modification. style=", captionsManager); - captionsManager.style.fontEdgeType = foreachList(captionsManager.style.fontEdgeType, ['none', 'raised', 'depressed', 'uniform', 'dropShadow']); - const after = printCaptionsManagerStyle(logTag + "captionsManager after modification. style=", captionsManager); - if (before != after) { - commonEventPublishOnTargetChangeExtra(caseName); - } + config.captionsStyle.get().then((res) => { + if (!res) { + console.info(logTag + "captionsStyle is undefined"); + return; + } + var captionsStyle = res; + printCaptionStyle(logTag + "captionsStyle before modification. style=", JSON.stringify(res)); + captionsStyle.fontEdgeType = foreachList(res.fontEdgeType, ['none', 'raised', 'depressed', 'uniform', 'dropShadow']); + printCaptionStyle(logTag + "captionsStyle after modification. style=", JSON.stringify(captionsStyle)); + config.captionsStyle.set(captionsStyle).then(() => { + commonEventPublishOnTargetChangeExtra(caseName); + }).catch((err) => { + console.info(logTag + "captionsStyle fontFamily set err=" + JSON.stringify(err)); + }); + }) }; const CaptionConfiguration_0090 = () => { const caseName = "CaptionConfiguration_0090" const logTag = LOG + caseName; - let captionsManager = accessibility.getCaptionsManager(); - if (!captionsManager) { - console.info(logTag + "captionsManager is undefined"); - return; - } - const before = printCaptionsManagerStyle(logTag + "captionsManager before modification. style=", captionsManager); - captionsManager.style.backgroundColor = foreachList(captionsManager.style.backgroundColor, ['red', 'yellow', 'blue', '#ff0000ff', '##ff000000', 'black', 'white']); - const after = printCaptionsManagerStyle(logTag + "captionsManager after modification. style=", captionsManager); - if (before != after) { - commonEventPublishOnTargetChangeExtra(caseName); - } + config.captionsStyle.get().then((res) => { + if (!res) { + console.info(logTag + "captionsStyle is undefined"); + return; + } + var captionsStyle = res; + printCaptionStyle(logTag + "captionsStyle before modification. style=", JSON.stringify(res)); + captionsStyle.backgroundColor = foreachList(res.backgroundColor, ['red', 'yellow', 'blue', '#ff0000ff', '#ff000000', '#00000000', '#f0000000', 'black', 'white']); + printCaptionStyle(logTag + "captionsStyle after modification. style=", JSON.stringify(captionsStyle)); + config.captionsStyle.set(captionsStyle).then(() => { + commonEventPublishOnTargetChangeExtra(caseName); + }).catch((err) => { + console.info(logTag + "captionsStyle fontFamily set err=" + JSON.stringify(err)); + }); + }) }; const CaptionConfiguration_0100 = () => { const caseName = "CaptionConfiguration_0100" const logTag = LOG + caseName; - let captionsManager = accessibility.getCaptionsManager(); - if (!captionsManager) { - console.info(logTag + "captionsManager is undefined"); - return; - } - const before = printCaptionsManagerStyle(logTag + "captionsManager before modification. style=", captionsManager); - captionsManager.style.windowColor = foreachList(captionsManager.style.windowColor, ['red', 'yellow', 'blue', '#ff0000ff', '#ff000000', 'black', 'white']); - const after = printCaptionsManagerStyle(logTag + "captionsManager after modification. style=", captionsManager); - if (before != after) { - commonEventPublishOnTargetChangeExtra(caseName); - } + config.captionsStyle.get().then((res) => { + if (!res) { + console.info(logTag + "captionsStyle is undefined"); + return; + } + var captionsStyle = res; + printCaptionStyle(logTag + "captionsStyle before modification. style=", JSON.stringify(res)); + captionsStyle.windowColor = foreachList(res.windowColor, ['red', 'yellow', 'blue', '#ff0000ff', '#ff000000', '#00000000', '#f0000000', 'black', 'white']); + printCaptionStyle(logTag + "captionsStyle after modification. style=", JSON.stringify(captionsStyle)); + config.captionsStyle.set(captionsStyle).then(() => { + commonEventPublishOnTargetChangeExtra(caseName); + }).catch((err) => { + console.info(logTag + "captionsStyle fontFamily set err=" + JSON.stringify(err)); + }); + }) }; const CaptionConfiguration_0110 = () => { const caseName = "CaptionConfiguration_0110" const logTag = LOG + caseName; - let captionsManager = accessibility.getCaptionsManager(); - if (!captionsManager) { - console.info(logTag + "captionsManager is undefined"); - return; - } - const before = printCaptionsManagerStyle(logTag + "captionsManager before modification. style=", captionsManager); - for (let index = 0; index < 3; index++) { - printCaptionsManagerStyle(logTag + "captionsManager before modification. times=" + index + ". style=", captionsManager); - captionsManager.style.windowColor = foreachList(captionsManager.style.windowColor, ['red', 'yellow', 'blue', '#ff0000ff', '#ff000000', '#00000000', '#f0000000', 'black', 'white']); - printCaptionsManagerStyle(logTag + "captionsManager after modification. times=" + index + ". style=", captionsManager); - } - setTimeout(() => { - const after = printCaptionsManagerStyle(logTag + "captionsManager after modification. style=", captionsManager); - if (before != after) { - commonEventPublishOnTargetChangeExtra(caseName); + config.captionsStyle.get().then((res) => { + if (!res) { + console.info(logTag + "captionsStyle is undefined"); + return; } - }, 2000) - + var captionsStyle = res; + for (let index = 0; index < 3; index++) { + printCaptionStyle(logTag + "captionsStyle before modification. style=", JSON.stringify(res)); + captionsStyle.windowColor = foreachList(res.windowColor, ['red', 'yellow', 'blue', '#ff0000ff', '#ff000000', '#00000000', '#f0000000', 'black', 'white']); + printCaptionStyle(logTag + "captionsStyle after modification. style=", JSON.stringify(captionsStyle)); + config.captionsStyle.set(captionsStyle).then(() => { + commonEventPublishOnTargetChangeExtra(caseName); + }).catch((err) => { + console.info(logTag + "captionsStyle fontFamily set err=" + JSON.stringify(err)); + }); + } + }) }; const CaptionConfiguration_0120 = () => { const caseName = "CaptionConfiguration_0120" const logTag = LOG + caseName; - let captionsManager = accessibility.getCaptionsManager(); - if (!captionsManager) { - console.info(logTag + "captionsManager is undefined"); - return; - } - const before = console.info(logTag + "captionsManager before modification. enabled=" + captionsManager.enabled); - captionsManager.enabled = undefined; - const after = console.info(logTag + "captionsManager after modification. enabled=" + captionsManager.enabled); - if (before != after) { - commonEventPublishOnTargetChangeExtra(caseName); - } + config.captions.get().then((res) => { + console.info(logTag + "Config before modification. enabled=" + res); + config.captions.set(!res).then(() => { + console.info(logTag + "Config after modification. enabled=" + !res); + commonEventPublishOnTargetChangeExtra(caseName); + }).catch((err) => { + console.info(logTag + "caption set err=" + JSON.stringify(err)); + }); + }); }; const CaptionConfiguration_0130 = () => { const caseName = "CaptionConfiguration_0130" const logTag = LOG + caseName; - let captionsManager = accessibility.getCaptionsManager(); - if (!captionsManager) { - console.info(logTag + "captionsManager is undefined"); - return; - } - const before = printCaptionsManagerStyle(logTag + "captionsManager before modification. style=", captionsManager); - captionsManager.style.fontEdgeType = undefined; - const after = printCaptionsManagerStyle(logTag + "captionsManager after modification. style=", captionsManager); - if (before != after) { - commonEventPublishOnTargetChangeExtra(caseName); - } + config.captionsStyle.get().then((res) => { + if (!res) { + console.info(logTag + "captionsStyle is undefined"); + return; + } + var captionsStyle = res; + printCaptionStyle(logTag + "captionsStyle before modification. style=", JSON.stringify(res)); + captionsStyle.fontEdgeType = undefined; + printCaptionStyle(logTag + "captionsStyle after modification. style=", JSON.stringify(captionsStyle)); + config.captionsStyle.set(captionsStyle).then(() => { + commonEventPublishOnTargetChangeExtra(caseName); + }).catch((err) => { + console.info(logTag + "captionsStyle fontFamily set err=" + JSON.stringify(err)); + }); + }) }; const CaptionConfiguration_0140 = () => { @@ -490,8 +514,6 @@ const CaptionConfiguration_0240 = () => { console.info(logTag + "captionsStyle fontFamily set err=" + JSON.stringify(err)); }); } - - }) }; diff --git a/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts b/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts deleted file mode 100644 index 0ab1a5fed..000000000 --- a/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 commonEvent from '@ohos.commonEvent' -import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility' -const logTag = "[xtsLog]" -class ServiceExtAbility extends AccessibilityExtensionAbility { - onConnect() { - const context = this.context; - console.info(logTag + "AccessibilityAll onAbilityConnected"); - var commonEventSubscribeInfo = { - events: ["on_assist_change", "execute_accessibility_event"] - } - - function subscriberCallback(err, data) { - console.info(logTag + "AccessibilityALLD subscriberCallback start"); - console.info(logTag + "AccessibilityALLD receive event err:" + JSON.stringify(err)); - console.info(logTag + "AccessibilityALLD receive event data:" + JSON.stringify(data)); - console.info(logTag + "AccessibilityALLD subscriberCallback end"); - } - - var subscriber - commonEvent.createSubscriber(commonEventSubscribeInfo).then(function (data) { - console.info(logTag + " AccessibilityALLD createSubscriber Start====") - subscriber = data; - commonEvent.subscribe(subscriber, subscriberCallback); - console.info(logTag + " AccessibilityALLD createSubscriber End====") - }) - console.info(logTag + " AccessibilityALLD onShow End====") - } - - onAccessibilityEvent(accessibilityEvent) { - printAccessibilityEvent(accessibilityEvent); - return true; - } - - onKeyEvent(keyEvent) { - console.info(" onKeyEvent"); - console.info(logTag + "onKeyEvent KeyInterception AccessibilityAllD: " + JSON.stringify(keyEvent)); - return true; - } -} - -const printAccessibilityEvent = (accessibilityEvent) => { - console.info(logTag + "AccessibilityAllD onAccessibilityEvent Start"); - console.info(logTag + "AccessibilityAllD onAccessibilityEvent accessibilityEvent=" + JSON.stringify(accessibilityEvent)); - console.info(logTag + "AccessibilityAllD onAccessibilityEvent End"); -} - -export default ServiceExtAbility diff --git a/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/ets/test/CaptionConfiguration.test.ets b/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/ets/test/CaptionConfiguration.test.ets index 2c179bbf9..9c3d0484d 100644 --- a/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/ets/test/CaptionConfiguration.test.ets +++ b/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/ets/test/CaptionConfiguration.test.ets @@ -18,6 +18,14 @@ import accessibility from '@ohos.accessibility'; import config from '@ohos.accessibility.config'; const LOG = "[xtsLog]" const START_TIMEOUT = 5000; +var backList = [] +let subScriber = undefined; +let registerOn = false; + +const callbackData = (data) => { + console.info(LOG + " captionsManager on res = " + JSON.stringify(data)) + registerOn = true +} const CaptionConfigurationOn = (logTag, captionType) => { let captionsManager = accessibility.getCaptionsManager(); @@ -25,11 +33,7 @@ const CaptionConfigurationOn = (logTag, captionType) => { console.info(logTag + " captionsManager is undefined"); return; } - captionsManager.on(captionType, (res) => { - console.info(logTag + " captionsManager on " + captionType + " res: " + JSON.stringify(res)); - onbackList.push(logTag + "_on_success") - console.info(logTag + "_on_success"); - }); + captionsManager.on(captionType, callbackData); } const CaptionConfigurationOff = (logTag, captionType) => { @@ -38,37 +42,32 @@ const CaptionConfigurationOff = (logTag, captionType) => { console.info(logTag + " captionsManager is undefined"); return; } - captionsManager.off(captionType, (res) => { - console.info(logTag + " captionsManager off " + captionType + " res: " + JSON.stringify(res)); - }); + captionsManager.off(captionType, callbackData); +} + +const CaptionConfigurationOffAll = (logTag, captionType) => { + let captionsManager = accessibility.getCaptionsManager(); + if (!captionsManager) { + console.info(logTag + " captionsManager is undefined"); + return; + } + captionsManager.off(captionType); } const captionOn = (logTag, caseName) => { - config.captions.on((res) => { - console.info(logTag + " captionOn res = " + JSON.stringify(res)); - console.info(logTag + "_on_success"); - onbackList.push(caseName + "_on_success") - }); + config.captions.on(callbackData); } const captionOff = (logTag, captionType) => { - config.captions.off((res) => { - console.info(logTag + " caption off " + captionType + " res: " + JSON.stringify(res)); - }); + config.captions.off(callbackData); } const captionStyleOn = (logTag, caseName) => { - config.captionsStyle.on((res) => { - console.info(logTag + " captionsStyle On res = " + JSON.stringify(res)); - console.info(logTag + "_on_success"); - onbackList.push(caseName + "_on_success") - }); + config.captionsStyle.on(callbackData); } const captionStyleOff = (logTag, captionType) => { - config.captionsStyle.off((res) => { - console.info(logTag + " captionsStyle off " + captionType + " res: " + JSON.stringify(res)); - }); + config.captionsStyle.off(callbackData); } const excuteCase = (caseNamePara) => { @@ -83,16 +82,15 @@ const excuteCase = (caseNamePara) => { } commonEvent.publish("on_target_change", commonEventPublishData, publishCallback); } -var backList = [] -let subScriber = undefined; -var onbackList = [] + export default function CaptionConfigurationTest() { describe('ActsCaptionConfigurationTest', function () { beforeEach(async function (done) { console.info(LOG + 'ActsCaptionConfigurationTest: beforeEach'); setTimeout(() => { + backList = [] done(); - }, 3000); + }, 1000); }); beforeAll(async function (done) { console.info(LOG + 'ActsCaptionConfigurationTest: beforeAll'); @@ -124,13 +122,14 @@ export default function CaptionConfigurationTest() { }); /** - * @tc.number: CaptionConfiguration_0010 + * @tc.number: CaptionConfiguration_0270 * @tc.name: Call api:getcaptionsmanager() to set the caption parameter. * @tc.desc: Call api:getcaptionsmanager() to set the caption parameter. */ - it('CaptionConfiguration_0010', 1, async function (done) { - const caseName = "CaptionConfiguration_0010"; + it('CaptionConfiguration_0270', 1, async function (done) { + const caseName = "CaptionConfiguration_0270"; const logF = LOG + caseName; + registerOn = false; setTimeout(() => { CaptionConfigurationOn(caseName, 'enableChange') }, 1000); @@ -139,117 +138,110 @@ export default function CaptionConfigurationTest() { }, 3000); setTimeout(() => { var isSucceedTarget: boolean = false; - var isSucceedOnBack: boolean = false; if (backList.indexOf(caseName + '_on_target_change_extra_success') !== -1) { isSucceedTarget = true; } - if (onbackList.indexOf(caseName + '_on_success') !== -1) { - isSucceedOnBack = true; - } - expect(isSucceedTarget && isSucceedOnBack).assertEqual(true); - console.info(logF + ' isSucceed : ' + (isSucceedTarget && isSucceedOnBack)); + expect(isSucceedTarget).assertEqual(true); + expect(registerOn).assertEqual(true); + console.info(logF + ' isSucceed : ' + (isSucceedTarget)); + CaptionConfigurationOff(caseName, 'enableChange') done(); }, 8000); }); /** - * @tc.number: CaptionConfiguration_0020 + * @tc.number: CaptionConfiguration_0280 * @tc.name: Call api:getcaptionsmanager() to set the caption parameter. * @tc.desc: Call api:getcaptionsmanager() to set the caption parameter. */ - it('CaptionConfiguration_0020', 1, async function (done) { - const caseName = "CaptionConfiguration_0020"; + it('CaptionConfiguration_0280', 1, async function (done) { + const caseName = "CaptionConfiguration_0280"; const logF = LOG + caseName; + registerOn = false; CaptionConfigurationOn(caseName, 'styleChange') setTimeout(() => { excuteCase(caseName); }, 3000); setTimeout(() => { var isSucceedTarget: boolean = false; - var isSucceedOnBack: boolean = false; if (backList.indexOf(caseName + '_on_target_change_extra_success') !== -1) { isSucceedTarget = true; } - if (onbackList.indexOf(caseName + '_on_success') !== -1) { - isSucceedOnBack = true; - } - expect(isSucceedTarget && isSucceedOnBack).assertEqual(true); - console.info(logF + ' isSucceed : ' + (isSucceedTarget && isSucceedOnBack)); + expect(isSucceedTarget).assertEqual(true); + expect(registerOn).assertEqual(true); + console.info(logF + ' isSucceed : ' + (isSucceedTarget)); + CaptionConfigurationOffAll(caseName, 'styleChange') done(); }, 8000); }); /** - * @tc.number: CaptionConfiguration_0030 + * @tc.number: CaptionConfiguration_0290 * @tc.name: Call api:getcaptionsmanager() to set the caption parameter. * @tc.desc: Call api:getcaptionsmanager() to set the caption parameter. */ - it('CaptionConfiguration_0030', 1, async function (done) { - const caseName = "CaptionConfiguration_0030"; + it('CaptionConfiguration_0290', 1, async function (done) { + const caseName = "CaptionConfiguration_0290"; const logF = LOG + caseName; + registerOn = false; setTimeout(() => { CaptionConfigurationOn(caseName, 'enableChange'); }, 1000); setTimeout(() => { CaptionConfigurationOff(caseName, 'enableChange') + setTimeout(() => { + excuteCase(caseName); + }, 3000); }, 2000); - setTimeout(() => { - excuteCase(caseName); - }, 3000); setTimeout(() => { var isSucceedTarget: boolean = false; - var isSucceedOnBack: boolean = false; if (backList.indexOf(caseName + '_on_target_change_extra_success') !== -1) { isSucceedTarget = true; } - if (onbackList.indexOf(caseName + '_on_success') == -1) { - isSucceedOnBack = true; - } - expect(isSucceedTarget && isSucceedOnBack).assertEqual(true); - console.info(logF + ' isSucceed : ' + (isSucceedTarget && isSucceedOnBack)); + expect(isSucceedTarget).assertEqual(true); + expect(registerOn).assertEqual(false); + console.info(logF + ' isSucceed : ' + (isSucceedTarget)); done(); }, 8000); }); - + /** - * @tc.number: CaptionConfiguration_0040 + * @tc.number: CaptionConfiguration_0300 * @tc.name: Call api:getcaptionsmanager() to set the caption parameter. * @tc.desc: Call api:getcaptionsmanager() to set the caption parameter. */ - it('CaptionConfiguration_0040', 1, async function (done) { - const caseName = "CaptionConfiguration_0040"; + it('CaptionConfiguration_0300', 1, async function (done) { + const caseName = "CaptionConfiguration_0300"; const logF = LOG + caseName; + registerOn = false; setTimeout(() => { CaptionConfigurationOn(caseName, 'styleChange'); }, 1000); setTimeout(() => { CaptionConfigurationOff(caseName, 'styleChange') + setTimeout(() => { + excuteCase(caseName); + }, 3000); }, 2000); - setTimeout(() => { - excuteCase(caseName); - }, 3000); setTimeout(() => { var isSucceedTarget: boolean = false; - var isSucceedOnBack: boolean = false; if (backList.indexOf(caseName + '_on_target_change_extra_success') !== -1) { isSucceedTarget = true; } - if (onbackList.indexOf(caseName + '_on_success') == -1) { - isSucceedOnBack = true; - } - expect(isSucceedTarget && isSucceedOnBack).assertEqual(true); - console.info(logF + ' isSucceed : ' + (isSucceedTarget && isSucceedOnBack)); + expect(isSucceedTarget).assertEqual(true); + expect(registerOn).assertEqual(false); + console.info(logF + ' isSucceed : ' + (isSucceedTarget)); done(); }, 8000); }); /** - * @tc.number: CaptionConfiguration_0050 + * @tc.number: CaptionConfiguration_0310 * @tc.name: Call api:getcaptionsmanager() to set the caption parameter. * @tc.desc: Call api:getcaptionsmanager() to set the caption parameter. */ - it('CaptionConfiguration_0050', 1, async function (done) { - const caseName = "CaptionConfiguration_0050"; + it('CaptionConfiguration_0310', 1, async function (done) { + const caseName = "CaptionConfiguration_0310"; const logF = LOG + caseName; setTimeout(() => { excuteCase(caseName); @@ -266,12 +258,12 @@ export default function CaptionConfigurationTest() { }); /** - * @tc.number: CaptionConfiguration_0060 + * @tc.number: CaptionConfiguration_0320 * @tc.name: Call api:getcaptionsmanager() to set the caption parameter. * @tc.desc: Call api:getcaptionsmanager() to set the caption parameter. */ - it('CaptionConfiguration_0060', 1, async function (done) { - const caseName = "CaptionConfiguration_0060"; + it('CaptionConfiguration_0320', 1, async function (done) { + const caseName = "CaptionConfiguration_0320"; const logF = LOG + caseName; setTimeout(() => { excuteCase(caseName); @@ -288,12 +280,12 @@ export default function CaptionConfigurationTest() { }); /** - * @tc.number: CaptionConfiguration_0070 + * @tc.number: CaptionConfiguration_0330 * @tc.name: Call api:getcaptionsmanager() to set the caption parameter. * @tc.desc: Call api:getcaptionsmanager() to set the caption parameter. */ - it('CaptionConfiguration_0070', 1, async function (done) { - const caseName = "CaptionConfiguration_0070"; + it('CaptionConfiguration_0330', 1, async function (done) { + const caseName = "CaptionConfiguration_0330"; const logF = LOG + caseName; setTimeout(() => { excuteCase(caseName); @@ -310,12 +302,12 @@ export default function CaptionConfigurationTest() { }); /** - * @tc.number: CaptionConfiguration_0080 + * @tc.number: CaptionConfiguration_0340 * @tc.name: Call api:getcaptionsmanager() to set the caption parameter. * @tc.desc: Call api:getcaptionsmanager() to set the caption parameter. */ - it('CaptionConfiguration_0080', 1, async function (done) { - const caseName = "CaptionConfiguration_0080"; + it('CaptionConfiguration_0340', 1, async function (done) { + const caseName = "CaptionConfiguration_0340"; const logF = LOG + caseName; setTimeout(() => { excuteCase(caseName); @@ -405,6 +397,7 @@ export default function CaptionConfigurationTest() { it('CaptionConfiguration_0120', 1, async function (done) { const caseName = "CaptionConfiguration_0120"; const logF = LOG + caseName; + registerOn = false; setTimeout(() => { CaptionConfigurationOn(caseName, undefined); }, 1000); @@ -413,15 +406,12 @@ export default function CaptionConfigurationTest() { }, 2000); setTimeout(() => { var isSucceedTarget: boolean = false; - var isSucceedOnBack: boolean = false; - if (backList.indexOf(caseName + '_on_target_change_extra_success') == -1) { + if (backList.indexOf(caseName + '_on_target_change_extra_success') != -1) { isSucceedTarget = true; } - if (onbackList.indexOf(caseName + '_on_success') == -1) { - isSucceedOnBack = true; - } - expect(isSucceedTarget && isSucceedOnBack).assertEqual(true); - console.info(logF + ' isSucceed : ' + (isSucceedTarget && isSucceedOnBack)); + expect(isSucceedTarget).assertEqual(true); + expect(registerOn).assertEqual(false); + console.info(logF + ' isSucceed : ' + (isSucceedTarget)); done(); }, 8000); }); @@ -456,23 +446,22 @@ export default function CaptionConfigurationTest() { it('CaptionConfiguration_0140', 1, async function (done) { const caseName = "CaptionConfiguration_0140"; const logF = LOG + caseName; + registerOn = false; setTimeout(() => { - captionOn(logF, caseName) + captionOn(logF, caseName); }, 1000); setTimeout(() => { excuteCase(caseName); }, 3000); setTimeout(() => { var isSucceedTarget: boolean = false; - var isSucceedOnBack: boolean = false; if (backList.indexOf(caseName + '_on_target_change_extra_success') !== -1) { isSucceedTarget = true; } - if (onbackList.indexOf(caseName + '_on_success') !== -1) { - isSucceedOnBack = true; - } - expect(isSucceedTarget && isSucceedOnBack).assertEqual(true); - console.info(logF + ' isSucceed : ' + (isSucceedTarget && isSucceedOnBack)); + expect(isSucceedTarget).assertEqual(true); + expect(registerOn).assertEqual(true); + console.info(logF + ' isSucceed : ' + (isSucceedTarget)); + captionOff(logF, caseName); done(); }, 8000); }); @@ -485,21 +474,20 @@ export default function CaptionConfigurationTest() { it('CaptionConfiguration_0150', 1, async function (done) { const caseName = "CaptionConfiguration_0150"; const logF = LOG + caseName; - captionStyleOn(logF, caseName) + registerOn = false; + captionStyleOn(logF, caseName); setTimeout(() => { excuteCase(caseName); }, 3000); setTimeout(() => { var isSucceedTarget: boolean = false; - var isSucceedOnBack: boolean = false; if (backList.indexOf(caseName + '_on_target_change_extra_success') !== -1) { isSucceedTarget = true; } - if (onbackList.indexOf(caseName + '_on_success') !== -1) { - isSucceedOnBack = true; - } - expect(isSucceedTarget && isSucceedOnBack).assertEqual(true); - console.info(logF + ' isSucceed : ' + (isSucceedTarget && isSucceedOnBack)); + expect(isSucceedTarget).assertEqual(true); + expect(registerOn).assertEqual(true); + console.info(logF + ' isSucceed : ' + (isSucceedTarget)); + config.captionsStyle.off(); done(); }, 8000); }); @@ -512,26 +500,24 @@ export default function CaptionConfigurationTest() { it('CaptionConfiguration_0160', 1, async function (done) { const caseName = "CaptionConfiguration_0160"; const logF = LOG + caseName; + registerOn = false; setTimeout(() => { captionOn(logF, caseName) }, 1000); setTimeout(() => { captionOff(logF, caseName) + setTimeout(() => { + excuteCase(caseName); + }, 3000); }, 2000); - setTimeout(() => { - excuteCase(caseName); - }, 3000); setTimeout(() => { var isSucceedTarget: boolean = false; - var isSucceedOnBack: boolean = false; if (backList.indexOf(caseName + '_on_target_change_extra_success') !== -1) { isSucceedTarget = true; } - if (onbackList.indexOf(caseName + '_on_success') == -1) { - isSucceedOnBack = true; - } - expect(isSucceedTarget && isSucceedOnBack).assertEqual(true); - console.info(logF + ' isSucceed : ' + (isSucceedTarget && isSucceedOnBack)); + expect(isSucceedTarget).assertEqual(true); + expect(registerOn).assertEqual(false); + console.info(logF + ' isSucceed : ' + (isSucceedTarget)); done(); }, 8000); }); @@ -544,26 +530,25 @@ export default function CaptionConfigurationTest() { it('CaptionConfiguration_0170', 1, async function (done) { const caseName = "CaptionConfiguration_0170"; const logF = LOG + caseName; + registerOn = false; setTimeout(() => { captionStyleOn(logF, caseName); }, 1000); setTimeout(() => { captionStyleOff(logF, caseName) + setTimeout(() => { + excuteCase(caseName); + }, 3000); }, 2000); - setTimeout(() => { - excuteCase(caseName); - }, 3000); + setTimeout(() => { var isSucceedTarget: boolean = false; - var isSucceedOnBack: boolean = false; if (backList.indexOf(caseName + '_on_target_change_extra_success') !== -1) { isSucceedTarget = true; } - if (onbackList.indexOf(caseName + '_on_success') == -1) { - isSucceedOnBack = true; - } - expect(isSucceedTarget && isSucceedOnBack).assertEqual(true); - console.info(logF + ' isSucceed : ' + (isSucceedTarget && isSucceedOnBack)); + expect(isSucceedTarget).assertEqual(true); + expect(registerOn).assertEqual(false); + console.info(logF + ' isSucceed : ' + (isSucceedTarget)); done(); }, 8000); }); @@ -741,7 +726,5 @@ export default function CaptionConfigurationTest() { done(); }, 8000); }); - - }) } diff --git a/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/module.json b/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/module.json index f136cb907..917b53268 100644 --- a/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/module.json +++ b/barrierfree/accessibletest/actscaptionconfigurationtest/entry/src/main/module.json @@ -33,21 +33,6 @@ ] } ], - "extensionAbilities": [ - { - "name": "ServiceExtAbility", - "srcEntrance": "./ets/ServiceExtAbility/ServiceExtAbility.ts", - "label": "$string:entry_desc", - "description": "$string:entry_desc", - "type": "accessibility", - "metadata": [ - { - "name": "ohos.accessibleability", - "resource": "$profile:accessibility_config" - } - ], - "permissions": ["ohos.permission.GET_BUNDLE_INFO"] - }], "requestPermissions": [ { "name": "ohos.permission.SYSTEM_FLOAT_WINDOW", -- GitLab