From a52e9ff8c25baab3f169a572310ece4f4909e219 Mon Sep 17 00:00:00 2001 From: jiyong_sd Date: Wed, 20 Jul 2022 13:39:01 +0800 Subject: [PATCH] Adapt to the new framework Signed-off-by: jiyong_sd Change-Id: I515611ff804182e50f253a2c5d64f339ab96415d --- distributedschedule/BUILD.gn | 2 +- distributedschedule/dmsfwk/BUILD.gn | 2 +- .../dmsfwk/continuationmanagertest/BUILD.gn | 12 +- .../dmsfwk/continuationmanagertest/Test.json | 37 +- .../entry/src/main/config.json | 62 - .../main/resources/base/element/string.json | 12 - .../src/main/config.json | 94 + .../main/js/MainAbility}/app.js | 44 +- .../src/main/js/MainAbility}/i18n/en-US.json | 14 +- .../src/main/js/MainAbility}/i18n/zh-CN.json | 14 +- .../js/MainAbility}/pages/index/index.css | 46 +- .../js/MainAbility}/pages/index/index.hml | 40 +- .../main/js/MainAbility}/pages/index/index.js | 65 +- .../src/main/js/TestAbility/app.js | 31 + .../main/js/TestAbility}/i18n/en-US.json | 14 +- .../src/main/js/TestAbility}/i18n/zh-CN.json | 14 +- .../main/js/TestAbility/pages/index/index.css | 30 + .../js/TestAbility}/pages/index/index.hml | 10 +- .../main/js/TestAbility/pages/index/index.js | 26 + .../js/TestRunner/OpenHarmonyTestRunner.js | 59 + .../test/ContinuationManagerJsunit.test.js | 537 ++--- .../default => src/main/js}/test/List.test.js | 33 +- .../main/resources/base/element/string.json | 28 + .../src/main/resources/base/media/icon.png | Bin powermgr/power_manager/BUILD.gn | 6 +- powermgr/power_manager/Test.json | 47 +- .../signature/openharmony_sx.p7b | Bin powermgr/power_manager/src/main/config.json | 143 +- .../main/js/{default => MainAbility}/app.js | 0 .../{default => MainAbility}/i18n/en-US.json | 10 +- .../src/main/js/MainAbility}/i18n/zh-CN.json | 10 +- .../pages/index/index.css | 48 +- .../pages/index/index.hml | 40 +- .../main/js/MainAbility/pages/index/index.js | 30 + .../src/main/js/TestAbility/app.js | 31 + .../src/main/js/TestAbility}/i18n/en-US.json | 14 +- .../src/main/js/TestAbility}/i18n/zh-CN.json | 14 +- .../main/js/TestAbility/pages/index/index.css | 30 + .../js/TestAbility}/pages/index/index.hml | 10 +- .../main/js/TestAbility/pages/index/index.js | 26 + .../js/TestRunner/OpenHarmonyTestRunner.js | 59 + .../src/main/js/default/pages/index/index.js | 43 - .../main/js/{default => }/test/List.test.js | 9 +- .../test/power_manager_power.test.js | 436 ++-- .../test/power_manager_rebootshut.test.js | 235 +- .../test/power_manager_running_lock.test.js | 464 ++-- .../test/power_performance_test.js | 306 +-- .../main/resources/base/element/string.json | 18 +- .../src/main/resources/base/media/icon.png | Bin powermgr/thermal_manager/BUILD.gn | 6 +- powermgr/thermal_manager/Test.json | 38 +- powermgr/thermal_manager/src/main/config.json | 145 +- .../main/js/{default => MainAbility}/app.js | 0 .../{default => MainAbility}/i18n/en-US.json | 10 +- .../src/main/js/MainAbility}/i18n/zh-CN.json | 10 +- .../pages/index/index.css | 48 +- .../pages/index/index.hml | 40 +- .../pages/index/index.js | 73 +- .../src/main/js/TestAbility/app.js | 31 + .../src/main/js/TestAbility/i18n/en-US.json | 8 + .../src/main/js/TestAbility/i18n/zh-CN.json | 8 + .../main/js/TestAbility/pages/index/index.css | 30 + .../main/js/TestAbility/pages/index/index.hml | 5 + .../main/js/TestAbility/pages/index/index.js | 26 + .../js/TestRunner/OpenHarmonyTestRunner.js | 59 + .../main/js/{default => }/test/List.test.js | 5 +- .../test/thermal_common_event.test.js | 147 +- .../test/thermal_performance.test.js | 174 +- .../{default => }/test/thermal_uint.test.js | 663 +++--- .../test/thermal_unittest.test.js | 139 +- .../main/resources/base/element/string.json | 18 +- .../telephonyjstest/call_manager/BUILD.gn | 2 +- .../call_manager_ims2_call/BUILD.gn | 64 +- .../call_manager_ims2_call/Test.json | 38 +- .../js/resources/base/element/string.json | 12 - .../main/resources/base/element/string.json | 12 - .../{entry => }/src/main/config.json | 245 +- .../src/main/js/MainAbility/app.js | 24 + .../src/main/js/MainAbility/i18n/en-US.json | 8 + .../src/main/js/MainAbility/i18n/zh-CN.json | 8 + .../js/MainAbility}/pages/index/index.css | 18 +- .../main/js/MainAbility/pages/index/index.hml | 5 + .../main/js/MainAbility}/pages/index/index.js | 90 +- .../main/js/TestAbility}/app.js | 46 +- .../src/main/js/TestAbility/i18n/en-US.json | 8 + .../src/main/js/TestAbility/i18n/zh-CN.json | 8 + .../main/js/TestAbility/pages/index/index.css | 30 + .../main/js/TestAbility/pages/index/index.hml | 5 + .../main/js/TestAbility/pages/index/index.js | 26 + .../js/TestRunner/OpenHarmonyTestRunner.js | 59 + .../src/main/js/test/CallManageAll.test.js | 2063 +++++++++-------- .../{entry => }/src/main/js/test/List.test.js | 34 +- .../src/main/js/test/lib/ApiToPromise.js | 78 +- .../js/test/lib/ApiToPromisePerfomance.js | 276 +-- .../js/test/lib/ApiToPromiseReliability.js | 262 +-- .../{entry => }/src/main/js/test/lib/Const.js | 456 ++-- .../src/main/js/test/lib/ScenceInCalling.js | 1366 +++++------ .../main/js/test/lib/ScenceLimitCalling.js | 114 +- .../src/main/js/test/lib/ScenceTransfer.js | 96 +- .../main/resources/base/element/string.json | 28 + .../main}/resources/base/media/icon.png | Bin .../cellular_data_abnormal/BUILD.gn | 64 +- .../cellular_data_abnormal/Test.json | 38 +- .../js/resources/base/element/string.json | 12 - .../src/main/js/resources/base/media/icon.png | Bin 6790 -> 0 bytes .../main/resources/base/element/string.json | 12 - .../src/main/resources/base/media/icon.png | Bin 6790 -> 0 bytes .../{entry => }/src/main/config.json | 247 +- .../main/js/MainAbility/app.js} | 80 +- .../src/main/js/MainAbility/i18n/en-US.json | 8 + .../src/main/js/MainAbility/i18n/zh-CN.json | 8 + .../js/MainAbility}/pages/index/index.css | 18 +- .../main/js/MainAbility/pages/index/index.hml | 5 + .../main/js/MainAbility/pages/index/index.js | 30 + .../main/js/TestAbility}/app.js | 46 +- .../src/main/js/TestAbility/i18n/en-US.json | 8 + .../src/main/js/TestAbility/i18n/zh-CN.json | 8 + .../main/js/TestAbility/pages/index/index.css | 30 + .../main/js/TestAbility/pages/index/index.hml | 5 + .../main/js/TestAbility/pages/index/index.js | 26 + .../js/TestRunner/OpenHarmonyTestRunner.js | 59 + .../main/js/test/CellularDataAbnorma.test.js | 411 ++-- .../{entry => }/src/main/js/test/List.test.js | 35 +- .../main/resources/base/element/string.json | 28 + .../src/main/resources/base/media/icon.png | Bin 125 files changed, 6321 insertions(+), 5276 deletions(-) delete mode 100644 distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/config.json delete mode 100644 distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/resources/base/element/string.json create mode 100644 distributedschedule/dmsfwk/continuationmanagertest/src/main/config.json rename distributedschedule/dmsfwk/continuationmanagertest/{entry/src/main/js/default => src/main/js/MainAbility}/app.js (97%) rename {telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default => distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility}/i18n/en-US.json (91%) rename {telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default => distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility}/i18n/zh-CN.json (91%) rename distributedschedule/dmsfwk/continuationmanagertest/{entry/src/main/js/default => src/main/js/MainAbility}/pages/index/index.css (96%) rename distributedschedule/dmsfwk/continuationmanagertest/{entry/src/main/js/default => src/main/js/MainAbility}/pages/index/index.hml (97%) rename distributedschedule/dmsfwk/continuationmanagertest/{entry/src/main/js/default => src/main/js/MainAbility}/pages/index/index.js (85%) create mode 100644 distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/app.js rename distributedschedule/dmsfwk/continuationmanagertest/{entry/src/main/js/default => src/main/js/TestAbility}/i18n/en-US.json (91%) rename {telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default => distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility}/i18n/zh-CN.json (91%) create mode 100644 distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/pages/index/index.css rename {telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default => distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility}/pages/index/index.hml (95%) create mode 100644 distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/pages/index/index.js create mode 100644 distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestRunner/OpenHarmonyTestRunner.js rename distributedschedule/dmsfwk/continuationmanagertest/{entry/src/main/js/default => src/main/js}/test/ContinuationManagerJsunit.test.js (96%) rename distributedschedule/dmsfwk/continuationmanagertest/{entry/src/main/js/default => src/main/js}/test/List.test.js (78%) create mode 100644 distributedschedule/dmsfwk/continuationmanagertest/src/main/resources/base/element/string.json rename distributedschedule/dmsfwk/continuationmanagertest/{entry => }/src/main/resources/base/media/icon.png (100%) mode change 100755 => 100644 powermgr/power_manager/BUILD.gn mode change 100755 => 100644 powermgr/power_manager/Test.json mode change 100755 => 100644 powermgr/power_manager/signature/openharmony_sx.p7b mode change 100755 => 100644 powermgr/power_manager/src/main/config.json rename powermgr/power_manager/src/main/js/{default => MainAbility}/app.js (100%) mode change 100755 => 100644 rename powermgr/power_manager/src/main/js/{default => MainAbility}/i18n/en-US.json (91%) mode change 100755 => 100644 rename powermgr/{thermal_manager/src/main/js/default => power_manager/src/main/js/MainAbility}/i18n/zh-CN.json (91%) rename powermgr/power_manager/src/main/js/{default => MainAbility}/pages/index/index.css (96%) mode change 100755 => 100644 rename powermgr/power_manager/src/main/js/{default => MainAbility}/pages/index/index.hml (97%) mode change 100755 => 100644 create mode 100644 powermgr/power_manager/src/main/js/MainAbility/pages/index/index.js create mode 100644 powermgr/power_manager/src/main/js/TestAbility/app.js rename {telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default => powermgr/power_manager/src/main/js/TestAbility}/i18n/en-US.json (91%) rename {distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default => powermgr/power_manager/src/main/js/TestAbility}/i18n/zh-CN.json (91%) create mode 100644 powermgr/power_manager/src/main/js/TestAbility/pages/index/index.css rename {telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default => powermgr/power_manager/src/main/js/TestAbility}/pages/index/index.hml (95%) create mode 100644 powermgr/power_manager/src/main/js/TestAbility/pages/index/index.js create mode 100644 powermgr/power_manager/src/main/js/TestRunner/OpenHarmonyTestRunner.js delete mode 100755 powermgr/power_manager/src/main/js/default/pages/index/index.js rename powermgr/power_manager/src/main/js/{default => }/test/List.test.js (71%) rename powermgr/power_manager/src/main/js/{default => }/test/power_manager_power.test.js (96%) rename powermgr/power_manager/src/main/js/{default => }/test/power_manager_rebootshut.test.js (95%) rename powermgr/power_manager/src/main/js/{default => }/test/power_manager_running_lock.test.js (97%) rename powermgr/power_manager/src/main/js/{default => }/test/power_performance_test.js (95%) mode change 100755 => 100644 powermgr/power_manager/src/main/resources/base/element/string.json mode change 100755 => 100644 powermgr/power_manager/src/main/resources/base/media/icon.png rename powermgr/thermal_manager/src/main/js/{default => MainAbility}/app.js (100%) rename powermgr/thermal_manager/src/main/js/{default => MainAbility}/i18n/en-US.json (91%) rename powermgr/{power_manager/src/main/js/default => thermal_manager/src/main/js/MainAbility}/i18n/zh-CN.json (91%) mode change 100755 => 100644 rename powermgr/thermal_manager/src/main/js/{default => MainAbility}/pages/index/index.css (96%) rename powermgr/thermal_manager/src/main/js/{default => MainAbility}/pages/index/index.hml (97%) rename powermgr/thermal_manager/src/main/js/{default => MainAbility}/pages/index/index.js (67%) create mode 100644 powermgr/thermal_manager/src/main/js/TestAbility/app.js create mode 100644 powermgr/thermal_manager/src/main/js/TestAbility/i18n/en-US.json create mode 100644 powermgr/thermal_manager/src/main/js/TestAbility/i18n/zh-CN.json create mode 100644 powermgr/thermal_manager/src/main/js/TestAbility/pages/index/index.css create mode 100644 powermgr/thermal_manager/src/main/js/TestAbility/pages/index/index.hml create mode 100644 powermgr/thermal_manager/src/main/js/TestAbility/pages/index/index.js create mode 100644 powermgr/thermal_manager/src/main/js/TestRunner/OpenHarmonyTestRunner.js rename powermgr/thermal_manager/src/main/js/{default => }/test/List.test.js (80%) rename powermgr/thermal_manager/src/main/js/{default => }/test/thermal_common_event.test.js (96%) rename powermgr/thermal_manager/src/main/js/{default => }/test/thermal_performance.test.js (93%) rename powermgr/thermal_manager/src/main/js/{default => }/test/thermal_uint.test.js (96%) rename powermgr/thermal_manager/src/main/js/{default => }/test/thermal_unittest.test.js (93%) delete mode 100644 telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/resources/base/element/string.json delete mode 100644 telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/resources/base/element/string.json rename telephony/telephonyjstest/call_manager/call_manager_ims2_call/{entry => }/src/main/config.json (67%) create mode 100644 telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/app.js create mode 100644 telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/i18n/en-US.json create mode 100644 telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/i18n/zh-CN.json rename telephony/telephonyjstest/call_manager/call_manager_ims2_call/{entry/src/main/js/default => src/main/js/MainAbility}/pages/index/index.css (93%) create mode 100644 telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/pages/index/index.hml rename telephony/telephonyjstest/call_manager/call_manager_ims2_call/{entry/src/main/js/default => src/main/js/MainAbility}/pages/index/index.js (68%) rename telephony/telephonyjstest/call_manager/call_manager_ims2_call/{entry/src/main/js/default => src/main/js/TestAbility}/app.js (91%) create mode 100644 telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/i18n/en-US.json create mode 100644 telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/i18n/zh-CN.json create mode 100644 telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/pages/index/index.css create mode 100644 telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/pages/index/index.hml create mode 100644 telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/pages/index/index.js create mode 100644 telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestRunner/OpenHarmonyTestRunner.js rename telephony/telephonyjstest/call_manager/call_manager_ims2_call/{entry => }/src/main/js/test/CallManageAll.test.js (97%) rename telephony/telephonyjstest/call_manager/call_manager_ims2_call/{entry => }/src/main/js/test/List.test.js (81%) rename telephony/telephonyjstest/call_manager/call_manager_ims2_call/{entry => }/src/main/js/test/lib/ApiToPromise.js (97%) rename telephony/telephonyjstest/call_manager/call_manager_ims2_call/{entry => }/src/main/js/test/lib/ApiToPromisePerfomance.js (97%) rename telephony/telephonyjstest/call_manager/call_manager_ims2_call/{entry => }/src/main/js/test/lib/ApiToPromiseReliability.js (97%) rename telephony/telephonyjstest/call_manager/call_manager_ims2_call/{entry => }/src/main/js/test/lib/Const.js (97%) rename telephony/telephonyjstest/call_manager/call_manager_ims2_call/{entry => }/src/main/js/test/lib/ScenceInCalling.js (97%) rename telephony/telephonyjstest/call_manager/call_manager_ims2_call/{entry => }/src/main/js/test/lib/ScenceLimitCalling.js (97%) rename telephony/telephonyjstest/call_manager/call_manager_ims2_call/{entry => }/src/main/js/test/lib/ScenceTransfer.js (97%) create mode 100644 telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/resources/base/element/string.json rename telephony/telephonyjstest/call_manager/call_manager_ims2_call/{entry/src/main/js => src/main}/resources/base/media/icon.png (100%) delete mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/resources/base/element/string.json delete mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/resources/base/media/icon.png delete mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/resources/base/element/string.json delete mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/resources/base/media/icon.png rename telephony/telephonyjstest/cellular_data/cellular_data_abnormal/{entry => }/src/main/config.json (67%) rename telephony/telephonyjstest/cellular_data/cellular_data_abnormal/{entry/src/main/js/default/pages/index/index.js => src/main/js/MainAbility/app.js} (50%) create mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/MainAbility/i18n/en-US.json create mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/MainAbility/i18n/zh-CN.json rename telephony/telephonyjstest/cellular_data/cellular_data_abnormal/{entry/src/main/js/default => src/main/js/MainAbility}/pages/index/index.css (93%) create mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/MainAbility/pages/index/index.hml create mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/MainAbility/pages/index/index.js rename telephony/telephonyjstest/cellular_data/cellular_data_abnormal/{entry/src/main/js/default => src/main/js/TestAbility}/app.js (91%) create mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/i18n/en-US.json create mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/i18n/zh-CN.json create mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/pages/index/index.css create mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/pages/index/index.hml create mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/pages/index/index.js create mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestRunner/OpenHarmonyTestRunner.js rename telephony/telephonyjstest/cellular_data/cellular_data_abnormal/{entry => }/src/main/js/test/CellularDataAbnorma.test.js (95%) rename telephony/telephonyjstest/cellular_data/cellular_data_abnormal/{entry => }/src/main/js/test/List.test.js (78%) create mode 100644 telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/resources/base/element/string.json rename telephony/telephonyjstest/{call_manager/call_manager_ims2_call/entry => cellular_data/cellular_data_abnormal}/src/main/resources/base/media/icon.png (100%) diff --git a/distributedschedule/BUILD.gn b/distributedschedule/BUILD.gn index de81fd254..c2478d430 100644 --- a/distributedschedule/BUILD.gn +++ b/distributedschedule/BUILD.gn @@ -9,7 +9,7 @@ # 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. import("//build/ohos_var.gni") diff --git a/distributedschedule/dmsfwk/BUILD.gn b/distributedschedule/dmsfwk/BUILD.gn index 44cc84825..bf5ae7cc6 100644 --- a/distributedschedule/dmsfwk/BUILD.gn +++ b/distributedschedule/dmsfwk/BUILD.gn @@ -9,7 +9,7 @@ # 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. import("//build/ohos_var.gni") diff --git a/distributedschedule/dmsfwk/continuationmanagertest/BUILD.gn b/distributedschedule/dmsfwk/continuationmanagertest/BUILD.gn index c3bf176b7..2ce221458 100644 --- a/distributedschedule/dmsfwk/continuationmanagertest/BUILD.gn +++ b/distributedschedule/dmsfwk/continuationmanagertest/BUILD.gn @@ -9,12 +9,12 @@ # 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. import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("continuationmanager_js_test") { - hap_profile = "./entry/src/main/config.json" + hap_profile = "./src/main/config.json" deps = [ ":continuationmanager_js_assets", ":continuationmanager_resources", @@ -23,9 +23,11 @@ ohos_js_hap_suite("continuationmanager_js_test") { hap_name = "ActsContinuationManagerJsTest" } ohos_js_assets("continuationmanager_js_assets") { - source_dir = "./entry/src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } ohos_resources("continuationmanager_resources") { - sources = [ "./entry/src/main/resources" ] - hap_profile = "./entry/src/main/config.json" + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" } diff --git a/distributedschedule/dmsfwk/continuationmanagertest/Test.json b/distributedschedule/dmsfwk/continuationmanagertest/Test.json index 933625ec5..7104e0ef7 100644 --- a/distributedschedule/dmsfwk/continuationmanagertest/Test.json +++ b/distributedschedule/dmsfwk/continuationmanagertest/Test.json @@ -1,18 +1,19 @@ -{ - "description": "Configuration for hjunit demo Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "1200000", - "package": "ohos.acts.distributedschedule.continuationmanager", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsContinuationManagerJsTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "1200000", + "shell-timeout": "1200000", + "bundle-name": "ohos.acts.distributedschedule.continuationmanager", + "package-name": "ohos.acts.distributedschedule.continuationmanager" + }, + "kits": [ + { + "test-file-name": [ + "ActsContinuationManagerJsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/config.json b/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/config.json deleted file mode 100644 index ab20c3060..000000000 --- a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/config.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "app": { - "bundleName": "ohos.acts.distributedschedule.continuationmanager", - "vendor": "example", - "version": { - "code": 1000000, - "name": "1.0.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5 - } - }, - "deviceConfig": {}, - "module": { - "package": "ohos.acts.distributedschedule.continuationmanager", - "name": ".MyApplication", - "mainAbility": "ohos.acts.distributedschedule.continuationmanager.MainAbility", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": false - }, - "abilities": [ - { - "visible": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "ohos.acts.distributedschedule.continuationmanager.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": true - } - } - ] - } -} \ No newline at end of file diff --git a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/resources/base/element/string.json b/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/resources/base/element/string.json deleted file mode 100644 index 2d49e6106..000000000 --- a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ContinuationManagerJsTest" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - } - ] -} diff --git a/distributedschedule/dmsfwk/continuationmanagertest/src/main/config.json b/distributedschedule/dmsfwk/continuationmanagertest/src/main/config.json new file mode 100644 index 000000000..73664228b --- /dev/null +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/config.json @@ -0,0 +1,94 @@ +{ + "app": { + "bundleName": "ohos.acts.distributedschedule.continuationmanager", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.acts.distributedschedule.continuationmanager", + "name": ".entry", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": true + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + }, + "srcPath": "" + } +} \ No newline at end of file diff --git a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/app.js b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/app.js similarity index 97% rename from distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/app.js rename to distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/app.js index 5fd779278..3a41e590e 100644 --- a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/app.js +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/app.js @@ -1,22 +1,22 @@ -/* -* Copyright (c) 2022 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -export default { - onCreate() { - console.info('TestApplication onCreate'); - }, - onDestroy() { - console.info('TestApplication onDestroy'); - } -}; +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +export default { + onCreate() { + console.info('TestApplication onCreate'); + }, + onDestroy() { + console.info('TestApplication onDestroy'); + } +}; diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default/i18n/en-US.json b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/i18n/en-US.json similarity index 91% rename from telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default/i18n/en-US.json rename to distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/i18n/en-US.json index 55561b837..3cb24b374 100644 --- a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default/i18n/en-US.json +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/i18n/en-US.json @@ -1,8 +1,8 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - }, - "Files": { - } +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } } \ No newline at end of file diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default/i18n/zh-CN.json b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/i18n/zh-CN.json similarity index 91% rename from telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default/i18n/zh-CN.json rename to distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/i18n/zh-CN.json index cce1af067..c804e32c0 100644 --- a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default/i18n/zh-CN.json +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/i18n/zh-CN.json @@ -1,8 +1,8 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - }, - "Files": { - } +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } } \ No newline at end of file diff --git a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/pages/index/index.css b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/pages/index/index.css similarity index 96% rename from distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/pages/index/index.css rename to distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/pages/index/index.css index 1beb14afd..0eb108601 100644 --- a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/pages/index/index.css +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/pages/index/index.css @@ -1,23 +1,23 @@ -/* -* 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. -*/ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} +/* +* 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. +*/ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/pages/index/index.hml b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/pages/index/index.hml similarity index 97% rename from distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/pages/index/index.hml rename to distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/pages/index/index.hml index 11314b639..2a54c0734 100644 --- a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/pages/index/index.hml +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/pages/index/index.hml @@ -1,20 +1,20 @@ -/* -* 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. -*/ - -
- - {{ $t('strings.hello') }} {{title}} - -
+/* +* 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. +*/ + +
+ + {{ $t('strings.hello') }} {{title}} + +
diff --git a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/pages/index/index.js b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/pages/index/index.js similarity index 85% rename from distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/pages/index/index.js rename to distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/pages/index/index.js index e8d7ef0b0..bd4cb14f0 100644 --- a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/pages/index/index.js +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/MainAbility/pages/index/index.js @@ -1,36 +1,31 @@ -/* -* Copyright (c) 2022 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -import {Core} from 'deccjsunit/index' - -const injectRef = Object.getPrototypeOf(global) || global -injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') - -export default { - data: { - title: '' - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - core.init() - require('../../test/List.test') - core.execute() - }, - onReady() { - }, +/* +* 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. +*/ + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: '' + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + }, + onReady() { + }, } \ No newline at end of file diff --git a/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/app.js b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/app.js new file mode 100644 index 000000000..cdc31f3dc --- /dev/null +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/i18n/en-US.json b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/i18n/en-US.json similarity index 91% rename from distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/i18n/en-US.json rename to distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/i18n/en-US.json index 55561b837..3cb24b374 100644 --- a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/i18n/en-US.json +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/i18n/en-US.json @@ -1,8 +1,8 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - }, - "Files": { - } +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } } \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/i18n/zh-CN.json b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/i18n/zh-CN.json similarity index 91% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/i18n/zh-CN.json rename to distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/i18n/zh-CN.json index cce1af067..c804e32c0 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/i18n/zh-CN.json +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/i18n/zh-CN.json @@ -1,8 +1,8 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - }, - "Files": { - } +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } } \ No newline at end of file diff --git a/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/pages/index/index.css b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 000000000..b1bcd4338 --- /dev/null +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,30 @@ +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default/pages/index/index.hml b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/pages/index/index.hml similarity index 95% rename from telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default/pages/index/index.hml rename to distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/pages/index/index.hml index f64b040a5..f629c71a9 100644 --- a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default/pages/index/index.hml +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/pages/index/index.hml @@ -1,5 +1,5 @@ -
- - {{ $t('strings.hello') }} {{ title }} - -
+
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/pages/index/index.js b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 000000000..88b083a7f --- /dev/null +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 000000000..c5fa8620c --- /dev/null +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/test/ContinuationManagerJsunit.test.js b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/test/ContinuationManagerJsunit.test.js similarity index 96% rename from distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/test/ContinuationManagerJsunit.test.js rename to distributedschedule/dmsfwk/continuationmanagertest/src/main/js/test/ContinuationManagerJsunit.test.js index 41b974f7f..070a1527b 100644 --- a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/test/ContinuationManagerJsunit.test.js +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/test/ContinuationManagerJsunit.test.js @@ -1,268 +1,269 @@ -/* - * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -import continuationManager from '@ohos.continuation.continuationManager'; - -const TEST_DEVICE_ID = "test_deviceId"; -const TEST_CONNECT_STATUS = continuationManager.DeviceConnectState.CONNECTED; -let token = -1; - -describe('ContinuationManagerTest', function() { - - beforeAll(async function (done) { - console.info('beforeAll'); - done(); - }) - - afterAll(async function (done) { - console.info('afterAll'); - done(); - }) - - beforeEach(async function (done) { - console.info('beforeEach'); - await continuationManager.register(function (err, data) { - token = data; - console.info('beforeEach register success'); - done(); - }); - console.info('beforeEach end'); - }) - - afterEach(async function (done) { - console.info('afterEach'); - await continuationManager.unregister(token, function (err, data) { - console.info('afterEach unregister success'); - done(); - }); - console.info('afterEach end'); - }) - - /** - * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_REGISTER_0100 - * @tc.name [JS-API8]ContinuationManager.register(). - * @tc.desc Test Js Api ContinuationManager.register() testcase 001 - */ - it('testRegister001', 0, async function(done) { - try { - continuationManager.register(function (err, data) { - expect(err.code == 0).assertTrue(); - expect(data - token == 1).assertTrue(); - done(); - }); - } catch (e) { - console.info("testRegister001 " + e); - expect(null).assertFail(); - done(); - } - }) - - /** - * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UNREGISTER_0100 - * @tc.name [JS-API8]ContinuationManager.unregister(). - * @tc.desc Test Js Api ContinuationManager.unregister() testcase 001 - */ - it('testUnregister001', 0, async function(done) { - try { - continuationManager.unregister(token, function (err, data) { - expect(err.code == 0).assertTrue(); - expect(data == undefined).assertTrue(); - }) - done(); - } catch (e) { - console.info("testUnregister001 " + e); - expect(null).assertFail(); - done(); - } - }) - - /** - * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0100 - * @tc.name [JS-API8]ContinuationManager.on(). - * @tc.desc Test Js Api ContinuationManager.on() testcase 001 - */ - it('testOn001', 0, async function(done) { - try { - continuationManager.on("deviceConnect", function (data) { - expect(data == undefined).assertTrue(); - }); - done(); - } catch (e) { - console.info("testOn001 " + e); - expect(null).assertFail(); - done(); - } - }) - - /** - * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0200 - * @tc.name [JS-API8]ContinuationManager.on(). - * @tc.desc Test Js Api ContinuationManager.on() testcase 002 - */ - it('testOn002', 0, async function(done) { - try { - continuationManager.on("deviceDisconnect", function (data) { - expect(data == undefined).assertTrue(); - }); - done(); - } catch (e) { - console.info("testOn002 " + e); - expect(null).assertFail(); - done(); - } - }) - - /** - * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0300 - * @tc.name [JS-API9]ContinuationManager.on(). - * @tc.desc Test Js Api ContinuationManager.on() testcase 003 - */ - it('testOn003', 0, async function(done) { - try { - continuationManager.on("deviceConnect", token, function (data) { - expect(data == undefined).assertTrue(); - }) - done(); - } catch (e) { - console.info("testOn003 " + e); - expect(null).assertFail(); - done(); - } - }) - - /** - * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0400 - * @tc.name [JS-API9]ContinuationManager.on(). - * @tc.desc Test Js Api ContinuationManager.on() testcase 004 - */ - it('testOn004', 0, async function(done) { - try { - continuationManager.on("deviceDisconnect", token, function (data) { - expect(data == undefined).assertTrue(); - }); - done(); - } catch (e) { - console.info("testOn004 " + e); - expect(null).assertFail(); - done(); - } - }) - - /** - * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0100 - * @tc.name [JS-API8]ContinuationManager.off(). - * @tc.desc Test Js Api ContinuationManager.off() testcase 001 - */ - it('testOff001', 0, async function(done) { - try { - continuationManager.off("deviceConnect", function (data) { - expect(data == undefined).assertTrue(); - }); - done(); - } catch (e) { - console.info("testOff001 " + e); - expect(null).assertFail(); - done(); - } - }) - - /** - * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0200 - * @tc.name [JS-API8]ContinuationManager.off(). - * @tc.desc Test Js Api ContinuationManager.off() testcase 002 - */ - it('testOff002', 0, async function(done) { - try { - continuationManager.off("deviceDisconnect", function (data) { - expect(data == undefined).assertTrue(); - }); - done(); - } catch (e) { - console.info("testOff002 " + e); - expect(null).assertFail(); - done(); - } - }) - - /** - * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0300 - * @tc.name [JS-API9]ContinuationManager.off(). - * @tc.desc Test Js Api ContinuationManager.off() testcase 003 - */ - it('testOff003', 0, async function(done) { - try { - continuationManager.off("deviceConnect", token); - done(); - } catch (e) { - console.info("testOff003 " + e); - expect(null).assertFail(); - done(); - } - }) - - /** - * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0400 - * @tc.name [JS-API9]ContinuationManager.off(). - * @tc.desc Test Js Api ContinuationManager.off() testcase 004 - */ - it('testOff004', 0, async function(done) { - try { - continuationManager.off("deviceDisconnect", token); - done(); - } catch (e) { - console.info("testOff004 " + e); - expect(null).assertFail(); - done(); - } - }) - - /** - * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_STARTDEVICEMANAGER_0100 - * @tc.name [JS-API8]ContinuationManager.startDeviceManager(). - * @tc.desc Test Js Api ContinuationManager.startDeviceManager() testcase 001 - */ - it('testStartDeviceManager001', 0, async function(done) { - try { - continuationManager.startDeviceManager(token, function (err, data) { - expect(err.code != 0).assertTrue(); - expect(data == undefined).assertTrue(); - }); - done(); - } catch (e) { - console.info("testStartDeviceManager001 " + e); - expect(null).assertFail(); - done(); - } - }) - - /** - * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UPDATECONNECTSTATUS_0100 - * @tc.name [JS-API8]ContinuationManager.updateConnectStatus(). - * @tc.desc Test Js Api ContinuationManager.updateConnectStatus() testcase 001 - */ - it('testUpdateConnectStatus001', 0, async function(done) { - try { - continuationManager.updateConnectStatus(token, TEST_DEVICE_ID, TEST_CONNECT_STATUS, function (err, data) { - expect(err.code != 0).assertTrue(); - expect(data == undefined).assertTrue(); - }); - done(); - } catch (e) { - console.info("testUpdateConnectStatus001 " + e); - expect(null).assertFail(); - done(); - } - }) -}) \ No newline at end of file +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import continuationManager from '@ohos.continuation.continuationManager'; + +const TEST_DEVICE_ID = "test_deviceId"; +const TEST_CONNECT_STATUS = continuationManager.DeviceConnectState.CONNECTED; +let token = -1; + +export default function ContinuationManagerTest() { +describe('ContinuationManagerTest', function() { + + beforeAll(async function (done) { + console.info('beforeAll'); + done(); + }) + + afterAll(async function (done) { + console.info('afterAll'); + done(); + }) + + beforeEach(async function (done) { + console.info('beforeEach'); + await continuationManager.register(function (err, data) { + token = data; + console.info('beforeEach register success'); + done(); + }); + console.info('beforeEach end'); + }) + + afterEach(async function (done) { + console.info('afterEach'); + await continuationManager.unregister(token, function (err, data) { + console.info('afterEach unregister success'); + done(); + }); + console.info('afterEach end'); + }) + + /** + * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_REGISTER_0100 + * @tc.name [JS-API8]ContinuationManager.register(). + * @tc.desc Test Js Api ContinuationManager.register() testcase 001 + */ + it('testRegister001', 0, async function(done) { + try { + continuationManager.register(function (err, data) { + expect(err.code == 0).assertTrue(); + expect(data - token == 1).assertTrue(); + done(); + }); + } catch (e) { + console.info("testRegister001 " + e); + expect(null).assertFail(); + done(); + } + }) + + /** + * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UNREGISTER_0100 + * @tc.name [JS-API8]ContinuationManager.unregister(). + * @tc.desc Test Js Api ContinuationManager.unregister() testcase 001 + */ + it('testUnregister001', 0, async function(done) { + try { + continuationManager.unregister(token, function (err, data) { + expect(err.code == 0).assertTrue(); + expect(data == undefined).assertTrue(); + }) + done(); + } catch (e) { + console.info("testUnregister001 " + e); + expect(null).assertFail(); + done(); + } + }) + + /** + * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0100 + * @tc.name [JS-API8]ContinuationManager.on(). + * @tc.desc Test Js Api ContinuationManager.on() testcase 001 + */ + it('testOn001', 0, async function(done) { + try { + continuationManager.on("deviceConnect", function (data) { + expect(data == undefined).assertTrue(); + }); + done(); + } catch (e) { + console.info("testOn001 " + e); + expect(null).assertFail(); + done(); + } + }) + + /** + * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0200 + * @tc.name [JS-API8]ContinuationManager.on(). + * @tc.desc Test Js Api ContinuationManager.on() testcase 002 + */ + it('testOn002', 0, async function(done) { + try { + continuationManager.on("deviceDisconnect", function (data) { + expect(data == undefined).assertTrue(); + }); + done(); + } catch (e) { + console.info("testOn002 " + e); + expect(null).assertFail(); + done(); + } + }) + + /** + * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0300 + * @tc.name [JS-API9]ContinuationManager.on(). + * @tc.desc Test Js Api ContinuationManager.on() testcase 003 + */ + it('testOn003', 0, async function(done) { + try { + continuationManager.on("deviceConnect", token, function (data) { + expect(data == undefined).assertTrue(); + }) + done(); + } catch (e) { + console.info("testOn003 " + e); + expect(null).assertFail(); + done(); + } + }) + + /** + * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0400 + * @tc.name [JS-API9]ContinuationManager.on(). + * @tc.desc Test Js Api ContinuationManager.on() testcase 004 + */ + it('testOn004', 0, async function(done) { + try { + continuationManager.on("deviceDisconnect", token, function (data) { + expect(data == undefined).assertTrue(); + }); + done(); + } catch (e) { + console.info("testOn004 " + e); + expect(null).assertFail(); + done(); + } + }) + + /** + * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0100 + * @tc.name [JS-API8]ContinuationManager.off(). + * @tc.desc Test Js Api ContinuationManager.off() testcase 001 + */ + it('testOff001', 0, async function(done) { + try { + continuationManager.off("deviceConnect", function (data) { + expect(data == undefined).assertTrue(); + }); + done(); + } catch (e) { + console.info("testOff001 " + e); + expect(null).assertFail(); + done(); + } + }) + + /** + * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0200 + * @tc.name [JS-API8]ContinuationManager.off(). + * @tc.desc Test Js Api ContinuationManager.off() testcase 002 + */ + it('testOff002', 0, async function(done) { + try { + continuationManager.off("deviceDisconnect", function (data) { + expect(data == undefined).assertTrue(); + }); + done(); + } catch (e) { + console.info("testOff002 " + e); + expect(null).assertFail(); + done(); + } + }) + + /** + * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0300 + * @tc.name [JS-API9]ContinuationManager.off(). + * @tc.desc Test Js Api ContinuationManager.off() testcase 003 + */ + it('testOff003', 0, async function(done) { + try { + continuationManager.off("deviceConnect", token); + done(); + } catch (e) { + console.info("testOff003 " + e); + expect(null).assertFail(); + done(); + } + }) + + /** + * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0400 + * @tc.name [JS-API9]ContinuationManager.off(). + * @tc.desc Test Js Api ContinuationManager.off() testcase 004 + */ + it('testOff004', 0, async function(done) { + try { + continuationManager.off("deviceDisconnect", token); + done(); + } catch (e) { + console.info("testOff004 " + e); + expect(null).assertFail(); + done(); + } + }) + + /** + * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_STARTDEVICEMANAGER_0100 + * @tc.name [JS-API8]ContinuationManager.startDeviceManager(). + * @tc.desc Test Js Api ContinuationManager.startDeviceManager() testcase 001 + */ + it('testStartDeviceManager001', 0, async function(done) { + try { + continuationManager.startDeviceManager(token, function (err, data) { + expect(err.code != 0).assertTrue(); + expect(data == undefined).assertTrue(); + }); + done(); + } catch (e) { + console.info("testStartDeviceManager001 " + e); + expect(null).assertFail(); + done(); + } + }) + + /** + * @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UPDATECONNECTSTATUS_0100 + * @tc.name [JS-API8]ContinuationManager.updateConnectStatus(). + * @tc.desc Test Js Api ContinuationManager.updateConnectStatus() testcase 001 + */ + it('testUpdateConnectStatus001', 0, async function(done) { + try { + continuationManager.updateConnectStatus(token, TEST_DEVICE_ID, TEST_CONNECT_STATUS, function (err, data) { + expect(err.code != 0).assertTrue(); + expect(data == undefined).assertTrue(); + }); + done(); + } catch (e) { + console.info("testUpdateConnectStatus001 " + e); + expect(null).assertFail(); + done(); + } + }) +})} diff --git a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/test/List.test.js b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/test/List.test.js similarity index 78% rename from distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/test/List.test.js rename to distributedschedule/dmsfwk/continuationmanagertest/src/main/js/test/List.test.js index ad86f4e8e..a6a82ae64 100644 --- a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/test/List.test.js +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/js/test/List.test.js @@ -1,15 +1,18 @@ -/* -* 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('./ContinuationManagerJsunit.test.js') \ No newline at end of file +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import ContinuationManagerTest from './ContinuationManagerJsunit.test.js' +export default function testsuite() { +ContinuationManagerTest() +} diff --git a/distributedschedule/dmsfwk/continuationmanagertest/src/main/resources/base/element/string.json b/distributedschedule/dmsfwk/continuationmanagertest/src/main/resources/base/element/string.json new file mode 100644 index 000000000..c931e1647 --- /dev/null +++ b/distributedschedule/dmsfwk/continuationmanagertest/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ContinuationManagerJsTest" + }, + { + "name": "mainability_description", + "value": "hap sample empty page" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} diff --git a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/resources/base/media/icon.png b/distributedschedule/dmsfwk/continuationmanagertest/src/main/resources/base/media/icon.png similarity index 100% rename from distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/resources/base/media/icon.png rename to distributedschedule/dmsfwk/continuationmanagertest/src/main/resources/base/media/icon.png diff --git a/powermgr/power_manager/BUILD.gn b/powermgr/power_manager/BUILD.gn old mode 100755 new mode 100644 index 81e9f2582..6696c40bd --- a/powermgr/power_manager/BUILD.gn +++ b/powermgr/power_manager/BUILD.gn @@ -9,7 +9,7 @@ # 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. import("//test/xts/tools/build/suite.gni") @@ -23,7 +23,9 @@ ohos_js_hap_suite("powermgr_power_test") { hap_name = "ActsPowerMgrPowerTest" } ohos_js_assets("powermgr_power_js_assets") { - source_dir = "./src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } ohos_resources("powermgr_power_resources") { sources = [ "./src/main/resources" ] diff --git a/powermgr/power_manager/Test.json b/powermgr/power_manager/Test.json old mode 100755 new mode 100644 index 6ecc3d186..6f158418f --- a/powermgr/power_manager/Test.json +++ b/powermgr/power_manager/Test.json @@ -1,24 +1,25 @@ -{ - "description": "Configuration for powermgr power Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "60000", - "package": "com.example.mypowerapp", - "shell-timeout": "60000" - }, - "kits": [ - { - "type": "ShellKit", - "run-command": [ - "power-shell wakeup" - ] - }, - { - "test-file-name": [ - "ActsPowerMgrPowerTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] +{ + "description": "Configuration for powermgr power Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "60000", + "shell-timeout": "60000", + "bundle-name": "com.example.mypowerapp", + "package-name": "com.example.mypowerapp" + }, + "kits": [ + { + "type": "ShellKit", + "run-command": [ + "power-shell wakeup" + ] + }, + { + "test-file-name": [ + "ActsPowerMgrPowerTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] } \ No newline at end of file diff --git a/powermgr/power_manager/signature/openharmony_sx.p7b b/powermgr/power_manager/signature/openharmony_sx.p7b old mode 100755 new mode 100644 diff --git a/powermgr/power_manager/src/main/config.json b/powermgr/power_manager/src/main/config.json old mode 100755 new mode 100644 index 254c01426..4e349dbc5 --- a/powermgr/power_manager/src/main/config.json +++ b/powermgr/power_manager/src/main/config.json @@ -1,60 +1,93 @@ { - "app": { - "bundleName": "com.example.mypowerapp", - "vendor": "example", - "version": { - "code": 1, - "name": "1.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5 - } - }, - "deviceConfig": {}, - "module": { - "package": "com.example.mypowerapp", - "name": ".MyApplication", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry" + "app": { + "bundleName": "com.example.mypowerapp", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 + } }, - "abilities": [ - { - "visible": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } + "deviceConfig": {}, + "module": { + "package": "com.example.mypowerapp", + "name": ".entry", + "deviceType": [ + "phone" ], - "name": "com.example.mypowerapp.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + }, + "mainAbility": ".MainAbility", + "srcPath": "" + } } \ No newline at end of file diff --git a/powermgr/power_manager/src/main/js/default/app.js b/powermgr/power_manager/src/main/js/MainAbility/app.js old mode 100755 new mode 100644 similarity index 100% rename from powermgr/power_manager/src/main/js/default/app.js rename to powermgr/power_manager/src/main/js/MainAbility/app.js diff --git a/powermgr/power_manager/src/main/js/default/i18n/en-US.json b/powermgr/power_manager/src/main/js/MainAbility/i18n/en-US.json old mode 100755 new mode 100644 similarity index 91% rename from powermgr/power_manager/src/main/js/default/i18n/en-US.json rename to powermgr/power_manager/src/main/js/MainAbility/i18n/en-US.json index e63c70d97..a4c13dcbd --- a/powermgr/power_manager/src/main/js/default/i18n/en-US.json +++ b/powermgr/power_manager/src/main/js/MainAbility/i18n/en-US.json @@ -1,6 +1,6 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } +{ + "strings": { + "hello": "Hello", + "world": "World" + } } \ No newline at end of file diff --git a/powermgr/thermal_manager/src/main/js/default/i18n/zh-CN.json b/powermgr/power_manager/src/main/js/MainAbility/i18n/zh-CN.json similarity index 91% rename from powermgr/thermal_manager/src/main/js/default/i18n/zh-CN.json rename to powermgr/power_manager/src/main/js/MainAbility/i18n/zh-CN.json index de6ee5748..b1c02368f 100644 --- a/powermgr/thermal_manager/src/main/js/default/i18n/zh-CN.json +++ b/powermgr/power_manager/src/main/js/MainAbility/i18n/zh-CN.json @@ -1,6 +1,6 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } +{ + "strings": { + "hello": "您好", + "world": "世界" + } } \ No newline at end of file diff --git a/powermgr/power_manager/src/main/js/default/pages/index/index.css b/powermgr/power_manager/src/main/js/MainAbility/pages/index/index.css old mode 100755 new mode 100644 similarity index 96% rename from powermgr/power_manager/src/main/js/default/pages/index/index.css rename to powermgr/power_manager/src/main/js/MainAbility/pages/index/index.css index 7311df556..239ac71e0 --- a/powermgr/power_manager/src/main/js/default/pages/index/index.css +++ b/powermgr/power_manager/src/main/js/MainAbility/pages/index/index.css @@ -1,24 +1,24 @@ -/* - * 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. - */ - -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/powermgr/power_manager/src/main/js/default/pages/index/index.hml b/powermgr/power_manager/src/main/js/MainAbility/pages/index/index.hml old mode 100755 new mode 100644 similarity index 97% rename from powermgr/power_manager/src/main/js/default/pages/index/index.hml rename to powermgr/power_manager/src/main/js/MainAbility/pages/index/index.hml index eeaf6a3fc..936e04ebd --- a/powermgr/power_manager/src/main/js/default/pages/index/index.hml +++ b/powermgr/power_manager/src/main/js/MainAbility/pages/index/index.hml @@ -1,20 +1,20 @@ - - -
- - {{ $t('strings.hello') }} {{ title }} - -
+ + +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/powermgr/power_manager/src/main/js/MainAbility/pages/index/index.js b/powermgr/power_manager/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 000000000..a9eab9841 --- /dev/null +++ b/powermgr/power_manager/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,30 @@ +/* + * 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 app from '@system.app' + + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + }, + onReady() { + }, +} \ No newline at end of file diff --git a/powermgr/power_manager/src/main/js/TestAbility/app.js b/powermgr/power_manager/src/main/js/TestAbility/app.js new file mode 100644 index 000000000..cdc31f3dc --- /dev/null +++ b/powermgr/power_manager/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/i18n/en-US.json b/powermgr/power_manager/src/main/js/TestAbility/i18n/en-US.json similarity index 91% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/i18n/en-US.json rename to powermgr/power_manager/src/main/js/TestAbility/i18n/en-US.json index 55561b837..3cb24b374 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/i18n/en-US.json +++ b/powermgr/power_manager/src/main/js/TestAbility/i18n/en-US.json @@ -1,8 +1,8 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - }, - "Files": { - } +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } } \ No newline at end of file diff --git a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/i18n/zh-CN.json b/powermgr/power_manager/src/main/js/TestAbility/i18n/zh-CN.json similarity index 91% rename from distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/i18n/zh-CN.json rename to powermgr/power_manager/src/main/js/TestAbility/i18n/zh-CN.json index cce1af067..c804e32c0 100644 --- a/distributedschedule/dmsfwk/continuationmanagertest/entry/src/main/js/default/i18n/zh-CN.json +++ b/powermgr/power_manager/src/main/js/TestAbility/i18n/zh-CN.json @@ -1,8 +1,8 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - }, - "Files": { - } +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } } \ No newline at end of file diff --git a/powermgr/power_manager/src/main/js/TestAbility/pages/index/index.css b/powermgr/power_manager/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 000000000..b1bcd4338 --- /dev/null +++ b/powermgr/power_manager/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,30 @@ +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/pages/index/index.hml b/powermgr/power_manager/src/main/js/TestAbility/pages/index/index.hml similarity index 95% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/pages/index/index.hml rename to powermgr/power_manager/src/main/js/TestAbility/pages/index/index.hml index f64b040a5..f629c71a9 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/pages/index/index.hml +++ b/powermgr/power_manager/src/main/js/TestAbility/pages/index/index.hml @@ -1,5 +1,5 @@ -
- - {{ $t('strings.hello') }} {{ title }} - -
+
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/powermgr/power_manager/src/main/js/TestAbility/pages/index/index.js b/powermgr/power_manager/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 000000000..88b083a7f --- /dev/null +++ b/powermgr/power_manager/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/powermgr/power_manager/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/powermgr/power_manager/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 000000000..c5fa8620c --- /dev/null +++ b/powermgr/power_manager/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/powermgr/power_manager/src/main/js/default/pages/index/index.js b/powermgr/power_manager/src/main/js/default/pages/index/index.js deleted file mode 100755 index 48e642298..000000000 --- a/powermgr/power_manager/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 app from '@system.app' - -import {Core, ExpectExtend} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - core.init() - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../test/List.test') - core.execute() - }, - onReady() { - }, -} \ No newline at end of file diff --git a/powermgr/power_manager/src/main/js/default/test/List.test.js b/powermgr/power_manager/src/main/js/test/List.test.js similarity index 71% rename from powermgr/power_manager/src/main/js/default/test/List.test.js rename to powermgr/power_manager/src/main/js/test/List.test.js index 99e94ceb3..93bfba329 100644 --- a/powermgr/power_manager/src/main/js/default/test/List.test.js +++ b/powermgr/power_manager/src/main/js/test/List.test.js @@ -12,6 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require('./power_manager_running_lock.test.js') -require('./power_manager_power.test.js') - +import appInfoTest_power_1 from './power_manager_power.test.js' +import appInfoTest_power_2 from './power_manager_running_lock.test.js' +export default function testsuite() { +appInfoTest_power_1() +appInfoTest_power_2() +} diff --git a/powermgr/power_manager/src/main/js/default/test/power_manager_power.test.js b/powermgr/power_manager/src/main/js/test/power_manager_power.test.js similarity index 96% rename from powermgr/power_manager/src/main/js/default/test/power_manager_power.test.js rename to powermgr/power_manager/src/main/js/test/power_manager_power.test.js index 9315bc810..fc0377d59 100644 --- a/powermgr/power_manager/src/main/js/default/test/power_manager_power.test.js +++ b/powermgr/power_manager/src/main/js/test/power_manager_power.test.js @@ -1,217 +1,219 @@ -/* - * 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 power from '@ohos.power'; - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - -describe('appInfoTest_power_1', function () { - console.log("*************Power Unit Test Begin*************"); - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0010 - * @tc.name Power_Is_Screnn_On_Promise_JSTest0010 - * @tc.desc Checks whether the screen of a device is on or off - */ - it('Power_Is_Screnn_On_Promise_JSTest0010', 0, async function (done) { - power.wakeupDevice("Power_Is_Screnn_On_Promise_JSTest0010"); - power.isScreenOn() - .then(screenOn => { - console.info('Power_Is_Screnn_On_Promise_JSTest0010 screenOn is ' + screenOn); - expect(screenOn).assertTrue(); - console.info('Power_Is_Screnn_On_Promise_JSTest0010 success'); - done(); - }) - .catch(error => { - console.log('Power_Is_Screnn_On_Promise_JSTest0010 error: ' + error); - expect().assertFail(); - done(); - }) - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0020 - * @tc.name Power_Is_Screnn_On_Callback_JSTest0020 - * @tc.desc Checks whether the screen of a device is on or off - */ - it('Power_Is_Screnn_On_Callback_JSTest0020', 0, async function (done) { - power.wakeupDevice("Power_Is_Screnn_On_Callback_JSTest0020"); - power.isScreenOn((error, screenOn) => { - if (typeof error === "undefined") { - console.info('Power_Is_Screnn_On_Callback_JSTest0020 screenOn is ' + screenOn); - expect(screenOn).assertTrue(); - console.info('Power_Is_Screnn_On_Callback_JSTest0020 success'); - done(); - } else { - console.log('Power_Is_Screnn_On_Callback_JSTest0020: ' + error); - expect().assertFail(); - done(); - } - }) - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0030 - * @tc.name Power_WakeupDevices_String_JSTest0030 - * @tc.desc Try to wakeup the device and let screen on - */ - it('Power_WakeupDevices_String_JSTest0030', 0, async function (done) { - power.isScreenOn() - .then(screenOn => { - console.info('Power_WakeupDevices_String_JSTest0030: The current screenOn is ' + screenOn); - if (screenOn) { - power.suspendDevice(); - } - }) - .catch(error => { - console.log('Power_WakeupDevices_String_JSTest0030 error: ' + error); - expect().assertFail(); - done(); - }) - setTimeout(function(){ - power.wakeupDevice("Power_WakeupDevices_String_JSTest0030"); - power.isScreenOn() - .then(screenOn => { - console.info('Power_WakeupDevices_String_JSTest0030: The current screenOn is ' + screenOn); - expect(screenOn).assertTrue(); - console.info('Power_WakeupDevices_String_JSTest0030 success'); - done(); - }) - .catch(error => { - console.log('Power_WakeupDevices_String_JSTest0030 error: ' + error); - expect().assertFail(); - done(); - }) - }, 2000); - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0040 - * @tc.name Power_SuspendDevices_JSTest0040 - * @tc.desc Try to suspend the device and let screen off - */ - it('Power_SuspendDevices_JSTest0040', 0, async function (done) { - power.isScreenOn() - .then(screenOn => { - console.info('Power_SuspendDevices_JSTest0040: The current screenOn is ' + screenOn); - if (!screenOn) { - power.wakeupDevice("Power_SuspendDevices_JSTest0040"); - } - }) - .catch(error => { - console.log('Power_SuspendDevices_JSTest0040 error: ' + error); - expect().assertFail(); - done(); - }) - setTimeout(function(){ - power.suspendDevice(); - console.info('Power_SuspendDevices_JSTest0040: SuspendDevice end'); - power.isScreenOn() - .then(screenOn => { - console.info('Power_SuspendDevices_JSTest0040: The current screenOn is ' + screenOn); - expect(screenOn).assertFalse(); - console.info('Power_SuspendDevices_JSTest0040 success'); - done(); - }) - .catch(error => { - console.log('Power_SuspendDevices_JSTest0040 error: ' + error); - expect().assertFail(); - done(); - }) - }, 2000); - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0050 - * @tc.name Power_Get_PowerMode_Callback_JSTest0050 - * @tc.desc Get The mode the device - */ - it('Power_Get_PowerMode_Callback_JSTest0050', 0, async function (done) { - power.getPowerMode() - .then(powerMode => { - console.info('Power_Get_PowerMode_Callback_JSTest0050 power mode is ' + powerMode); - expect(powerMode >= 600 && powerMode <= 603).assertTrue(); - done(); - }) - .catch(error => { - console.log('Power_Get_PowerMode_Callback_JSTest0050 error: ' + error); - expect().assertFail(); - done(); - }) - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0060 - * @tc.name Power_Get_PowerMode_Promise_JSTest0060 - * @tc.desc Get The mode the device - */ - it('Power_Get_PowerMode_Promise_JSTest0060', 0, async function (done) { - power.getPowerMode((error, powerMode) => { - if (typeof error === "undefined") { - console.info('Power_Get_PowerMode_Promise_JSTest0060 power mode is ' + powerMode); - expect(powerMode >= 600 && powerMode <= 603).assertTrue(); - done(); - } else { - console.log('Power_Get_PowerMode_Promise_JSTest0060: ' + error); - expect().assertFail(); - done(); - } - }) - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0070 - * @tc.name Power_Device_Power_Mode_MODENORMAL_JSTest0070 - * @tc.desc Get device power mode MODE_NORMAL - */ - it('Power_Device_Power_Mode_MODENORMAL_JSTest0070', 0, function () { - let devicePowerMode = power.DevicePowerMode.MODE_NORMAL; - console.info('MODE_NORMAL = ' + devicePowerMode); - expect(devicePowerMode === 600).assertTrue(); - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0080 - * @tc.name Power_Device_Power_Mode_MODEPOWERSAVE_JSTest0080 - * @tc.desc Get device power mode MODE_POWER_SAVE - */ - it('Power_Device_Power_Mode_MODEPOWERSAVE_JSTest0080', 0, function () { - let devicePowerMode = power.DevicePowerMode.MODE_POWER_SAVE; - console.info('MODE_POWER_SAVE = ' + devicePowerMode); - expect(devicePowerMode === 601).assertTrue(); - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0090 - * @tc.name Power_Device_pPower_Mode_MODEPERFORMANCE_JSTest0090 - * @tc.desc Get device power mode MODE_PERFORMANCE - */ - it('Power_Device_pPower_Mode_MODEPERFORMANCE_JSTest0090', 0, function () { - let devicePowerMode = power.DevicePowerMode.MODE_PERFORMANCE; - console.info('MODE_PERFORMANCE = ' + devicePowerMode); - expect(devicePowerMode === 602).assertTrue(); - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0100 - * @tc.name Power_Device_Power_Mode_MODE_EXTREME_POWER_SAVE_JSTest0100 - * @tc.desc Get device power mode MODE_EXTREME_POWER_SAVE - */ - it('Power_Device_Power_Mode_MODE_EXTREME_POWER_SAVE_JSTest0100', 0, function () { - let devicePowerMode = power.DevicePowerMode.MODE_EXTREME_POWER_SAVE; - console.info('MODE_EXTREME_POWER_SAVE = ' + devicePowerMode); - expect(devicePowerMode === 603).assertTrue(); - }) -}) +/* + * 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 power from '@ohos.power'; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +export default function appInfoTest_power_1() { +describe('appInfoTest_power_1', function () { + console.log("*************Power Unit Test Begin*************"); + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0010 + * @tc.name Power_Is_Screnn_On_Promise_JSTest0010 + * @tc.desc Checks whether the screen of a device is on or off + */ + it('Power_Is_Screnn_On_Promise_JSTest0010', 0, async function (done) { + power.wakeupDevice("Power_Is_Screnn_On_Promise_JSTest0010"); + power.isScreenOn() + .then(screenOn => { + console.info('Power_Is_Screnn_On_Promise_JSTest0010 screenOn is ' + screenOn); + expect(screenOn).assertTrue(); + console.info('Power_Is_Screnn_On_Promise_JSTest0010 success'); + done(); + }) + .catch(error => { + console.log('Power_Is_Screnn_On_Promise_JSTest0010 error: ' + error); + expect().assertFail(); + done(); + }) + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0020 + * @tc.name Power_Is_Screnn_On_Callback_JSTest0020 + * @tc.desc Checks whether the screen of a device is on or off + */ + it('Power_Is_Screnn_On_Callback_JSTest0020', 0, async function (done) { + power.wakeupDevice("Power_Is_Screnn_On_Callback_JSTest0020"); + power.isScreenOn((error, screenOn) => { + if (typeof error === "undefined") { + console.info('Power_Is_Screnn_On_Callback_JSTest0020 screenOn is ' + screenOn); + expect(screenOn).assertTrue(); + console.info('Power_Is_Screnn_On_Callback_JSTest0020 success'); + done(); + } else { + console.log('Power_Is_Screnn_On_Callback_JSTest0020: ' + error); + expect().assertFail(); + done(); + } + }) + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0030 + * @tc.name Power_WakeupDevices_String_JSTest0030 + * @tc.desc Try to wakeup the device and let screen on + */ + it('Power_WakeupDevices_String_JSTest0030', 0, async function (done) { + power.isScreenOn() + .then(screenOn => { + console.info('Power_WakeupDevices_String_JSTest0030: The current screenOn is ' + screenOn); + if (screenOn) { + power.suspendDevice(); + } + }) + .catch(error => { + console.log('Power_WakeupDevices_String_JSTest0030 error: ' + error); + expect().assertFail(); + done(); + }) + setTimeout(function(){ + power.wakeupDevice("Power_WakeupDevices_String_JSTest0030"); + power.isScreenOn() + .then(screenOn => { + console.info('Power_WakeupDevices_String_JSTest0030: The current screenOn is ' + screenOn); + expect(screenOn).assertTrue(); + console.info('Power_WakeupDevices_String_JSTest0030 success'); + done(); + }) + .catch(error => { + console.log('Power_WakeupDevices_String_JSTest0030 error: ' + error); + expect().assertFail(); + done(); + }) + }, 2000); + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0040 + * @tc.name Power_SuspendDevices_JSTest0040 + * @tc.desc Try to suspend the device and let screen off + */ + it('Power_SuspendDevices_JSTest0040', 0, async function (done) { + power.isScreenOn() + .then(screenOn => { + console.info('Power_SuspendDevices_JSTest0040: The current screenOn is ' + screenOn); + if (!screenOn) { + power.wakeupDevice("Power_SuspendDevices_JSTest0040"); + } + }) + .catch(error => { + console.log('Power_SuspendDevices_JSTest0040 error: ' + error); + expect().assertFail(); + done(); + }) + setTimeout(function(){ + power.suspendDevice(); + console.info('Power_SuspendDevices_JSTest0040: SuspendDevice end'); + power.isScreenOn() + .then(screenOn => { + console.info('Power_SuspendDevices_JSTest0040: The current screenOn is ' + screenOn); + expect(screenOn).assertFalse(); + console.info('Power_SuspendDevices_JSTest0040 success'); + done(); + }) + .catch(error => { + console.log('Power_SuspendDevices_JSTest0040 error: ' + error); + expect().assertFail(); + done(); + }) + }, 2000); + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0050 + * @tc.name Power_Get_PowerMode_Callback_JSTest0050 + * @tc.desc Get The mode the device + */ + it('Power_Get_PowerMode_Callback_JSTest0050', 0, async function (done) { + power.getPowerMode() + .then(powerMode => { + console.info('Power_Get_PowerMode_Callback_JSTest0050 power mode is ' + powerMode); + expect(powerMode >= 600 && powerMode <= 603).assertTrue(); + done(); + }) + .catch(error => { + console.log('Power_Get_PowerMode_Callback_JSTest0050 error: ' + error); + expect().assertFail(); + done(); + }) + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0060 + * @tc.name Power_Get_PowerMode_Promise_JSTest0060 + * @tc.desc Get The mode the device + */ + it('Power_Get_PowerMode_Promise_JSTest0060', 0, async function (done) { + power.getPowerMode((error, powerMode) => { + if (typeof error === "undefined") { + console.info('Power_Get_PowerMode_Promise_JSTest0060 power mode is ' + powerMode); + expect(powerMode >= 600 && powerMode <= 603).assertTrue(); + done(); + } else { + console.log('Power_Get_PowerMode_Promise_JSTest0060: ' + error); + expect().assertFail(); + done(); + } + }) + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0070 + * @tc.name Power_Device_Power_Mode_MODENORMAL_JSTest0070 + * @tc.desc Get device power mode MODE_NORMAL + */ + it('Power_Device_Power_Mode_MODENORMAL_JSTest0070', 0, function () { + let devicePowerMode = power.DevicePowerMode.MODE_NORMAL; + console.info('MODE_NORMAL = ' + devicePowerMode); + expect(devicePowerMode === 600).assertTrue(); + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0080 + * @tc.name Power_Device_Power_Mode_MODEPOWERSAVE_JSTest0080 + * @tc.desc Get device power mode MODE_POWER_SAVE + */ + it('Power_Device_Power_Mode_MODEPOWERSAVE_JSTest0080', 0, function () { + let devicePowerMode = power.DevicePowerMode.MODE_POWER_SAVE; + console.info('MODE_POWER_SAVE = ' + devicePowerMode); + expect(devicePowerMode === 601).assertTrue(); + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0090 + * @tc.name Power_Device_pPower_Mode_MODEPERFORMANCE_JSTest0090 + * @tc.desc Get device power mode MODE_PERFORMANCE + */ + it('Power_Device_pPower_Mode_MODEPERFORMANCE_JSTest0090', 0, function () { + let devicePowerMode = power.DevicePowerMode.MODE_PERFORMANCE; + console.info('MODE_PERFORMANCE = ' + devicePowerMode); + expect(devicePowerMode === 602).assertTrue(); + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0100 + * @tc.name Power_Device_Power_Mode_MODE_EXTREME_POWER_SAVE_JSTest0100 + * @tc.desc Get device power mode MODE_EXTREME_POWER_SAVE + */ + it('Power_Device_Power_Mode_MODE_EXTREME_POWER_SAVE_JSTest0100', 0, function () { + let devicePowerMode = power.DevicePowerMode.MODE_EXTREME_POWER_SAVE; + console.info('MODE_EXTREME_POWER_SAVE = ' + devicePowerMode); + expect(devicePowerMode === 603).assertTrue(); + }) +}) +} diff --git a/powermgr/power_manager/src/main/js/default/test/power_manager_rebootshut.test.js b/powermgr/power_manager/src/main/js/test/power_manager_rebootshut.test.js similarity index 95% rename from powermgr/power_manager/src/main/js/default/test/power_manager_rebootshut.test.js rename to powermgr/power_manager/src/main/js/test/power_manager_rebootshut.test.js index bf685c793..7be3b45ac 100644 --- a/powermgr/power_manager/src/main/js/default/test/power_manager_rebootshut.test.js +++ b/powermgr/power_manager/src/main/js/test/power_manager_rebootshut.test.js @@ -1,117 +1,118 @@ -/* - * 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 power from '@ohos.power'; - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - -describe('appInfoTest', function () { - console.log("*************Power Unit Test Begin*************"); - - /** - * @tc.number power_js_001 - * @tc.name power_creat_shutdownDevice_test - * @tc.desc Device shutdown interface validation - */ - it('creat_shutdownDevice_test01', 0, async function () { - function shutPromise(){ - new Promise(function(resolve,reject){ - power.isScreenOn((error, screenOn)=>{ - if(screenOn){ - console.log('devices shutdown error'); - reject(screenOn); - }else{ - console.log('devices shutdown success'); - resolve(error); - } - },1000) - }) - } - power.shutdownDevice("shutsown"); - shutPromise(); - }) - - /** - * @tc.number power_js_002 - * @tc.name power_creat_shutdownDevice_test - * @tc.desc Device shutdown interface validation - */ - it('creat_shutdownDevice_test02', 0, async function () { - power.isScreenOn() - .then(screenOn => { - console.info('power_shutdownDevice_test: The current screenOn is ' + screenOn); - if (!screenOn) { - power.wakeupDevice("power_shutdownDevice_test"); - } - }) - .catch(error => { - console.log('power_shutdownDevice_test error: ' + error); - expect().assertFail(); - done(); - }) - power.shutdownDevice("shutsown"); - console.info('power_shutdownDevice_test: shutdownDevice end'); - setTimeout(function(){ - power.isScreenOn() - .then(screenOn => { - console.info('power_shutdownDevice_test: The current screenOn is ' + screenOn); - expect(screenOn).assertFalse(); - console.info('power_shutdownDevice_test success'); - done(); - }) - .catch(error => { - console.log('power_shutdownDevice_test error: ' + error); - expect().assertFail(); - done(); - }) - }, 2000); - }) - - /** - * @tc.number power_js_003 - * @tc.name power_creat_rebootDeviceDevice_test - * @tc.desc Device reboot interface verification - */ - it('creat_rebootDeviceDevice_test', 0, async function () { - power.isScreenOn() - .then(screenOn => { - console.info('power_rebootDevice_test: The current screenOn is ' + screenOn); - if (!screenOn) { - power.wakeupDevice("power_rebootDevice_test"); - } - }) - .catch(error => { - console.log('power_rebootDevice_test error: ' + error); - expect().assertFail(); - done(); - }) - power.rebootDevice("shutsown"); - console.info('power_rebootDevice_test: rebootDevice end'); - setTimeout(function(){ - power.isScreenOn() - .then(screenOn => { - console.info('power_rebootDevice_test: The current screenOn is ' + screenOn); - expect(screenOn).assertFalse(); - console.info('power_rebootDevice_test success'); - done(); - }) - .catch(error => { - console.log('power_rebootDevice_test error: ' + error); - expect().assertFail(); - done(); - }) - }, 2000); - }) -}) \ No newline at end of file +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import power from '@ohos.power'; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +export default function appInfoTest() { +describe('appInfoTest', function () { + console.log("*************Power Unit Test Begin*************"); + + /** + * @tc.number power_js_001 + * @tc.name power_creat_shutdownDevice_test + * @tc.desc Device shutdown interface validation + */ + it('creat_shutdownDevice_test01', 0, async function () { + function shutPromise(){ + new Promise(function(resolve,reject){ + power.isScreenOn((error, screenOn)=>{ + if(screenOn){ + console.log('devices shutdown error'); + reject(screenOn); + }else{ + console.log('devices shutdown success'); + resolve(error); + } + },1000) + }) + } + power.shutdownDevice("shutsown"); + shutPromise(); + }) + + /** + * @tc.number power_js_002 + * @tc.name power_creat_shutdownDevice_test + * @tc.desc Device shutdown interface validation + */ + it('creat_shutdownDevice_test02', 0, async function () { + power.isScreenOn() + .then(screenOn => { + console.info('power_shutdownDevice_test: The current screenOn is ' + screenOn); + if (!screenOn) { + power.wakeupDevice("power_shutdownDevice_test"); + } + }) + .catch(error => { + console.log('power_shutdownDevice_test error: ' + error); + expect().assertFail(); + done(); + }) + power.shutdownDevice("shutsown"); + console.info('power_shutdownDevice_test: shutdownDevice end'); + setTimeout(function(){ + power.isScreenOn() + .then(screenOn => { + console.info('power_shutdownDevice_test: The current screenOn is ' + screenOn); + expect(screenOn).assertFalse(); + console.info('power_shutdownDevice_test success'); + done(); + }) + .catch(error => { + console.log('power_shutdownDevice_test error: ' + error); + expect().assertFail(); + done(); + }) + }, 2000); + }) + + /** + * @tc.number power_js_003 + * @tc.name power_creat_rebootDeviceDevice_test + * @tc.desc Device reboot interface verification + */ + it('creat_rebootDeviceDevice_test', 0, async function () { + power.isScreenOn() + .then(screenOn => { + console.info('power_rebootDevice_test: The current screenOn is ' + screenOn); + if (!screenOn) { + power.wakeupDevice("power_rebootDevice_test"); + } + }) + .catch(error => { + console.log('power_rebootDevice_test error: ' + error); + expect().assertFail(); + done(); + }) + power.rebootDevice("shutsown"); + console.info('power_rebootDevice_test: rebootDevice end'); + setTimeout(function(){ + power.isScreenOn() + .then(screenOn => { + console.info('power_rebootDevice_test: The current screenOn is ' + screenOn); + expect(screenOn).assertFalse(); + console.info('power_rebootDevice_test success'); + done(); + }) + .catch(error => { + console.log('power_rebootDevice_test error: ' + error); + expect().assertFail(); + done(); + }) + }, 2000); + }) +})} diff --git a/powermgr/power_manager/src/main/js/default/test/power_manager_running_lock.test.js b/powermgr/power_manager/src/main/js/test/power_manager_running_lock.test.js similarity index 97% rename from powermgr/power_manager/src/main/js/default/test/power_manager_running_lock.test.js rename to powermgr/power_manager/src/main/js/test/power_manager_running_lock.test.js index ce1707b36..0d61e34b7 100644 --- a/powermgr/power_manager/src/main/js/default/test/power_manager_running_lock.test.js +++ b/powermgr/power_manager/src/main/js/test/power_manager_running_lock.test.js @@ -1,231 +1,233 @@ -/* - * 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 runningLock from '@ohos.runninglock' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - -describe('appInfoTest_power_2', function () { - console.log("*************RunningLock Unit Test Begin*************"); - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0110 - * @tc.name Create_Running_Lock_Promise_JSTest0010 - * @tc.desc Create running lock - */ - it('Create_Running_Lock_Promise_JSTest0010', 0, async function (done) { - runningLock.createRunningLock("running_lock_test_1", runningLock.RunningLockType.BACKGROUND) - .then(runninglock => { - expect(runninglock !== null).assertTrue(); - console.info('Create_Running_Lock_Promise_JSTest0010 success'); - done(); - }) - .catch(error => { - console.log('Create_Running_Lock_Promise_JSTest0010 error: ' + error); - expect().assertFail(); - done(); - }) - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0120 - * @tc.name Create_Running_Lock_CallBack_JSTest0020 - * @tc.desc Create running lock - */ - it('Create_Running_Lock_CallBack_JSTest0020', 0, async function (done) { - runningLock.createRunningLock("running_lock_test_2", runningLock.RunningLockType.BACKGROUND, - (error, runninglock) => { - if (typeof error === "undefined") { - console.info('Create_Running_Lock_CallBack_JSTest0020: runningLock is ' + runninglock); - expect(runninglock !== null).assertTrue(); - let used = runninglock.isUsed(); - console.info('Create_Running_Lock_CallBack_JSTest0020 is used: ' + used); - expect(used).assertFalse(); - runninglock.lock(500); - used = runninglock.isUsed(); - console.info('after lock Create_Running_Lock_CallBack_JSTest0020 is used: ' + used); - expect(used).assertTrue(); - console.info('Create_Running_Lock_CallBack_JSTest0020 success'); - done(); - } else { - console.log('Create_Running_Lock_CallBack_JSTest0020: ' + error); - expect().assertFail(); - done(); - } - }) - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0130 - * @tc.name Running_Lock_Lock_JSTest0030 - * @tc.desc Prevents the system from hibernating and sets the lock duration - */ - it('Running_Lock_Lock_JSTest0030', 0, async function (done) { - runningLock.createRunningLock("running_lock_test_3", runningLock.RunningLockType.BACKGROUND) - .then(runninglock => { - expect(runninglock !== null).assertTrue(); - let used = runninglock.isUsed(); - console.info('Running_Lock_Lock_JSTest0030 is used: ' + used); - expect(used).assertFalse(); - runninglock.lock(500); - used = runninglock.isUsed(); - console.info('after lock Running_Lock_Lock_JSTest0030 is used: ' + used); - expect(used).assertTrue(); - console.info('Running_Lock_Lock_JSTest0030 success'); - done(); - }) - .catch(error => { - console.log('Running_Lock_Lock_JSTest0030 error: ' + error); - expect().assertFail(); - done(); - }) - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0140 - * @tc.name Running_Lock_used_JSTest0040 - * @tc.desc Checks whether a lock is held or in use - */ - it('Running_Lock_used_JSTest0040', 0, async function (done) { - runningLock.createRunningLock("running_lock_test_4", runningLock.RunningLockType.BACKGROUND) - .then(runninglock => { - expect(runninglock !== null).assertTrue(); - let used = runninglock.isUsed(); - console.info('Running_Lock_used_JSTest0040 used: ' + used); - expect(used).assertFalse(); - console.info('Running_Lock_used_JSTest0040 success'); - done(); - }) - .catch(error => { - console.log('Running_Lock_used_JSTest0040 error: ' + error); - expect().assertFail(); - done(); - }) - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0150 - * @tc.name Running_Lock_Unlock_JSTest0050 - * @tc.desc Release running lock - */ - it('Running_Lock_Unlock_JSTest0050', 0, async function (done) { - runningLock.createRunningLock("running_lock_test_5", runningLock.RunningLockType.BACKGROUND) - .then(runninglock => { - expect(runninglock !== null).assertTrue(); - let used = runninglock.isUsed(); - console.info('Running_Lock_Unlock_JSTest0050 is used: ' + used); - expect(used).assertFalse(); - runninglock.lock(500); - used = runninglock.isUsed(); - console.info('after lock Running_Lock_Unlock_JSTest0050 is used: ' + used); - expect(used).assertTrue(); - runninglock.unlock(); - used = runninglock.isUsed(); - console.info('after unlock Running_Lock_Unlock_JSTest0050 is used: ' + used); - expect(used).assertFalse(); - console.info('Running_Lock_Unlock_JSTest0050 success'); - done(); - }) - .catch(error => { - console.log('Running_Lock_Unlock_JSTest0050 error: ' + error); - expect().assertFail(); - done(); - }) - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0160 - * @tc.name Enum_RunningLock_Type_Background_JSTest0060 - * @tc.desc The lock type is BACKGROUND - */ - it('Enum_RunningLock_Type_Background_JSTest0060', 0, function () { - let runningLockType = runningLock.RunningLockType.BACKGROUND; - console.info('runningLockType = ' + runningLockType); - expect(runningLockType == 1).assertTrue(); - console.info('Enum_RunningLock_Type_Background_JSTest0060 success'); - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0170 - * @tc.name Enum_RunningLock_Type_Proximityscreencontrol_JSTest0070 - * @tc.desc The lock type is PROXIMITY_SCREEN_CONTROL - */ - it('Enum_RunningLock_Type_Proximityscreencontrol_JSTest0070', 0, function () { - let runningLockType = runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL; - console.info('runningLockType = ' + runningLockType); - expect(runningLockType == 2).assertTrue(); - console.info('Enum_RunningLock_Type_Proximityscreencontrol_JSTest0070 success'); - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0180 - * @tc.name Is_Runninglock_Type_Supported_Promise_Test1_JSTest0080 - * @tc.desc Checks whether the specified RunningLockType is supported. - */ - it('Is_Runninglock_Type_Supported_Promise_Test1_JSTest0080', 0, async function (done) { - runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL) - .then(supported => { - console.info('is_runninglock_type_supported_test_1 PROXIMITY_SCREEN_CONTROL supported is ' + supported); - expect(supported).assertTrue(); - console.info('is_runninglock_type_supported_test_1 success'); - done(); - }) - .catch(error => { - console.log('is_runninglock_type_supported_test_1 error: ' + error); - expect().assertFail(); - done(); - }) - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0190 - * @tc.name Is_Runninglock_Type_Supported_Promise_Test2_JSTest0090 - * @tc.desc Checks whether the specified RunningLockType is supported. - */ - it('Is_Runninglock_Type_Supported_Promise_Test2_JSTest0090', 0, async function (done) { - runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND) - .then(supported => { - console.info('Is_Runninglock_Type_Supported_Promise_Test2 BACKGROUND supported is ' + supported); - expect(supported).assertTrue(); - console.info('Is_Runninglock_Type_Supported_Promise_Test2 success'); - done(); - }) - .catch(error => { - console.log('Is_Runninglock_Type_Supported_Promise_Test2 error: ' + error); - expect().assertFail(); - done(); - }) - }) - - /** - * @tc.number SUB_PowerSystem_PowerManager_JSTest_0200 - * @tc.name Is_Runninglock_Type_Supported_Callback_test3_JSTest0100 - * @tc.desc Checks whether the specified RunningLockType is supported. - */ - it('Is_Runninglock_Type_Supported_Callback_test3_JSTest0100', 0, async function (done) { - runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND, (error, supported) => { - if (typeof error === "undefined") { - console.info('Is_Runninglock_Type_Supported_Callback_test3_JSTest supported is ' + supported); - expect(supported).assertTrue(); - console.info('Is_Runninglock_Type_Supported_Callback_test3_JSTest success'); - done(); - } else { - console.log('Is_Runninglock_Type_Supported_Callback_test3_JSTest: ' + error); - expect().assertFail(); - 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 runningLock from '@ohos.runninglock' + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +export default function appInfoTest_power_2() { +describe('appInfoTest_power_2', function () { + console.log("*************RunningLock Unit Test Begin*************"); + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0110 + * @tc.name Create_Running_Lock_Promise_JSTest0010 + * @tc.desc Create running lock + */ + it('Create_Running_Lock_Promise_JSTest0010', 0, async function (done) { + runningLock.createRunningLock("running_lock_test_1", runningLock.RunningLockType.BACKGROUND) + .then(runninglock => { + expect(runninglock !== null).assertTrue(); + console.info('Create_Running_Lock_Promise_JSTest0010 success'); + done(); + }) + .catch(error => { + console.log('Create_Running_Lock_Promise_JSTest0010 error: ' + error); + expect().assertFail(); + done(); + }) + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0120 + * @tc.name Create_Running_Lock_CallBack_JSTest0020 + * @tc.desc Create running lock + */ + it('Create_Running_Lock_CallBack_JSTest0020', 0, async function (done) { + runningLock.createRunningLock("running_lock_test_2", runningLock.RunningLockType.BACKGROUND, + (error, runninglock) => { + if (typeof error === "undefined") { + console.info('Create_Running_Lock_CallBack_JSTest0020: runningLock is ' + runninglock); + expect(runninglock !== null).assertTrue(); + let used = runninglock.isUsed(); + console.info('Create_Running_Lock_CallBack_JSTest0020 is used: ' + used); + expect(used).assertFalse(); + runninglock.lock(500); + used = runninglock.isUsed(); + console.info('after lock Create_Running_Lock_CallBack_JSTest0020 is used: ' + used); + expect(used).assertTrue(); + console.info('Create_Running_Lock_CallBack_JSTest0020 success'); + done(); + } else { + console.log('Create_Running_Lock_CallBack_JSTest0020: ' + error); + expect().assertFail(); + done(); + } + }) + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0130 + * @tc.name Running_Lock_Lock_JSTest0030 + * @tc.desc Prevents the system from hibernating and sets the lock duration + */ + it('Running_Lock_Lock_JSTest0030', 0, async function (done) { + runningLock.createRunningLock("running_lock_test_3", runningLock.RunningLockType.BACKGROUND) + .then(runninglock => { + expect(runninglock !== null).assertTrue(); + let used = runninglock.isUsed(); + console.info('Running_Lock_Lock_JSTest0030 is used: ' + used); + expect(used).assertFalse(); + runninglock.lock(500); + used = runninglock.isUsed(); + console.info('after lock Running_Lock_Lock_JSTest0030 is used: ' + used); + expect(used).assertTrue(); + console.info('Running_Lock_Lock_JSTest0030 success'); + done(); + }) + .catch(error => { + console.log('Running_Lock_Lock_JSTest0030 error: ' + error); + expect().assertFail(); + done(); + }) + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0140 + * @tc.name Running_Lock_used_JSTest0040 + * @tc.desc Checks whether a lock is held or in use + */ + it('Running_Lock_used_JSTest0040', 0, async function (done) { + runningLock.createRunningLock("running_lock_test_4", runningLock.RunningLockType.BACKGROUND) + .then(runninglock => { + expect(runninglock !== null).assertTrue(); + let used = runninglock.isUsed(); + console.info('Running_Lock_used_JSTest0040 used: ' + used); + expect(used).assertFalse(); + console.info('Running_Lock_used_JSTest0040 success'); + done(); + }) + .catch(error => { + console.log('Running_Lock_used_JSTest0040 error: ' + error); + expect().assertFail(); + done(); + }) + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0150 + * @tc.name Running_Lock_Unlock_JSTest0050 + * @tc.desc Release running lock + */ + it('Running_Lock_Unlock_JSTest0050', 0, async function (done) { + runningLock.createRunningLock("running_lock_test_5", runningLock.RunningLockType.BACKGROUND) + .then(runninglock => { + expect(runninglock !== null).assertTrue(); + let used = runninglock.isUsed(); + console.info('Running_Lock_Unlock_JSTest0050 is used: ' + used); + expect(used).assertFalse(); + runninglock.lock(500); + used = runninglock.isUsed(); + console.info('after lock Running_Lock_Unlock_JSTest0050 is used: ' + used); + expect(used).assertTrue(); + runninglock.unlock(); + used = runninglock.isUsed(); + console.info('after unlock Running_Lock_Unlock_JSTest0050 is used: ' + used); + expect(used).assertFalse(); + console.info('Running_Lock_Unlock_JSTest0050 success'); + done(); + }) + .catch(error => { + console.log('Running_Lock_Unlock_JSTest0050 error: ' + error); + expect().assertFail(); + done(); + }) + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0160 + * @tc.name Enum_RunningLock_Type_Background_JSTest0060 + * @tc.desc The lock type is BACKGROUND + */ + it('Enum_RunningLock_Type_Background_JSTest0060', 0, function () { + let runningLockType = runningLock.RunningLockType.BACKGROUND; + console.info('runningLockType = ' + runningLockType); + expect(runningLockType == 1).assertTrue(); + console.info('Enum_RunningLock_Type_Background_JSTest0060 success'); + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0170 + * @tc.name Enum_RunningLock_Type_Proximityscreencontrol_JSTest0070 + * @tc.desc The lock type is PROXIMITY_SCREEN_CONTROL + */ + it('Enum_RunningLock_Type_Proximityscreencontrol_JSTest0070', 0, function () { + let runningLockType = runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL; + console.info('runningLockType = ' + runningLockType); + expect(runningLockType == 2).assertTrue(); + console.info('Enum_RunningLock_Type_Proximityscreencontrol_JSTest0070 success'); + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0180 + * @tc.name Is_Runninglock_Type_Supported_Promise_Test1_JSTest0080 + * @tc.desc Checks whether the specified RunningLockType is supported. + */ + it('Is_Runninglock_Type_Supported_Promise_Test1_JSTest0080', 0, async function (done) { + runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL) + .then(supported => { + console.info('is_runninglock_type_supported_test_1 PROXIMITY_SCREEN_CONTROL supported is ' + supported); + expect(supported).assertTrue(); + console.info('is_runninglock_type_supported_test_1 success'); + done(); + }) + .catch(error => { + console.log('is_runninglock_type_supported_test_1 error: ' + error); + expect().assertFail(); + done(); + }) + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0190 + * @tc.name Is_Runninglock_Type_Supported_Promise_Test2_JSTest0090 + * @tc.desc Checks whether the specified RunningLockType is supported. + */ + it('Is_Runninglock_Type_Supported_Promise_Test2_JSTest0090', 0, async function (done) { + runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND) + .then(supported => { + console.info('Is_Runninglock_Type_Supported_Promise_Test2 BACKGROUND supported is ' + supported); + expect(supported).assertTrue(); + console.info('Is_Runninglock_Type_Supported_Promise_Test2 success'); + done(); + }) + .catch(error => { + console.log('Is_Runninglock_Type_Supported_Promise_Test2 error: ' + error); + expect().assertFail(); + done(); + }) + }) + + /** + * @tc.number SUB_PowerSystem_PowerManager_JSTest_0200 + * @tc.name Is_Runninglock_Type_Supported_Callback_test3_JSTest0100 + * @tc.desc Checks whether the specified RunningLockType is supported. + */ + it('Is_Runninglock_Type_Supported_Callback_test3_JSTest0100', 0, async function (done) { + runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND, (error, supported) => { + if (typeof error === "undefined") { + console.info('Is_Runninglock_Type_Supported_Callback_test3_JSTest supported is ' + supported); + expect(supported).assertTrue(); + console.info('Is_Runninglock_Type_Supported_Callback_test3_JSTest success'); + done(); + } else { + console.log('Is_Runninglock_Type_Supported_Callback_test3_JSTest: ' + error); + expect().assertFail(); + done(); + } + }) + }) +}) +} diff --git a/powermgr/power_manager/src/main/js/default/test/power_performance_test.js b/powermgr/power_manager/src/main/js/test/power_performance_test.js similarity index 95% rename from powermgr/power_manager/src/main/js/default/test/power_performance_test.js rename to powermgr/power_manager/src/main/js/test/power_performance_test.js index 56f6492f3..cd854962e 100644 --- a/powermgr/power_manager/src/main/js/default/test/power_performance_test.js +++ b/powermgr/power_manager/src/main/js/test/power_performance_test.js @@ -1,152 +1,154 @@ -/* - * 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 runningLock from '@ohos.runninglock'; -import power from '@ohos.power'; -import brightness from '@ohos.brightness'; -import { describe, it, expect } from 'deccjsunit/index'; - -describe('appInfoTest_power_3', function () { - - console.log("*************Power Performance Test Begin*************"); - const MAXNUM = 1000; - const MIDNUM = 100; - const MS_TO_US = 1000; - const LIMIT_TIME = 1500; - const LIMIT_TIME_LONG = 4000; - - /** - * @tc.number PowerPerformance_001 - * @tc.name createRunningLock_test - * @tc.desc Interface is called normally - */ - it('PowerPerformance_001', 0, async function (done) { - let startTime = new Date().getTime(); - for (let i = 0; i < MIDNUM; i++) { - await runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND) - } - let waitTime = new Date().getTime() - startTime; - let avgTime = waitTime / MIDNUM * MS_TO_US; //us - console.info(`POWER_Performance_001: Promise: runningLock.createRunningLock Wait Time : ${waitTime}`); - avgTime < LIMIT_TIME_LONG ? expect(true).assertTrue() : expect(false).assertTrue(); - done(); - }) - - /** - * @tc.number PowerPerformance_003 - * @tc.name lock_test - * @tc.desc Interface is called normally - */ - it('PowerPerformance_003', 0, async function (done) { - let avgTime = 0; - runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND, (error, runningLock) => { - if (typeof error === "undefined") { - let startTime = new Date().getTime(); - for (let i = 0; i < MAXNUM; i++) { - runningLock.lock(500); - } - let waitTime = new Date().getTime() - startTime; - avgTime = avgTime + waitTime; //us - console.info(`PowerPerformance_003: Promise: runningLock.lock Wait Time : ${waitTime}`); - avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue(); - runningLock.unlock(); - done(); - } else { - console.log('PowerPerformance_003: ' + error); - console.info('PowerPerformance_003: lock is ' + runningLock); - done(); - } - }) - }) - - /** - * @tc.number PowerPerformance_004 - * @tc.name unlock_test - * @tc.desc Interface is called normally - */ - it('PowerPerformance_004', 0, async function (done) { - let avgTime = 0; - runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND, (error, runningLock) => { - if (typeof error === "undefined") { - runningLock.lock(500); - let startTime = new Date().getTime(); - for (let i = 0; i < MAXNUM; i++) { - runningLock.unlock(); - } - let waitTime = new Date().getTime() - startTime; - avgTime = avgTime + waitTime; //us - console.info(`PowerPerformance_004: Promise: runningLock.unlock Wait Time : ${waitTime}`); - avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue(); - done(); - } else { - console.log('PowerPerformance_004: ' + error); - console.info('PowerPerformance_004: lock is ' + runningLock); - done(); - } - }) - }) - - /** - * @tc.number PowerPerformance_005 - * @tc.name isProximitySupported_test - * @tc.desc Interface is called normally - */ - it('PowerPerformance_005', 0, async function (done) { - let startTime = new Date().getTime(); - for (let i = 0; i < MAXNUM; i++) { - await runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL) - } - let waitTime = new Date().getTime() - startTime; - let avgTime = waitTime / MAXNUM * MS_TO_US; //us - console.info(`PowerPerformance_005: Promise: await runningLock.isRunningLockTypeSupported Wait Time : - ${waitTime}`); - avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue(); - done(); - }) - - /** - * @tc.number PowerPerformance_006 - * @tc.name isScreenOn_test - * @tc.desc AsyncCallback judge whether the screen is lit and return to true - */ - it('PowerPerformance_006', 0, async function (done) { - let startTime = new Date().getTime(); - for (let i = 0; i < MAXNUM; i++) { - await power.isScreenOn() - } - let waitTime = new Date().getTime() - startTime; - let avgTime = waitTime / MAXNUM * MS_TO_US; //us - console.info(`PowerPerformance_006: Promise: await power.isScreenOn Wait Time : ${waitTime}`); - avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue(); - done(); - }) - - /** - * @tc.number PowerPerformance_007 - * @tc.name setValue_test - * @tc.desc Interface is called normally - */ - it('PowerPerformance_007', 0, function () { - let startTime = new Date().getTime(); - for (let i = 0; i < MAXNUM; i++) { - brightness.setValue(100); - } - let waitTime = new Date().getTime() - startTime; - let avgTime = waitTime / MAXNUM * MS_TO_US; //us - console.info(`PowerPerformance_007: Promise: brightness.setValue Wait Time : ${waitTime}`); - avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue(); - }) - -}) +/* + * 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 runningLock from '@ohos.runninglock'; +import power from '@ohos.power'; +import brightness from '@ohos.brightness'; +import { describe, it, expect } from '@ohos/hypium'; + +export default function appInfoTest_power_3() { +describe('appInfoTest_power_3', function () { + + console.log("*************Power Performance Test Begin*************"); + const MAXNUM = 1000; + const MIDNUM = 100; + const MS_TO_US = 1000; + const LIMIT_TIME = 1500; + const LIMIT_TIME_LONG = 4000; + + /** + * @tc.number PowerPerformance_001 + * @tc.name createRunningLock_test + * @tc.desc Interface is called normally + */ + it('PowerPerformance_001', 0, async function (done) { + let startTime = new Date().getTime(); + for (let i = 0; i < MIDNUM; i++) { + await runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND) + } + let waitTime = new Date().getTime() - startTime; + let avgTime = waitTime / MIDNUM * MS_TO_US; //us + console.info(`POWER_Performance_001: Promise: runningLock.createRunningLock Wait Time : ${waitTime}`); + avgTime < LIMIT_TIME_LONG ? expect(true).assertTrue() : expect(false).assertTrue(); + done(); + }) + + /** + * @tc.number PowerPerformance_003 + * @tc.name lock_test + * @tc.desc Interface is called normally + */ + it('PowerPerformance_003', 0, async function (done) { + let avgTime = 0; + runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND, (error, runningLock) => { + if (typeof error === "undefined") { + let startTime = new Date().getTime(); + for (let i = 0; i < MAXNUM; i++) { + runningLock.lock(500); + } + let waitTime = new Date().getTime() - startTime; + avgTime = avgTime + waitTime; //us + console.info(`PowerPerformance_003: Promise: runningLock.lock Wait Time : ${waitTime}`); + avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue(); + runningLock.unlock(); + done(); + } else { + console.log('PowerPerformance_003: ' + error); + console.info('PowerPerformance_003: lock is ' + runningLock); + done(); + } + }) + }) + + /** + * @tc.number PowerPerformance_004 + * @tc.name unlock_test + * @tc.desc Interface is called normally + */ + it('PowerPerformance_004', 0, async function (done) { + let avgTime = 0; + runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND, (error, runningLock) => { + if (typeof error === "undefined") { + runningLock.lock(500); + let startTime = new Date().getTime(); + for (let i = 0; i < MAXNUM; i++) { + runningLock.unlock(); + } + let waitTime = new Date().getTime() - startTime; + avgTime = avgTime + waitTime; //us + console.info(`PowerPerformance_004: Promise: runningLock.unlock Wait Time : ${waitTime}`); + avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue(); + done(); + } else { + console.log('PowerPerformance_004: ' + error); + console.info('PowerPerformance_004: lock is ' + runningLock); + done(); + } + }) + }) + + /** + * @tc.number PowerPerformance_005 + * @tc.name isProximitySupported_test + * @tc.desc Interface is called normally + */ + it('PowerPerformance_005', 0, async function (done) { + let startTime = new Date().getTime(); + for (let i = 0; i < MAXNUM; i++) { + await runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL) + } + let waitTime = new Date().getTime() - startTime; + let avgTime = waitTime / MAXNUM * MS_TO_US; //us + console.info(`PowerPerformance_005: Promise: await runningLock.isRunningLockTypeSupported Wait Time : + ${waitTime}`); + avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue(); + done(); + }) + + /** + * @tc.number PowerPerformance_006 + * @tc.name isScreenOn_test + * @tc.desc AsyncCallback judge whether the screen is lit and return to true + */ + it('PowerPerformance_006', 0, async function (done) { + let startTime = new Date().getTime(); + for (let i = 0; i < MAXNUM; i++) { + await power.isScreenOn() + } + let waitTime = new Date().getTime() - startTime; + let avgTime = waitTime / MAXNUM * MS_TO_US; //us + console.info(`PowerPerformance_006: Promise: await power.isScreenOn Wait Time : ${waitTime}`); + avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue(); + done(); + }) + + /** + * @tc.number PowerPerformance_007 + * @tc.name setValue_test + * @tc.desc Interface is called normally + */ + it('PowerPerformance_007', 0, function () { + let startTime = new Date().getTime(); + for (let i = 0; i < MAXNUM; i++) { + brightness.setValue(100); + } + let waitTime = new Date().getTime() - startTime; + let avgTime = waitTime / MAXNUM * MS_TO_US; //us + console.info(`PowerPerformance_007: Promise: brightness.setValue Wait Time : ${waitTime}`); + avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue(); + }) + +}) +} diff --git a/powermgr/power_manager/src/main/resources/base/element/string.json b/powermgr/power_manager/src/main/resources/base/element/string.json old mode 100755 new mode 100644 index e1322c118..97df9fd9b --- a/powermgr/power_manager/src/main/resources/base/element/string.json +++ b/powermgr/power_manager/src/main/resources/base/element/string.json @@ -7,6 +7,22 @@ { "name": "mainability_description", "value": "JS_Phone_Empty Feature Ability" - } + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } ] } \ No newline at end of file diff --git a/powermgr/power_manager/src/main/resources/base/media/icon.png b/powermgr/power_manager/src/main/resources/base/media/icon.png old mode 100755 new mode 100644 diff --git a/powermgr/thermal_manager/BUILD.gn b/powermgr/thermal_manager/BUILD.gn index 65797fa6c..cd5a84849 100644 --- a/powermgr/thermal_manager/BUILD.gn +++ b/powermgr/thermal_manager/BUILD.gn @@ -9,7 +9,7 @@ # 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. import("//test/xts/tools/build/suite.gni") @@ -23,7 +23,9 @@ ohos_js_hap_suite("powermgr_thermal_test") { hap_name = "ActsPowerMgrThermalTest" } ohos_js_assets("powermgr_thermal_js_assets") { - source_dir = "./src/main/js/default" + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" } ohos_resources("powermgr_thermal_resources") { sources = [ "./src/main/resources" ] diff --git a/powermgr/thermal_manager/Test.json b/powermgr/thermal_manager/Test.json index 620b0e924..312d67822 100644 --- a/powermgr/thermal_manager/Test.json +++ b/powermgr/thermal_manager/Test.json @@ -1,19 +1,19 @@ -{ - "description": "Configuration for powermgr thermal Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "120000", - "package": "com.example.mythermalapp", - "shell-timeout": "120000" - }, - "kits": [ - { - "test-file-name": [ - "ActsPowerMgrThermalTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} - +{ + "description": "Configuration for powermgr thermal Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "120000", + "shell-timeout": "120000", + "bundle-name": "com.example.mythermalapp", + "package-name": "com.example.mythermalapp" + }, + "kits": [ + { + "test-file-name": [ + "ActsPowerMgrThermalTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/powermgr/thermal_manager/src/main/config.json b/powermgr/thermal_manager/src/main/config.json index 74321b19b..118479d8c 100644 --- a/powermgr/thermal_manager/src/main/config.json +++ b/powermgr/thermal_manager/src/main/config.json @@ -1,60 +1,93 @@ { - "app": { - "bundleName": "com.example.mythermalapp", - "vendor": "example", - "version": { - "code": 1, - "name": "1.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5 - } - }, - "deviceConfig": {}, - "module": { - "package": "com.example.mythermalapp", - "name": ".MyApplication", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry" + "app": { + "bundleName": "com.example.mythermalapp", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 + } }, - "abilities": [ - { - "visible": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } + "deviceConfig": {}, + "module": { + "package": "com.example.mythermalapp", + "name": ".entry", + "deviceType": [ + "phone" ], - "name": "com.example.mythermalapp.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } -} + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + }, + "mainAbility": ".MainAbility", + "srcPath": "" + } +} \ No newline at end of file diff --git a/powermgr/thermal_manager/src/main/js/default/app.js b/powermgr/thermal_manager/src/main/js/MainAbility/app.js similarity index 100% rename from powermgr/thermal_manager/src/main/js/default/app.js rename to powermgr/thermal_manager/src/main/js/MainAbility/app.js diff --git a/powermgr/thermal_manager/src/main/js/default/i18n/en-US.json b/powermgr/thermal_manager/src/main/js/MainAbility/i18n/en-US.json similarity index 91% rename from powermgr/thermal_manager/src/main/js/default/i18n/en-US.json rename to powermgr/thermal_manager/src/main/js/MainAbility/i18n/en-US.json index e63c70d97..a4c13dcbd 100644 --- a/powermgr/thermal_manager/src/main/js/default/i18n/en-US.json +++ b/powermgr/thermal_manager/src/main/js/MainAbility/i18n/en-US.json @@ -1,6 +1,6 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } +{ + "strings": { + "hello": "Hello", + "world": "World" + } } \ No newline at end of file diff --git a/powermgr/power_manager/src/main/js/default/i18n/zh-CN.json b/powermgr/thermal_manager/src/main/js/MainAbility/i18n/zh-CN.json old mode 100755 new mode 100644 similarity index 91% rename from powermgr/power_manager/src/main/js/default/i18n/zh-CN.json rename to powermgr/thermal_manager/src/main/js/MainAbility/i18n/zh-CN.json index de6ee5748..b1c02368f --- a/powermgr/power_manager/src/main/js/default/i18n/zh-CN.json +++ b/powermgr/thermal_manager/src/main/js/MainAbility/i18n/zh-CN.json @@ -1,6 +1,6 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } +{ + "strings": { + "hello": "您好", + "world": "世界" + } } \ No newline at end of file diff --git a/powermgr/thermal_manager/src/main/js/default/pages/index/index.css b/powermgr/thermal_manager/src/main/js/MainAbility/pages/index/index.css similarity index 96% rename from powermgr/thermal_manager/src/main/js/default/pages/index/index.css rename to powermgr/thermal_manager/src/main/js/MainAbility/pages/index/index.css index 7300d2a1f..cff50023c 100644 --- a/powermgr/thermal_manager/src/main/js/default/pages/index/index.css +++ b/powermgr/thermal_manager/src/main/js/MainAbility/pages/index/index.css @@ -1,24 +1,24 @@ -/* - * 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. - */ - -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} +/* + * 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/powermgr/thermal_manager/src/main/js/default/pages/index/index.hml b/powermgr/thermal_manager/src/main/js/MainAbility/pages/index/index.hml similarity index 97% rename from powermgr/thermal_manager/src/main/js/default/pages/index/index.hml rename to powermgr/thermal_manager/src/main/js/MainAbility/pages/index/index.hml index eeaf6a3fc..936e04ebd 100644 --- a/powermgr/thermal_manager/src/main/js/default/pages/index/index.hml +++ b/powermgr/thermal_manager/src/main/js/MainAbility/pages/index/index.hml @@ -1,20 +1,20 @@ - - -
- - {{ $t('strings.hello') }} {{ title }} - -
+ + +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/powermgr/thermal_manager/src/main/js/default/pages/index/index.js b/powermgr/thermal_manager/src/main/js/MainAbility/pages/index/index.js similarity index 67% rename from powermgr/thermal_manager/src/main/js/default/pages/index/index.js rename to powermgr/thermal_manager/src/main/js/MainAbility/pages/index/index.js index 8b86d31dd..98d501573 100644 --- a/powermgr/thermal_manager/src/main/js/default/pages/index/index.js +++ b/powermgr/thermal_manager/src/main/js/MainAbility/pages/index/index.js @@ -1,43 +1,30 @@ -/* - * 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 app from '@system.app' - -import {Core, ExpectExtend} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - core.init() - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../test/List.test') - core.execute() - }, - onReady() { - }, -} +/* + * 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 app from '@system.app' + + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + }, + onReady() { + }, +} diff --git a/powermgr/thermal_manager/src/main/js/TestAbility/app.js b/powermgr/thermal_manager/src/main/js/TestAbility/app.js new file mode 100644 index 000000000..cdc31f3dc --- /dev/null +++ b/powermgr/thermal_manager/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/powermgr/thermal_manager/src/main/js/TestAbility/i18n/en-US.json b/powermgr/thermal_manager/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 000000000..3cb24b374 --- /dev/null +++ b/powermgr/thermal_manager/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/powermgr/thermal_manager/src/main/js/TestAbility/i18n/zh-CN.json b/powermgr/thermal_manager/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 000000000..c804e32c0 --- /dev/null +++ b/powermgr/thermal_manager/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/powermgr/thermal_manager/src/main/js/TestAbility/pages/index/index.css b/powermgr/thermal_manager/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 000000000..b1bcd4338 --- /dev/null +++ b/powermgr/thermal_manager/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,30 @@ +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/powermgr/thermal_manager/src/main/js/TestAbility/pages/index/index.hml b/powermgr/thermal_manager/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 000000000..f629c71a9 --- /dev/null +++ b/powermgr/thermal_manager/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/powermgr/thermal_manager/src/main/js/TestAbility/pages/index/index.js b/powermgr/thermal_manager/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 000000000..88b083a7f --- /dev/null +++ b/powermgr/thermal_manager/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/powermgr/thermal_manager/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/powermgr/thermal_manager/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 000000000..c5fa8620c --- /dev/null +++ b/powermgr/thermal_manager/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/powermgr/thermal_manager/src/main/js/default/test/List.test.js b/powermgr/thermal_manager/src/main/js/test/List.test.js similarity index 80% rename from powermgr/thermal_manager/src/main/js/default/test/List.test.js rename to powermgr/thermal_manager/src/main/js/test/List.test.js index f42c57c0a..6f217c276 100644 --- a/powermgr/thermal_manager/src/main/js/default/test/List.test.js +++ b/powermgr/thermal_manager/src/main/js/test/List.test.js @@ -12,4 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require('./thermal_unittest.test.js') \ No newline at end of file +import appInfoTest_thermal_1 from './thermal_unittest.test.js' +export default function testsuite() { +appInfoTest_thermal_1() +} diff --git a/powermgr/thermal_manager/src/main/js/default/test/thermal_common_event.test.js b/powermgr/thermal_manager/src/main/js/test/thermal_common_event.test.js similarity index 96% rename from powermgr/thermal_manager/src/main/js/default/test/thermal_common_event.test.js rename to powermgr/thermal_manager/src/main/js/test/thermal_common_event.test.js index 69439f9ef..e85fb2a03 100644 --- a/powermgr/thermal_manager/src/main/js/default/test/thermal_common_event.test.js +++ b/powermgr/thermal_manager/src/main/js/test/thermal_common_event.test.js @@ -1,73 +1,74 @@ -/* - * 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 thermal from "@ohos.thermal" - -describe('appInfoTest_thermal_3', function () { - console.log("*************Thermal commonEvent Test Begin*************"); - - /** - * @tc.number ThermalCommonEventTest_001 - * @tc.name subscribe thermal level changed common event - * @tc.desc Thermal acquisition kit - */ - it('ThermalCommonEventTest_001', 0, function (done) { - createSubscriber(); - done(); - }) - console.log("*************Thermal commonEvent Test End*************"); -}) - -function createSubscriber() { - let commonEventSubscribeInfo = { - events: [commonEvent.Support.COMMON_EVENT_THERMAL_LEVEL_CHANGED], - }; - commonEvent.createSubscriber(commonEventSubscribeInfo) - .then(subscriber => { - console.info('createSubscriber success'); - let mySubscriber = subscriber; - console.log(subscriber); - - if (subscriber == "" || subscriber == undefined || subscriber == null) { - console.info("createSubscriber failed"); - } - mySubscriber.getCode() - .then((data) => { - console.info('Subscriber getCode success : ' + JSON.stringify(data)); - }).catch((error) => { - console.error('Subscriber getCode error because: ' + JSON.stringify(error)); - }) - mySubscriber.getData() - .then((data) => { - console.info('Subscriber getData success : ' + JSON.stringify(data)); - }).catch((error) => { - console.error('Subscriber getData error because: ' + JSON.stringify(error)); - }) - console.info('subscribe begin '); - - commonEvent.subscribe(mySubscriber, (error, commonEventData) => { - console.error('err code: ' + JSON.stringify(error)); - console.info('subscribe callback: ' + JSON.stringify(commonEventData)); - console.info("commonEventData event: " + commonEventData.event); - console.info("commonEventData bundleName: " + commonEventData.bundleName); - console.info("commonEventData data: " + commonEventData.data); - console.info("commonEventData parameter: " + commonEventData.parameters[0]); - let level = -1; - expect(level >= thermal.ThermalLevel.COOL && warm <= level.ThermalLevel.EMERGENCY).assertTrue(); - }); - }).catch((error) => { - console.error('Operation failed. Cause: ' + JSON.stringify(error)); - }); -} \ No newline at end of file +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import commonEvent from '@ohos.commonEvent'; +import thermal from "@ohos.thermal" + +export default function appInfoTest_thermal_3() { +describe('appInfoTest_thermal_3', function () { + console.log("*************Thermal commonEvent Test Begin*************"); + + /** + * @tc.number ThermalCommonEventTest_001 + * @tc.name subscribe thermal level changed common event + * @tc.desc Thermal acquisition kit + */ + it('ThermalCommonEventTest_001', 0, function (done) { + createSubscriber(); + done(); + }) + console.log("*************Thermal commonEvent Test End*************"); +}) + +function createSubscriber() { + let commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_THERMAL_LEVEL_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createSubscriber success'); + let mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + let level = -1; + expect(level >= thermal.ThermalLevel.COOL && warm <= level.ThermalLevel.EMERGENCY).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +}} diff --git a/powermgr/thermal_manager/src/main/js/default/test/thermal_performance.test.js b/powermgr/thermal_manager/src/main/js/test/thermal_performance.test.js similarity index 93% rename from powermgr/thermal_manager/src/main/js/default/test/thermal_performance.test.js rename to powermgr/thermal_manager/src/main/js/test/thermal_performance.test.js index d60391d52..fb73e2fbd 100644 --- a/powermgr/thermal_manager/src/main/js/default/test/thermal_performance.test.js +++ b/powermgr/thermal_manager/src/main/js/test/thermal_performance.test.js @@ -1,86 +1,88 @@ -/* - * 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 thermal from "@ohos.thermal" -import { describe, it, expect } from 'deccjsunit/index'; - -describe('appInfoTest_thermal_4', function () { - console.log("*************Thermal Performance Test Begin*************"); - performanceTest1(); - performanceTest2(); - performanceTest3(); - console.log("*************Thermal Performance Test End*************"); -}) - -function performanceTest1() { - let MAXNUM = 1000; - - /** - * @tc.number ThermalPerformance_001 - * @tc.name test get thermal level - * @tc.desc Thermal acquisition kit - */ - it('ThermalPerformance_001', 0, function () { - let startTime = new Date().getTime(); - for (let i = 0; i < MAXNUM; i++) { - let level = thermal.getThermalLevel(); - } - let waitTime = new Date().getTime() - startTime; - let avgTime = waitTime; //us - console.info(`ThermalPerformance_001: Promise: getlevel Wait Time : ${waitTime}`); - }) -} - -function performanceTest2() { - let MAXNUM = 1000; - - /** - * @tc.number ThermalPerformance_002 - * @tc.name subscribe thermal level - * @tc.desc Thermal acquisition kit - */ - it('ThermalPerformance_002', 0, function () { - let startTime = new Date().getTime(); - for (let i = 0; i < MAXNUM; i++) { - thermal.subscribeThermalLevel((level) => { - console.info("hot level is: " + level); - }) - } - let waitTime = new Date().getTime() - startTime; - let avgTime = waitTime; //us - console.info(`ThermalPerformance_002: Promise: subscribeThermalLevel Wait Time : ${waitTime}`); - }) -} - -function performanceTest3() { - let MAXNUM = 1000; - - /** - * @tc.number ThermalPerformance_002 - * @tc.name subscribe thermal level - * @tc.desc Thermal acquisition kit - */ - it('ThermalPerformance_003', 0, function () { - let startTime = new Date().getTime(); - for (let i = 0; i < MAXNUM; i++) { - thermal.unsubscribeThermalLevel(() => { - console.info("unsubscribe success."); - }); - } - let waitTime = new Date().getTime() - startTime; - let avgTime = waitTime; //us - console.info(`ThermalPerformance_003: Promise: unsubscribeThermalLevel Wait Time : ${waitTime}`); - }) -} +/* + * 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 thermal from "@ohos.thermal" +import { describe, it, expect } from '@ohos/hypium'; + +export default function appInfoTest_thermal_4() { +describe('appInfoTest_thermal_4', function () { + console.log("*************Thermal Performance Test Begin*************"); + performanceTest1(); + performanceTest2(); + performanceTest3(); + console.log("*************Thermal Performance Test End*************"); +}) + +function performanceTest1() { + let MAXNUM = 1000; + + /** + * @tc.number ThermalPerformance_001 + * @tc.name test get thermal level + * @tc.desc Thermal acquisition kit + */ + it('ThermalPerformance_001', 0, function () { + let startTime = new Date().getTime(); + for (let i = 0; i < MAXNUM; i++) { + let level = thermal.getThermalLevel(); + } + let waitTime = new Date().getTime() - startTime; + let avgTime = waitTime; //us + console.info(`ThermalPerformance_001: Promise: getlevel Wait Time : ${waitTime}`); + }) +} + +function performanceTest2() { + let MAXNUM = 1000; + + /** + * @tc.number ThermalPerformance_002 + * @tc.name subscribe thermal level + * @tc.desc Thermal acquisition kit + */ + it('ThermalPerformance_002', 0, function () { + let startTime = new Date().getTime(); + for (let i = 0; i < MAXNUM; i++) { + thermal.subscribeThermalLevel((level) => { + console.info("hot level is: " + level); + }) + } + let waitTime = new Date().getTime() - startTime; + let avgTime = waitTime; //us + console.info(`ThermalPerformance_002: Promise: subscribeThermalLevel Wait Time : ${waitTime}`); + }) +} + +function performanceTest3() { + let MAXNUM = 1000; + + /** + * @tc.number ThermalPerformance_002 + * @tc.name subscribe thermal level + * @tc.desc Thermal acquisition kit + */ + it('ThermalPerformance_003', 0, function () { + let startTime = new Date().getTime(); + for (let i = 0; i < MAXNUM; i++) { + thermal.unsubscribeThermalLevel(() => { + console.info("unsubscribe success."); + }); + } + let waitTime = new Date().getTime() - startTime; + let avgTime = waitTime; //us + console.info(`ThermalPerformance_003: Promise: unsubscribeThermalLevel Wait Time : ${waitTime}`); + }) +} +} diff --git a/powermgr/thermal_manager/src/main/js/default/test/thermal_uint.test.js b/powermgr/thermal_manager/src/main/js/test/thermal_uint.test.js similarity index 96% rename from powermgr/thermal_manager/src/main/js/default/test/thermal_uint.test.js rename to powermgr/thermal_manager/src/main/js/test/thermal_uint.test.js index 84df85d08..47940d479 100644 --- a/powermgr/thermal_manager/src/main/js/default/test/thermal_uint.test.js +++ b/powermgr/thermal_manager/src/main/js/test/thermal_uint.test.js @@ -1,331 +1,332 @@ -// @ts-nocheck -/* - * 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 app from '@system.app' -import thermal from "@ohos.thermal" -import ThermalLevel from "@ohos.thermal" -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - -describe('appInfoTest_thermal_2', function () { - console.log("*************Thermal API Test Begin*************"); - test1(); - test2(); - test3(); - test4(); - test5(); - test6(); - test7(); - test8(); - test9(); - test10(); - test11(); - test12(); - test13(); - console.log("*************Thermal API Test End*************"); -}) - -function test1() { - const MSEC_1000 = 1000; - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0010 - * @tc.name Thermal_JSTest0010 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_JSTest0010', 0, async function (done) { - console.info("enter"); - await new Promise((resolve, reject) => { - setTimeout(() => { - let cold = thermal.getThermalLevel(); - console.info("cold level is: " + cold); - expect(cold >= thermal.ThermalLevel.COOL && cold <= thermal.ThermalLevel.EMERGENCY).assertTrue(); - resolve(); - done(); - }, MSEC_1000 * 1); - }) - }) -} - -function test2() { - const MSEC_1000 = 1000; - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0020 - * @tc.name Thermal_JSTest0020 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_JSTest0020', 0, async function (done) { - await new Promise((resolve, reject) => { - setTimeout(() => { - let warm = thermal.getThermalLevel(); - console.info("warm level is: " + warm); - expect(warm >= thermal.ThermalLevel.COOL && warm <= thermal.ThermalLevel.EMERGENCY).assertTrue(); - resolve(); - done(); - }, MSEC_1000 * 1); - }) - }) -} - -function test3() { - const MSEC_1000 = 1000; - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0030 - * @tc.name Thermal_JSTest0030 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_JSTest0030', 0, async function (done) { - await new Promise((resolve, reject) => { - setTimeout(() => { - let hot = thermal.getThermalLevel(); - console.info("hot level is: " + hot); - expect(hot >= thermal.ThermalLevel.COOL && hot <= thermal.ThermalLevel.EMERGENCY).assertTrue(); - resolve(); - done(); - }, MSEC_1000 * 1); - }) - }) -} - -function test4() { - const MSEC_1000 = 1000; - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0040 - * @tc.name Thermal_JSTest0040 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_JSTest0040', 0, async function (done) { - await new Promise((resolve, reject) => { - setTimeout(() => { - let overheated = thermal.getThermalLevel(); - console.info("overheated level is: " + overheated); - expect(overheated >= thermal.ThermalLevel.COOL && - overheated <= thermal.ThermalLevel.EMERGENCY).assertTrue(); - resolve(); - done(); - }, MSEC_1000 * 1); - }) - }) -} - -function test5() { - const MSEC_1000 = 1000; - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0050 - * @tc.name Thermal_JSTest0050 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_JSTest0050', 0, async function (done) { - await new Promise((resolve, reject) => { - setTimeout(() => { - let warning = thermal.getThermalLevel(); - console.info("warning level is: " + warning); - expect(warning >= thermal.ThermalLevel.COOL && warning <= thermal.ThermalLevel.EMERGENCY).assertTrue(); - resolve(); - done(); - }, MSEC_1000 * 1); - }) - }) -} - -function test6() { - const MSEC_1000 = 1000; - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0060 - * @tc.name Thermal_JSTest0060 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_JSTest0060', 0, async function (done) { - await new Promise((resolve, reject) => { - setTimeout(() => { - let emergency = thermal.getThermalLevel(); - console.info("emergency level is: " + emergency); - expect(emergency >= thermal.ThermalLevel.COOL && - emergency <= thermal.ThermalLevel.EMERGENCY).assertTrue(); - resolve(); - done(); - }, MSEC_1000 * 1); - }) - }) -} - -function test7() { - const MSEC_1000 = 1000; - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0070 - * @tc.name Thermal_JSTest0070 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_JSTest0070', 0, async function (done) { - thermal.subscribeThermalLevel((cool) => { - console.info("warm level is: " + cool); - expect(cool >= thermal.ThermalLevel.COOL && cool <= thermal.ThermalLevel.EMERGENCY).assertTrue(); - done(); - }) - await new Promise((resolve, reject) => { - setTimeout(() => { - thermal.unsubscribeThermalLevel(() => { - console.info("unsubscribe successfully!"); - }); - resolve(); - }, MSEC_1000 * 4); - }) - }) -} - -function test8() { - const MSEC_1000 = 1000; - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0080 - * @tc.name Thermal_JSTest0080 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_JSTest0080', 0, async function (done) { - thermal.subscribeThermalLevel((warm) => { - console.info("warm level is: " + warm); - expect(warm >= thermal.ThermalLevel.COOL && warm <= thermal.ThermalLevel.EMERGENCY).assertTrue(); - done(); - }) - await new Promise((resolve, reject) => { - setTimeout(() => { - thermal.unsubscribeThermalLevel(() => { - console.info("unsubscribe successfully!"); - }); - resolve(); - }, MSEC_1000 * 4); - }) - }) -} - -function test9() { - const MSEC_1000 = 1000; - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0090 - * @tc.name Thermal_JSTest0090 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_JSTest0090', 0, async function (done) { - thermal.subscribeThermalLevel((hot) => { - console.info("hot level is: " + hot); - expect(hot >= thermal.ThermalLevel.COOL && hot <= thermal.ThermalLevel.EMERGENCY).assertTrue(); - done(); - }) - await new Promise((resolve, reject) => { - setTimeout(() => { - thermal.unsubscribeThermalLevel(() => { - console.info("unsubscribe successfully!"); - }); - resolve(); - }, MSEC_1000 * 2); - }) - }) - -} - -function test10() { - const MSEC_1000 = 1000; - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0100 - * @tc.name Thermal_JSTest0100 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_JSTest0100', 0, async function (done) { - thermal.subscribeThermalLevel((overheated) => { - console.info("overheated level is: " + overheated); - expect(overheated >= thermal.ThermalLevel.COOL && - overheated <= thermal.ThermalLevel.EMERGENCY).assertTrue(); - done(); - }) - await new Promise((resolve, reject) => { - setTimeout(() => { - thermal.unsubscribeThermalLevel(() => { - console.info("unsubscribe successfully!"); - }); - resolve(); - }, MSEC_1000 * 2); - }) - }) -} - -function test11() { - const MSEC_1000 = 1000; - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0110 - * @tc.name Thermal_JSTest0110 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_JSTest0110', 0, async function (done) { - thermal.subscribeThermalLevel((warning) => { - console.info("warning level is: " + warning); - expect(warning >= thermal.ThermalLevel.COOL && warning <= thermal.ThermalLevel.EMERGENCY).assertTrue(); - done(); - }) - await new Promise((resolve, reject) => { - setTimeout(() => { - thermal.unsubscribeThermalLevel(() => { - console.info("unsubscribe successfully!"); - }); - resolve(); - }, MSEC_1000 * 4); - }) - }) -} - -function test12() { - const MSEC_1000 = 1000; - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0120 - * @tc.name Thermal_JSTest0120 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_JSTest0120', 0, async function (done) { - thermal.subscribeThermalLevel((emergency) => { - console.info("emergency level is: " + emergency); - expect(emergency >= thermal.ThermalLevel.COOL && emergency <= thermal.ThermalLevel.EMERGENCY).assertTrue(); - done(); - }) - await new Promise((resolve, reject) => { - setTimeout(() => { - thermal.unsubscribeThermalLevel(() => { - console.info("unsubscribe successfully!"); - }); - resolve(); - }, MSEC_1000 * 4); - }) - }) -} - -function test13() { - const MSEC_1000 = 1000; - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0130 - * @tc.name Thermal_JSTest0130 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_JSTest0130', 0, async function (done) { - thermal.subscribeThermalLevel((cool) => { - console.info("cool level is: " + cool); - expect(cool >= thermal.ThermalLevel.COOL && cool <= thermal.ThermalLevel.EMERGENCY).assertTrue(); - done(); - }) - await new Promise((resolve, reject) => { - setTimeout(() => { - thermal.unsubscribeThermalLevel(() => { - console.info("unsubscribe successfully!"); - }); - resolve(); - }, MSEC_1000 * 4); - }) - }) -} \ No newline at end of file +// @ts-nocheck +/* + * 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 app from '@system.app' +import thermal from "@ohos.thermal" +import ThermalLevel from "@ohos.thermal" +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +export default function appInfoTest_thermal_2() { +describe('appInfoTest_thermal_2', function () { + console.log("*************Thermal API Test Begin*************"); + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); + test7(); + test8(); + test9(); + test10(); + test11(); + test12(); + test13(); + console.log("*************Thermal API Test End*************"); +}) + +function test1() { + const MSEC_1000 = 1000; + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0010 + * @tc.name Thermal_JSTest0010 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_JSTest0010', 0, async function (done) { + console.info("enter"); + await new Promise((resolve, reject) => { + setTimeout(() => { + let cold = thermal.getThermalLevel(); + console.info("cold level is: " + cold); + expect(cold >= thermal.ThermalLevel.COOL && cold <= thermal.ThermalLevel.EMERGENCY).assertTrue(); + resolve(); + done(); + }, MSEC_1000 * 1); + }) + }) +} + +function test2() { + const MSEC_1000 = 1000; + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0020 + * @tc.name Thermal_JSTest0020 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_JSTest0020', 0, async function (done) { + await new Promise((resolve, reject) => { + setTimeout(() => { + let warm = thermal.getThermalLevel(); + console.info("warm level is: " + warm); + expect(warm >= thermal.ThermalLevel.COOL && warm <= thermal.ThermalLevel.EMERGENCY).assertTrue(); + resolve(); + done(); + }, MSEC_1000 * 1); + }) + }) +} + +function test3() { + const MSEC_1000 = 1000; + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0030 + * @tc.name Thermal_JSTest0030 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_JSTest0030', 0, async function (done) { + await new Promise((resolve, reject) => { + setTimeout(() => { + let hot = thermal.getThermalLevel(); + console.info("hot level is: " + hot); + expect(hot >= thermal.ThermalLevel.COOL && hot <= thermal.ThermalLevel.EMERGENCY).assertTrue(); + resolve(); + done(); + }, MSEC_1000 * 1); + }) + }) +} + +function test4() { + const MSEC_1000 = 1000; + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0040 + * @tc.name Thermal_JSTest0040 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_JSTest0040', 0, async function (done) { + await new Promise((resolve, reject) => { + setTimeout(() => { + let overheated = thermal.getThermalLevel(); + console.info("overheated level is: " + overheated); + expect(overheated >= thermal.ThermalLevel.COOL && + overheated <= thermal.ThermalLevel.EMERGENCY).assertTrue(); + resolve(); + done(); + }, MSEC_1000 * 1); + }) + }) +} + +function test5() { + const MSEC_1000 = 1000; + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0050 + * @tc.name Thermal_JSTest0050 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_JSTest0050', 0, async function (done) { + await new Promise((resolve, reject) => { + setTimeout(() => { + let warning = thermal.getThermalLevel(); + console.info("warning level is: " + warning); + expect(warning >= thermal.ThermalLevel.COOL && warning <= thermal.ThermalLevel.EMERGENCY).assertTrue(); + resolve(); + done(); + }, MSEC_1000 * 1); + }) + }) +} + +function test6() { + const MSEC_1000 = 1000; + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0060 + * @tc.name Thermal_JSTest0060 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_JSTest0060', 0, async function (done) { + await new Promise((resolve, reject) => { + setTimeout(() => { + let emergency = thermal.getThermalLevel(); + console.info("emergency level is: " + emergency); + expect(emergency >= thermal.ThermalLevel.COOL && + emergency <= thermal.ThermalLevel.EMERGENCY).assertTrue(); + resolve(); + done(); + }, MSEC_1000 * 1); + }) + }) +} + +function test7() { + const MSEC_1000 = 1000; + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0070 + * @tc.name Thermal_JSTest0070 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_JSTest0070', 0, async function (done) { + thermal.subscribeThermalLevel((cool) => { + console.info("warm level is: " + cool); + expect(cool >= thermal.ThermalLevel.COOL && cool <= thermal.ThermalLevel.EMERGENCY).assertTrue(); + done(); + }) + await new Promise((resolve, reject) => { + setTimeout(() => { + thermal.unsubscribeThermalLevel(() => { + console.info("unsubscribe successfully!"); + }); + resolve(); + }, MSEC_1000 * 4); + }) + }) +} + +function test8() { + const MSEC_1000 = 1000; + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0080 + * @tc.name Thermal_JSTest0080 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_JSTest0080', 0, async function (done) { + thermal.subscribeThermalLevel((warm) => { + console.info("warm level is: " + warm); + expect(warm >= thermal.ThermalLevel.COOL && warm <= thermal.ThermalLevel.EMERGENCY).assertTrue(); + done(); + }) + await new Promise((resolve, reject) => { + setTimeout(() => { + thermal.unsubscribeThermalLevel(() => { + console.info("unsubscribe successfully!"); + }); + resolve(); + }, MSEC_1000 * 4); + }) + }) +} + +function test9() { + const MSEC_1000 = 1000; + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0090 + * @tc.name Thermal_JSTest0090 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_JSTest0090', 0, async function (done) { + thermal.subscribeThermalLevel((hot) => { + console.info("hot level is: " + hot); + expect(hot >= thermal.ThermalLevel.COOL && hot <= thermal.ThermalLevel.EMERGENCY).assertTrue(); + done(); + }) + await new Promise((resolve, reject) => { + setTimeout(() => { + thermal.unsubscribeThermalLevel(() => { + console.info("unsubscribe successfully!"); + }); + resolve(); + }, MSEC_1000 * 2); + }) + }) + +} + +function test10() { + const MSEC_1000 = 1000; + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0100 + * @tc.name Thermal_JSTest0100 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_JSTest0100', 0, async function (done) { + thermal.subscribeThermalLevel((overheated) => { + console.info("overheated level is: " + overheated); + expect(overheated >= thermal.ThermalLevel.COOL && + overheated <= thermal.ThermalLevel.EMERGENCY).assertTrue(); + done(); + }) + await new Promise((resolve, reject) => { + setTimeout(() => { + thermal.unsubscribeThermalLevel(() => { + console.info("unsubscribe successfully!"); + }); + resolve(); + }, MSEC_1000 * 2); + }) + }) +} + +function test11() { + const MSEC_1000 = 1000; + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0110 + * @tc.name Thermal_JSTest0110 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_JSTest0110', 0, async function (done) { + thermal.subscribeThermalLevel((warning) => { + console.info("warning level is: " + warning); + expect(warning >= thermal.ThermalLevel.COOL && warning <= thermal.ThermalLevel.EMERGENCY).assertTrue(); + done(); + }) + await new Promise((resolve, reject) => { + setTimeout(() => { + thermal.unsubscribeThermalLevel(() => { + console.info("unsubscribe successfully!"); + }); + resolve(); + }, MSEC_1000 * 4); + }) + }) +} + +function test12() { + const MSEC_1000 = 1000; + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0120 + * @tc.name Thermal_JSTest0120 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_JSTest0120', 0, async function (done) { + thermal.subscribeThermalLevel((emergency) => { + console.info("emergency level is: " + emergency); + expect(emergency >= thermal.ThermalLevel.COOL && emergency <= thermal.ThermalLevel.EMERGENCY).assertTrue(); + done(); + }) + await new Promise((resolve, reject) => { + setTimeout(() => { + thermal.unsubscribeThermalLevel(() => { + console.info("unsubscribe successfully!"); + }); + resolve(); + }, MSEC_1000 * 4); + }) + }) +} + +function test13() { + const MSEC_1000 = 1000; + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0130 + * @tc.name Thermal_JSTest0130 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_JSTest0130', 0, async function (done) { + thermal.subscribeThermalLevel((cool) => { + console.info("cool level is: " + cool); + expect(cool >= thermal.ThermalLevel.COOL && cool <= thermal.ThermalLevel.EMERGENCY).assertTrue(); + done(); + }) + await new Promise((resolve, reject) => { + setTimeout(() => { + thermal.unsubscribeThermalLevel(() => { + console.info("unsubscribe successfully!"); + }); + resolve(); + }, MSEC_1000 * 4); + }) + }) +}} diff --git a/powermgr/thermal_manager/src/main/js/default/test/thermal_unittest.test.js b/powermgr/thermal_manager/src/main/js/test/thermal_unittest.test.js similarity index 93% rename from powermgr/thermal_manager/src/main/js/default/test/thermal_unittest.test.js rename to powermgr/thermal_manager/src/main/js/test/thermal_unittest.test.js index 1da7f1376..22d727182 100644 --- a/powermgr/thermal_manager/src/main/js/default/test/thermal_unittest.test.js +++ b/powermgr/thermal_manager/src/main/js/test/thermal_unittest.test.js @@ -1,69 +1,70 @@ -/* - * 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 app from '@system.app' -import thermal from "@ohos.thermal" -import ThermalLevel from "@ohos.thermal" -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -const MSEC_1000 = 1000; - -describe('appInfoTest_thermal_1', function () { - console.log("*************Thermal API Test Begin*************"); - test14(); - test15(); -}) - -function test14() { - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0010 - * @tc.name Thermal_014 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_014', 0, async function (done) { - console.info("enter"); - await new Promise((resolve, reject) => { - setTimeout(() => { - let level = thermal.getThermalLevel(); - console.info("level is: " + level); - expect(level >= 0 && level <= 6).assertTrue(); - resolve(); - done(); - }, MSEC_1000 * 4); - }) - }) -} - -function test15() { - - /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0020 - * @tc.name Thermal_015 - * @tc.desc Thermal acquisition kit - */ - it('Thermal_015', 0, async function (done) { - thermal.subscribeThermalLevel((level) => { - console.info("level is: " + level); - expect(level >= 0 && level <= 6).assertTrue(); - done(); - }) - await new Promise((resolve, reject) => { - setTimeout(() => { - thermal.unsubscribeThermalLevel(() => { - console.info("unsubscribe successfully!"); - }); - resolve(); - }, MSEC_1000 * 4); - }) - }) -} \ No newline at end of file +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import app from '@system.app' +import thermal from "@ohos.thermal" +import ThermalLevel from "@ohos.thermal" +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +const MSEC_1000 = 1000; + +export default function appInfoTest_thermal_1() { +describe('appInfoTest_thermal_1', function () { + console.log("*************Thermal API Test Begin*************"); + test14(); + test15(); +}) + +function test14() { + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0010 + * @tc.name Thermal_014 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_014', 0, async function (done) { + console.info("enter"); + await new Promise((resolve, reject) => { + setTimeout(() => { + let level = thermal.getThermalLevel(); + console.info("level is: " + level); + expect(level >= 0 && level <= 6).assertTrue(); + resolve(); + done(); + }, MSEC_1000 * 4); + }) + }) +} + +function test15() { + + /* @tc.number USB_PowerSystem_ThermalManager_JSTest_0020 + * @tc.name Thermal_015 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_015', 0, async function (done) { + thermal.subscribeThermalLevel((level) => { + console.info("level is: " + level); + expect(level >= 0 && level <= 6).assertTrue(); + done(); + }) + await new Promise((resolve, reject) => { + setTimeout(() => { + thermal.unsubscribeThermalLevel(() => { + console.info("unsubscribe successfully!"); + }); + resolve(); + }, MSEC_1000 * 4); + }) + }) +}} diff --git a/powermgr/thermal_manager/src/main/resources/base/element/string.json b/powermgr/thermal_manager/src/main/resources/base/element/string.json index 83554c4c1..0568991c6 100644 --- a/powermgr/thermal_manager/src/main/resources/base/element/string.json +++ b/powermgr/thermal_manager/src/main/resources/base/element/string.json @@ -7,6 +7,22 @@ { "name": "mainability_description", "value": "JS_Phone_Empty Feature Ability" - } + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } ] } \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/BUILD.gn b/telephony/telephonyjstest/call_manager/BUILD.gn index afa53e6ce..81582258d 100644 --- a/telephony/telephonyjstest/call_manager/BUILD.gn +++ b/telephony/telephonyjstest/call_manager/BUILD.gn @@ -9,7 +9,7 @@ # 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. import("//test/xts/tools/build/suite.gni") diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/BUILD.gn b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/BUILD.gn index 235315030..db6294d47 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/BUILD.gn +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/BUILD.gn @@ -1,31 +1,33 @@ -# 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("ActsCallManagerIms2CallTest") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":hjs_demo_js_assets", - ":hjs_demo_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsCallManagerIms2CallTest" -} -ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./entry/src/main/js/default" -} -ohos_resources("hjs_demo_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} +# 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("ActsCallManagerIms2CallTest") { + hap_profile = "./src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsCallManagerIms2CallTest" +} +ohos_js_assets("hjs_demo_js_assets") { + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/Test.json b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/Test.json index 37539e4d7..b6f449333 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/Test.json +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/Test.json @@ -1,18 +1,20 @@ -{ - "description": "Configuration for ActsCallManagerIms2CallTest Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "1800000", - "package": "com.ohos.actscallmanagerims2calltest", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "$module.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} +{ + "description": "Configuration for ActsCallManagerIms2CallTest Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "1800000", + "bundle-name": "com.ohos.actscallmanagerims2calltest", + "package-name": "com.ohos.actscallmanagerims2calltest", + "shell-timeout": "1800000", + "testcase-timeout": "30000" + }, + "kits": [ + { + "test-file-name": [ + "$module.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/resources/base/element/string.json b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/resources/base/element/string.json deleted file mode 100644 index 2f9470d82..000000000 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "MyApplication" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/resources/base/element/string.json deleted file mode 100644 index 359c05368..000000000 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "CallManager" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/config.json b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/config.json similarity index 67% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/config.json rename to telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/config.json index 4f0547a2e..51e031a98 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/config.json +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/config.json @@ -1,107 +1,140 @@ -{ - "app": { - "bundleName": "com.ohos.actscallmanagerims2calltest", - "vendor": "ohos", - "version": { - "code": 1000000, - "name": "1.0.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5, - "releaseType": "Release" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.ohos.actscallmanagerims2calltest", - "name": ".MyApplication", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry" - }, - "abilities": [ - { - "visible": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "com.ohos.actscallmanagerims2calltest.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard" - } - ], - "reqPermissions": [ - { - "name": "ohos.permission.LOCATION", - "reason": "need use ohos.permission.LOCATION" - }, - { - "name":"ohos.permission.SET_TELEPHONY_STATE", - "reason":"need use ohos.permission.SET_TELEPHONY_STATE" - }, - { - "name":"ohos.permission.GET_TELEPHONY_STATE", - "reason":"need use ohos.permission.GET_TELEPHONY_STATE" - }, - { - "name":"ohos.permission.PLACE_CALL", - "reason":"need use ohos.permission.PLACE_CALL" - }, - { - "name":"ohos.permission.READ_CONTACTS", - "reason":"need use ohos.permission.READ_CONTACTS" - }, - { - "name":"ohos.permission.WRITE_CONTACTS", - "reason":"need use ohos.permission.WRITE_CONTACTS" - }, - { - "name":"ohos.permission.SEND_MESSAGES", - "reason":"need use ohos.permission.SEND_MESSAGES" - }, - { - "name":"ohos.permission.RECEIVE_SMS", - "reason":"need use ohos.permission.RECEIVE_SMS" - }, - { - "name":"ohos.permission.READ_CALL_LOG", - "reason":"need use ohos.permission.READ_CALL_LOG" - }, - { - "name":"ohos.permission.GET_NETWORK_INFO", - "reason":"need use ohos.permission.GET_NETWORK_INFO" - }, - { - "name":"ohos.permission.INTERNET", - "reason":"need use ohos.permission.INTERNET" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } +{ + "app": { + "bundleName": "com.ohos.actscallmanagerims2calltest", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Release" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.actscallmanagerims2calltest", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath":"", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.LOCATION", + "reason": "need use ohos.permission.LOCATION" + }, + { + "name":"ohos.permission.SET_TELEPHONY_STATE", + "reason":"need use ohos.permission.SET_TELEPHONY_STATE" + }, + { + "name":"ohos.permission.GET_TELEPHONY_STATE", + "reason":"need use ohos.permission.GET_TELEPHONY_STATE" + }, + { + "name":"ohos.permission.PLACE_CALL", + "reason":"need use ohos.permission.PLACE_CALL" + }, + { + "name":"ohos.permission.READ_CONTACTS", + "reason":"need use ohos.permission.READ_CONTACTS" + }, + { + "name":"ohos.permission.WRITE_CONTACTS", + "reason":"need use ohos.permission.WRITE_CONTACTS" + }, + { + "name":"ohos.permission.SEND_MESSAGES", + "reason":"need use ohos.permission.SEND_MESSAGES" + }, + { + "name":"ohos.permission.RECEIVE_SMS", + "reason":"need use ohos.permission.RECEIVE_SMS" + }, + { + "name":"ohos.permission.READ_CALL_LOG", + "reason":"need use ohos.permission.READ_CALL_LOG" + }, + { + "name":"ohos.permission.GET_NETWORK_INFO", + "reason":"need use ohos.permission.GET_NETWORK_INFO" + }, + { + "name":"ohos.permission.INTERNET", + "reason":"need use ohos.permission.INTERNET" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + } + } } \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/app.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/app.js new file mode 100644 index 000000000..9061142c5 --- /dev/null +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/app.js @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export default { + onCreate() { + console.info('TestApplication onCreate') + + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; + diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/i18n/en-US.json b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/i18n/en-US.json new file mode 100644 index 000000000..3cb24b374 --- /dev/null +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/i18n/zh-CN.json b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/i18n/zh-CN.json new file mode 100644 index 000000000..c804e32c0 --- /dev/null +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/pages/index/index.css b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/pages/index/index.css similarity index 93% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/pages/index/index.css rename to telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/pages/index/index.css index 6fda79275..5c52a87a0 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/pages/index/index.css +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/pages/index/index.css @@ -1,9 +1,9 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/pages/index/index.hml b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 000000000..f629c71a9 --- /dev/null +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/pages/index/index.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/pages/index/index.js similarity index 68% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/pages/index/index.js rename to telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/pages/index/index.js index 3d02d9362..4e0755497 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/pages/index/index.js +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/MainAbility/pages/index/index.js @@ -1,48 +1,42 @@ -/* - * 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 file from '@system.file' -import app from '@system.app' -import device from '@system.device' -import router from '@system.router' -import {Core, ExpectExtend} from 'deccjsunit/index' - -const injectRef = Object.getPrototypeOf(global) || global -injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - core.init() - const configService = core.getDefaultService('config') - this.timeout = 30000; - configService.setConfig(this) - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} +/* + * 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 file from '@system.file' +import app from '@system.app' +import device from '@system.device' +import router from '@system.router' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onReady() { + }, +} diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/app.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/app.js similarity index 91% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/app.js rename to telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/app.js index c1a2274b0..e64117c26 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/default/app.js +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/app.js @@ -1,23 +1,23 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export default { - onCreate() { - console.info('TestApplication onCreate'); - }, - onDestroy() { - console.info('TestApplication onDestroy'); - } -}; +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export default { + onCreate() { + console.info('TestApplication onCreate'); + }, + onDestroy() { + console.info('TestApplication onDestroy'); + } +}; + diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/i18n/en-US.json b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 000000000..3cb24b374 --- /dev/null +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/i18n/zh-CN.json b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 000000000..c804e32c0 --- /dev/null +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/pages/index/index.css b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 000000000..b1bcd4338 --- /dev/null +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,30 @@ +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/pages/index/index.hml b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 000000000..f629c71a9 --- /dev/null +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/pages/index/index.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 000000000..88b083a7f --- /dev/null +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 000000000..05ba57825 --- /dev/null +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/CallManageAll.test.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/CallManageAll.test.js similarity index 97% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/CallManageAll.test.js rename to telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/CallManageAll.test.js index e59ba2cb1..485f8dab9 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/CallManageAll.test.js +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/CallManageAll.test.js @@ -1,1030 +1,1033 @@ -/** - * 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 call from '@ohos.telephony.call'; -import observer from '@ohos.telephony.observer'; -import {describe, afterAll, it, expect, beforeAll, afterEach} from 'deccjsunit/index'; -import { - AUTO_ACCEPT_NUMBER, - AUTO_ACCEPT_NUMBER2, - PHONE_NUMBER_LENGTH_11, - CALL_STATUS_DIALING, - CALL_ID_NOT_EXIST, - CALL_STATE_UNKNOWN, - CALL_STATE_IDLE, - DEFAULT_SLOT_ID, - CALL_MODE_IMS, - SLOT_ID_INVALID, - PHONE_LIST2, - RTT_MSG, - CALL_MODE_SEND_RECEIVE, - POS_700, - POS_10, - POS_LENGTH_300, - POS_LENGTH_600, - DEVICE_EARPIECE, - BOUNDARY_NUMBER_INT, - SENT_STRING_C, - MINUS_VALUE, - PHONE_NUMBER_LONG, - NULL_PHONE_NUMBER, - DIAL_CARRIER_TYPE, - DIAL_SCENCE_CALL_PRIVILEGED, - MEDIA_TYPE_VOICE, - ROTATION_MINUS_1, - IMAGE_LOCAL_ERROR_PATH, - POS_Z_ERROR, - RESTRICTION_TYPE_ROAMING_INCOMING, - RESTRICTION_MODE_ACTIVATION, - RIGHT_PASSWORD, - RESTRICTION_TYPE_ALL_INCOMING, - TRANSFER_TYPE_NOT_REACHABLE, - TRANSFER_TYPE_UNCONDITIONAL, - PHONE_NUMBER_AREA_LAND, - CALL_TRANSFER_DISABLE, - TRANSFER_TYPE_NO_REPLY, - COMMAND_CALL_ERROR4, - COMMAND_CALL_ERROR, - CARMER_ID_NOT_EXIT, - ZOOM_RATIO_MINUS_1_0, - DIAL_SCENCE_CALL_NORMAL, - DIAL_TYPE_OTT, - EVENT_OTT_FUNCTION_UNSUPPORTED, - TEL_CONFERENCE_IDLE -} from './lib/Const.js'; -import {toString} from './lib/ApiToPromise.js'; -import { - scenceInCalling, - hangupCall2, - hangupCall, - callDetailsChangeOn, - callId as gloabCallId, - reachState, - callDetailsChangeOff, - reachCallEventState -} from './lib/ScenceInCalling.js'; -const GETMAIN_CALLID_ERRO = -1; -const REJECT_MESSAGE_STR = 'Hi,hello?'; -const REJECT_MESSAGE_NUM = 1234567890123456789012345678901234567890; -const ERR_SLOT_ID = -1; -const SLOTID = 0; -const THE_THREE_NUMBER = '112'; -const DIAL_TYPE_ERR_CALL = 3; -const TIME_OUT = 20000; -const WAITING_TIME = 200; - -let callId = null; -class RejectMessageOptions { - constructor (str) { - this.messageContent = str; - } -} -class EmergencyNumberOptions { - constructor (num) { - this.slotId = num; - } -} -class NumberFormatOptions { - constructor (str) { - this.countryCode = str; - } -} -class CallAttributeOptions { - constructor (accountNumber, speakerphoneOn, accountId, videoState, startTime, - isEcc, callType, callId, callState, conferenceState) { - this.accountNumber = accountNumber; - this.speakerphoneOn = speakerphoneOn; - this.accountId = accountId; - this.videoState = videoState; - this.startTime = startTime; - this.isEcc = isEcc; - this.callType = callType; - this.callId = callId; - this.callState = callState; - this.conferenceState = conferenceState; - } -} - -const sleep = (time) => { - return new Promise((resolve, reject) => { - setTimeout(() => { - resolve(); - }, time); - }); -}; - -var callState = -1; -var timing = 0; -var endTime = 0; -describe('CallManageImsCall', function () { - beforeAll(async function (done) { - try { - console.log('Telephony_CallManager enableImsSwitch success'); - await call.setCallPreferenceMode(DEFAULT_SLOT_ID, CALL_MODE_IMS); - console.log('Telephony_CallManager setCallPreferenceMode success'); - } catch (error) { - console.log(`Telephony_CallManager setCallPreferenceMode or enableImsSwitch error,error:${toString(error)}`); - } - done(); - }); - - afterEach(async function () { - try { - const CURRENT_TIME = new Date().valueOf(); - const TEMP_CALL_ID = 10; - const IS_ECC = true; - const SPEAK_ON = true; - let callAttributeOptions = new CallAttributeOptions(AUTO_ACCEPT_NUMBER, SPEAK_ON, DEFAULT_SLOT_ID, - MEDIA_TYPE_VOICE, CURRENT_TIME, IS_ECC, DIAL_TYPE_OTT, TEMP_CALL_ID, CALL_STATUS_DIALING, - TEL_CONFERENCE_IDLE); - console.log(`Telephony_CallManager ${toString(callAttributeOptions)}`); - expect(callAttributeOptions.accountNumber === AUTO_ACCEPT_NUMBER).assertTrue(); - expect(callAttributeOptions.speakerphoneOn === SPEAK_ON).assertTrue(); - expect(callAttributeOptions.accountId === DEFAULT_SLOT_ID).assertTrue(); - expect(callAttributeOptions.videoState === MEDIA_TYPE_VOICE).assertTrue(); - expect(callAttributeOptions.startTime === CURRENT_TIME).assertTrue(); - expect(callAttributeOptions.isEcc === IS_ECC).assertTrue(); - expect(callAttributeOptions.callType === DIAL_TYPE_OTT).assertTrue(); - expect(callAttributeOptions.callId === TEMP_CALL_ID).assertTrue(); - expect(callAttributeOptions.callState === CALL_STATUS_DIALING).assertTrue(); - expect(callAttributeOptions.conferenceState === TEL_CONFERENCE_IDLE).assertTrue(); - } catch (error) { - console.log(`Telephony_CallManager ${toString(error)}`); - } - try { - let callState = await call.getCallState(); - console.log(`Telephony_CallManager callState ${callState} ${gloabCallId}`); - if (callState === CALL_STATE_UNKNOWN || callState === CALL_STATE_IDLE) { - return; - } - if (gloabCallId) { - let data = await hangupCall('Telephony_CallManager', gloabCallId); - console.log(`Telephony_CallManager hangupCall success ${toString(data)}`); - } - } catch (error) { - console.log('Telephony_CallManager hangupCall or getCallState error'); - } - }); - - afterAll(function () { - observer.off('callStateChange'); - callDetailsChangeOff(); - console.log('Telephony_CallManager all 54 case is over for callmanager CallManageImsCall'); - }); - - /** - * @tc.number Telephony_CallManager_IMS_enableLteEnhanceMode_Async_0400 - * @tc.name Run the function enableLteEnhanceMode by args slotId SLOT_ID_INVALID, - * by callback,the function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_IMS_enableLteEnhanceMode_Async_0400', 0, function (done) { - let caseName = 'Telephony_CallManager_IMS_enableLteEnhanceMode_Async_0400'; - call.enableLteEnhanceMode(SLOT_ID_INVALID, (error, data) => { - if (error) { - console.log(`${caseName} enableLteEnhanceMode error,case success,error:${toString(error)}`); - done(); - return; - } - expect().assertFail(); - console.log(`${caseName} enableLteEnhanceMode success,case failed,data:${toString(data)}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_IMS_enableLteEnhanceMode_Promise_0400 - * @tc.name Run the function enableLteEnhanceMode by args slotId SLOT_ID_INVALID by promise, - * the function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_IMS_enableLteEnhanceMode_Promise_0400', 0, function (done) { - let caseName = 'Telephony_CallManager_IMS_enableLteEnhanceMode_Promise_0400'; - call.enableLteEnhanceMode(SLOT_ID_INVALID).then(data => { - expect().assertFail(); - console.log(`${caseName} enableLteEnhanceMode success,case failed,data:${toString(data)}`); - done(); - }).catch(error => { - console.log(`${caseName} enableLteEnhanceMode error,case success,error:${toString(error)}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_IMS_disableLteEnhanceMode_Async_0400 - * @tc.name Run the function disableLteEnhanceMode by args slotId SLOT_ID_INVALID, - * by callback,the function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_IMS_disableLteEnhanceMode_Async_0400', 0, function (done) { - let caseName = 'Telephony_CallManager_IMS_disableLteEnhanceMode_Async_0400'; - call.disableLteEnhanceMode(SLOT_ID_INVALID, (error, data) => { - if (error) { - console.log(`${caseName} disableLteEnhanceMode error,case success,error:${toString(error)}`); - done(); - return; - } - expect().assertFail(); - console.log(`${caseName} disableLteEnhanceMode success,case failed,data:${toString(data)}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_IMS_disableLteEnhanceMode_Promise_0400 - * @tc.name Run the function disableLteEnhanceMode by args slotId SLOT_ID_INVALID by promise, - * the function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_IMS_disableLteEnhanceMode_Promise_0400', 0, function (done) { - let caseName = 'Telephony_CallManager_IMS_disableLteEnhanceMode_Promise_0400'; - call.disableLteEnhanceMode(SLOT_ID_INVALID).then(data => { - expect().assertFail(); - console.log(`${caseName} disableLteEnhanceMode success,case failed,data:${toString(data)}`); - done(); - }).catch(error => { - console.log(`${caseName} disableLteEnhanceMode error,case success,error:${toString(error)}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_IMS_isLteEnhanceModeEnabled_Async_0400 - * @tc.name Run the function isLteEnhanceModeEnabled by args slotId SLOT_ID_INVALID by callback, - * the function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_IMS_isLteEnhanceModeEnabled_Async_0400', 0, function (done) { - let caseName = 'Telephony_CallManager_IMS_isLteEnhanceModeEnabled_Async_0400'; - call.isLteEnhanceModeEnabled(SLOT_ID_INVALID, (error, data) => { - if (error) { - console.log(`${caseName} isLteEnhanceModeEnabled error,case success,error:${toString(error)}`); - done(); - return; - } - expect().assertFail(); - console.log(`${caseName} isLteEnhanceModeEnabled success,case failed,data:${toString(data)}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_IMS_isLteEnhanceModeEnabled_Promise_0400 - * @tc.name Run the function isLteEnhanceModeEnabled by args slotId SLOT_ID_INVALID by promise, - * the function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_IMS_isLteEnhanceModeEnabled_Promise_0400', 0, function (done) { - let caseName = 'Telephony_CallManager_IMS_isLteEnhanceModeEnabled_Promise_0400'; - call.isLteEnhanceModeEnabled(SLOT_ID_INVALID).then(data => { - expect().assertFail(); - console.log(`${caseName} isLteEnhanceModeEnabled success,case failed,data:${toString(data)}`); - done(); - }).catch(error => { - console.log(`${caseName} isLteEnhanceModeEnabled error,case success,error:${toString(error)}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_IMS_startRTT_Async_0200 - * @tc.name Run function startRTT by args callId CALL_ID_NOT_EXIST,msg RTT_MSG by callback, - * the function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_IMS_startRTT_Async_0200', 0, function (done) { - let caseName = 'Telephony_CallManager_IMS_startRTT_Async_0200'; - call.startRTT(CALL_ID_NOT_EXIST, RTT_MSG, (error, data) => { - if (error) { - console.log(`${caseName} startRTT ${callId} error,case success,error:${toString(error)}`); - done(); - return; - } - expect().assertFail(); - console.log(`${caseName} startRTT success,case failed,data:${toString(data)}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_IMS_startRTT_Promise_0200 - * @tc.name Run function startRTT by args callId CALL_ID_NOT_EXIST,msg RTT_MSG by callback, - * the function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_IMS_startRTT_Promise_0200', 0, function (done) { - let caseName = 'Telephony_CallManager_IMS_startRTT_Promise_0200'; - call.startRTT(CALL_ID_NOT_EXIST, RTT_MSG).then(data => { - expect().assertFail(); - console.log(`${caseName} startRTT success,case failed,data:${toString(data)}`); - done(); - }).catch(error => { - console.log(`${caseName} startRTT ${callId} error,case success,error:${toString(error)}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_IMS_stopRTT_Async_0200 - * @tc.name Run function stopRTT by args callId CALL_ID_NOT_EXIST by callback,the function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_IMS_stopRTT_Async_0200', 0, function (done) { - let caseName = 'Telephony_CallManager_IMS_stopRTT_Async_0200'; - call.stopRTT(CALL_ID_NOT_EXIST, (error, data) => { - if (error) { - console.log(`${caseName} stopRTT ${callId} error,case success,error:${toString(error)}`); - done(); - return; - } - expect().assertFail(); - console.log(`${caseName} stopRTT success,case failed,data:${toString(data)}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_IMS_stopRTT_Promise_0200 - * @tc.name Run function stopRTT by args callId CALL_ID_NOT_EXIST by callback,the function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_IMS_stopRTT_Promise_0200', 0, function (done) { - let caseName = 'Telephony_CallManager_IMS_stopRTT_Promise_0200'; - call.stopRTT(CALL_ID_NOT_EXIST).then(data => { - expect().assertFail(); - console.log(`${caseName} stopRTT success,case failed,data:${toString(data)}`); - done(); - }).catch(error => { - console.log(`${caseName} stopRTT ${callId} error,case success,error:${toString(error)}`); - done(); - }); - }); - - - /** - * @tc.number Telephony_CallManager_controlCamera_Async_0200 - * @tc.name Dial a call and after answering the call,run function controlCamera by - * args cameraId CARMER_ID_NOT_EXIT by callback, - * the callback function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_controlCamera_Async_0200', 0, function (done) { - let caseName = 'Telephony_CallManager_controlCamera_Async_0200'; - scenceInCalling({ - caseName:caseName, - phoneNumber:AUTO_ACCEPT_NUMBER2, - checkState:CALL_STATUS_DIALING - }).then(data => { - callId = data.callId; - let cameraId = CARMER_ID_NOT_EXIT; - call.controlCamera(cameraId, (error) => { - if (error) { - console.log(`${caseName} error,case success,error:${toString(error)}`); - hangupCall2(caseName, done, callId); - return; - } - console.log(`${caseName} case failed`); - expect().assertFail(); - hangupCall2(caseName, done, callId); - }); - }).catch(error => { - console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_controlCamera_Promise_0200 - * @tc.name Dial a call and after answering the call,run function controlCamera by args cameraId - * CARMER_ID_NOT_EXIT by promise,the function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_controlCamera_Promise_0200', 0, async function (done) { - let caseName = 'Telephony_CallManager_controlCamera_Promise_0200'; - let cameraId = CARMER_ID_NOT_EXIT; - try { - let data = await scenceInCalling({ - caseName:caseName, - phoneNumber:AUTO_ACCEPT_NUMBER2, - checkState:CALL_STATUS_DIALING - }); - callId = data.callId; - } catch (error) { - console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); - done(); - return; - } - try { - await call.controlCamera(cameraId); - console.log(`${caseName} case failed`); - expect().assertFail(); - } catch (err) { - console.log(`${caseName} case success. error:${toString(err)}`); - } - hangupCall2(caseName, done, callId); - }); - - /** - * @tc.number Telephony_CallManager_setPreviewWindow_Async_0300 - * @tc.name Dial a call and after answering the call,run function setPreviewWindow by args - * x POS_700,y POS_10,z POS_Z_ERROR,width POS_LENGTH_300,height POS_LENGTH_600 by callback, - * the callback function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_setPreviewWindow_Async_0300', 0, function (done) { - let caseName = 'Telephony_CallManager_setPreviewWindow_Async_0300'; - scenceInCalling({ - caseName:caseName, - phoneNumber:AUTO_ACCEPT_NUMBER, - checkState:CALL_STATUS_DIALING - }).then(data => { - callId = data.callId; - let info = {x: POS_700, y: POS_10, z: POS_Z_ERROR, width: POS_LENGTH_300, height: POS_LENGTH_600}; - call.setPreviewWindow(info, (error) => { - if (error) { - console.log(`${caseName} error,case success,error:${toString(error)}`); - hangupCall2(caseName, done, callId); - return; - } - console.log(`${caseName} case faild`); - expect().assertFail(); - hangupCall2(caseName, done, callId); - }); - }).catch(error => { - console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_setPreviewWindow_Promise_0300 - * @tc.name Dial a call and after answering the call,run function setPreviewWindow by args - * x POS_700,y POS_10,z POS_Z_ERROR,width POS_LENGTH_300,height POS_LENGTH_600 by promise, - * the function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_setPreviewWindow_Promise_0300', 0, async function (done) { - let caseName = 'Telephony_CallManager_setPreviewWindow_Promise_0300'; - try { - let data = await scenceInCalling({ - caseName:caseName, - phoneNumber:AUTO_ACCEPT_NUMBER, - checkState:CALL_STATUS_DIALING - }); - callId = data.callId; - } catch (error) { - console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); - done(); - return; - } - try { - let info = {x: POS_700, y: POS_10, z: POS_Z_ERROR, width: POS_LENGTH_300, height: POS_LENGTH_600}; - await call.setPreviewWindow(info); - console.log(`${caseName} case faild`); - expect().assertFail(); - } catch (error) { - console.log(`${caseName} error,case success,error:${toString(error)}`); - } - hangupCall2(caseName, done, callId); - }); - - /** - * @tc.number Telephony_CallManager_setDisplayWindow_Async_0300 - * @tc.name Dial a call and after answering the call,run function setDisplayWindow by args - * x POS_700,y POS_10,z POS_Z_ERROR,width POS_LENGTH_300,height POS_LENGTH_600 by callback, - * the callback function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_setDisplayWindow_Async_0300', 0, async function (done) { - let caseName = 'Telephony_CallManager_setDisplayWindow_Async_0300'; - try { - let data = await scenceInCalling({ - caseName:caseName, - phoneNumber:AUTO_ACCEPT_NUMBER, - checkState:CALL_STATUS_DIALING - }); - callId = data.callId; - } catch (error) { - console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); - done(); - return; - } - try { - let info = {x: POS_700, y: POS_10, z: POS_Z_ERROR, width: POS_LENGTH_300, height: POS_LENGTH_600}; - await call.setDisplayWindow(info); - console.log(`${caseName} case faild`); - expect().assertFail(); - } catch (error) { - console.log(`${caseName} error,case success,error:${toString(error)}`); - } - hangupCall2(caseName, done, callId); - }); - - /** - * @tc.number Telephony_CallManager_setDisplayWindow_Promise_0300 - * @tc.name Dial a call and after answering the call,run function setDisplayWindow by args - * x POS_700,y POS_10,z POS_Z_ERROR,width POS_LENGTH_300,height POS_LENGTH_600 by promise, - * the function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_setDisplayWindow_Promise_0300', 0, async function (done) { - let caseName = 'Telephony_CallManager_setDisplayWindow_Promise_0300'; - try { - let data = await scenceInCalling({ - caseName:caseName, - phoneNumber:AUTO_ACCEPT_NUMBER, - checkState:CALL_STATUS_DIALING - }); - callId = data.callId; - } catch (error) { - console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); - done(); - return; - } - try { - let info = {x: POS_700, y: POS_10, z: POS_Z_ERROR, width: POS_LENGTH_300, height: POS_LENGTH_600}; - await call.setDisplayWindow(info); - console.log(`${caseName} case faild`); - expect().assertFail(); - } catch (error) { - console.log(`${caseName} error,case success,error:${toString(error)}`); - } - hangupCall2(caseName, done, callId); - }); - - /** - * @tc.number Telephony_CallManager_setCameraZoom_Async_0400 - * @tc.name Dial a call and after answering the call,run function setCameraZoom by args - * zoomRatio ZOOM_RATIO_MINUS_1_0 by callback,the callback function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_setCameraZoom_Async_0400', 0, function (done) { - let caseName = 'Telephony_CallManager_setCameraZoom_Async_0400'; - scenceInCalling({ - caseName:caseName, - phoneNumber:AUTO_ACCEPT_NUMBER2, - checkState:CALL_STATUS_DIALING - }).then(data => { - callId = data.callId; - call.setCameraZoom(ZOOM_RATIO_MINUS_1_0, (error) => { - if (error) { - console.log(`${caseName} error,case success,error:${toString(error)}`); - hangupCall2(caseName, done, callId); - return; - } - console.log(`${caseName} case failed`); - expect().assertFail(); - hangupCall2(caseName, done, callId); - }); - }).catch(error => { - console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_setCameraZoom_Promise_0400 - * @tc.name Dial a call and after answering the call,run function setCameraZoom by args - * zoomRatio ZOOM_RATIO_MINUS_1_0 by promise,the function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_setCameraZoom_Promise_0400', 0, async function (done) { - let caseName = 'Telephony_CallManager_setCameraZoom_Promise_0400'; - try { - let data = await scenceInCalling({ - caseName:caseName, - phoneNumber:AUTO_ACCEPT_NUMBER, - checkState:CALL_STATUS_DIALING - }); - callId = data.callId; - } catch (error) { - console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); - done(); - return; - } - try { - await call.setCameraZoom(ZOOM_RATIO_MINUS_1_0); - console.log(`${caseName} case failed`); - expect().assertFail(); - } catch (error) { - console.log(`${caseName} error,case success,error:${toString(error)}`); - } - hangupCall2(caseName, done, callId); - }); - - /** - * @tc.number Telephony_CallManager_setPausePicture_Async_0500 - * @tc.name Dial a call and after answering the call,run function setPausePicture by args - * path IMAGE_LOCAL_ERROR_PATH by callback,the callback function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_setPausePicture_Async_0500', 0, function (done) { - let caseName = 'Telephony_CallManager_setPausePicture_Async_0500'; - scenceInCalling({ - caseName:caseName, - phoneNumber:AUTO_ACCEPT_NUMBER, - checkState:CALL_STATUS_DIALING - }).then(data => { - callId = data.callId; - call.setPausePicture(IMAGE_LOCAL_ERROR_PATH, (error) => { - if (error) { - console.log(`${caseName} case success,error:${toString(error)}`); - hangupCall2(caseName, done, callId); - return; - } - console.log(`${caseName} success,case failed`); - hangupCall2(caseName, done, callId); - }); - }).catch(error => { - console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_setPausePicture_Promise_0500 - * @tc.name Dial a call and after answering the call,run function setPausePicture - * by args path IMAGE_LOCAL_ERROR_PATH by promise, - * the callback function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_setPausePicture_Promise_0500', 0, async function (done) { - let caseName = 'Telephony_CallManager_setPausePicture_Promise_0500'; - try { - let data = await scenceInCalling({ - caseName:caseName, - phoneNumber:AUTO_ACCEPT_NUMBER, - checkState:CALL_STATUS_DIALING - }); - callId = data.callId; - } catch (error) { - console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); - done(); - return; - } - try { - await call.setPausePicture(IMAGE_LOCAL_ERROR_PATH); - console.log(`${caseName} success,case failed`); - } catch (error) { - console.log(`${caseName} case success,error:${toString(error)}`); - } - hangupCall2(caseName, done, callId); - }); - - /** - * @tc.number Telephony_CallManager_setDeviceDirection_Async_0500 - * @tc.name Dial a call and after answering the call,run function setDeviceDirection - * by args rotation ROTATION_MINUS_1 by callback,the callback function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_setDeviceDirection_Async_0500', 0, function (done) { - let caseName = 'Telephony_CallManager_setDeviceDirection_Async_0500'; - scenceInCalling({ - caseName:caseName, - phoneNumber:AUTO_ACCEPT_NUMBER, - checkState:CALL_STATUS_DIALING - }).then(data => { - callId = data.callId; - call.setDeviceDirection(ROTATION_MINUS_1, (error) => { - if (error) { - console.log(`${caseName} success, case success`); - hangupCall2(caseName, done, callId); - return; - } - console.log(`${caseName} error,case failed,error:${toString(error)}`); - expect().assertFail(); - hangupCall2(caseName, done, callId); - }); - }).catch(error => { - console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_setDeviceDirection_Promise_0500 - * @tc.name Dial a call and after answering the call,run function setDeviceDirection - * by args rotation ROTATION_MINUS_1 by promise,the callback function return error - * @tc.desc Function test - */ - it('Telephony_CallManager_setDeviceDirection_Promise_0500', 0, async function (done) { - let caseName = 'Telephony_CallManager_setDeviceDirection_Promise_0500'; - try { - let data = await scenceInCalling({ - caseName:caseName, - phoneNumber:AUTO_ACCEPT_NUMBER2, - checkState:CALL_STATUS_DIALING - }); - callId = data.callId; - } catch (error) { - console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); - done(); - return; - } - try { - await call.setDeviceDirection(ROTATION_MINUS_1); - console.log(`${caseName} success,case error`); - expect().assertFail(); - } catch (error) { - console.log(`${caseName} case success,error:${toString(error)}`); - } - hangupCall2(caseName, done, callId); - }); - - /** - * @tc.number Telephony_CallManager_getCallState_Async_0100 - * @tc.name To get the idle call status, call getCallState() to get the current call status. - * call.CALL_STATE_IDLE is returned - * @tc.desc Function test - */ - it('Telephony_CallManager_getCallState_Async_0100', 0, async function (done) { - call.getCallState((err, data) => { - if (err) { - console.log(`Telephony_CallManager_getCallState_Async_0100 : err = ${err.message}`); - expect().assertFail(); - done(); - return; - } - expect(data == call.CALL_STATE_IDLE || - data == call.CALL_STATE_UNKNOWN || - data == call.CALL_STATE_RINGING || - data == call.CALL_STATE_OFFHOOK).assertTrue(); - console.log(`Telephony_CallManager_getCallState_Async_0100 finish data = ${data}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_getCallState_Promise_0100 - * @tc.name To get the idle call status, call getCallState() to get the current call status. - * call.CALL_STATE_IDLE is returned - * @tc.desc Function test - */ - it('Telephony_CallManager_getCallState_Promise_0100', 0, async function (done) { - try { - var data = await call.getCallState(); - expect(data == call.CALL_STATE_IDLE || - data == call.CALL_STATE_UNKNOWN || - data == call.CALL_STATE_RINGING || - data == call.CALL_STATE_OFFHOOK).assertTrue(); - console.log(`Telephony_CallManager_getCallState_Promise_0100 finish data = ${data}`); - done(); - } catch (err) { - console.log(`Telephony_CallManager_getCallState_Promise_0100 : err = ${err.message}`); - expect().assertFail(); - done(); - - } - }); - - /** - * @tc.number Telephony_CallManager_hasCall_Async_0400 - * @tc.name When idle, hasCall() is called to confirm that there is no current call,returning false - * @tc.desc Function test - */ - it('Telephony_CallManager_hasCall_Async_0400', 0, async function (done) { - call.hasCall((err, data) => { - if (err) { - console.log('Telephony_CallManager_hasCall_Async_0400 fail'); - expect().assertFail(); - done(); - return; - } - console.log(`Telephony_CallManager_hasCall_Async_0400 finish data = ${data}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_hasCall_Promise_0400 - * @tc.name When idle, hasCall() is called to confirm that there is no current call, returning false - * @tc.desc Function test - */ - it('Telephony_CallManager_hasCall_Promise_0400', 0, async function (done) { - try { - var data = await call.hasCall(); - console.log(`Telephony_CallManager_hasCall_Promise_0400 finish data = ${data}`); - done(); - } catch (err) { - console.log('Telephony_CallManager_hasCall_Promise_0400 fail'); - expect().assertFail(); - done(); - - } - }); - - /** - * @tc.number Telephony_CallManager_formatPhoneNumber_Async_0100 - * @tc.name PhoneNumber is 100000000000. Call formatPhoneNumber() to format the number. - * The return value is 10 000 000 0000 - * @tc.desc Function test - */ - it('Telephony_CallManager_formatPhoneNumber_Async_0100', 0, async function (done) { - call.formatPhoneNumber('100000000000', (err, data) => { - if (err) { - console.log(`Telephony_CallManager_formatPhoneNumber_Async_0100 err = ${err.message}`); - console.log('Telephony_CallManager_formatPhoneNumber_Async_0100 fail'); - expect().assertFail(); - done(); - return; - } - expect(data === '10 000 000 0000').assertTrue(); - console.log(`Telephony_CallManager_formatPhoneNumber_Async_0100 finish data = ${data}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_formatPhoneNumber_Promise_0100 - * @tc.name PhoneNumber is 2000000. Call formatPhoneNumber() to format the number. - * The return value is 200 0000 - * @tc.desc Function test - */ - it('Telephony_CallManager_formatPhoneNumber_Promise_0100', 0, async function (done) { - try { - var data = await call.formatPhoneNumber('2000000'); - expect(data === '200 0000').assertTrue(); - console.log(`Telephony_CallManager_formatPhoneNumber_Promise_0100 finish data = ${data}`); - done(); - } catch (err) { - console.log('Telephony_CallManager_formatPhoneNumber_Promise_0100 fail'); - expect().assertFail(); - done(); - - } - }); - - /** - * @tc.number Telephony_CallManager_formatPhoneNumber_Async_0200 - * @tc.name testFormatPhoneNumber_0200 - * @tc.desc PhoneNumber is 13900000000, options: CN, test formatPhoneNumber() api by callback. - * The return value is 139 0000 0000 - */ - it('Telephony_CallManager_formatPhoneNumber_Async_0200', 0, async function (done) { - let numberFormatOptions = new NumberFormatOptions('CN'); - call.formatPhoneNumber('13900000000', numberFormatOptions, (err, data) => { - if (err) { - console.log(`Telephony_CallManager_formatPhoneNumber_Async_0200 err = ${err.message}`); - console.log('Telephony_CallManager_formatPhoneNumber_Async_0200 fail'); - expect().assertFail(); - done(); - return; - } - expect(data === '139 0000 0000').assertTrue(); - console.log(`Telephony_CallManager_formatPhoneNumber_Async_0200 finish data = ${data}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_formatPhoneNumber_Async_0300 - * @tc.name testFormatPhoneNumber_0300 - * @tc.desc PhoneNumber is 13900000000, options: US, test formatPhoneNumber() api by promise. - * The return value is '1 390-000-0000' - */ - it('Telephony_CallManager_formatPhoneNumber_Promise_0200', 0, async function (done) { - let numberFormatOptions = new NumberFormatOptions('US'); - try { - var data = await call.formatPhoneNumber('13900000000', numberFormatOptions); - expect(data === '1 390-000-0000').assertTrue(); - console.log(`Telephony_CallManager_formatPhoneNumber_Promise_0200 finish data = ${data}`); - done(); - } catch (err) { - console.log('Telephony_CallManager_formatPhoneNumber_Promise_0200 fail'); - expect().assertFail(); - done(); - } - }); - - /** - * @tc.number Telephony_CallManager_formatPhoneNumberToE164_Async_0100 - * @tc.name PhoneNumber is 010-0000-0000, options: CN, call formatPhoneNumberToE164() to format the number, - * and return +861000000000 - * @tc.desc Function test - */ - it('Telephony_CallManager_formatPhoneNumberToE164_Async_0100', 0, async function (done) { - let numberFormatOptions = new NumberFormatOptions('CN'); - call.formatPhoneNumberToE164('010-0000-0000', numberFormatOptions.countryCode, (err, data) => { - if (err) { - console.log('Telephony_CallManager_formatPhoneNumberToE164_Async_0100 fail'); - expect().assertFail(); - done(); - return; - } - expect(data === '+861000000000').assertTrue(); - console.log(`Telephony_CallManager_formatPhoneNumberToE164_Async_0100 finish data = ${data}`); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_formatPhoneNumberToE164_Promise_0100 - * @tc.name PhoneNumber is 52300000000, options: CN, call formatPhoneNumberToE164() to format the number, - * return +8652300000000 - * @tc.desc Function test - */ - it('Telephony_CallManager_formatPhoneNumberToE164_Promise_0100', 0, async function (done) { - let numberFormatOptions = new NumberFormatOptions('CN'); - try { - var data = await call.formatPhoneNumberToE164('52300000000', numberFormatOptions.countryCode); - expect(data === '+8652300000000').assertTrue(); - console.log(`Telephony_CallManager_formatPhoneNumberToE164_Promise_0100 finish data = ${data}`); - done(); - } catch (err) { - console.log('Telephony_CallManager_formatPhoneNumberToE164_Promise_0100 fail'); - expect().assertFail(); - done(); - - } - }); - - /** - * @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Async_1300 - * @tc.name PhoneNumber: 110, options -1. Call isEmergencyPhoneNumber() to check whether it is an emergency - * number. The return value is false - * @tc.desc Function test - */ - it('Telephony_CallManager_isEmergencyPhoneNumber_Async_1300', 0, async function (done) { - let emergencyNumberOptions = new EmergencyNumberOptions(ERR_SLOT_ID); - call.isEmergencyPhoneNumber('110', emergencyNumberOptions, (err) => { - if (err) { - console.log(`Telephony_CallManager_isEmergencyPhoneNumber_Async_1300 finish err = ${err}`); - done(); - return; - } - expect().assertFail(); - console.log('Telephony_CallManager_isEmergencyPhoneNumber_Async_1300 fail '); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Promise_1300 - * @tc.name PhoneNumber: 120, options -1. Call isEmergencyPhoneNumber() to check whether it is an emergency - * number. The return value is false - * @tc.desc Function test - */ - it('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1300', 0, async function (done) { - let emergencyNumberOptions = new EmergencyNumberOptions(ERR_SLOT_ID); - try { - var data = await call.isEmergencyPhoneNumber('120', emergencyNumberOptions); - expect().assertFail(); - console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1300 fail '); - done(); - } catch (err) { - console.log(`Telephony_CallManager_isEmergencyPhoneNumber_Promise_1300 finish err = ${err}`); - done(); - } - }); - - /** - * @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Async_1400 - * @tc.name testIsEmergencyPhoneNumber_1400 - * @tc.desc PhoneNumber: 110, no options. Call isEmergencyPhoneNumber() api by callback. - * The return value is true - */ - it('Telephony_CallManager_isEmergencyPhoneNumber_Async_1400', 0, async function (done) { - call.isEmergencyPhoneNumber('110', (err) => { - if (err) { - console.log(`Telephony_CallManager_isEmergencyPhoneNumber_Async_1400 finish err = ${err}`); - expect().assertFail(); - done(); - return; - } - expect(true).assertTrue(); - console.log('Telephony_CallManager_isEmergencyPhoneNumber_Async_1400 PASSED '); - done(); - }); - }); - - /** - * @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Async_1500 - * @tc.name testIsEmergencyPhoneNumber_1500 - * @tc.desc PhoneNumber: 120, no options. Call isEmergencyPhoneNumber() api by promise. - * The return value is true - */ - it('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1400', 0, async function (done) { - try { - var data = await call.isEmergencyPhoneNumber('120'); - expect(true).assertTrue(); - console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1400 PASSED '); - done(); - } catch (err) { - console.log(`Telephony_CallManager_isEmergencyPhoneNumber_Promise_1400 finish err = ${err}`); - expect().assertFail(); - done(); - } - }); -}); \ No newline at end of file +/** + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import call from '@ohos.telephony.call'; +import observer from '@ohos.telephony.observer'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +import { + AUTO_ACCEPT_NUMBER, + AUTO_ACCEPT_NUMBER2, + PHONE_NUMBER_LENGTH_11, + CALL_STATUS_DIALING, + CALL_ID_NOT_EXIST, + CALL_STATE_UNKNOWN, + CALL_STATE_IDLE, + DEFAULT_SLOT_ID, + CALL_MODE_IMS, + SLOT_ID_INVALID, + PHONE_LIST2, + RTT_MSG, + CALL_MODE_SEND_RECEIVE, + POS_700, + POS_10, + POS_LENGTH_300, + POS_LENGTH_600, + DEVICE_EARPIECE, + BOUNDARY_NUMBER_INT, + SENT_STRING_C, + MINUS_VALUE, + PHONE_NUMBER_LONG, + NULL_PHONE_NUMBER, + DIAL_CARRIER_TYPE, + DIAL_SCENCE_CALL_PRIVILEGED, + MEDIA_TYPE_VOICE, + ROTATION_MINUS_1, + IMAGE_LOCAL_ERROR_PATH, + POS_Z_ERROR, + RESTRICTION_TYPE_ROAMING_INCOMING, + RESTRICTION_MODE_ACTIVATION, + RIGHT_PASSWORD, + RESTRICTION_TYPE_ALL_INCOMING, + TRANSFER_TYPE_NOT_REACHABLE, + TRANSFER_TYPE_UNCONDITIONAL, + PHONE_NUMBER_AREA_LAND, + CALL_TRANSFER_DISABLE, + TRANSFER_TYPE_NO_REPLY, + COMMAND_CALL_ERROR4, + COMMAND_CALL_ERROR, + CARMER_ID_NOT_EXIT, + ZOOM_RATIO_MINUS_1_0, + DIAL_SCENCE_CALL_NORMAL, + DIAL_TYPE_OTT, + EVENT_OTT_FUNCTION_UNSUPPORTED, + TEL_CONFERENCE_IDLE +} from './lib/Const.js'; +import {toString} from './lib/ApiToPromise.js'; +import { + scenceInCalling, + hangupCall2, + hangupCall, + callDetailsChangeOn, + callId as gloabCallId, + reachState, + callDetailsChangeOff, + reachCallEventState +} from './lib/ScenceInCalling.js'; +const GETMAIN_CALLID_ERRO = -1; +const REJECT_MESSAGE_STR = 'Hi,hello?'; +const REJECT_MESSAGE_NUM = 1234567890123456789012345678901234567890; +const ERR_SLOT_ID = -1; +const SLOTID = 0; +const THE_THREE_NUMBER = '112'; +const DIAL_TYPE_ERR_CALL = 3; +const TIME_OUT = 20000; +const WAITING_TIME = 200; + +let callId = null; +class RejectMessageOptions { + constructor (str) { + this.messageContent = str; + } +} +class EmergencyNumberOptions { + constructor (num) { + this.slotId = num; + } +} +class NumberFormatOptions { + constructor (str) { + this.countryCode = str; + } +} +class CallAttributeOptions { + constructor (accountNumber, speakerphoneOn, accountId, videoState, startTime, + isEcc, callType, callId, callState, conferenceState) { + this.accountNumber = accountNumber; + this.speakerphoneOn = speakerphoneOn; + this.accountId = accountId; + this.videoState = videoState; + this.startTime = startTime; + this.isEcc = isEcc; + this.callType = callType; + this.callId = callId; + this.callState = callState; + this.conferenceState = conferenceState; + } +} + +const sleep = (time) => { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve(); + }, time); + }); +}; + +var callState = -1; +var timing = 0; +var endTime = 0; +export default function CallManageImsCall() { +describe('CallManageImsCall', function () { + beforeAll(async function (done) { + try { + console.log('Telephony_CallManager enableImsSwitch success'); + await call.setCallPreferenceMode(DEFAULT_SLOT_ID, CALL_MODE_IMS); + console.log('Telephony_CallManager setCallPreferenceMode success'); + } catch (error) { + console.log(`Telephony_CallManager setCallPreferenceMode or enableImsSwitch error,error:${toString(error)}`); + } + done(); + }); + + afterEach(async function () { + try { + const CURRENT_TIME = new Date().valueOf(); + const TEMP_CALL_ID = 10; + const IS_ECC = true; + const SPEAK_ON = true; + let callAttributeOptions = new CallAttributeOptions(AUTO_ACCEPT_NUMBER, SPEAK_ON, DEFAULT_SLOT_ID, + MEDIA_TYPE_VOICE, CURRENT_TIME, IS_ECC, DIAL_TYPE_OTT, TEMP_CALL_ID, CALL_STATUS_DIALING, + TEL_CONFERENCE_IDLE); + console.log(`Telephony_CallManager ${toString(callAttributeOptions)}`); + expect(callAttributeOptions.accountNumber === AUTO_ACCEPT_NUMBER).assertTrue(); + expect(callAttributeOptions.speakerphoneOn === SPEAK_ON).assertTrue(); + expect(callAttributeOptions.accountId === DEFAULT_SLOT_ID).assertTrue(); + expect(callAttributeOptions.videoState === MEDIA_TYPE_VOICE).assertTrue(); + expect(callAttributeOptions.startTime === CURRENT_TIME).assertTrue(); + expect(callAttributeOptions.isEcc === IS_ECC).assertTrue(); + expect(callAttributeOptions.callType === DIAL_TYPE_OTT).assertTrue(); + expect(callAttributeOptions.callId === TEMP_CALL_ID).assertTrue(); + expect(callAttributeOptions.callState === CALL_STATUS_DIALING).assertTrue(); + expect(callAttributeOptions.conferenceState === TEL_CONFERENCE_IDLE).assertTrue(); + } catch (error) { + console.log(`Telephony_CallManager ${toString(error)}`); + } + try { + let callState = await call.getCallState(); + console.log(`Telephony_CallManager callState ${callState} ${gloabCallId}`); + if (callState === CALL_STATE_UNKNOWN || callState === CALL_STATE_IDLE) { + return; + } + if (gloabCallId) { + let data = await hangupCall('Telephony_CallManager', gloabCallId); + console.log(`Telephony_CallManager hangupCall success ${toString(data)}`); + } + } catch (error) { + console.log('Telephony_CallManager hangupCall or getCallState error'); + } + }); + + afterAll(function () { + observer.off('callStateChange'); + callDetailsChangeOff(); + console.log('Telephony_CallManager all 54 case is over for callmanager CallManageImsCall'); + }); + + /** + * @tc.number Telephony_CallManager_IMS_enableLteEnhanceMode_Async_0400 + * @tc.name Run the function enableLteEnhanceMode by args slotId SLOT_ID_INVALID, + * by callback,the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_IMS_enableLteEnhanceMode_Async_0400', 0, function (done) { + let caseName = 'Telephony_CallManager_IMS_enableLteEnhanceMode_Async_0400'; + call.enableLteEnhanceMode(SLOT_ID_INVALID, (error, data) => { + if (error) { + console.log(`${caseName} enableLteEnhanceMode error,case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} enableLteEnhanceMode success,case failed,data:${toString(data)}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_IMS_enableLteEnhanceMode_Promise_0400 + * @tc.name Run the function enableLteEnhanceMode by args slotId SLOT_ID_INVALID by promise, + * the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_IMS_enableLteEnhanceMode_Promise_0400', 0, function (done) { + let caseName = 'Telephony_CallManager_IMS_enableLteEnhanceMode_Promise_0400'; + call.enableLteEnhanceMode(SLOT_ID_INVALID).then(data => { + expect().assertFail(); + console.log(`${caseName} enableLteEnhanceMode success,case failed,data:${toString(data)}`); + done(); + }).catch(error => { + console.log(`${caseName} enableLteEnhanceMode error,case success,error:${toString(error)}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_IMS_disableLteEnhanceMode_Async_0400 + * @tc.name Run the function disableLteEnhanceMode by args slotId SLOT_ID_INVALID, + * by callback,the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_IMS_disableLteEnhanceMode_Async_0400', 0, function (done) { + let caseName = 'Telephony_CallManager_IMS_disableLteEnhanceMode_Async_0400'; + call.disableLteEnhanceMode(SLOT_ID_INVALID, (error, data) => { + if (error) { + console.log(`${caseName} disableLteEnhanceMode error,case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} disableLteEnhanceMode success,case failed,data:${toString(data)}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_IMS_disableLteEnhanceMode_Promise_0400 + * @tc.name Run the function disableLteEnhanceMode by args slotId SLOT_ID_INVALID by promise, + * the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_IMS_disableLteEnhanceMode_Promise_0400', 0, function (done) { + let caseName = 'Telephony_CallManager_IMS_disableLteEnhanceMode_Promise_0400'; + call.disableLteEnhanceMode(SLOT_ID_INVALID).then(data => { + expect().assertFail(); + console.log(`${caseName} disableLteEnhanceMode success,case failed,data:${toString(data)}`); + done(); + }).catch(error => { + console.log(`${caseName} disableLteEnhanceMode error,case success,error:${toString(error)}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_IMS_isLteEnhanceModeEnabled_Async_0400 + * @tc.name Run the function isLteEnhanceModeEnabled by args slotId SLOT_ID_INVALID by callback, + * the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_IMS_isLteEnhanceModeEnabled_Async_0400', 0, function (done) { + let caseName = 'Telephony_CallManager_IMS_isLteEnhanceModeEnabled_Async_0400'; + call.isLteEnhanceModeEnabled(SLOT_ID_INVALID, (error, data) => { + if (error) { + console.log(`${caseName} isLteEnhanceModeEnabled error,case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} isLteEnhanceModeEnabled success,case failed,data:${toString(data)}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_IMS_isLteEnhanceModeEnabled_Promise_0400 + * @tc.name Run the function isLteEnhanceModeEnabled by args slotId SLOT_ID_INVALID by promise, + * the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_IMS_isLteEnhanceModeEnabled_Promise_0400', 0, function (done) { + let caseName = 'Telephony_CallManager_IMS_isLteEnhanceModeEnabled_Promise_0400'; + call.isLteEnhanceModeEnabled(SLOT_ID_INVALID).then(data => { + expect().assertFail(); + console.log(`${caseName} isLteEnhanceModeEnabled success,case failed,data:${toString(data)}`); + done(); + }).catch(error => { + console.log(`${caseName} isLteEnhanceModeEnabled error,case success,error:${toString(error)}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_IMS_startRTT_Async_0200 + * @tc.name Run function startRTT by args callId CALL_ID_NOT_EXIST,msg RTT_MSG by callback, + * the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_IMS_startRTT_Async_0200', 0, function (done) { + let caseName = 'Telephony_CallManager_IMS_startRTT_Async_0200'; + call.startRTT(CALL_ID_NOT_EXIST, RTT_MSG, (error, data) => { + if (error) { + console.log(`${caseName} startRTT ${callId} error,case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} startRTT success,case failed,data:${toString(data)}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_IMS_startRTT_Promise_0200 + * @tc.name Run function startRTT by args callId CALL_ID_NOT_EXIST,msg RTT_MSG by callback, + * the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_IMS_startRTT_Promise_0200', 0, function (done) { + let caseName = 'Telephony_CallManager_IMS_startRTT_Promise_0200'; + call.startRTT(CALL_ID_NOT_EXIST, RTT_MSG).then(data => { + expect().assertFail(); + console.log(`${caseName} startRTT success,case failed,data:${toString(data)}`); + done(); + }).catch(error => { + console.log(`${caseName} startRTT ${callId} error,case success,error:${toString(error)}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_IMS_stopRTT_Async_0200 + * @tc.name Run function stopRTT by args callId CALL_ID_NOT_EXIST by callback,the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_IMS_stopRTT_Async_0200', 0, function (done) { + let caseName = 'Telephony_CallManager_IMS_stopRTT_Async_0200'; + call.stopRTT(CALL_ID_NOT_EXIST, (error, data) => { + if (error) { + console.log(`${caseName} stopRTT ${callId} error,case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} stopRTT success,case failed,data:${toString(data)}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_IMS_stopRTT_Promise_0200 + * @tc.name Run function stopRTT by args callId CALL_ID_NOT_EXIST by callback,the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_IMS_stopRTT_Promise_0200', 0, function (done) { + let caseName = 'Telephony_CallManager_IMS_stopRTT_Promise_0200'; + call.stopRTT(CALL_ID_NOT_EXIST).then(data => { + expect().assertFail(); + console.log(`${caseName} stopRTT success,case failed,data:${toString(data)}`); + done(); + }).catch(error => { + console.log(`${caseName} stopRTT ${callId} error,case success,error:${toString(error)}`); + done(); + }); + }); + + + /** + * @tc.number Telephony_CallManager_controlCamera_Async_0200 + * @tc.name Dial a call and after answering the call,run function controlCamera by + * args cameraId CARMER_ID_NOT_EXIT by callback, + * the callback function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_controlCamera_Async_0200', 0, function (done) { + let caseName = 'Telephony_CallManager_controlCamera_Async_0200'; + scenceInCalling({ + caseName:caseName, + phoneNumber:AUTO_ACCEPT_NUMBER2, + checkState:CALL_STATUS_DIALING + }).then(data => { + callId = data.callId; + let cameraId = CARMER_ID_NOT_EXIT; + call.controlCamera(cameraId, (error) => { + if (error) { + console.log(`${caseName} error,case success,error:${toString(error)}`); + hangupCall2(caseName, done, callId); + return; + } + console.log(`${caseName} case failed`); + expect().assertFail(); + hangupCall2(caseName, done, callId); + }); + }).catch(error => { + console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_controlCamera_Promise_0200 + * @tc.name Dial a call and after answering the call,run function controlCamera by args cameraId + * CARMER_ID_NOT_EXIT by promise,the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_controlCamera_Promise_0200', 0, async function (done) { + let caseName = 'Telephony_CallManager_controlCamera_Promise_0200'; + let cameraId = CARMER_ID_NOT_EXIT; + try { + let data = await scenceInCalling({ + caseName:caseName, + phoneNumber:AUTO_ACCEPT_NUMBER2, + checkState:CALL_STATUS_DIALING + }); + callId = data.callId; + } catch (error) { + console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); + done(); + return; + } + try { + await call.controlCamera(cameraId); + console.log(`${caseName} case failed`); + expect().assertFail(); + } catch (err) { + console.log(`${caseName} case success. error:${toString(err)}`); + } + hangupCall2(caseName, done, callId); + }); + + /** + * @tc.number Telephony_CallManager_setPreviewWindow_Async_0300 + * @tc.name Dial a call and after answering the call,run function setPreviewWindow by args + * x POS_700,y POS_10,z POS_Z_ERROR,width POS_LENGTH_300,height POS_LENGTH_600 by callback, + * the callback function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_setPreviewWindow_Async_0300', 0, function (done) { + let caseName = 'Telephony_CallManager_setPreviewWindow_Async_0300'; + scenceInCalling({ + caseName:caseName, + phoneNumber:AUTO_ACCEPT_NUMBER, + checkState:CALL_STATUS_DIALING + }).then(data => { + callId = data.callId; + let info = {x: POS_700, y: POS_10, z: POS_Z_ERROR, width: POS_LENGTH_300, height: POS_LENGTH_600}; + call.setPreviewWindow(info, (error) => { + if (error) { + console.log(`${caseName} error,case success,error:${toString(error)}`); + hangupCall2(caseName, done, callId); + return; + } + console.log(`${caseName} case faild`); + expect().assertFail(); + hangupCall2(caseName, done, callId); + }); + }).catch(error => { + console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_setPreviewWindow_Promise_0300 + * @tc.name Dial a call and after answering the call,run function setPreviewWindow by args + * x POS_700,y POS_10,z POS_Z_ERROR,width POS_LENGTH_300,height POS_LENGTH_600 by promise, + * the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_setPreviewWindow_Promise_0300', 0, async function (done) { + let caseName = 'Telephony_CallManager_setPreviewWindow_Promise_0300'; + try { + let data = await scenceInCalling({ + caseName:caseName, + phoneNumber:AUTO_ACCEPT_NUMBER, + checkState:CALL_STATUS_DIALING + }); + callId = data.callId; + } catch (error) { + console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); + done(); + return; + } + try { + let info = {x: POS_700, y: POS_10, z: POS_Z_ERROR, width: POS_LENGTH_300, height: POS_LENGTH_600}; + await call.setPreviewWindow(info); + console.log(`${caseName} case faild`); + expect().assertFail(); + } catch (error) { + console.log(`${caseName} error,case success,error:${toString(error)}`); + } + hangupCall2(caseName, done, callId); + }); + + /** + * @tc.number Telephony_CallManager_setDisplayWindow_Async_0300 + * @tc.name Dial a call and after answering the call,run function setDisplayWindow by args + * x POS_700,y POS_10,z POS_Z_ERROR,width POS_LENGTH_300,height POS_LENGTH_600 by callback, + * the callback function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_setDisplayWindow_Async_0300', 0, async function (done) { + let caseName = 'Telephony_CallManager_setDisplayWindow_Async_0300'; + try { + let data = await scenceInCalling({ + caseName:caseName, + phoneNumber:AUTO_ACCEPT_NUMBER, + checkState:CALL_STATUS_DIALING + }); + callId = data.callId; + } catch (error) { + console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); + done(); + return; + } + try { + let info = {x: POS_700, y: POS_10, z: POS_Z_ERROR, width: POS_LENGTH_300, height: POS_LENGTH_600}; + await call.setDisplayWindow(info); + console.log(`${caseName} case faild`); + expect().assertFail(); + } catch (error) { + console.log(`${caseName} error,case success,error:${toString(error)}`); + } + hangupCall2(caseName, done, callId); + }); + + /** + * @tc.number Telephony_CallManager_setDisplayWindow_Promise_0300 + * @tc.name Dial a call and after answering the call,run function setDisplayWindow by args + * x POS_700,y POS_10,z POS_Z_ERROR,width POS_LENGTH_300,height POS_LENGTH_600 by promise, + * the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_setDisplayWindow_Promise_0300', 0, async function (done) { + let caseName = 'Telephony_CallManager_setDisplayWindow_Promise_0300'; + try { + let data = await scenceInCalling({ + caseName:caseName, + phoneNumber:AUTO_ACCEPT_NUMBER, + checkState:CALL_STATUS_DIALING + }); + callId = data.callId; + } catch (error) { + console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); + done(); + return; + } + try { + let info = {x: POS_700, y: POS_10, z: POS_Z_ERROR, width: POS_LENGTH_300, height: POS_LENGTH_600}; + await call.setDisplayWindow(info); + console.log(`${caseName} case faild`); + expect().assertFail(); + } catch (error) { + console.log(`${caseName} error,case success,error:${toString(error)}`); + } + hangupCall2(caseName, done, callId); + }); + + /** + * @tc.number Telephony_CallManager_setCameraZoom_Async_0400 + * @tc.name Dial a call and after answering the call,run function setCameraZoom by args + * zoomRatio ZOOM_RATIO_MINUS_1_0 by callback,the callback function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_setCameraZoom_Async_0400', 0, function (done) { + let caseName = 'Telephony_CallManager_setCameraZoom_Async_0400'; + scenceInCalling({ + caseName:caseName, + phoneNumber:AUTO_ACCEPT_NUMBER2, + checkState:CALL_STATUS_DIALING + }).then(data => { + callId = data.callId; + call.setCameraZoom(ZOOM_RATIO_MINUS_1_0, (error) => { + if (error) { + console.log(`${caseName} error,case success,error:${toString(error)}`); + hangupCall2(caseName, done, callId); + return; + } + console.log(`${caseName} case failed`); + expect().assertFail(); + hangupCall2(caseName, done, callId); + }); + }).catch(error => { + console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_setCameraZoom_Promise_0400 + * @tc.name Dial a call and after answering the call,run function setCameraZoom by args + * zoomRatio ZOOM_RATIO_MINUS_1_0 by promise,the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_setCameraZoom_Promise_0400', 0, async function (done) { + let caseName = 'Telephony_CallManager_setCameraZoom_Promise_0400'; + try { + let data = await scenceInCalling({ + caseName:caseName, + phoneNumber:AUTO_ACCEPT_NUMBER, + checkState:CALL_STATUS_DIALING + }); + callId = data.callId; + } catch (error) { + console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); + done(); + return; + } + try { + await call.setCameraZoom(ZOOM_RATIO_MINUS_1_0); + console.log(`${caseName} case failed`); + expect().assertFail(); + } catch (error) { + console.log(`${caseName} error,case success,error:${toString(error)}`); + } + hangupCall2(caseName, done, callId); + }); + + /** + * @tc.number Telephony_CallManager_setPausePicture_Async_0500 + * @tc.name Dial a call and after answering the call,run function setPausePicture by args + * path IMAGE_LOCAL_ERROR_PATH by callback,the callback function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_setPausePicture_Async_0500', 0, function (done) { + let caseName = 'Telephony_CallManager_setPausePicture_Async_0500'; + scenceInCalling({ + caseName:caseName, + phoneNumber:AUTO_ACCEPT_NUMBER, + checkState:CALL_STATUS_DIALING + }).then(data => { + callId = data.callId; + call.setPausePicture(IMAGE_LOCAL_ERROR_PATH, (error) => { + if (error) { + console.log(`${caseName} case success,error:${toString(error)}`); + hangupCall2(caseName, done, callId); + return; + } + console.log(`${caseName} success,case failed`); + hangupCall2(caseName, done, callId); + }); + }).catch(error => { + console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_setPausePicture_Promise_0500 + * @tc.name Dial a call and after answering the call,run function setPausePicture + * by args path IMAGE_LOCAL_ERROR_PATH by promise, + * the callback function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_setPausePicture_Promise_0500', 0, async function (done) { + let caseName = 'Telephony_CallManager_setPausePicture_Promise_0500'; + try { + let data = await scenceInCalling({ + caseName:caseName, + phoneNumber:AUTO_ACCEPT_NUMBER, + checkState:CALL_STATUS_DIALING + }); + callId = data.callId; + } catch (error) { + console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); + done(); + return; + } + try { + await call.setPausePicture(IMAGE_LOCAL_ERROR_PATH); + console.log(`${caseName} success,case failed`); + } catch (error) { + console.log(`${caseName} case success,error:${toString(error)}`); + } + hangupCall2(caseName, done, callId); + }); + + /** + * @tc.number Telephony_CallManager_setDeviceDirection_Async_0500 + * @tc.name Dial a call and after answering the call,run function setDeviceDirection + * by args rotation ROTATION_MINUS_1 by callback,the callback function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_setDeviceDirection_Async_0500', 0, function (done) { + let caseName = 'Telephony_CallManager_setDeviceDirection_Async_0500'; + scenceInCalling({ + caseName:caseName, + phoneNumber:AUTO_ACCEPT_NUMBER, + checkState:CALL_STATUS_DIALING + }).then(data => { + callId = data.callId; + call.setDeviceDirection(ROTATION_MINUS_1, (error) => { + if (error) { + console.log(`${caseName} success, case success`); + hangupCall2(caseName, done, callId); + return; + } + console.log(`${caseName} error,case failed,error:${toString(error)}`); + expect().assertFail(); + hangupCall2(caseName, done, callId); + }); + }).catch(error => { + console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_setDeviceDirection_Promise_0500 + * @tc.name Dial a call and after answering the call,run function setDeviceDirection + * by args rotation ROTATION_MINUS_1 by promise,the callback function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_setDeviceDirection_Promise_0500', 0, async function (done) { + let caseName = 'Telephony_CallManager_setDeviceDirection_Promise_0500'; + try { + let data = await scenceInCalling({ + caseName:caseName, + phoneNumber:AUTO_ACCEPT_NUMBER2, + checkState:CALL_STATUS_DIALING + }); + callId = data.callId; + } catch (error) { + console.log(`${caseName} scenceInCalling error ,case failed,error:${toString(error)}`); + done(); + return; + } + try { + await call.setDeviceDirection(ROTATION_MINUS_1); + console.log(`${caseName} success,case error`); + expect().assertFail(); + } catch (error) { + console.log(`${caseName} case success,error:${toString(error)}`); + } + hangupCall2(caseName, done, callId); + }); + + /** + * @tc.number Telephony_CallManager_getCallState_Async_0100 + * @tc.name To get the idle call status, call getCallState() to get the current call status. + * call.CALL_STATE_IDLE is returned + * @tc.desc Function test + */ + it('Telephony_CallManager_getCallState_Async_0100', 0, async function (done) { + call.getCallState((err, data) => { + if (err) { + console.log(`Telephony_CallManager_getCallState_Async_0100 : err = ${err.message}`); + expect().assertFail(); + done(); + return; + } + expect(data == call.CALL_STATE_IDLE || + data == call.CALL_STATE_UNKNOWN || + data == call.CALL_STATE_RINGING || + data == call.CALL_STATE_OFFHOOK).assertTrue(); + console.log(`Telephony_CallManager_getCallState_Async_0100 finish data = ${data}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_getCallState_Promise_0100 + * @tc.name To get the idle call status, call getCallState() to get the current call status. + * call.CALL_STATE_IDLE is returned + * @tc.desc Function test + */ + it('Telephony_CallManager_getCallState_Promise_0100', 0, async function (done) { + try { + var data = await call.getCallState(); + expect(data == call.CALL_STATE_IDLE || + data == call.CALL_STATE_UNKNOWN || + data == call.CALL_STATE_RINGING || + data == call.CALL_STATE_OFFHOOK).assertTrue(); + console.log(`Telephony_CallManager_getCallState_Promise_0100 finish data = ${data}`); + done(); + } catch (err) { + console.log(`Telephony_CallManager_getCallState_Promise_0100 : err = ${err.message}`); + expect().assertFail(); + done(); + + } + }); + + /** + * @tc.number Telephony_CallManager_hasCall_Async_0400 + * @tc.name When idle, hasCall() is called to confirm that there is no current call,returning false + * @tc.desc Function test + */ + it('Telephony_CallManager_hasCall_Async_0400', 0, async function (done) { + call.hasCall((err, data) => { + if (err) { + console.log('Telephony_CallManager_hasCall_Async_0400 fail'); + expect().assertFail(); + done(); + return; + } + console.log(`Telephony_CallManager_hasCall_Async_0400 finish data = ${data}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_hasCall_Promise_0400 + * @tc.name When idle, hasCall() is called to confirm that there is no current call, returning false + * @tc.desc Function test + */ + it('Telephony_CallManager_hasCall_Promise_0400', 0, async function (done) { + try { + var data = await call.hasCall(); + console.log(`Telephony_CallManager_hasCall_Promise_0400 finish data = ${data}`); + done(); + } catch (err) { + console.log('Telephony_CallManager_hasCall_Promise_0400 fail'); + expect().assertFail(); + done(); + + } + }); + + /** + * @tc.number Telephony_CallManager_formatPhoneNumber_Async_0100 + * @tc.name PhoneNumber is 100000000000. Call formatPhoneNumber() to format the number. + * The return value is 10 000 000 0000 + * @tc.desc Function test + */ + it('Telephony_CallManager_formatPhoneNumber_Async_0100', 0, async function (done) { + call.formatPhoneNumber('100000000000', (err, data) => { + if (err) { + console.log(`Telephony_CallManager_formatPhoneNumber_Async_0100 err = ${err.message}`); + console.log('Telephony_CallManager_formatPhoneNumber_Async_0100 fail'); + expect().assertFail(); + done(); + return; + } + expect(data === '10 000 000 0000').assertTrue(); + console.log(`Telephony_CallManager_formatPhoneNumber_Async_0100 finish data = ${data}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_formatPhoneNumber_Promise_0100 + * @tc.name PhoneNumber is 2000000. Call formatPhoneNumber() to format the number. + * The return value is 200 0000 + * @tc.desc Function test + */ + it('Telephony_CallManager_formatPhoneNumber_Promise_0100', 0, async function (done) { + try { + var data = await call.formatPhoneNumber('2000000'); + expect(data === '200 0000').assertTrue(); + console.log(`Telephony_CallManager_formatPhoneNumber_Promise_0100 finish data = ${data}`); + done(); + } catch (err) { + console.log('Telephony_CallManager_formatPhoneNumber_Promise_0100 fail'); + expect().assertFail(); + done(); + + } + }); + + /** + * @tc.number Telephony_CallManager_formatPhoneNumber_Async_0200 + * @tc.name testFormatPhoneNumber_0200 + * @tc.desc PhoneNumber is 13900000000, options: CN, test formatPhoneNumber() api by callback. + * The return value is 139 0000 0000 + */ + it('Telephony_CallManager_formatPhoneNumber_Async_0200', 0, async function (done) { + let numberFormatOptions = new NumberFormatOptions('CN'); + call.formatPhoneNumber('13900000000', numberFormatOptions, (err, data) => { + if (err) { + console.log(`Telephony_CallManager_formatPhoneNumber_Async_0200 err = ${err.message}`); + console.log('Telephony_CallManager_formatPhoneNumber_Async_0200 fail'); + expect().assertFail(); + done(); + return; + } + expect(data === '139 0000 0000').assertTrue(); + console.log(`Telephony_CallManager_formatPhoneNumber_Async_0200 finish data = ${data}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_formatPhoneNumber_Async_0300 + * @tc.name testFormatPhoneNumber_0300 + * @tc.desc PhoneNumber is 13900000000, options: US, test formatPhoneNumber() api by promise. + * The return value is '1 390-000-0000' + */ + it('Telephony_CallManager_formatPhoneNumber_Promise_0200', 0, async function (done) { + let numberFormatOptions = new NumberFormatOptions('US'); + try { + var data = await call.formatPhoneNumber('13900000000', numberFormatOptions); + expect(data === '1 390-000-0000').assertTrue(); + console.log(`Telephony_CallManager_formatPhoneNumber_Promise_0200 finish data = ${data}`); + done(); + } catch (err) { + console.log('Telephony_CallManager_formatPhoneNumber_Promise_0200 fail'); + expect().assertFail(); + done(); + } + }); + + /** + * @tc.number Telephony_CallManager_formatPhoneNumberToE164_Async_0100 + * @tc.name PhoneNumber is 010-0000-0000, options: CN, call formatPhoneNumberToE164() to format the number, + * and return +861000000000 + * @tc.desc Function test + */ + it('Telephony_CallManager_formatPhoneNumberToE164_Async_0100', 0, async function (done) { + let numberFormatOptions = new NumberFormatOptions('CN'); + call.formatPhoneNumberToE164('010-0000-0000', numberFormatOptions.countryCode, (err, data) => { + if (err) { + console.log('Telephony_CallManager_formatPhoneNumberToE164_Async_0100 fail'); + expect().assertFail(); + done(); + return; + } + expect(data === '+861000000000').assertTrue(); + console.log(`Telephony_CallManager_formatPhoneNumberToE164_Async_0100 finish data = ${data}`); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_formatPhoneNumberToE164_Promise_0100 + * @tc.name PhoneNumber is 52300000000, options: CN, call formatPhoneNumberToE164() to format the number, + * return +8652300000000 + * @tc.desc Function test + */ + it('Telephony_CallManager_formatPhoneNumberToE164_Promise_0100', 0, async function (done) { + let numberFormatOptions = new NumberFormatOptions('CN'); + try { + var data = await call.formatPhoneNumberToE164('52300000000', numberFormatOptions.countryCode); + expect(data === '+8652300000000').assertTrue(); + console.log(`Telephony_CallManager_formatPhoneNumberToE164_Promise_0100 finish data = ${data}`); + done(); + } catch (err) { + console.log('Telephony_CallManager_formatPhoneNumberToE164_Promise_0100 fail'); + expect().assertFail(); + done(); + + } + }); + + /** + * @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Async_1300 + * @tc.name PhoneNumber: 110, options -1. Call isEmergencyPhoneNumber() to check whether it is an emergency + * number. The return value is false + * @tc.desc Function test + */ + it('Telephony_CallManager_isEmergencyPhoneNumber_Async_1300', 0, async function (done) { + let emergencyNumberOptions = new EmergencyNumberOptions(ERR_SLOT_ID); + call.isEmergencyPhoneNumber('110', emergencyNumberOptions, (err) => { + if (err) { + console.log(`Telephony_CallManager_isEmergencyPhoneNumber_Async_1300 finish err = ${err}`); + done(); + return; + } + expect().assertFail(); + console.log('Telephony_CallManager_isEmergencyPhoneNumber_Async_1300 fail '); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Promise_1300 + * @tc.name PhoneNumber: 120, options -1. Call isEmergencyPhoneNumber() to check whether it is an emergency + * number. The return value is false + * @tc.desc Function test + */ + it('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1300', 0, async function (done) { + let emergencyNumberOptions = new EmergencyNumberOptions(ERR_SLOT_ID); + try { + var data = await call.isEmergencyPhoneNumber('120', emergencyNumberOptions); + expect().assertFail(); + console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1300 fail '); + done(); + } catch (err) { + console.log(`Telephony_CallManager_isEmergencyPhoneNumber_Promise_1300 finish err = ${err}`); + done(); + } + }); + + /** + * @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Async_1400 + * @tc.name testIsEmergencyPhoneNumber_1400 + * @tc.desc PhoneNumber: 110, no options. Call isEmergencyPhoneNumber() api by callback. + * The return value is true + */ + it('Telephony_CallManager_isEmergencyPhoneNumber_Async_1400', 0, async function (done) { + call.isEmergencyPhoneNumber('110', (err) => { + if (err) { + console.log(`Telephony_CallManager_isEmergencyPhoneNumber_Async_1400 finish err = ${err}`); + expect().assertFail(); + done(); + return; + } + expect(true).assertTrue(); + console.log('Telephony_CallManager_isEmergencyPhoneNumber_Async_1400 PASSED '); + done(); + }); + }); + + /** + * @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Async_1500 + * @tc.name testIsEmergencyPhoneNumber_1500 + * @tc.desc PhoneNumber: 120, no options. Call isEmergencyPhoneNumber() api by promise. + * The return value is true + */ + it('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1400', 0, async function (done) { + try { + var data = await call.isEmergencyPhoneNumber('120'); + expect(true).assertTrue(); + console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1400 PASSED '); + done(); + } catch (err) { + console.log(`Telephony_CallManager_isEmergencyPhoneNumber_Promise_1400 finish err = ${err}`); + expect().assertFail(); + done(); + } + }); +}); +} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/List.test.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/List.test.js similarity index 81% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/List.test.js rename to telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/List.test.js index f4aa98ba2..549a4b4de 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/List.test.js +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/List.test.js @@ -1,15 +1,19 @@ -/** - * 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. - */ - require('./CallManageAll.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 CallManageImsCall from './CallManageAll.test.js' + +export default function testsuite() { + CallManageImsCall() +} diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ApiToPromise.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ApiToPromise.js similarity index 97% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ApiToPromise.js rename to telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ApiToPromise.js index 6b600564f..10981333a 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ApiToPromise.js +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ApiToPromise.js @@ -1,40 +1,40 @@ -/** - * 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 function toString (data) { - if (typeof data === 'object') { - return JSON.stringify(data); - } else { - return data; - } -} - -export function promisify (fn) { - return function () { - let args = Array.prototype.slice.call(arguments); - return new Promise(function (resolve, reject) { - console.log(`Telephony_CallManager promisify args:${toString(arguments)},fn:${fn}`); - args.push(function (error, data) { - console.log(`Telephony_CallManager promisify error:${toString(error)},data:${toString(data)}`); - if (error) { - reject(error); - } else { - resolve(data); - } - }); - fn.apply(null, args); - }); - }; +/** + * 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 function toString (data) { + if (typeof data === 'object') { + return JSON.stringify(data); + } else { + return data; + } +} + +export function promisify (fn) { + return function () { + let args = Array.prototype.slice.call(arguments); + return new Promise(function (resolve, reject) { + console.log(`Telephony_CallManager promisify args:${toString(arguments)},fn:${fn}`); + args.push(function (error, data) { + console.log(`Telephony_CallManager promisify error:${toString(error)},data:${toString(data)}`); + if (error) { + reject(error); + } else { + resolve(data); + } + }); + fn.apply(null, args); + }); + }; } \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ApiToPromisePerfomance.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ApiToPromisePerfomance.js similarity index 97% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ApiToPromisePerfomance.js rename to telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ApiToPromisePerfomance.js index 5a56f7556..09c3181de 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ApiToPromisePerfomance.js +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ApiToPromisePerfomance.js @@ -1,139 +1,139 @@ - -/** - * 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_PERF_COUNT, PERF_GOAL_TIME} from './Const.js'; -import {toString} from './ApiToPromise.js'; -// packaging the function to the perfomace test function -export async function apiToPromisePerfomace (options, args) { - // recursion plan - let {func, caseName, target, perfTime, compareFunc} = options; - let flag = true; - let count = TEST_PERF_COUNT; - perfTime = perfTime ? perfTime : PERF_GOAL_TIME; - - console.log(`${caseName} apiToPromisePerfomace func ${func}, caseName ${caseName},args:${toString(args)}`); - function excuteCallbackPromise () { - return new Promise((resolve, reject) => { - function excuteCallback () { - target[func](...args); - } - args[args.length - 1] = function (error, data) { - if (count === 0) { - if (flag) { - resolve(flag); - } else { - reject(new Error(`flag:${flag}`)); - } - } else { - flag = flag && !!compareFunc(error, data); - count--; - excuteCallback(); - } - }; - excuteCallback(); - }); - } - - let startTime = new Date().getTime(); - if (typeof args[args.length - 1] === 'function') { - try { - flag = await excuteCallbackPromise(); - } catch (error) { - flag = false; - } - } else { - for (;count > 0;count--) { - let error = null; - let data = null; - try { - data = await target[func](...args); - flag = flag && !!compareFunc(error, data); - } catch (err) { - error = err; - flag = flag && !!compareFunc(error, data); - } - } - } - let endTime = new Date().getTime(); - const cost = endTime - startTime; - console.log(`${caseName} ${func} result flag:${toString(flag)} count:${TEST_PERF_COUNT}` + - ` cost:${cost}ms avarage:${parseInt(cost * 1000 / TEST_PERF_COUNT)}`); - if (flag && cost < perfTime) { - return flag; - } else { - throw new Error(`flag:${flag}`); - } -} - -export async function apiToPerfomace (options, args) { - // recursion plan - let {func, caseName, target, perfTime, compareFunc, runedFunc} = options; - let flag = true; - let count = TEST_PERF_COUNT; - perfTime = perfTime ? perfTime : PERF_GOAL_TIME; - - console.log(`${caseName} apiToPerfomace func ${func}, caseName ${caseName},args:${toString(args)}`); - function excuteCallbackPromise () { - return new Promise((resolve, reject) => { - function excuteCallback () { - target[func](...args); - } - args[args.length - 1] = function (error, data) { - if (count === 0) { - if (flag) { - resolve(flag); - } else { - reject(new Error(`flag:${flag}`)); - } - } else { - flag = flag && !!compareFunc(error, data); - count--; - excuteCallback(); - } - }; - excuteCallback(); - }); - } - - let startTime = new Date().getTime(); - if (typeof args[args.length - 1] === 'function') { - try { - flag = await excuteCallbackPromise(); - } catch (error) { - flag = false; - } - } else { - for (;count > 0;count--) { - let error = null; - let data = null; - try { - data = await target[func](...args); - flag = flag && !!compareFunc(error, data); - } catch (err) { - error = err; - flag = flag && !!compareFunc(error, data); - } - } - } - let endTime = new Date().getTime(); - const cost = endTime - startTime; - console.log(`${caseName} ${func} result flag:${toString(flag)} count:${TEST_PERF_COUNT}` + - ` cost:${cost}ms avarage:${parseInt(cost * 1000 / TEST_PERF_COUNT)}`); - runedFunc(flag && cost < perfTime); -} -export function validate (error, data, func) { - return func(error, data); + +/** + * 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_PERF_COUNT, PERF_GOAL_TIME} from './Const.js'; +import {toString} from './ApiToPromise.js'; +// packaging the function to the perfomace test function +export async function apiToPromisePerfomace (options, args) { + // recursion plan + let {func, caseName, target, perfTime, compareFunc} = options; + let flag = true; + let count = TEST_PERF_COUNT; + perfTime = perfTime ? perfTime : PERF_GOAL_TIME; + + console.log(`${caseName} apiToPromisePerfomace func ${func}, caseName ${caseName},args:${toString(args)}`); + function excuteCallbackPromise () { + return new Promise((resolve, reject) => { + function excuteCallback () { + target[func](...args); + } + args[args.length - 1] = function (error, data) { + if (count === 0) { + if (flag) { + resolve(flag); + } else { + reject(new Error(`flag:${flag}`)); + } + } else { + flag = flag && !!compareFunc(error, data); + count--; + excuteCallback(); + } + }; + excuteCallback(); + }); + } + + let startTime = new Date().getTime(); + if (typeof args[args.length - 1] === 'function') { + try { + flag = await excuteCallbackPromise(); + } catch (error) { + flag = false; + } + } else { + for (;count > 0;count--) { + let error = null; + let data = null; + try { + data = await target[func](...args); + flag = flag && !!compareFunc(error, data); + } catch (err) { + error = err; + flag = flag && !!compareFunc(error, data); + } + } + } + let endTime = new Date().getTime(); + const cost = endTime - startTime; + console.log(`${caseName} ${func} result flag:${toString(flag)} count:${TEST_PERF_COUNT}` + + ` cost:${cost}ms avarage:${parseInt(cost * 1000 / TEST_PERF_COUNT)}`); + if (flag && cost < perfTime) { + return flag; + } else { + throw new Error(`flag:${flag}`); + } +} + +export async function apiToPerfomace (options, args) { + // recursion plan + let {func, caseName, target, perfTime, compareFunc, runedFunc} = options; + let flag = true; + let count = TEST_PERF_COUNT; + perfTime = perfTime ? perfTime : PERF_GOAL_TIME; + + console.log(`${caseName} apiToPerfomace func ${func}, caseName ${caseName},args:${toString(args)}`); + function excuteCallbackPromise () { + return new Promise((resolve, reject) => { + function excuteCallback () { + target[func](...args); + } + args[args.length - 1] = function (error, data) { + if (count === 0) { + if (flag) { + resolve(flag); + } else { + reject(new Error(`flag:${flag}`)); + } + } else { + flag = flag && !!compareFunc(error, data); + count--; + excuteCallback(); + } + }; + excuteCallback(); + }); + } + + let startTime = new Date().getTime(); + if (typeof args[args.length - 1] === 'function') { + try { + flag = await excuteCallbackPromise(); + } catch (error) { + flag = false; + } + } else { + for (;count > 0;count--) { + let error = null; + let data = null; + try { + data = await target[func](...args); + flag = flag && !!compareFunc(error, data); + } catch (err) { + error = err; + flag = flag && !!compareFunc(error, data); + } + } + } + let endTime = new Date().getTime(); + const cost = endTime - startTime; + console.log(`${caseName} ${func} result flag:${toString(flag)} count:${TEST_PERF_COUNT}` + + ` cost:${cost}ms avarage:${parseInt(cost * 1000 / TEST_PERF_COUNT)}`); + runedFunc(flag && cost < perfTime); +} +export function validate (error, data, func) { + return func(error, data); } \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ApiToPromiseReliability.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ApiToPromiseReliability.js similarity index 97% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ApiToPromiseReliability.js rename to telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ApiToPromiseReliability.js index c38a591c2..3a65a8520 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ApiToPromiseReliability.js +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ApiToPromiseReliability.js @@ -1,131 +1,131 @@ -/** - * 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 {toString} from './ApiToPromise.js'; -import {TEST_RELY_NUMBER} from './Const.js'; -// packaging the function to the reliability test function -export async function apiToPromiseReliability (options, args) { - // recursion plan - let {func, caseName, target, compareFunc} = options; - let flag = true; - let count = TEST_RELY_NUMBER; - - console.log(`${caseName} apiToPromiseReliability func ${func}, caseName ${caseName},args:${toString(args)}`); - function excuteCallbackPromise () { - return new Promise((resolve, reject) => { - function excuteCallback () { - target[func](...args); - } - args[args.length - 1] = function (error, data) { - if (count === 0) { - if (flag) { - resolve(flag); - } else { - reject(new Error(`flag:${flag}`)); - } - } else { - flag = flag && !!compareFunc(error, data); - count--; - excuteCallback(); - } - }; - excuteCallback(); - }); - } - - if (typeof args[args.length - 1] === 'function') { - try { - flag = await excuteCallbackPromise(); - } catch (error) { - flag = false; - } - } else { - for (;count > 0;count--) { - let error = null; - let data = null; - try { - data = await target[func](...args); - flag = flag && !!compareFunc(error, data); - } catch (err) { - error = err; - flag = flag && !!compareFunc(error, data); - } - } - } - console.log(`${caseName} result ${func} flag:${toString(flag)} count:${TEST_RELY_NUMBER}`); - if (flag) { - return flag; - } else { - throw new Error(`flag:${flag}`); - } -} - -export async function apiToReliability (options, args) { - // recursion plan - let {func, caseName, target, compareFunc, runedFunc} = options; - let flag = true; - let count = TEST_RELY_NUMBER; - - console.log(`${caseName} apiToPromiseReliability func ${func}, caseName ${caseName},args:${toString(args)}`); - function excuteCallbackPromise () { - return new Promise((resolve, reject) => { - function excuteCallback () { - target[func](...args); - } - args[args.length - 1] = function (error, data) { - console.log(`${caseName} error ${toString(error)} data ${toString(data)}`); - if (count === 0) { - if (flag) { - resolve(flag); - } else { - reject(new Error(`flag:${flag}`)); - } - } else { - flag = flag && !!compareFunc(error, data); - count--; - console.log(`${caseName} error:${toString(error)},data:${toString(data)},` + - `flag:${flag},count:${count}`); - excuteCallback(); - } - }; - excuteCallback(); - }); - } - - if (typeof args[args.length - 1] === 'function') { - try { - flag = await excuteCallbackPromise(); - } catch (error) { - flag = false; - } - } else { - for (;count > 0;count--) { - let error = null; - let data = null; - try { - data = await target[func](...args); - flag = flag && !!compareFunc(error, data); - } catch (err) { - error = err; - flag = flag && !!compareFunc(error, data); - } - console.log(`${caseName} error:${toString(error)},data:${toString(data)},flag:${flag},count:${count}`); - } - } - console.log(`${caseName} result ${func} flag:${toString(flag)} count:${TEST_RELY_NUMBER}`); - runedFunc(flag); -} - - +/** + * 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 {toString} from './ApiToPromise.js'; +import {TEST_RELY_NUMBER} from './Const.js'; +// packaging the function to the reliability test function +export async function apiToPromiseReliability (options, args) { + // recursion plan + let {func, caseName, target, compareFunc} = options; + let flag = true; + let count = TEST_RELY_NUMBER; + + console.log(`${caseName} apiToPromiseReliability func ${func}, caseName ${caseName},args:${toString(args)}`); + function excuteCallbackPromise () { + return new Promise((resolve, reject) => { + function excuteCallback () { + target[func](...args); + } + args[args.length - 1] = function (error, data) { + if (count === 0) { + if (flag) { + resolve(flag); + } else { + reject(new Error(`flag:${flag}`)); + } + } else { + flag = flag && !!compareFunc(error, data); + count--; + excuteCallback(); + } + }; + excuteCallback(); + }); + } + + if (typeof args[args.length - 1] === 'function') { + try { + flag = await excuteCallbackPromise(); + } catch (error) { + flag = false; + } + } else { + for (;count > 0;count--) { + let error = null; + let data = null; + try { + data = await target[func](...args); + flag = flag && !!compareFunc(error, data); + } catch (err) { + error = err; + flag = flag && !!compareFunc(error, data); + } + } + } + console.log(`${caseName} result ${func} flag:${toString(flag)} count:${TEST_RELY_NUMBER}`); + if (flag) { + return flag; + } else { + throw new Error(`flag:${flag}`); + } +} + +export async function apiToReliability (options, args) { + // recursion plan + let {func, caseName, target, compareFunc, runedFunc} = options; + let flag = true; + let count = TEST_RELY_NUMBER; + + console.log(`${caseName} apiToPromiseReliability func ${func}, caseName ${caseName},args:${toString(args)}`); + function excuteCallbackPromise () { + return new Promise((resolve, reject) => { + function excuteCallback () { + target[func](...args); + } + args[args.length - 1] = function (error, data) { + console.log(`${caseName} error ${toString(error)} data ${toString(data)}`); + if (count === 0) { + if (flag) { + resolve(flag); + } else { + reject(new Error(`flag:${flag}`)); + } + } else { + flag = flag && !!compareFunc(error, data); + count--; + console.log(`${caseName} error:${toString(error)},data:${toString(data)},` + + `flag:${flag},count:${count}`); + excuteCallback(); + } + }; + excuteCallback(); + }); + } + + if (typeof args[args.length - 1] === 'function') { + try { + flag = await excuteCallbackPromise(); + } catch (error) { + flag = false; + } + } else { + for (;count > 0;count--) { + let error = null; + let data = null; + try { + data = await target[func](...args); + flag = flag && !!compareFunc(error, data); + } catch (err) { + error = err; + flag = flag && !!compareFunc(error, data); + } + console.log(`${caseName} error:${toString(error)},data:${toString(data)},flag:${flag},count:${count}`); + } + } + console.log(`${caseName} result ${func} flag:${toString(flag)} count:${TEST_RELY_NUMBER}`); + runedFunc(flag); +} + + diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/Const.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/Const.js similarity index 97% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/Const.js rename to telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/Const.js index b7d269010..544249a44 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/Const.js +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/Const.js @@ -1,228 +1,228 @@ -/** - * 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 const AUTO_ACCEPT_NUMBER = '10010'; -export const AUTO_ACCEPT_NUMBER2 = '10010'; -export const PHONE_NUMBER_AREA_LAND = '089800000000'; -export const PHONE_NUMBER_LENGTH_8 = '86459751'; - -export const PHONE_NUMBER_LENGTH_11 = '10000000001'; -export const PHONE_NUMBER_VOICE_MAIL = '12599'; -export const PHONE_NUMBER_LONG = '1234567890123456789012345678901234567890123' + - '4567890123456789012345678901234567890123456789012345678901'; -export const EMERGENCY_NUMBER = '112'; -export const RIGHT_PASSWORD = '000001'; -export const ERROR_PASSWORD = '1234567890123456789012345678901234567890123' + -'4567890123456789012345678901234567890123456789012345678901'; -export const CALL_EMERGENCY = 2; -export const PHONE_LIST = ['10000000001']; -export const PHONE_LIST2 = ['10000000001', '10000000002']; -export const NULL_PHONE_NUMBER = ''; -export const SPECIA_CHAR_NUMBER = '"=#$%^&*()+'; -export const PHONE_NUMBER_CHAR = 'abcdefghijk'; -export const BOUNDARY_NUMBER_INT = 2147483649; -export const MINUS_BOUNDARY_NUMBER_INT = -2147483649; -export const MINUS_VALUE = -100; -export const TEST_RELY_NUMBER = 20; // test count for Reliability -export const TEST_PERF_COUNT = 20; // test count for Perfomace -export const PERF_GOAL_TIME = TEST_PERF_COUNT * 0.5; - -export const CALL_STATUS_ACTIVE = 0; -export const CALL_STATUS_HOLDING = 1; -export const CALL_STATUS_DIALING = 2; -export const CALL_STATUS_ALERTING = 3; -export const CALL_STATUS_INCOMING = 4; -export const CALL_STATUS_WAITING = 5; -export const CALL_STATUS_DISCONNECTED = 6; -export const CALL_STATUS_DISCONNECTING = 7; -export const CALL_STATUS_IDLE = 8; - -export const TEL_CONFERENCE_IDLE = 0; -export const TEL_CONFERENCE_ACTIVE = 1; -export const TEL_CONFERENCE_DISCONNECTING = 2; -export const TEL_CONFERENCE_DISCONNECTED = 3; - -export const DEVICE_EARPIECE = 0; -export const DEVICE_SPEAKER = 1; -export const DEVICE_WIRED_HEADSET = 2; -export const DEVICE_BLUETOOTH_SCO = 3; -export const DEVICE_INVALID = -1; -export const DEVICE_INVALID4 = 4; - -export const RESTRICTION_MODE_DEACTIVATION = 0; -export const RESTRICTION_MODE_ACTIVATION = 1; -export const RESTRICTION_MODE_INVALID = -1; -export const RESTRICTION_MODE_INVALID2 = 2; - -export const RESTRICTION_DISABLE = 0; -export const RESTRICTION_ENABLE = 1; - -export const RESTRICTION_TYPE_ALL_INCOMING = 0; -export const RESTRICTION_TYPE_ALL_OUTGOING = 1; -export const RESTRICTION_TYPE_INTERNATIONAL = 2; -export const RESTRICTION_TYPE_INTERNATIONAL_EXCLUDING_HOME = 3; -export const RESTRICTION_TYPE_ROAMING_INCOMING = 4; -export const RESTRICTION_TYPE_INCOMING_SERVICES = 7; -export const RESTRICTION_TYPE_OUTGOING_SERVICES = 6; -export const RESTRICTION_TYPE_ALL_CALLS = 5; -export const RESTRICTION_TYPE_INVALID = -1; -export const RESTRICTION_TYPE_INVALID2 = 8; - -export const DEFAULT_SLOT_ID = 0; -export const SLOT_ID1 = 1; -export const SLOT_ID_INVALID = -1; -export const SLOT_ID_INVALID_2 = 2; -export const CALL_ID_NOT_EXIST = 999; -export const VIDEO_STATE_AUDIO = 0; -export const CALL_TYPE_CS = 0; -export const CALL_TYPE_IMS = 1; - -export const EVENT_START_DTMF_SUCCESS = 3; -export const EVENT_STOP_DTMF_SUCCESS = 5; - -export const CALL_STATE_UNKNOWN = -1; -export const CALL_STATE_IDLE = 0; -export const CALL_STATE_RINGING = 1; -export const CALL_STATE_OFFHOOK = 2; - -export const TIMEOUT_LENTH = 1000; - -// call error code -export const CALL_MANAGER_NUMBER_NULL_NOTICE = '83951616'; - -export const TRANSFER_DISABLE = 0; // tran is close -export const TRANSFER_ENABLE = 1; // tran is open - -export const CALL_TRANSFER_ENABLE = 0; -export const CALL_TRANSFER_DISABLE = 1; -export const CALL_TRANSFER_REGISTRATION = 3; // open tran function -export const CALL_TRANSFER_ERASURE = 4; // close tran function -export const CALL_TRANSFER_INVALID = -1; -export const CALL_TRANSFER_INVALID2 = 5; -export const CALL_TRANSFER_INVALID3 = 2; - -export const TRANSFER_TYPE_BUSY = 1; // tran busy -export const TRANSFER_TYPE_NO_REPLY = 2;// no response tran -export const TRANSFER_TYPE_NOT_REACHABLE = 3; // untouchable(no signal/shut down) tran -export const TRANSFER_TYPE_UNCONDITIONAL = 0; // unconditional tran -export const TRANSFER_TYPE_INVALID = -1; -export const TRANSFER_TYPE_INVALID4 = 4; - -export const REACH_TIMES = 10; -export const AFTER_HANUP_TIMES = 5; - -export const CARMER_ID_NOT_EXIT = 'xtsautotest123456'; -export const CARMER_ID_SPACE = ''; -export const IMAGE_PNG_PATH = '/system/data/callManager.png'; -export const IMAGE_JPG_PATH = '/system/data/callManager.jpg'; -export const IMAGE_BMP_PATH = '/system/data/callManager.bmp'; -export const IMAGE_WEBP_PATH = '/system/data/callManager.webp'; -export const IMAGE_LOCAL_ERROR_PATH = '/system/data/callManager/notexistpath.png'; -export const IMAGE_SPACE_PATH = ''; -export const SENT_STRING_0 = '0'; -export const SENT_STRING_1 = '1'; -export const SENT_STRING_2 = '2'; -export const SENT_STRING_3 = '3'; -export const SENT_STRING_4 = '4'; -export const SENT_STRING_5 = '5'; -export const SENT_STRING_6 = '6'; -export const SENT_STRING_7 = '7'; -export const SENT_STRING_8 = '8'; -export const SENT_STRING_9 = '9'; -export const SENT_STRING_ERROR_10 = '10'; -export const SENT_STRING_A = 'A'; -export const SENT_STRING_Z = 'Z'; -export const SENT_STRING_C = 'C'; -export const SENT_STRING_D = 'D'; -export const SENT_STRING_E = 'E'; -export const SENT_STRING_LOW_A = 'a'; -export const SENT_STRING_LOW_C = 'c'; -export const SENT_STRING_LOW_B = 'b'; -export const SENT_STRING_LOW_D = 'd'; -export const SENT_STRING_STAR = '*'; -export const SENT_STRING_ADD = '+'; -export const SENT_STRING_MINUS = '-'; -export const SENT_STRING_JIN = '#'; -export const CALL_MODE_CS = 0; -export const CALL_MODE_IMS = 3; -export const MEDIA_TYPE_VOICE = 0; -export const MEDIA_TYPE_VIDEO = 1; -export const MEDIA_TYPE_ERROR = -1; -export const MEDIA_TYPE_ERROR2 = 2; -export const DIAL_SCENCE_CALL_NORMAL = 0; -export const DIAL_SCENCE_CALL_PRIVILEGED = 1; -export const DIAL_SCENCE_CALL_CALL_EMERGENCY = 2; -export const DIAL_SCENCE_ERROR = -1; -export const DIAL_SCENCE_ERROR2 = 3; -export const DIAL_CARRIER_TYPE = 0; -export const DIAL_VOICE_MAIL_TYPE = 1; -export const DIAL_OTT_TYPE = 2; -export const DIAL_TYPE_ERROR = -1; -export const DIAL_TYPE_ERROR3 = 3; - -export const POS_700 = 700; -export const POS_10 = 10; -export const POS_Z_0 = 0; -export const POS_Z_1 = 1; -export const POS_Z_ERROR = -1; -export const POS_Z_ERROR2 = 2; -export const POS_LENGTH_300 = 300; -export const POS_LENGTH_600 = 600; - -export const ZOOM_RATIO_5_0 = 5.0; -export const ZOOM_RATIO_15_0 = 15.0; -export const ZOOM_RATIO_0_0 = 0.0; -export const ZOOM_RATIO_10_1 = 10.1; -export const ZOOM_RATIO_MINUS_1_0 = -1.0; - -export const ROTATION_0 = 0; -export const ROTATION_90 = 90; -export const ROTATION_60 = 60; -export const ROTATION_180 = 180; -export const ROTATION_270 = 270; -export const ROTATION_360 = 360; -export const ROTATION_MINUS_1 = -1; - -export const COMMAND_CALL_WAITTING_OPEN = '*43#'; -export const COMMAND_CALL_WAITTING_CLOSE = '#43#'; -export const COMMAND_CALL_WAITTING_QUERY = '*#43#'; -export const COMMAND_CALL_TRANS_OPEN = '*21*10000000001#'; -export const COMMAND_CALL_TRANS_OPEN2 = '**21*10000000001*10#'; -export const COMMAND_CALL_TRANS_RESET = '##21#'; -export const COMMAND_CALL_ERROR = '**21*10000000001******10#'; -export const COMMAND_CALL_ERROR2 = '*ABCDEF123456789#'; -export const COMMAND_CALL_ERROR3 = '#ABCDEF123456789#'; -export const COMMAND_CALL_ERROR4 = '*#ABCDE123456789#'; -export const COMMAND_CALL_ERROR5 = '**ABCDE123456789#'; -export const COMMAND_CALL_ERROR6 = '##ABCDEF123456789#'; - -export const CALL_WAITING_DISABLE = 0; -export const CALL_WAITING_ENABLE = 1; - -export const EVENT_SEND_USSD_SUCCESS = 17; -export const EVENT_SEND_USSD_FAILED = 18; -export const EVENT_SEND_MEDIA_MODE_UPDATE = 19; - -export const RTT_MSG = 'Ab666&#'; - -export const CALL_MODE_AUDIO_ONLY = 0; -export const CALL_MODE_SEND_RECEIVE = 3; -export const CALL_MODE_SEND_ONLY = 1; -export const CALL_MODE_RECEIVE_ONLY = 2; -export const CALL_MODE_VIDEO_PAUSED = 4; -export const CALL_MODE_INVALID_MINUS_1 = -1; -export const CALL_MODE_INVALID_5 = 5; - +/** + * 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 const AUTO_ACCEPT_NUMBER = '10010'; +export const AUTO_ACCEPT_NUMBER2 = '10010'; +export const PHONE_NUMBER_AREA_LAND = '089800000000'; +export const PHONE_NUMBER_LENGTH_8 = '86459751'; + +export const PHONE_NUMBER_LENGTH_11 = '10000000001'; +export const PHONE_NUMBER_VOICE_MAIL = '12599'; +export const PHONE_NUMBER_LONG = '1234567890123456789012345678901234567890123' + + '4567890123456789012345678901234567890123456789012345678901'; +export const EMERGENCY_NUMBER = '112'; +export const RIGHT_PASSWORD = '000001'; +export const ERROR_PASSWORD = '1234567890123456789012345678901234567890123' + +'4567890123456789012345678901234567890123456789012345678901'; +export const CALL_EMERGENCY = 2; +export const PHONE_LIST = ['10000000001']; +export const PHONE_LIST2 = ['10000000001', '10000000002']; +export const NULL_PHONE_NUMBER = ''; +export const SPECIA_CHAR_NUMBER = '"=#$%^&*()+'; +export const PHONE_NUMBER_CHAR = 'abcdefghijk'; +export const BOUNDARY_NUMBER_INT = 2147483649; +export const MINUS_BOUNDARY_NUMBER_INT = -2147483649; +export const MINUS_VALUE = -100; +export const TEST_RELY_NUMBER = 20; // test count for Reliability +export const TEST_PERF_COUNT = 20; // test count for Perfomace +export const PERF_GOAL_TIME = TEST_PERF_COUNT * 0.5; + +export const CALL_STATUS_ACTIVE = 0; +export const CALL_STATUS_HOLDING = 1; +export const CALL_STATUS_DIALING = 2; +export const CALL_STATUS_ALERTING = 3; +export const CALL_STATUS_INCOMING = 4; +export const CALL_STATUS_WAITING = 5; +export const CALL_STATUS_DISCONNECTED = 6; +export const CALL_STATUS_DISCONNECTING = 7; +export const CALL_STATUS_IDLE = 8; + +export const TEL_CONFERENCE_IDLE = 0; +export const TEL_CONFERENCE_ACTIVE = 1; +export const TEL_CONFERENCE_DISCONNECTING = 2; +export const TEL_CONFERENCE_DISCONNECTED = 3; + +export const DEVICE_EARPIECE = 0; +export const DEVICE_SPEAKER = 1; +export const DEVICE_WIRED_HEADSET = 2; +export const DEVICE_BLUETOOTH_SCO = 3; +export const DEVICE_INVALID = -1; +export const DEVICE_INVALID4 = 4; + +export const RESTRICTION_MODE_DEACTIVATION = 0; +export const RESTRICTION_MODE_ACTIVATION = 1; +export const RESTRICTION_MODE_INVALID = -1; +export const RESTRICTION_MODE_INVALID2 = 2; + +export const RESTRICTION_DISABLE = 0; +export const RESTRICTION_ENABLE = 1; + +export const RESTRICTION_TYPE_ALL_INCOMING = 0; +export const RESTRICTION_TYPE_ALL_OUTGOING = 1; +export const RESTRICTION_TYPE_INTERNATIONAL = 2; +export const RESTRICTION_TYPE_INTERNATIONAL_EXCLUDING_HOME = 3; +export const RESTRICTION_TYPE_ROAMING_INCOMING = 4; +export const RESTRICTION_TYPE_INCOMING_SERVICES = 7; +export const RESTRICTION_TYPE_OUTGOING_SERVICES = 6; +export const RESTRICTION_TYPE_ALL_CALLS = 5; +export const RESTRICTION_TYPE_INVALID = -1; +export const RESTRICTION_TYPE_INVALID2 = 8; + +export const DEFAULT_SLOT_ID = 0; +export const SLOT_ID1 = 1; +export const SLOT_ID_INVALID = -1; +export const SLOT_ID_INVALID_2 = 2; +export const CALL_ID_NOT_EXIST = 999; +export const VIDEO_STATE_AUDIO = 0; +export const CALL_TYPE_CS = 0; +export const CALL_TYPE_IMS = 1; + +export const EVENT_START_DTMF_SUCCESS = 3; +export const EVENT_STOP_DTMF_SUCCESS = 5; + +export const CALL_STATE_UNKNOWN = -1; +export const CALL_STATE_IDLE = 0; +export const CALL_STATE_RINGING = 1; +export const CALL_STATE_OFFHOOK = 2; + +export const TIMEOUT_LENTH = 1000; + +// call error code +export const CALL_MANAGER_NUMBER_NULL_NOTICE = '83951616'; + +export const TRANSFER_DISABLE = 0; // tran is close +export const TRANSFER_ENABLE = 1; // tran is open + +export const CALL_TRANSFER_ENABLE = 0; +export const CALL_TRANSFER_DISABLE = 1; +export const CALL_TRANSFER_REGISTRATION = 3; // open tran function +export const CALL_TRANSFER_ERASURE = 4; // close tran function +export const CALL_TRANSFER_INVALID = -1; +export const CALL_TRANSFER_INVALID2 = 5; +export const CALL_TRANSFER_INVALID3 = 2; + +export const TRANSFER_TYPE_BUSY = 1; // tran busy +export const TRANSFER_TYPE_NO_REPLY = 2;// no response tran +export const TRANSFER_TYPE_NOT_REACHABLE = 3; // untouchable(no signal/shut down) tran +export const TRANSFER_TYPE_UNCONDITIONAL = 0; // unconditional tran +export const TRANSFER_TYPE_INVALID = -1; +export const TRANSFER_TYPE_INVALID4 = 4; + +export const REACH_TIMES = 10; +export const AFTER_HANUP_TIMES = 5; + +export const CARMER_ID_NOT_EXIT = 'xtsautotest123456'; +export const CARMER_ID_SPACE = ''; +export const IMAGE_PNG_PATH = '/system/data/callManager.png'; +export const IMAGE_JPG_PATH = '/system/data/callManager.jpg'; +export const IMAGE_BMP_PATH = '/system/data/callManager.bmp'; +export const IMAGE_WEBP_PATH = '/system/data/callManager.webp'; +export const IMAGE_LOCAL_ERROR_PATH = '/system/data/callManager/notexistpath.png'; +export const IMAGE_SPACE_PATH = ''; +export const SENT_STRING_0 = '0'; +export const SENT_STRING_1 = '1'; +export const SENT_STRING_2 = '2'; +export const SENT_STRING_3 = '3'; +export const SENT_STRING_4 = '4'; +export const SENT_STRING_5 = '5'; +export const SENT_STRING_6 = '6'; +export const SENT_STRING_7 = '7'; +export const SENT_STRING_8 = '8'; +export const SENT_STRING_9 = '9'; +export const SENT_STRING_ERROR_10 = '10'; +export const SENT_STRING_A = 'A'; +export const SENT_STRING_Z = 'Z'; +export const SENT_STRING_C = 'C'; +export const SENT_STRING_D = 'D'; +export const SENT_STRING_E = 'E'; +export const SENT_STRING_LOW_A = 'a'; +export const SENT_STRING_LOW_C = 'c'; +export const SENT_STRING_LOW_B = 'b'; +export const SENT_STRING_LOW_D = 'd'; +export const SENT_STRING_STAR = '*'; +export const SENT_STRING_ADD = '+'; +export const SENT_STRING_MINUS = '-'; +export const SENT_STRING_JIN = '#'; +export const CALL_MODE_CS = 0; +export const CALL_MODE_IMS = 3; +export const MEDIA_TYPE_VOICE = 0; +export const MEDIA_TYPE_VIDEO = 1; +export const MEDIA_TYPE_ERROR = -1; +export const MEDIA_TYPE_ERROR2 = 2; +export const DIAL_SCENCE_CALL_NORMAL = 0; +export const DIAL_SCENCE_CALL_PRIVILEGED = 1; +export const DIAL_SCENCE_CALL_CALL_EMERGENCY = 2; +export const DIAL_SCENCE_ERROR = -1; +export const DIAL_SCENCE_ERROR2 = 3; +export const DIAL_CARRIER_TYPE = 0; +export const DIAL_VOICE_MAIL_TYPE = 1; +export const DIAL_OTT_TYPE = 2; +export const DIAL_TYPE_ERROR = -1; +export const DIAL_TYPE_ERROR3 = 3; + +export const POS_700 = 700; +export const POS_10 = 10; +export const POS_Z_0 = 0; +export const POS_Z_1 = 1; +export const POS_Z_ERROR = -1; +export const POS_Z_ERROR2 = 2; +export const POS_LENGTH_300 = 300; +export const POS_LENGTH_600 = 600; + +export const ZOOM_RATIO_5_0 = 5.0; +export const ZOOM_RATIO_15_0 = 15.0; +export const ZOOM_RATIO_0_0 = 0.0; +export const ZOOM_RATIO_10_1 = 10.1; +export const ZOOM_RATIO_MINUS_1_0 = -1.0; + +export const ROTATION_0 = 0; +export const ROTATION_90 = 90; +export const ROTATION_60 = 60; +export const ROTATION_180 = 180; +export const ROTATION_270 = 270; +export const ROTATION_360 = 360; +export const ROTATION_MINUS_1 = -1; + +export const COMMAND_CALL_WAITTING_OPEN = '*43#'; +export const COMMAND_CALL_WAITTING_CLOSE = '#43#'; +export const COMMAND_CALL_WAITTING_QUERY = '*#43#'; +export const COMMAND_CALL_TRANS_OPEN = '*21*10000000001#'; +export const COMMAND_CALL_TRANS_OPEN2 = '**21*10000000001*10#'; +export const COMMAND_CALL_TRANS_RESET = '##21#'; +export const COMMAND_CALL_ERROR = '**21*10000000001******10#'; +export const COMMAND_CALL_ERROR2 = '*ABCDEF123456789#'; +export const COMMAND_CALL_ERROR3 = '#ABCDEF123456789#'; +export const COMMAND_CALL_ERROR4 = '*#ABCDE123456789#'; +export const COMMAND_CALL_ERROR5 = '**ABCDE123456789#'; +export const COMMAND_CALL_ERROR6 = '##ABCDEF123456789#'; + +export const CALL_WAITING_DISABLE = 0; +export const CALL_WAITING_ENABLE = 1; + +export const EVENT_SEND_USSD_SUCCESS = 17; +export const EVENT_SEND_USSD_FAILED = 18; +export const EVENT_SEND_MEDIA_MODE_UPDATE = 19; + +export const RTT_MSG = 'Ab666&#'; + +export const CALL_MODE_AUDIO_ONLY = 0; +export const CALL_MODE_SEND_RECEIVE = 3; +export const CALL_MODE_SEND_ONLY = 1; +export const CALL_MODE_RECEIVE_ONLY = 2; +export const CALL_MODE_VIDEO_PAUSED = 4; +export const CALL_MODE_INVALID_MINUS_1 = -1; +export const CALL_MODE_INVALID_5 = 5; + diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ScenceInCalling.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ScenceInCalling.js similarity index 97% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ScenceInCalling.js rename to telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ScenceInCalling.js index 6dd3654dd..301d72023 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ScenceInCalling.js +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ScenceInCalling.js @@ -1,684 +1,684 @@ -/** - * 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 { - CALL_MANAGER_NUMBER_NULL_NOTICE, - NULL_PHONE_NUMBER, - CALL_STATUS_HOLDING, - CALL_STATUS_DIALING, - CALL_STATUS_DISCONNECTED, - CALL_STATUS_DISCONNECTING, - TIMEOUT_LENTH, - DEFAULT_SLOT_ID, - CALL_STATUS_ACTIVE, - REACH_TIMES, - AFTER_HANUP_TIMES -} from './Const.js'; -import {toString} from './ApiToPromise.js'; -import call from '@ohos.telephony.call'; -import observer from '@ohos.telephony.observer'; - -let hunupTimeOut = null; - -export function clearHandupTime (caseName) { - console.log(`${caseName} clearHandupTime success`); - clearTimeout(hunupTimeOut); -} - -let stateStorage = []; -export let callId = null; -export function callDetailsChangeOn () { - console.log('Telephony_CallManager callDetailsChangeOn'); - call.on('callDetailsChange', (err, callStateInfo) => { - console.log(`Telephony_CallManager callDetailsChange error ${toString(err)}` + - `,callStateInfo ${toString(callStateInfo)}`); - if (callStateInfo) { - stateStorage.push({...callStateInfo}); - callId = callStateInfo.callId; - } - }); -} -export function callDetailsChangeOff () { - console.log('Telephony_CallManager callDetailsChangeOff'); - call.off('callDetailsChange'); -} - -let reachStateTimeout = null; -export function reachState (caseName, checkState, tag, isHunup, target) { - clearInterval(reachStateTimeout); - stateStorage = []; - let oldTime = new Date(); - let timeoutflag = false; - let timeOutLenth = 2 * REACH_TIMES * TIMEOUT_LENTH; - return new Promise((resolve, reject) => { - reachStateTimeout = setInterval(() => { - let now = new Date(); - console.log(`${caseName} ${tag} reachState now:${toString(now)},stateStorage:${toString({stateStorage})}`); - let find = stateStorage.find(ele => { - if (target && target.callId === null && ele.callState === CALL_STATUS_DIALING) { - target.callId = ele.callId; - } - if (target) { // be satisfied with multing call - return ele.callState === checkState && ele.callId === target.callId; - } else { - return ele.callState === checkState; - } - }); - if (find) { - clearInterval(reachStateTimeout); - const message = `${caseName} ${tag} reachState,get the right state checkState:${checkState}`; - console.log(message); - resolve(find); - return; - } - find = stateStorage.find(ele => { - if (target) { // be satisfied with multing call - return ele.callState === CALL_STATUS_DISCONNECTED && ele.callId === target.callId; - } else { - return ele.callState === CALL_STATUS_DISCONNECTED; - } - }); - if (find) { - clearInterval(reachStateTimeout); - reachStateTimeout = setTimeout(() => { - const message = `${caseName} ${tag} reachState,get the state CALL_STATUS_DISCONNECTED from` + - ` ${timeoutflag ? 'local' : 'opposite'}, callId ${find.callId}`; - console.log(message); - if (target) { // be satisfied with multing call - target.callId = null; - } - reject(new Error(message)); - }, AFTER_HANUP_TIMES * TIMEOUT_LENTH); - return; - } - if (new Date() - oldTime > timeOutLenth) { - if (isHunup) { - const message = `${caseName} ${tag} timeout,hunup is runed`; - console.log(message); - clearInterval(reachStateTimeout); - reject(new Error(message)); - return; - } - if (timeoutflag === false) { - timeoutflag = true; - let callId = target ? target.callId : callId;// be satisfied with multing call - if (!callId) { - clearInterval(reachStateTimeout); - const message = `${caseName} ${tag} timeout reachState,callId is not exit`; - reject(new Error(message)); - return; - } - const message = `${caseName} ${tag} timeout reachState,start hunupCall`; - console.log(message); - hangupCall(caseName, callId).then(data => { - const message = `${caseName} ${tag} timeout hangupCall success,data:${toString(data)}`; - console.log(message); - clearInterval(reachStateTimeout); - reject(new Error(message)); - }).catch(error => { - clearInterval(reachStateTimeout); - const message = `${caseName} ${tag} timeout hangupCall error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - } - } - }, 1 * TIMEOUT_LENTH); - }); -} - -export function clearReachState () { - clearInterval(reachStateTimeout); -} - -// dial call in a nomal scence,when specific state arrive,we get the information of this state -export function scenceInCalling (options) { - console.log(`scenceInCalling options ${toString(options)}`); - if (!options.target) { // be satisfied with multing call - callId = null; - } - return new Promise((resolve, reject) => { - let {caseName, phoneNumber, checkState, dialOptions, target} = options; - try { - reachState(caseName, checkState, 'scenceInCalling', false, target)// be satisfied with multing call - .then(data => { - const message = `${caseName} reach the right state success,data:${toString(data)}`; - console.log(message); - resolve(data); - }) - .catch(error => { - const message = `${caseName} reach the right state error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - const callback = (error, data) => { - if (error) { - const message = `${caseName} scenceInCalling dial error,error:${toString(error)}`; - console.log(message); - clearReachState(); - reject(new Error(message)); - return; - } - if (data !== true) { - const message = `${caseName} scenceInCalling dial data error,data:${toString(data)}`; - console.log(message); - clearReachState(); - reject(new Error(message)); - return; - } - console.log(`${caseName} dial true,run continue`); - }; - let arg = [phoneNumber]; - if (dialOptions) { - arg.push(dialOptions); - } - arg.push(callback); - call.dial(...arg); - } catch (error) { - const message = `${caseName} dial try catch error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - } - }); -} - -/* normal function - dial a call with number '',we shoudld get the error */ -export function scenceInCallingNull (options) { - console.log(`scenceInCallingNull options ${toString(options)}`); - return new Promise((resolve, reject) => { - let {caseName, dialOptions} = options; - const callback = (err, data) => { - if (err && err.message === CALL_MANAGER_NUMBER_NULL_NOTICE) { - console.log(`${caseName} dial call null number,data:${toString(err)}`); - resolve(data); - return; - } - const message = `${caseName} should be CALL_MANAGER_NUMBER_NULL_NOTICE,` + - `dial error:${toString(err)},data:${toString(data)}`; - console.log(message); - reject(new Error(message)); - }; - let arg = [NULL_PHONE_NUMBER]; - if (dialOptions) { - arg.push(dialOptions); - } - arg.push(callback); - try { - call.dial(...arg); - } catch (error) { - const message = `${caseName} error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - } - }); -} - -// holding call scence,use it should base on scenceInCalling,get the information at CALL_STATUS_HOLDING state -export function scenceInHolding (options) { - console.log(`scenceInHolding options ${toString(options)}`); - return new Promise(async (resolve, reject) => { - let {caseName, callId} = options; - if (callId) { - reachState(caseName, CALL_STATUS_HOLDING, 'scenceInHolding', false) - .then(data => { - const message = `${caseName} scenceInHolding get the right state success,data:${toString(data)}`; - console.log(message); - resolve(data); - }) - .catch(error => { - const message = `${caseName} scenceInHolding get the right state error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - call.holdCall(callId, (error, data) => { - if (error) { - const message = `${caseName} scenceInHolding holdCall error,error:${toString(error)}`; - console.log(message); - clearReachState(); - reject(new Error(message)); - } - - }); - } else { - const message = `${caseName} scenceInHolding error,need callId`; - console.log(message); - reject(new Error(message)); - } - }); -} - -export function scenceInUnHolding (options) { - console.log(`scenceInUnHolding options ${toString(options)}`); - return new Promise(async (resolve, reject) => { - let {caseName, callId} = options; - if (callId) { - reachState(caseName, CALL_STATUS_ACTIVE, 'scenceInUnHolding', false) - .then(data => { - const message = `${caseName} scenceInUnHolding get the right state success,data:${toString(data)}`; - console.log(message); - resolve(data); - }) - .catch(error => { - const message = `${caseName} scenceInUnHolding get the right state error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - call.unHoldCall(callId, (error, data) => { - if (error) { - const message = `${caseName} scenceInUnHolding error,error:${toString(error)}`; - console.log(message); - clearReachState(); - reject(new Error(message)); - } - - }); - } else { - const message = `${caseName} scenceInUnHolding error,need callId`; - console.log(message); - reject(new Error(message)); - } - }); -} - -// hunup call scence,use it should base on scenceInCalling,specific state arrive,get the information at this state -export function scenceInHangup (options) { - console.log(`scenceInHangup options ${toString(options)}`); - return new Promise(async (resolve, reject) => { - let {caseName, callId, checkState} = options; - if (callId) { - reachState(caseName, checkState, 'scenceInHangup', true).then(data => { - const message = `${caseName} scenceInHangup get the right state success ,data:${toString(data)}`; - console.log(message); - resolve(data); - }).catch(error => { - const message = `${caseName} scenceInHangup get the right state error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - call.hangup(callId) - .then((data) => { - const message = `${caseName} scenceInHangup data,data:${toString(data)}`; - console.log(message); - }) - .catch(error => { - const message = `${caseName} func hangup,error:${toString(error)}`; - console.log(message); - clearReachState(); - reject(new Error(message)); - }); - - } else { - const message = `${caseName} scenceInHangup error,need callId`; - console.log(message); - reject(new Error(message)); - } - }); -} - -// hunup the call ,used in test case -export function hangupCall2 (caseName, done, callId, delaytime) { - let timeout = null; - if (callId) { - const message = `${caseName} hunup,hangupCall2 callId ${callId}`; - console.log(message); - reachState(caseName, CALL_STATUS_DISCONNECTED, 'hangupCall2', true) - .then(data => { - const message = `${caseName} hangupCall2 get right state success,data:${toString(data)}`; - console.log(message); - clearTimeout(timeout); - timeout = setTimeout(function () { - done(); - }, AFTER_HANUP_TIMES * TIMEOUT_LENTH); - }) - .catch(error => { - const message = `${caseName} hangupCall2 get right state error,error:${toString(error)}`; - console.log(message); - }); - call.hangup(callId) - .then((data) => { - console.log(`${caseName} func hangup success,${toString(data)}`); - }) - .catch(error => { - const message = `${caseName} func hangup,error:${toString(error)}`; - console.log(message); - clearReachState(); - done(); - }); - - } else { - const message = `${caseName} hangupCall2 error,need callId`; - console.log(message); - done(); - } -} - -// hunup the call ,used in packaging function -export function hangupCall (caseName, callId) { - return new Promise((resolve, reject) => { - let timeout = null; - if (callId) { - let message = `${caseName} hunup,hangupCall callId:${callId}`; - console.log(message); - reachState(caseName, CALL_STATUS_DISCONNECTED, 'hangupCall', true) - .then(data => { - const message = `${caseName} hangupCall get right state success,data:${toString(data)}`; - console.log(message); - clearTimeout(timeout); - timeout = setTimeout(function () { - resolve(data); - }, AFTER_HANUP_TIMES * TIMEOUT_LENTH); - }) - .catch(error => { - const message = `${caseName} hangupCall get right state error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - call.hangup(callId) - .then((data) => { - console.log(`${caseName} func hangup success,${toString(data)}`); - }) - .catch(error => { - const message = `${caseName} func hangup,error:${toString(error)}`; - console.log(message); - clearReachState(); - reject(new Error(message)); - }); - } else { - const message = `${caseName} func hangup error,need callId`; - console.log(message); - reject(new Error(message)); - } - - }); -} - -/* dial call in a nomal scence used in third-party applications,when specific state arrive, - we get the information of this state */ -export function scenceInCallingForRegister (options) { - console.log(`scenceInCallingForRegister options ${toString(options)}`); - return new Promise((resolve, reject) => { - let {caseName} = options; - let callId = null; - let callChangeData = null; - let func = null; - let count = 0; - if (options.isOnce) { - func = observer.once; - } else { - func = observer.on; - } - if (typeof func !== 'function') { - let message = `${caseName} observer.once or observer.on is not exit,options:${toString(options)}`; - console.log(message); - reject(new Error(message)); - return; - } - func('callStateChange', {slotId: DEFAULT_SLOT_ID}, (data) => { - console.log(`${caseName} callStateChange,data:${toString(data)}`); - callChangeData = data; - count++; - }); - - scenceInCalling({...options}) - .then(data => { - callId = data.callId; - let tempCallChangeData = {count, ...callChangeData}; - console.log(`${caseName} scenceInCalling data,data:${toString(data)},` + - `tempCallChangeData:${toString(tempCallChangeData)}`); - observer.off('callStateChange'); - hangupCall(caseName, callId) - .then(data => { - console.log(`${caseName} scenceInCalling hangupCall data,data:${toString(data)}`); - resolve(tempCallChangeData); - }) - .catch(error => { - const message = `${caseName} scenceInCalling hangupCall error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - }) - .catch(error => { - const message = `${caseName} scenceInCalling error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - }); -} - -// holding call scence used in third-party applications,we get the information of state at CALL_STATUS_HOLDING state -export function scenceInCallingHoldingForRegister (options) { - console.log(`scenceInCallingHoldingForRegister options ${toString(options)}`); - return new Promise((resolve, reject) => { - let {caseName} = options; - let callId = null; - let callChangeData = null; - let func = null; - let count = 0; - if (options.isOnce) { - func = observer.once; - } else { - func = observer.on; - } - if (typeof func !== 'function') { - reject(new Error(`${caseName} observer.once or observer.on is not exit,options:${toString(options)}`)); - return; - } - func('callStateChange', {slotId: DEFAULT_SLOT_ID}, (data) => { - console.log(`${caseName} callStateChange,data:${toString(data)}`); - count++; - callChangeData = data; - }); - scenceInCalling(options) - .then(data => { - scenceInHolding({callId:data.callId, ...options}) - .then(data => { - callId = data.callId; - let tempCallChangeData = {count, ...callChangeData}; - console.log(`${caseName} scenceInHolding data,data:${toString(data)}` + - `,tempCallChangeData:${toString(tempCallChangeData)}`); - observer.off('callStateChange'); - hangupCall(caseName, callId) - .then(data => { - console.log(`${caseName} hangupCall data,data:${toString(data)}`); - resolve(tempCallChangeData); - }) - .catch(error => { - const message = `${caseName} hangupCall error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - }) - .catch(error => { - const message = `${caseName} scenceInHolding ,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - }) - .catch(error => { - const message = `${caseName} scenceInCalling error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - }); -} - -// holding call scence used in third-party applications,we get the information of state when unHoldCall the call -export function scenceInCallingNnHoldingForRegister (options) { - console.log(`scenceInCallingNnHoldingForRegister options ${toString(options)}`); - return new Promise((resolve, reject) => { - let {caseName} = options; - let callId = null; - let callChangeData = null; - let func = null; - let count = 0; - if (options.isOnce) { - func = observer.once; - } else { - func = observer.on; - } - if (typeof func !== 'function') { - reject(new Error(`${caseName} observer.once or observer.on is not exit,options:${toString(options)}`)); - return; - } - func('callStateChange', {slotId:DEFAULT_SLOT_ID}, (data) => { - console.log(`${caseName} callStateChange,data:${toString(data)}`); - count++; - callChangeData = data; - }); - scenceInCalling(options) - .then(data => { - scenceInHolding({callId:data.callId, ...options}) - .then(data => { - callId = data.callId; - scenceInUnHolding({callId:data.callId, ...options}) - .then(data => { - let tempCallChangeData = {count, ...callChangeData}; - console.log(`${caseName} unHoldCall data,data:${toString(data)}, - tempCallChangeData:${toString(tempCallChangeData)}`); - observer.off('callStateChange'); - hangupCall(caseName, callId) - .then(data => { - console.log(`${caseName} hangupCall data,data:${toString(data)}`); - resolve(tempCallChangeData); - }) - .catch(error => { - const message = `${caseName} hangupCall error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - }) - .catch(error => { - const message = `${caseName} unHoldCall error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - }) - .catch(error => { - const message = `${caseName} scenceInHolding error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - }) - .catch(error => { - const message = `${caseName} scenceInCalling error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - }); -} - -// hunup call scence used in third-party applications,we get the information of state when hunup the call -export function scenceInCallingHangupForRegister (options) { - console.log(`scenceInCallingHangupForRegister options ${toString(options)}`); - return new Promise((resolve, reject) => { - let {caseName} = options; - let callId = null; - let callChangeData = null; - let func = null; - let count = 0; - if (options.isOnce) { - func = observer.once; - } else { - func = observer.on; - } - if (typeof func !== 'function') { - reject(new Error(`${caseName} observer.once or observer.on is not exit,options:${toString(options)}`)); - return; - } - func('callStateChange', {slotId: DEFAULT_SLOT_ID}, (data) => { - console.log(`${caseName} callStateChange,data:${toString(data)}`); - count++; - callChangeData = data; - }); - scenceInCalling(options) - .then(data => { - options.checkState = CALL_STATUS_DISCONNECTED; - scenceInHangup({callId:data.callId, ...options}) - .then(data => { - callId = data.callId; - let tempCallChangeData = {count, ...callChangeData}; - console.log(`${caseName} scenceInHangup data,data:${toString(data)},` + - `tempCallChangeData:${toString(tempCallChangeData)}`); - observer.off('callStateChange'); - resolve(tempCallChangeData); - }) - .catch(error => { - const message = `${caseName} scenceInHangup error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - }) - .catch(error => { - const message = `${caseName} scenceInCalling error,error:${toString(error)}`; - console.log(message); - reject(new Error(message)); - }); - }); -} - -export function isHanupEd (state) { - return (state === CALL_STATUS_DISCONNECTING) || (state === CALL_STATUS_DISCONNECTED); -} - -export function reachCallEventState (eventId) { - return new Promise(function (resolve, reject) { - let time = null; - call.on('callEventChange', (err, value) => { - console.log(`Telephony_CallManager callEventChange error ${toString(err)},callStateInfo ${ - toString(value)}`); - if (err) { - let message = `Telephony_CallManager reachCallEventState err message = ${toString(err)}`; - console.log(message); - clearTimeout(time); - reject(new Error(message)); - return; - } - if (eventId === value.eventId) { - let message = `Telephony_CallManager reachCallEventState get the right eventId ${toString(value)}`; - console.log(message); - clearTimeout(time); - resolve(value); - } else { - let message = `Telephony_CallManager reachCallEventState get the error eventId ${toString(value)}`; - console.log(message); - clearTimeout(time); - reject(new Error(message)); - } - }); - time = setTimeout(function () { - let message = 'Telephony_CallManager reachCallEventState time out'; - console.log(message); - reject(new Error(message)); - }, 20 * TIMEOUT_LENTH); - }); -} - -export class TeleCall { - constructor () { - this.callId = null; - } - callScenceInCalling (options) { - this.callId = null; - options.target = this; - return scenceInCalling(options); - } - callReachState (caseName, checkState, tag, isHunup) { - return reachState(caseName, checkState, tag, isHunup, this); - } - callHangupCall (caseName) { - return hangupCall(caseName, this.callId, this); - } +/** + * 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 { + CALL_MANAGER_NUMBER_NULL_NOTICE, + NULL_PHONE_NUMBER, + CALL_STATUS_HOLDING, + CALL_STATUS_DIALING, + CALL_STATUS_DISCONNECTED, + CALL_STATUS_DISCONNECTING, + TIMEOUT_LENTH, + DEFAULT_SLOT_ID, + CALL_STATUS_ACTIVE, + REACH_TIMES, + AFTER_HANUP_TIMES +} from './Const.js'; +import {toString} from './ApiToPromise.js'; +import call from '@ohos.telephony.call'; +import observer from '@ohos.telephony.observer'; + +let hunupTimeOut = null; + +export function clearHandupTime (caseName) { + console.log(`${caseName} clearHandupTime success`); + clearTimeout(hunupTimeOut); +} + +let stateStorage = []; +export let callId = null; +export function callDetailsChangeOn () { + console.log('Telephony_CallManager callDetailsChangeOn'); + call.on('callDetailsChange', (err, callStateInfo) => { + console.log(`Telephony_CallManager callDetailsChange error ${toString(err)}` + + `,callStateInfo ${toString(callStateInfo)}`); + if (callStateInfo) { + stateStorage.push({...callStateInfo}); + callId = callStateInfo.callId; + } + }); +} +export function callDetailsChangeOff () { + console.log('Telephony_CallManager callDetailsChangeOff'); + call.off('callDetailsChange'); +} + +let reachStateTimeout = null; +export function reachState (caseName, checkState, tag, isHunup, target) { + clearInterval(reachStateTimeout); + stateStorage = []; + let oldTime = new Date(); + let timeoutflag = false; + let timeOutLenth = 2 * REACH_TIMES * TIMEOUT_LENTH; + return new Promise((resolve, reject) => { + reachStateTimeout = setInterval(() => { + let now = new Date(); + console.log(`${caseName} ${tag} reachState now:${toString(now)},stateStorage:${toString({stateStorage})}`); + let find = stateStorage.find(ele => { + if (target && target.callId === null && ele.callState === CALL_STATUS_DIALING) { + target.callId = ele.callId; + } + if (target) { // be satisfied with multing call + return ele.callState === checkState && ele.callId === target.callId; + } else { + return ele.callState === checkState; + } + }); + if (find) { + clearInterval(reachStateTimeout); + const message = `${caseName} ${tag} reachState,get the right state checkState:${checkState}`; + console.log(message); + resolve(find); + return; + } + find = stateStorage.find(ele => { + if (target) { // be satisfied with multing call + return ele.callState === CALL_STATUS_DISCONNECTED && ele.callId === target.callId; + } else { + return ele.callState === CALL_STATUS_DISCONNECTED; + } + }); + if (find) { + clearInterval(reachStateTimeout); + reachStateTimeout = setTimeout(() => { + const message = `${caseName} ${tag} reachState,get the state CALL_STATUS_DISCONNECTED from` + + ` ${timeoutflag ? 'local' : 'opposite'}, callId ${find.callId}`; + console.log(message); + if (target) { // be satisfied with multing call + target.callId = null; + } + reject(new Error(message)); + }, AFTER_HANUP_TIMES * TIMEOUT_LENTH); + return; + } + if (new Date() - oldTime > timeOutLenth) { + if (isHunup) { + const message = `${caseName} ${tag} timeout,hunup is runed`; + console.log(message); + clearInterval(reachStateTimeout); + reject(new Error(message)); + return; + } + if (timeoutflag === false) { + timeoutflag = true; + let callId = target ? target.callId : callId;// be satisfied with multing call + if (!callId) { + clearInterval(reachStateTimeout); + const message = `${caseName} ${tag} timeout reachState,callId is not exit`; + reject(new Error(message)); + return; + } + const message = `${caseName} ${tag} timeout reachState,start hunupCall`; + console.log(message); + hangupCall(caseName, callId).then(data => { + const message = `${caseName} ${tag} timeout hangupCall success,data:${toString(data)}`; + console.log(message); + clearInterval(reachStateTimeout); + reject(new Error(message)); + }).catch(error => { + clearInterval(reachStateTimeout); + const message = `${caseName} ${tag} timeout hangupCall error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + } + } + }, 1 * TIMEOUT_LENTH); + }); +} + +export function clearReachState () { + clearInterval(reachStateTimeout); +} + +// dial call in a nomal scence,when specific state arrive,we get the information of this state +export function scenceInCalling (options) { + console.log(`scenceInCalling options ${toString(options)}`); + if (!options.target) { // be satisfied with multing call + callId = null; + } + return new Promise((resolve, reject) => { + let {caseName, phoneNumber, checkState, dialOptions, target} = options; + try { + reachState(caseName, checkState, 'scenceInCalling', false, target)// be satisfied with multing call + .then(data => { + const message = `${caseName} reach the right state success,data:${toString(data)}`; + console.log(message); + resolve(data); + }) + .catch(error => { + const message = `${caseName} reach the right state error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + const callback = (error, data) => { + if (error) { + const message = `${caseName} scenceInCalling dial error,error:${toString(error)}`; + console.log(message); + clearReachState(); + reject(new Error(message)); + return; + } + if (data !== true) { + const message = `${caseName} scenceInCalling dial data error,data:${toString(data)}`; + console.log(message); + clearReachState(); + reject(new Error(message)); + return; + } + console.log(`${caseName} dial true,run continue`); + }; + let arg = [phoneNumber]; + if (dialOptions) { + arg.push(dialOptions); + } + arg.push(callback); + call.dial(...arg); + } catch (error) { + const message = `${caseName} dial try catch error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + } + }); +} + +/* normal function + dial a call with number '',we shoudld get the error */ +export function scenceInCallingNull (options) { + console.log(`scenceInCallingNull options ${toString(options)}`); + return new Promise((resolve, reject) => { + let {caseName, dialOptions} = options; + const callback = (err, data) => { + if (err && err.message === CALL_MANAGER_NUMBER_NULL_NOTICE) { + console.log(`${caseName} dial call null number,data:${toString(err)}`); + resolve(data); + return; + } + const message = `${caseName} should be CALL_MANAGER_NUMBER_NULL_NOTICE,` + + `dial error:${toString(err)},data:${toString(data)}`; + console.log(message); + reject(new Error(message)); + }; + let arg = [NULL_PHONE_NUMBER]; + if (dialOptions) { + arg.push(dialOptions); + } + arg.push(callback); + try { + call.dial(...arg); + } catch (error) { + const message = `${caseName} error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + } + }); +} + +// holding call scence,use it should base on scenceInCalling,get the information at CALL_STATUS_HOLDING state +export function scenceInHolding (options) { + console.log(`scenceInHolding options ${toString(options)}`); + return new Promise(async (resolve, reject) => { + let {caseName, callId} = options; + if (callId) { + reachState(caseName, CALL_STATUS_HOLDING, 'scenceInHolding', false) + .then(data => { + const message = `${caseName} scenceInHolding get the right state success,data:${toString(data)}`; + console.log(message); + resolve(data); + }) + .catch(error => { + const message = `${caseName} scenceInHolding get the right state error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + call.holdCall(callId, (error, data) => { + if (error) { + const message = `${caseName} scenceInHolding holdCall error,error:${toString(error)}`; + console.log(message); + clearReachState(); + reject(new Error(message)); + } + + }); + } else { + const message = `${caseName} scenceInHolding error,need callId`; + console.log(message); + reject(new Error(message)); + } + }); +} + +export function scenceInUnHolding (options) { + console.log(`scenceInUnHolding options ${toString(options)}`); + return new Promise(async (resolve, reject) => { + let {caseName, callId} = options; + if (callId) { + reachState(caseName, CALL_STATUS_ACTIVE, 'scenceInUnHolding', false) + .then(data => { + const message = `${caseName} scenceInUnHolding get the right state success,data:${toString(data)}`; + console.log(message); + resolve(data); + }) + .catch(error => { + const message = `${caseName} scenceInUnHolding get the right state error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + call.unHoldCall(callId, (error, data) => { + if (error) { + const message = `${caseName} scenceInUnHolding error,error:${toString(error)}`; + console.log(message); + clearReachState(); + reject(new Error(message)); + } + + }); + } else { + const message = `${caseName} scenceInUnHolding error,need callId`; + console.log(message); + reject(new Error(message)); + } + }); +} + +// hunup call scence,use it should base on scenceInCalling,specific state arrive,get the information at this state +export function scenceInHangup (options) { + console.log(`scenceInHangup options ${toString(options)}`); + return new Promise(async (resolve, reject) => { + let {caseName, callId, checkState} = options; + if (callId) { + reachState(caseName, checkState, 'scenceInHangup', true).then(data => { + const message = `${caseName} scenceInHangup get the right state success ,data:${toString(data)}`; + console.log(message); + resolve(data); + }).catch(error => { + const message = `${caseName} scenceInHangup get the right state error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + call.hangup(callId) + .then((data) => { + const message = `${caseName} scenceInHangup data,data:${toString(data)}`; + console.log(message); + }) + .catch(error => { + const message = `${caseName} func hangup,error:${toString(error)}`; + console.log(message); + clearReachState(); + reject(new Error(message)); + }); + + } else { + const message = `${caseName} scenceInHangup error,need callId`; + console.log(message); + reject(new Error(message)); + } + }); +} + +// hunup the call ,used in test case +export function hangupCall2 (caseName, done, callId, delaytime) { + let timeout = null; + if (callId) { + const message = `${caseName} hunup,hangupCall2 callId ${callId}`; + console.log(message); + reachState(caseName, CALL_STATUS_DISCONNECTED, 'hangupCall2', true) + .then(data => { + const message = `${caseName} hangupCall2 get right state success,data:${toString(data)}`; + console.log(message); + clearTimeout(timeout); + timeout = setTimeout(function () { + done(); + }, AFTER_HANUP_TIMES * TIMEOUT_LENTH); + }) + .catch(error => { + const message = `${caseName} hangupCall2 get right state error,error:${toString(error)}`; + console.log(message); + }); + call.hangup(callId) + .then((data) => { + console.log(`${caseName} func hangup success,${toString(data)}`); + }) + .catch(error => { + const message = `${caseName} func hangup,error:${toString(error)}`; + console.log(message); + clearReachState(); + done(); + }); + + } else { + const message = `${caseName} hangupCall2 error,need callId`; + console.log(message); + done(); + } +} + +// hunup the call ,used in packaging function +export function hangupCall (caseName, callId) { + return new Promise((resolve, reject) => { + let timeout = null; + if (callId) { + let message = `${caseName} hunup,hangupCall callId:${callId}`; + console.log(message); + reachState(caseName, CALL_STATUS_DISCONNECTED, 'hangupCall', true) + .then(data => { + const message = `${caseName} hangupCall get right state success,data:${toString(data)}`; + console.log(message); + clearTimeout(timeout); + timeout = setTimeout(function () { + resolve(data); + }, AFTER_HANUP_TIMES * TIMEOUT_LENTH); + }) + .catch(error => { + const message = `${caseName} hangupCall get right state error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + call.hangup(callId) + .then((data) => { + console.log(`${caseName} func hangup success,${toString(data)}`); + }) + .catch(error => { + const message = `${caseName} func hangup,error:${toString(error)}`; + console.log(message); + clearReachState(); + reject(new Error(message)); + }); + } else { + const message = `${caseName} func hangup error,need callId`; + console.log(message); + reject(new Error(message)); + } + + }); +} + +/* dial call in a nomal scence used in third-party applications,when specific state arrive, + we get the information of this state */ +export function scenceInCallingForRegister (options) { + console.log(`scenceInCallingForRegister options ${toString(options)}`); + return new Promise((resolve, reject) => { + let {caseName} = options; + let callId = null; + let callChangeData = null; + let func = null; + let count = 0; + if (options.isOnce) { + func = observer.once; + } else { + func = observer.on; + } + if (typeof func !== 'function') { + let message = `${caseName} observer.once or observer.on is not exit,options:${toString(options)}`; + console.log(message); + reject(new Error(message)); + return; + } + func('callStateChange', {slotId: DEFAULT_SLOT_ID}, (data) => { + console.log(`${caseName} callStateChange,data:${toString(data)}`); + callChangeData = data; + count++; + }); + + scenceInCalling({...options}) + .then(data => { + callId = data.callId; + let tempCallChangeData = {count, ...callChangeData}; + console.log(`${caseName} scenceInCalling data,data:${toString(data)},` + + `tempCallChangeData:${toString(tempCallChangeData)}`); + observer.off('callStateChange'); + hangupCall(caseName, callId) + .then(data => { + console.log(`${caseName} scenceInCalling hangupCall data,data:${toString(data)}`); + resolve(tempCallChangeData); + }) + .catch(error => { + const message = `${caseName} scenceInCalling hangupCall error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + }) + .catch(error => { + const message = `${caseName} scenceInCalling error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + }); +} + +// holding call scence used in third-party applications,we get the information of state at CALL_STATUS_HOLDING state +export function scenceInCallingHoldingForRegister (options) { + console.log(`scenceInCallingHoldingForRegister options ${toString(options)}`); + return new Promise((resolve, reject) => { + let {caseName} = options; + let callId = null; + let callChangeData = null; + let func = null; + let count = 0; + if (options.isOnce) { + func = observer.once; + } else { + func = observer.on; + } + if (typeof func !== 'function') { + reject(new Error(`${caseName} observer.once or observer.on is not exit,options:${toString(options)}`)); + return; + } + func('callStateChange', {slotId: DEFAULT_SLOT_ID}, (data) => { + console.log(`${caseName} callStateChange,data:${toString(data)}`); + count++; + callChangeData = data; + }); + scenceInCalling(options) + .then(data => { + scenceInHolding({callId:data.callId, ...options}) + .then(data => { + callId = data.callId; + let tempCallChangeData = {count, ...callChangeData}; + console.log(`${caseName} scenceInHolding data,data:${toString(data)}` + + `,tempCallChangeData:${toString(tempCallChangeData)}`); + observer.off('callStateChange'); + hangupCall(caseName, callId) + .then(data => { + console.log(`${caseName} hangupCall data,data:${toString(data)}`); + resolve(tempCallChangeData); + }) + .catch(error => { + const message = `${caseName} hangupCall error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + }) + .catch(error => { + const message = `${caseName} scenceInHolding ,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + }) + .catch(error => { + const message = `${caseName} scenceInCalling error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + }); +} + +// holding call scence used in third-party applications,we get the information of state when unHoldCall the call +export function scenceInCallingNnHoldingForRegister (options) { + console.log(`scenceInCallingNnHoldingForRegister options ${toString(options)}`); + return new Promise((resolve, reject) => { + let {caseName} = options; + let callId = null; + let callChangeData = null; + let func = null; + let count = 0; + if (options.isOnce) { + func = observer.once; + } else { + func = observer.on; + } + if (typeof func !== 'function') { + reject(new Error(`${caseName} observer.once or observer.on is not exit,options:${toString(options)}`)); + return; + } + func('callStateChange', {slotId:DEFAULT_SLOT_ID}, (data) => { + console.log(`${caseName} callStateChange,data:${toString(data)}`); + count++; + callChangeData = data; + }); + scenceInCalling(options) + .then(data => { + scenceInHolding({callId:data.callId, ...options}) + .then(data => { + callId = data.callId; + scenceInUnHolding({callId:data.callId, ...options}) + .then(data => { + let tempCallChangeData = {count, ...callChangeData}; + console.log(`${caseName} unHoldCall data,data:${toString(data)}, + tempCallChangeData:${toString(tempCallChangeData)}`); + observer.off('callStateChange'); + hangupCall(caseName, callId) + .then(data => { + console.log(`${caseName} hangupCall data,data:${toString(data)}`); + resolve(tempCallChangeData); + }) + .catch(error => { + const message = `${caseName} hangupCall error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + }) + .catch(error => { + const message = `${caseName} unHoldCall error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + }) + .catch(error => { + const message = `${caseName} scenceInHolding error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + }) + .catch(error => { + const message = `${caseName} scenceInCalling error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + }); +} + +// hunup call scence used in third-party applications,we get the information of state when hunup the call +export function scenceInCallingHangupForRegister (options) { + console.log(`scenceInCallingHangupForRegister options ${toString(options)}`); + return new Promise((resolve, reject) => { + let {caseName} = options; + let callId = null; + let callChangeData = null; + let func = null; + let count = 0; + if (options.isOnce) { + func = observer.once; + } else { + func = observer.on; + } + if (typeof func !== 'function') { + reject(new Error(`${caseName} observer.once or observer.on is not exit,options:${toString(options)}`)); + return; + } + func('callStateChange', {slotId: DEFAULT_SLOT_ID}, (data) => { + console.log(`${caseName} callStateChange,data:${toString(data)}`); + count++; + callChangeData = data; + }); + scenceInCalling(options) + .then(data => { + options.checkState = CALL_STATUS_DISCONNECTED; + scenceInHangup({callId:data.callId, ...options}) + .then(data => { + callId = data.callId; + let tempCallChangeData = {count, ...callChangeData}; + console.log(`${caseName} scenceInHangup data,data:${toString(data)},` + + `tempCallChangeData:${toString(tempCallChangeData)}`); + observer.off('callStateChange'); + resolve(tempCallChangeData); + }) + .catch(error => { + const message = `${caseName} scenceInHangup error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + }) + .catch(error => { + const message = `${caseName} scenceInCalling error,error:${toString(error)}`; + console.log(message); + reject(new Error(message)); + }); + }); +} + +export function isHanupEd (state) { + return (state === CALL_STATUS_DISCONNECTING) || (state === CALL_STATUS_DISCONNECTED); +} + +export function reachCallEventState (eventId) { + return new Promise(function (resolve, reject) { + let time = null; + call.on('callEventChange', (err, value) => { + console.log(`Telephony_CallManager callEventChange error ${toString(err)},callStateInfo ${ + toString(value)}`); + if (err) { + let message = `Telephony_CallManager reachCallEventState err message = ${toString(err)}`; + console.log(message); + clearTimeout(time); + reject(new Error(message)); + return; + } + if (eventId === value.eventId) { + let message = `Telephony_CallManager reachCallEventState get the right eventId ${toString(value)}`; + console.log(message); + clearTimeout(time); + resolve(value); + } else { + let message = `Telephony_CallManager reachCallEventState get the error eventId ${toString(value)}`; + console.log(message); + clearTimeout(time); + reject(new Error(message)); + } + }); + time = setTimeout(function () { + let message = 'Telephony_CallManager reachCallEventState time out'; + console.log(message); + reject(new Error(message)); + }, 20 * TIMEOUT_LENTH); + }); +} + +export class TeleCall { + constructor () { + this.callId = null; + } + callScenceInCalling (options) { + this.callId = null; + options.target = this; + return scenceInCalling(options); + } + callReachState (caseName, checkState, tag, isHunup) { + return reachState(caseName, checkState, tag, isHunup, this); + } + callHangupCall (caseName) { + return hangupCall(caseName, this.callId, this); + } } \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ScenceLimitCalling.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ScenceLimitCalling.js similarity index 97% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ScenceLimitCalling.js rename to telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ScenceLimitCalling.js index eade0379d..d1fe283b1 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ScenceLimitCalling.js +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ScenceLimitCalling.js @@ -1,57 +1,57 @@ -/** - * 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 {RIGHT_PASSWORD, DEFAULT_SLOT_ID, RESTRICTION_MODE_DEACTIVATION} from './Const.js'; -import {toString} from './ApiToPromise.js'; -import call from '@ohos.telephony.call'; - -// limit call scence -export function scenceLimitCalling (caseName, type, mode, slotId) { - return new Promise((resolve, reject) => { - console.log(`${caseName} scenceLimitCalling type:${type},mode:${mode}`); - call.setCallRestriction(slotId ? slotId : DEFAULT_SLOT_ID, { - type, - mode, - password:RIGHT_PASSWORD, - }) - .then(data => { - console.log(`${caseName} setCallRestriction success, data:${toString(data)}`); - resolve(data); - }) - .catch((error) => { - console.log(`${caseName} setCallRestriction error,error:${toString(error)}`); - reject(error); - }); - }); -} - -export function scenceLimitCancel (caseName, type, slotId) { - return new Promise((resolve, reject) => { - console.log(`${caseName} scenceLimitCancel type:${type}`); - call.setCallRestriction(slotId ? slotId : DEFAULT_SLOT_ID, { - type, - mode:RESTRICTION_MODE_DEACTIVATION, - password:RIGHT_PASSWORD, - }) - .then(data => { - console.log(`${caseName} scenceLimitCancel success, data:${toString(data)}`); - resolve(data); - }) - .catch((error) => { - console.log(`${caseName} scenceLimitCancel error,error:${toString(error)}`); - reject(error); - }); - }); -} +/** + * 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 {RIGHT_PASSWORD, DEFAULT_SLOT_ID, RESTRICTION_MODE_DEACTIVATION} from './Const.js'; +import {toString} from './ApiToPromise.js'; +import call from '@ohos.telephony.call'; + +// limit call scence +export function scenceLimitCalling (caseName, type, mode, slotId) { + return new Promise((resolve, reject) => { + console.log(`${caseName} scenceLimitCalling type:${type},mode:${mode}`); + call.setCallRestriction(slotId ? slotId : DEFAULT_SLOT_ID, { + type, + mode, + password:RIGHT_PASSWORD, + }) + .then(data => { + console.log(`${caseName} setCallRestriction success, data:${toString(data)}`); + resolve(data); + }) + .catch((error) => { + console.log(`${caseName} setCallRestriction error,error:${toString(error)}`); + reject(error); + }); + }); +} + +export function scenceLimitCancel (caseName, type, slotId) { + return new Promise((resolve, reject) => { + console.log(`${caseName} scenceLimitCancel type:${type}`); + call.setCallRestriction(slotId ? slotId : DEFAULT_SLOT_ID, { + type, + mode:RESTRICTION_MODE_DEACTIVATION, + password:RIGHT_PASSWORD, + }) + .then(data => { + console.log(`${caseName} scenceLimitCancel success, data:${toString(data)}`); + resolve(data); + }) + .catch((error) => { + console.log(`${caseName} scenceLimitCancel error,error:${toString(error)}`); + reject(error); + }); + }); +} diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ScenceTransfer.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ScenceTransfer.js similarity index 97% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ScenceTransfer.js rename to telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ScenceTransfer.js index 41cfdbaf5..e07d2220e 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/lib/ScenceTransfer.js +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/js/test/lib/ScenceTransfer.js @@ -1,48 +1,48 @@ -/** - * 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 call from '@ohos.telephony.call'; -import {toString} from './ApiToPromise.js'; -export function scenceTransferCalling (caseName, settingType, type, phoneNumber) { - return new Promise((resolve, reject) => { - call.setCallTransfer(0, { - settingType, - type, - phoneNumber, - }) - .then(data => { - console.log(`${caseName} scenceTransferCalling success,data:${toString(data)}`); - resolve(data); - }) - .catch((error) => { - console.log(`${caseName} scenceTransferCalling error,error:${toString(error)}`); - reject(error); - }); - }); -} - -export function scenceTransferCancel (caseName) { - return new Promise((resolve, reject) => { - call.dial('##002#') - .then(data => { - console.log(`${caseName} scenceTransferCancel success,data:${toString(data)}`); - resolve(data); - }) - .catch((error) => { - console.log(`${caseName} scenceTransferCancel error,error${toString(error)}`); - reject(error); - }); - }); -} - +/** + * 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 call from '@ohos.telephony.call'; +import {toString} from './ApiToPromise.js'; +export function scenceTransferCalling (caseName, settingType, type, phoneNumber) { + return new Promise((resolve, reject) => { + call.setCallTransfer(0, { + settingType, + type, + phoneNumber, + }) + .then(data => { + console.log(`${caseName} scenceTransferCalling success,data:${toString(data)}`); + resolve(data); + }) + .catch((error) => { + console.log(`${caseName} scenceTransferCalling error,error:${toString(error)}`); + reject(error); + }); + }); +} + +export function scenceTransferCancel (caseName) { + return new Promise((resolve, reject) => { + call.dial('##002#') + .then(data => { + console.log(`${caseName} scenceTransferCancel success,data:${toString(data)}`); + resolve(data); + }) + .catch((error) => { + console.log(`${caseName} scenceTransferCancel error,error${toString(error)}`); + reject(error); + }); + }); +} + diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/resources/base/element/string.json b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/resources/base/element/string.json new file mode 100644 index 000000000..37616f875 --- /dev/null +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/resources/base/media/icon.png b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/resources/base/media/icon.png similarity index 100% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/resources/base/media/icon.png rename to telephony/telephonyjstest/call_manager/call_manager_ims2_call/src/main/resources/base/media/icon.png diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/BUILD.gn b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/BUILD.gn index d71d00f31..0d2efeb3e 100644 --- a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/BUILD.gn +++ b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/BUILD.gn @@ -1,31 +1,33 @@ -# 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("ActsCellularDataAbnormalTest") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":hjs_demo_js_assets", - ":hjs_demo_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsCellularDataAbnormalTest" -} -ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./entry/src/main/js/default" -} -ohos_resources("hjs_demo_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} +# 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("ActsCellularDataAbnormalTest") { + hap_profile = "./src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsCellularDataAbnormalTest" +} +ohos_js_assets("hjs_demo_js_assets") { + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/Test.json b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/Test.json index d7145f5da..450767c2d 100644 --- a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/Test.json +++ b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/Test.json @@ -1,18 +1,20 @@ -{ - "description": "Configuration for callmanager Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "1800000", - "package": "com.ohos.cellulardata", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "$module.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} +{ + "description": "Configuration for callmanager Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "1800000", + "bundle-name": "com.ohos.cellulardata", + "package-name": "com.ohos.cellulardata", + "shell-timeout": "1800000", + "testcase-timeout": "30000" + }, + "kits": [ + { + "test-file-name": [ + "$module.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/resources/base/element/string.json b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/resources/base/element/string.json deleted file mode 100644 index 359c05368..000000000 --- a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "CallManager" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/resources/base/media/icon.png b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obwdgLDVP5+s zy1=_DWG0Y-Jb3t^WXmkr(d9~08k-|#Ly zaNOmT(^9tIb&eb4%CzIT zAm3CUtWSr1t4?h1kk#NBi{U|pJslvME{q|_eS^3En>SOqSxyuN1x;Is@8~m?*>}** znrRFArP!K_52RpX*&JHMR<^lVdm8ypJ}0R(SD(51j;6@ni$6bQ+2XL+R^|NnSp5}(kzvMZ^(@4fD_{QVu$(&K6H|C37TG1Am9Re{<<3gd zh@`>;BqkXMW&p0T6rt|iB$)~CvFe(XC)F9WgAZn*0@t$oZo;!*}r@_`h?KKH&6A@3= zISXoQB+~`op>NP-buiA*^0n{@i{_?MRG)&k)c)k_F+-2Lud!S9pc+i`s74NpBCaGF zXN+pHkubw*msGBTY27BKHv)RRh3;nMg4&$fD_6X9Vt~;_4D+5XPH~#Kn-yjcy!$}1 zigv#FNY>TqMhtIBb@UoF!cE~Q8~;!Pek>SQQwHnHuWKoVBosAiOr}q>!>aE*Krc)V zBUMEcJ5NU0g8}-h6i1zpMY9>m4ne?=U2~`w7K7Q0gB_=p@$5K7p6}thw z-~3dMj?YNX2X$lZ+7ngQ$=s}3mizNN@kE%OtB)?c&i~2L55z8^=yz;xMHLmlY>&Q# zJj?!)M#q_SyfkQh)k?j8IfLtB)ZCp|*vf4_B zos?73yd^h-Ac+;?E4*bpf=o*^3x3-`TVjbY4n6!EN10K6o@fxdyps05Vo3PU)otB} z`3kR+2w7_C#8Z!q`J)p{Vh!+m9-UP!$STp+Hb}}#@#_u^SsUQg<}59< zTvH3%XS4G+6FF^(m6bVF&nSUIXcl;nw{=H$%fgeJ>CgDYiLdpDXr{;-AnG z8dvcrHYVMI&`R6;GWekI@Ir3!uo)oz4^{6q0m^}@f2tM9&=YHNi6-?rh0-{+k@cQm zdp`g#YdQn%MDVg2GR>wZ`n2<0l4)9nx1Wfr&!Dvz=bPwU!h2S?ez6MVc5APE4-xLB zi&W9Q8k2@0w!C53g?iAIQ}~p*3O(@zja6KQ=M3zfW*_6o5SwR-)6VBh~m7{^-=MC-owYH5-u40a}a0liho3QZZ5L{bS_xM1)4}19)zTU$$MY zq3eZML1WC{K%YFd`Be0M-rkO^l?h{kM{$2oK1*A@HVJ57*yhDkUF!2WZ&oA4Y-sK( zCY69%#`mBCi6>6uw(x4gbFaP0+FD*JKJ-q!F1E?vLJ+d35!I5d7@^eU?(CS|C^tmI5?lv@s{{*|1F zFg|OzNpZ0hxljdjaW%45O0MOttRrd(Z?h{HYbB-KFUx&9GfFL3b8NwZ$zNu)WbBD` zYkj$^UB5%3Pj1MDr>S2Ejr9pUcgA!;ZG!@{uAy12)vG=*^9-|dNQBc8&`oxBlU~#y zs!anJX&T?57Jdr^sb>e+V`MVfY>Y0ESg7MG<7W0g&bR-ZYzzZ%2H&Etcp zcd6QeXO1D!5A#zM0lx*GH}`M)2~ZFLE;sP^RSB5wVMNfiZXPd(cmO>j=OSA3`o5r& zna(|^jGXbdN7PK)U8b7^zYtYkkeb%<%F~=OqB~kXMQkq}ii|skh@WSRt>5za;cjP0 zZ~nD%6)wzedqE}BMLt~qKwlvTr33))#uP~xyw#*Eaa|DbMQ_%mG0U8numf8)0DX`r zRoG2bM;#g|p-8gWnwRV5SCW0tLjLO&9Z?K>FImeIxlGUgo0Zk`9Qzhj1eco~7XZy+hXc@YF&ZQ=? zn*^1O56yK^x{y}q`j7}blGCx%dydV!c7)g~tJzmHhV=W~jbWRRR{1<^oDK+1clprm zz$eCy7y9+?{E|YgkW~}}iB#I4XoJ*xr8R?i_Hv$=Cof5bo-Nj~f`-DLebH}&0% zfQj9@WGd4;N~Y?mzQsHJTJq6!Qzl^-vwol(+fMt#Pl=Wh#lI5Vmu@QM0=_r+1wHt` z+8WZ~c2}KQQ+q)~2Ki77QvV&`xb|xVcTms99&cD$Zz4+-^R4kvUBxG8gDk7Y`K*)JZ^2rL(+ZWV~%W(@6 z)0bPArG#BROa_PHs~&WplQ_UIrpd)1N1QGPfv!J(Z9jNT#i%H?CE6|pPZb9hJ1JW4 z^q;ft#!HRNV0YgPojzIYT`8LuET2rUe-J|c!9l4`^*;4WtY@Ew@pL>wkjmMgGfN7 ze}}GtmU0@<_#08~I-Suk=^*9GLW=H4xhsml;vAV{%hy5Eegl@!6qKqbG024%n2HHw zCc@ivW_$@5ZoHP70(7D+(`PvgjW1Pd`wsiuv-aCukMrafwDm)B!xXVy*j2opohhoU zcJz%ADmj>i3`-3-$7nQKBQQuGY;2Qt&+(L~C>vSGFj5{Mlv?T_^dql;{zkpe4R1}R z%XfZyQ}wr*sr>jrKgm*PWLjuVc%6&&`Kbf1SuFpHPN&>W)$GmqC;pIoBC`=4-hPY8 zT*>%I2fP}vGW;R=^!1be?ta2UQd2>alOFFbVl;(SQJ4Jk#)4Z0^wpWEVvY4=vyDk@ zqlModi@iVPMC+{?rm=4(n+<;|lmUO@UKYA>EPTS~AndtK^Wy^%#3<;(dQdk3WaUkRtzSMC9}7x2||CNpF#(3T4C)@ z$~RWs`BNABKX|{cmBt>Q=&gkXl&x!!NK_%5hW0LS)Z4PB>%sV?F-{Wyj#s7W%$F{D zXdK^Fp3wvy+48+GP6F_|^PCRx=ddcTO3sG;B23A49~Qaw31SZ0Rc~`r4qqt%#OGW{ zCA_(LG5^N>yzUn&kAgVmxb=EA8s&tBXC}S1CZ(KoW)(%^JjLTPo^fs`Va;`=YlVPgmB$!yB}<(4ym6OeZ3xAJJ#;)2+B%p3P1Wt+d$eo`vz`T zXfUP2))kBDPoscH;Jc7I3NU<({|@wM$&GaDt`n7WLgIY3IA7A6-_R?z8N3mz|}*i z(zl5ot--Oq@f2-nv{X(ujT2T(k1vY_qh93pK@>H-qc%2Xta)IP0Q%zt%bqYgI`o!wv!0QerB`nCN^1n|@$sVOQ!V0teVG!I z_fD%JvfDeT1cK#-{o6Gv7}& zY0#NWin~kVaf$aufV&;63Hbs|`QVZWpDX6IMk1Hj2G}fiH9e-^6u2zf^FIr^BwD<6zjw63+{yUe8PUFvk8v{sJ=R{d#`O!sz`Q13~< zPT$JS(w=yQfU2`zPCNfSw=&zup@DXc(98afjhv@1w_f!m2Z>rMJ19AB&dB%P#Ls3b z=lK7OILM+SQ&VEd=1GN6o&>YVVtIzoZ%=Z_SdqJN2}E43{bE`>w+A;=y->@^k{oCC z$F*WTY&?34;kfyFV?b*Xb1Pq`Z=%OgwEg)Rz)tx=`f%5#w_INP=x&z5!jI;#;N$ma zhO)+MDm;SxOEVL15; zGq(v2pL3&P1Sl)8P*;G-fd{l1QJsv@e@d8)1PK4w2m*M%V3j-V~L^$i|&C@b?D?9tfwE{B^}Z$k8e5FmQ>v7Xz)sG32g9t}YBt zyR$+*_00RmPx+0mW+vVG4mxd(n$(eQf3-w>JPl2UJpafrPaL5@2j}%{VE-) zBI%6Qpj*dsdH<;g!S!avA~bv^0E+ zfyJbSjPb+j;J52U)<|cIcntQBI2T#>2;tOxu{%D?kML476AErF(qN9hPva5Nkc@BF zC-tLF@3ZFb%Kpj)M<{)x*l|*Ia@ECeXo2E4h2f!aV=cHAhi_E_mfUth(sM4^hJq7B zQsGWqdZUm9S%F`$nQ*_#NcuD`&)Ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}yR?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obwdgLDVP5+s zy1=_DWG0Y-Jb3t^WXmkr(d9~08k-|#Ly zaNOmT(^9tIb&eb4%CzIT zAm3CUtWSr1t4?h1kk#NBi{U|pJslvME{q|_eS^3En>SOqSxyuN1x;Is@8~m?*>}** znrRFArP!K_52RpX*&JHMR<^lVdm8ypJ}0R(SD(51j;6@ni$6bQ+2XL+R^|NnSp5}(kzvMZ^(@4fD_{QVu$(&K6H|C37TG1Am9Re{<<3gd zh@`>;BqkXMW&p0T6rt|iB$)~CvFe(XC)F9WgAZn*0@t$oZo;!*}r@_`h?KKH&6A@3= zISXoQB+~`op>NP-buiA*^0n{@i{_?MRG)&k)c)k_F+-2Lud!S9pc+i`s74NpBCaGF zXN+pHkubw*msGBTY27BKHv)RRh3;nMg4&$fD_6X9Vt~;_4D+5XPH~#Kn-yjcy!$}1 zigv#FNY>TqMhtIBb@UoF!cE~Q8~;!Pek>SQQwHnHuWKoVBosAiOr}q>!>aE*Krc)V zBUMEcJ5NU0g8}-h6i1zpMY9>m4ne?=U2~`w7K7Q0gB_=p@$5K7p6}thw z-~3dMj?YNX2X$lZ+7ngQ$=s}3mizNN@kE%OtB)?c&i~2L55z8^=yz;xMHLmlY>&Q# zJj?!)M#q_SyfkQh)k?j8IfLtB)ZCp|*vf4_B zos?73yd^h-Ac+;?E4*bpf=o*^3x3-`TVjbY4n6!EN10K6o@fxdyps05Vo3PU)otB} z`3kR+2w7_C#8Z!q`J)p{Vh!+m9-UP!$STp+Hb}}#@#_u^SsUQg<}59< zTvH3%XS4G+6FF^(m6bVF&nSUIXcl;nw{=H$%fgeJ>CgDYiLdpDXr{;-AnG z8dvcrHYVMI&`R6;GWekI@Ir3!uo)oz4^{6q0m^}@f2tM9&=YHNi6-?rh0-{+k@cQm zdp`g#YdQn%MDVg2GR>wZ`n2<0l4)9nx1Wfr&!Dvz=bPwU!h2S?ez6MVc5APE4-xLB zi&W9Q8k2@0w!C53g?iAIQ}~p*3O(@zja6KQ=M3zfW*_6o5SwR-)6VBh~m7{^-=MC-owYH5-u40a}a0liho3QZZ5L{bS_xM1)4}19)zTU$$MY zq3eZML1WC{K%YFd`Be0M-rkO^l?h{kM{$2oK1*A@HVJ57*yhDkUF!2WZ&oA4Y-sK( zCY69%#`mBCi6>6uw(x4gbFaP0+FD*JKJ-q!F1E?vLJ+d35!I5d7@^eU?(CS|C^tmI5?lv@s{{*|1F zFg|OzNpZ0hxljdjaW%45O0MOttRrd(Z?h{HYbB-KFUx&9GfFL3b8NwZ$zNu)WbBD` zYkj$^UB5%3Pj1MDr>S2Ejr9pUcgA!;ZG!@{uAy12)vG=*^9-|dNQBc8&`oxBlU~#y zs!anJX&T?57Jdr^sb>e+V`MVfY>Y0ESg7MG<7W0g&bR-ZYzzZ%2H&Etcp zcd6QeXO1D!5A#zM0lx*GH}`M)2~ZFLE;sP^RSB5wVMNfiZXPd(cmO>j=OSA3`o5r& zna(|^jGXbdN7PK)U8b7^zYtYkkeb%<%F~=OqB~kXMQkq}ii|skh@WSRt>5za;cjP0 zZ~nD%6)wzedqE}BMLt~qKwlvTr33))#uP~xyw#*Eaa|DbMQ_%mG0U8numf8)0DX`r zRoG2bM;#g|p-8gWnwRV5SCW0tLjLO&9Z?K>FImeIxlGUgo0Zk`9Qzhj1eco~7XZy+hXc@YF&ZQ=? zn*^1O56yK^x{y}q`j7}blGCx%dydV!c7)g~tJzmHhV=W~jbWRRR{1<^oDK+1clprm zz$eCy7y9+?{E|YgkW~}}iB#I4XoJ*xr8R?i_Hv$=Cof5bo-Nj~f`-DLebH}&0% zfQj9@WGd4;N~Y?mzQsHJTJq6!Qzl^-vwol(+fMt#Pl=Wh#lI5Vmu@QM0=_r+1wHt` z+8WZ~c2}KQQ+q)~2Ki77QvV&`xb|xVcTms99&cD$Zz4+-^R4kvUBxG8gDk7Y`K*)JZ^2rL(+ZWV~%W(@6 z)0bPArG#BROa_PHs~&WplQ_UIrpd)1N1QGPfv!J(Z9jNT#i%H?CE6|pPZb9hJ1JW4 z^q;ft#!HRNV0YgPojzIYT`8LuET2rUe-J|c!9l4`^*;4WtY@Ew@pL>wkjmMgGfN7 ze}}GtmU0@<_#08~I-Suk=^*9GLW=H4xhsml;vAV{%hy5Eegl@!6qKqbG024%n2HHw zCc@ivW_$@5ZoHP70(7D+(`PvgjW1Pd`wsiuv-aCukMrafwDm)B!xXVy*j2opohhoU zcJz%ADmj>i3`-3-$7nQKBQQuGY;2Qt&+(L~C>vSGFj5{Mlv?T_^dql;{zkpe4R1}R z%XfZyQ}wr*sr>jrKgm*PWLjuVc%6&&`Kbf1SuFpHPN&>W)$GmqC;pIoBC`=4-hPY8 zT*>%I2fP}vGW;R=^!1be?ta2UQd2>alOFFbVl;(SQJ4Jk#)4Z0^wpWEVvY4=vyDk@ zqlModi@iVPMC+{?rm=4(n+<;|lmUO@UKYA>EPTS~AndtK^Wy^%#3<;(dQdk3WaUkRtzSMC9}7x2||CNpF#(3T4C)@ z$~RWs`BNABKX|{cmBt>Q=&gkXl&x!!NK_%5hW0LS)Z4PB>%sV?F-{Wyj#s7W%$F{D zXdK^Fp3wvy+48+GP6F_|^PCRx=ddcTO3sG;B23A49~Qaw31SZ0Rc~`r4qqt%#OGW{ zCA_(LG5^N>yzUn&kAgVmxb=EA8s&tBXC}S1CZ(KoW)(%^JjLTPo^fs`Va;`=YlVPgmB$!yB}<(4ym6OeZ3xAJJ#;)2+B%p3P1Wt+d$eo`vz`T zXfUP2))kBDPoscH;Jc7I3NU<({|@wM$&GaDt`n7WLgIY3IA7A6-_R?z8N3mz|}*i z(zl5ot--Oq@f2-nv{X(ujT2T(k1vY_qh93pK@>H-qc%2Xta)IP0Q%zt%bqYgI`o!wv!0QerB`nCN^1n|@$sVOQ!V0teVG!I z_fD%JvfDeT1cK#-{o6Gv7}& zY0#NWin~kVaf$aufV&;63Hbs|`QVZWpDX6IMk1Hj2G}fiH9e-^6u2zf^FIr^BwD<6zjw63+{yUe8PUFvk8v{sJ=R{d#`O!sz`Q13~< zPT$JS(w=yQfU2`zPCNfSw=&zup@DXc(98afjhv@1w_f!m2Z>rMJ19AB&dB%P#Ls3b z=lK7OILM+SQ&VEd=1GN6o&>YVVtIzoZ%=Z_SdqJN2}E43{bE`>w+A;=y->@^k{oCC z$F*WTY&?34;kfyFV?b*Xb1Pq`Z=%OgwEg)Rz)tx=`f%5#w_INP=x&z5!jI;#;N$ma zhO)+MDm;SxOEVL15; zGq(v2pL3&P1Sl)8P*;G-fd{l1QJsv@e@d8)1PK4w2m*M%V3j-V~L^$i|&C@b?D?9tfwE{B^}Z$k8e5FmQ>v7Xz)sG32g9t}YBt zyR$+*_00RmPx+0mW+vVG4mxd(n$(eQf3-w>JPl2UJpafrPaL5@2j}%{VE-) zBI%6Qpj*dsdH<;g!S!avA~bv^0E+ zfyJbSjPb+j;J52U)<|cIcntQBI2T#>2;tOxu{%D?kML476AErF(qN9hPva5Nkc@BF zC-tLF@3ZFb%Kpj)M<{)x*l|*Ia@ECeXo2E4h2f!aV=cHAhi_E_mfUth(sM4^hJq7B zQsGWqdZUm9S%F`$nQ*_#NcuD`&)Ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y + + {{ $t('strings.hello') }} {{ title }} + + diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/MainAbility/pages/index/index.js b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 000000000..e42e40004 --- /dev/null +++ b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,30 @@ +/* + * 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. + */ + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish!') + }, + onReady() { + }, +} \ No newline at end of file diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default/app.js b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/app.js similarity index 91% rename from telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default/app.js rename to telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/app.js index f6cc8926d..e64117c26 100644 --- a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/default/app.js +++ b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/app.js @@ -1,23 +1,23 @@ -/* - * 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('TestApplication onCreate'); - }, - onDestroy() { - console.info('TestApplication onDestroy'); - } -}; +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export default { + onCreate() { + console.info('TestApplication onCreate'); + }, + onDestroy() { + console.info('TestApplication onDestroy'); + } +}; + diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/i18n/en-US.json b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 000000000..3cb24b374 --- /dev/null +++ b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/i18n/zh-CN.json b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 000000000..c804e32c0 --- /dev/null +++ b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/pages/index/index.css b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 000000000..b1bcd4338 --- /dev/null +++ b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/pages/index/index.css @@ -0,0 +1,30 @@ +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/pages/index/index.hml b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 000000000..f629c71a9 --- /dev/null +++ b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/pages/index/index.js b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 000000000..88b083a7f --- /dev/null +++ b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 000000000..05ba57825 --- /dev/null +++ b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/test/CellularDataAbnorma.test.js b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/test/CellularDataAbnorma.test.js similarity index 95% rename from telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/test/CellularDataAbnorma.test.js rename to telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/test/CellularDataAbnorma.test.js index 2e76b7d77..019dd98b0 100644 --- a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/test/CellularDataAbnorma.test.js +++ b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/test/CellularDataAbnorma.test.js @@ -1,205 +1,206 @@ -/* - * 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 cellular from "@ohos.telephony.data"; -import { describe, it, expect } from "deccjsunit/index"; - -describe("ActsCellularDataAbnormalTest", function () { - const ERR_SLOT_ID = 3; - - /* - * @tc.number Telephony_CellularData_isCellularDataEnabled_Async_0100 - * @tc.name Call the enableCellularData interface and then call the isCellularDataEnabled interface. - * The result is true - * @tc.desc Function test - */ - it("Telephony_CellularData_isCellularDataEnabled_Async_0100", 0, async function (done) { - cellular.isCellularDataEnabled((err, data) => { - if (err) { - expect().assertFail(); - console.log("Telephony_CellularData_isCellularDataEnabled_Async_0100 fail"); - done(); - return; - } - console.log("Telephony_CellularData_isCellularDataEnabled_Async_0100 finish"); - done(); - }) - }) - - /* - * @tc.number Telephony_CellularData_getCellularDataState_Async_0100 - * @tc.name Call the enableCellularData interface, call the getCellularDataState interface, - * and get the result 1 or 2 - * @tc.desc Function test - */ - it("Telephony_CellularData_getCellularDataState_Async_0100", 0, async function (done) { - cellular.getCellularDataState((err, data) => { - if (err) { - expect().assertFail(); - console.log("Telephony_CellularData_getCellularDataState_Async_0100 fail"); - done(); - return; - } - console.log("Telephony_CellularData_getCellularDataState_Async_0100 finish"); - done(); - }) - }) - - /* - * @tc.number Telephony_CellularData_getCellularDataFlowType_Async_0100 - * @tc.name When cellular data is turned on, call getCellularDataFlowType() to get the data stream type and - * verify that the callback value is within the enumeration value range - * @tc.desc Function test - */ - it("Telephony_CellularData_getCellularDataFlowType_Async_0100", 0, async function (done) { - cellular.getCellularDataFlowType((err, data) => { - if (err) { - expect().assertFail(); - console.log("Telephony_CellularData_getCellularDataFlowType_Async_0100 fail"); - done(); - return; - } - console.log("Telephony_CellularData_getCellularDataFlowType_Async_0100 finish"); - done(); - }) - }) - - /* - * @tc.number Telephony_CellularData_isCellularDataRoamingEnabled_Async_0200 - * @tc.name Call isCellularDataRoamingEnabled, set the slotId to error values (3), to check the correction - * results - * @tc.desc Function test - */ - it("Telephony_CellularData_isCellularDataRoamingEnabled_Async_0200", 0, async function (done) { - cellular.isCellularDataRoamingEnabled(ERR_SLOT_ID, (err) => { - if (err) { - console.log("Telephony_CellularData_isCellularDataRoamingEnabled_Async_0200 finish"); - done(); - return; - } - expect().assertFail(); - console.log("Telephony_CellularData_isCellularDataRoamingEnabled_Async_0200 fail"); - done(); - }) - }) - - /* - * @tc.number Telephony_CellularData_getDefaultCellularDataSlotId_Async_0500 - * @tc.name Call getDefaultCellularDataSlotId() interface and verify whether the setting failed (Async) - * @tc.desc Function test - */ - it("Telephony_CellularData_getDefaultCellularDataSlotId_Async_0500", 0, async function (done) { - cellular.getDefaultCellularDataSlotId((err) => { - if (!err) { - expect(true).assertTrue(); - console.info("Telephony_CellularData_getDefaultCellularDataSlotId_Async_0500 finish"); - done(); - } else { - console.info("Telephony_CellularData_getDefaultCellularDataSlotId_Async_0500 finish"); - done(); - } - }) - }) - - - /* - * @tc.number Telephony_CellularData_isCellularDataEnabled_Promise_0100 - * @tc.name Call the enableCellularData interface and then call the isCellularDataEnabled interface. - * The result is true - * @tc.desc Function test - */ - it("Telephony_CellularData_isCellularDataEnabled_Promise_0100", 0, async function (done) { - try { - await cellular.isCellularDataEnabled(); - console.log("Telephony_CellularData_isCellularDataEnabled_Promise_0100 finish"); - done(); - } catch (err) { - expect().assertFail(); - console.log("Telephony_CellularData_isCellularDataEnabled_Promise_0100 fail"); - done(); - } - }) - - /* - * @tc.number Telephony_CellularData_getCellularDataState_Promise_0100 - * @tc.name Call the enableCellularData interface, call the getCellularDataState interface, - * and get the result 1 or 2 - * @tc.desc Function test - */ - it("Telephony_CellularData_getCellularDataState_Promise_0100", 0, async function (done) { - try { - await cellular.getCellularDataState(); - console.log("Telephony_CellularData_getCellularDataState_Promise_0100 finish"); - done(); - } catch (err) { - expect().assertFail(); - console.log("Telephony_CellularData_getCellularDataState_Promise_0100 fail"); - done(); - } - }) - - /* - * @tc.number Telephony_CellularData_getCellularDataFlowType_Promise_0100 - * @tc.name When cellular data is turned on, call getCellularDataFlowType() to get the data stream type and - * verify that the callback value is within the enumeration value range - * @tc.desc Function test - */ - it("Telephony_CellularData_getCellularDataFlowType_Promise_0100", 0, async function (done) { - try { - await cellular.getCellularDataFlowType(); - console.log("Telephony_CellularData_getCellularDataFlowType_Promise_0100 finish"); - done(); - } catch (err) { - expect().assertFail(); - console.log("Telephony_CellularData_getCellularDataFlowType_Promise_0100 fail"); - done(); - } - }) - - /* - * @tc.number Telephony_CellularData_isCellularDataRoamingEnabled_Promise_0200 - * @tc.name Call isCellularDataRoamingEnabled, set the slotId to error values (3), to check the correction - * results - * @tc.desc Function test - */ - it("Telephony_CellularData_isCellularDataRoamingEnabled_Promise_0200", 0, async function (done) { - try { - await cellular.isCellularDataRoamingEnabled(ERR_SLOT_ID); - expect().assertFail(); - console.log("Telephony_CellularData_isCellularDataRoamingEnabled_Promise_0200 fail"); - done(); - } catch (err) { - console.log("Telephony_CellularData_isCellularDataRoamingEnabled_Promise_0200 finish"); - done(); - } - }) - - /* - * @tc.number Telephony_CellularData_getDefaultCellularDataSlotId_Promise_0500 - * @tc.name Call getDefaultCellularDataSlotId() interface and verify whether the setting failed (Async) - * @tc.desc Function test - */ - it("Telephony_CellularData_getDefaultCellularDataSlotId_Promise_0500", 0, async function (done) { - try { - await cellular.getDefaultCellularDataSlotId(); - console.info("Telephony_CellularData_getDefaultCellularDataSlotId_Promise_0500 finish"); - done(); - } catch (err) { - expect(true).assertTrue(); - console.info("Telephony_CellularData_getDefaultCellularDataSlotId_Promise_0500 finish"); - 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 cellular from "@ohos.telephony.data"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +export default function ActsCellularDataAbnormalTest() { +describe("ActsCellularDataAbnormalTest", function () { + const ERR_SLOT_ID = 3; + + /* + * @tc.number Telephony_CellularData_isCellularDataEnabled_Async_0100 + * @tc.name Call the enableCellularData interface and then call the isCellularDataEnabled interface. + * The result is true + * @tc.desc Function test + */ + it("Telephony_CellularData_isCellularDataEnabled_Async_0100", 0, async function (done) { + cellular.isCellularDataEnabled((err, data) => { + if (err) { + expect().assertFail(); + console.log("Telephony_CellularData_isCellularDataEnabled_Async_0100 fail"); + done(); + return; + } + console.log("Telephony_CellularData_isCellularDataEnabled_Async_0100 finish"); + done(); + }) + }) + + /* + * @tc.number Telephony_CellularData_getCellularDataState_Async_0100 + * @tc.name Call the enableCellularData interface, call the getCellularDataState interface, + * and get the result 1 or 2 + * @tc.desc Function test + */ + it("Telephony_CellularData_getCellularDataState_Async_0100", 0, async function (done) { + cellular.getCellularDataState((err, data) => { + if (err) { + expect().assertFail(); + console.log("Telephony_CellularData_getCellularDataState_Async_0100 fail"); + done(); + return; + } + console.log("Telephony_CellularData_getCellularDataState_Async_0100 finish"); + done(); + }) + }) + + /* + * @tc.number Telephony_CellularData_getCellularDataFlowType_Async_0100 + * @tc.name When cellular data is turned on, call getCellularDataFlowType() to get the data stream type and + * verify that the callback value is within the enumeration value range + * @tc.desc Function test + */ + it("Telephony_CellularData_getCellularDataFlowType_Async_0100", 0, async function (done) { + cellular.getCellularDataFlowType((err, data) => { + if (err) { + expect().assertFail(); + console.log("Telephony_CellularData_getCellularDataFlowType_Async_0100 fail"); + done(); + return; + } + console.log("Telephony_CellularData_getCellularDataFlowType_Async_0100 finish"); + done(); + }) + }) + + /* + * @tc.number Telephony_CellularData_isCellularDataRoamingEnabled_Async_0200 + * @tc.name Call isCellularDataRoamingEnabled, set the slotId to error values (3), to check the correction + * results + * @tc.desc Function test + */ + it("Telephony_CellularData_isCellularDataRoamingEnabled_Async_0200", 0, async function (done) { + cellular.isCellularDataRoamingEnabled(ERR_SLOT_ID, (err) => { + if (err) { + console.log("Telephony_CellularData_isCellularDataRoamingEnabled_Async_0200 finish"); + done(); + return; + } + expect().assertFail(); + console.log("Telephony_CellularData_isCellularDataRoamingEnabled_Async_0200 fail"); + done(); + }) + }) + + /* + * @tc.number Telephony_CellularData_getDefaultCellularDataSlotId_Async_0500 + * @tc.name Call getDefaultCellularDataSlotId() interface and verify whether the setting failed (Async) + * @tc.desc Function test + */ + it("Telephony_CellularData_getDefaultCellularDataSlotId_Async_0500", 0, async function (done) { + cellular.getDefaultCellularDataSlotId((err) => { + if (!err) { + expect(true).assertTrue(); + console.info("Telephony_CellularData_getDefaultCellularDataSlotId_Async_0500 finish"); + done(); + } else { + console.info("Telephony_CellularData_getDefaultCellularDataSlotId_Async_0500 finish"); + done(); + } + }) + }) + + + /* + * @tc.number Telephony_CellularData_isCellularDataEnabled_Promise_0100 + * @tc.name Call the enableCellularData interface and then call the isCellularDataEnabled interface. + * The result is true + * @tc.desc Function test + */ + it("Telephony_CellularData_isCellularDataEnabled_Promise_0100", 0, async function (done) { + try { + await cellular.isCellularDataEnabled(); + console.log("Telephony_CellularData_isCellularDataEnabled_Promise_0100 finish"); + done(); + } catch (err) { + expect().assertFail(); + console.log("Telephony_CellularData_isCellularDataEnabled_Promise_0100 fail"); + done(); + } + }) + + /* + * @tc.number Telephony_CellularData_getCellularDataState_Promise_0100 + * @tc.name Call the enableCellularData interface, call the getCellularDataState interface, + * and get the result 1 or 2 + * @tc.desc Function test + */ + it("Telephony_CellularData_getCellularDataState_Promise_0100", 0, async function (done) { + try { + await cellular.getCellularDataState(); + console.log("Telephony_CellularData_getCellularDataState_Promise_0100 finish"); + done(); + } catch (err) { + expect().assertFail(); + console.log("Telephony_CellularData_getCellularDataState_Promise_0100 fail"); + done(); + } + }) + + /* + * @tc.number Telephony_CellularData_getCellularDataFlowType_Promise_0100 + * @tc.name When cellular data is turned on, call getCellularDataFlowType() to get the data stream type and + * verify that the callback value is within the enumeration value range + * @tc.desc Function test + */ + it("Telephony_CellularData_getCellularDataFlowType_Promise_0100", 0, async function (done) { + try { + await cellular.getCellularDataFlowType(); + console.log("Telephony_CellularData_getCellularDataFlowType_Promise_0100 finish"); + done(); + } catch (err) { + expect().assertFail(); + console.log("Telephony_CellularData_getCellularDataFlowType_Promise_0100 fail"); + done(); + } + }) + + /* + * @tc.number Telephony_CellularData_isCellularDataRoamingEnabled_Promise_0200 + * @tc.name Call isCellularDataRoamingEnabled, set the slotId to error values (3), to check the correction + * results + * @tc.desc Function test + */ + it("Telephony_CellularData_isCellularDataRoamingEnabled_Promise_0200", 0, async function (done) { + try { + await cellular.isCellularDataRoamingEnabled(ERR_SLOT_ID); + expect().assertFail(); + console.log("Telephony_CellularData_isCellularDataRoamingEnabled_Promise_0200 fail"); + done(); + } catch (err) { + console.log("Telephony_CellularData_isCellularDataRoamingEnabled_Promise_0200 finish"); + done(); + } + }) + + /* + * @tc.number Telephony_CellularData_getDefaultCellularDataSlotId_Promise_0500 + * @tc.name Call getDefaultCellularDataSlotId() interface and verify whether the setting failed (Async) + * @tc.desc Function test + */ + it("Telephony_CellularData_getDefaultCellularDataSlotId_Promise_0500", 0, async function (done) { + try { + await cellular.getDefaultCellularDataSlotId(); + console.info("Telephony_CellularData_getDefaultCellularDataSlotId_Promise_0500 finish"); + done(); + } catch (err) { + expect(true).assertTrue(); + console.info("Telephony_CellularData_getDefaultCellularDataSlotId_Promise_0500 finish"); + done(); + } + }) +}) +} diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/test/List.test.js b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/test/List.test.js similarity index 78% rename from telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/test/List.test.js rename to telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/test/List.test.js index 90fc09236..e74414a60 100644 --- a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/entry/src/main/js/test/List.test.js +++ b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/test/List.test.js @@ -1,16 +1,19 @@ -/* - * 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. - */ - -require('./CellularDataAbnorma.test.js') \ No newline at end of file +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import ActsCellularDataAbnormalTest from './CellularDataAbnorma.test.js' + +export default function testsuite() { + ActsCellularDataAbnormalTest() +} \ No newline at end of file diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/resources/base/element/string.json b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/resources/base/element/string.json new file mode 100644 index 000000000..7e93f36cb --- /dev/null +++ b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "app_name", + "value": "CallManager" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/resources/base/media/icon.png b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/resources/base/media/icon.png similarity index 100% rename from telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/resources/base/media/icon.png rename to telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/resources/base/media/icon.png -- GitLab