From 09fd7bd7b7b834f91a2b41d36929d1967d114a71 Mon Sep 17 00:00:00 2001 From: zhangyushuai Date: Tue, 21 Feb 2023 03:11:14 +0000 Subject: [PATCH] add tests Signed-off-by: zhangyushuai --- inputmethod/BUILD.gn | 21 + .../InputMethodTest_Stage/AppScope/app.json | 21 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin 0 -> 6790 bytes inputmethod/InputMethodTest_Stage/BUILD.gn | 43 + inputmethod/InputMethodTest_Stage/Test.json | 18 + .../src/main/ets/Application/AbilityStage.ts | 23 + .../main/ets/ImExtAbility/ImExtAbility.ets | 54 + .../src/main/ets/MainAbility/MainAbility.ts | 51 + .../ets/TestRunner/OpenHarmonyTestRunner.ts | 78 ++ .../entry/src/main/ets/pages/index/index.ets | 51 + .../src/main/ets/pages/second/second.ets | 43 + .../entry/src/main/ets/test/List.test.ets | 22 + .../src/main/ets/test/imeAbilityTest.test.ets | 113 ++ .../main/ets/test/inputMethodStageJSUnit.ets | 613 +++++++++ .../entry/src/main/module.json | 64 + .../main/resources/base/element/string.json | 36 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/main_pages.json | 6 + .../signature/ActInputMethodStageAPITest.p7b | Bin 0 -> 3613 bytes inputmethod/InputMethodTest_ets/BUILD.gn | 38 + inputmethod/InputMethodTest_ets/Test.json | 19 + .../entry/src/main/config.json | 106 ++ .../entry/src/main/ets/MainAbility/app.ets | 32 + .../src/main/ets/MainAbility/pages/index.ets | 36 + .../src/main/ets/MainAbility/pages/input.ets | 45 + .../entry/src/main/ets/TestAbility/app.ets | 32 + .../src/main/ets/TestAbility/pages/index.ets | 49 + .../ets/TestRunner/OpenHarmonyTestRunner.ts | 77 ++ .../entry/src/main/ets/test/List.test.ets | 21 + .../entry/src/main/ets/test/Utils.ets | 118 ++ .../main/ets/test/inputMethodEngineJSUnit.ets | 717 ++++++++++ .../src/main/ets/test/inputMethodJSUnit.ets | 343 +++++ .../main/resources/base/element/string.json | 32 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../signature/ActInputMethodEtsAPITest.p7b | Bin 0 -> 3531 bytes request/BUILD.gn | 21 + request/RequestTest_Stage/AppScope/app.json | 15 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin 0 -> 6790 bytes request/RequestTest_Stage/BUILD.gn | 43 + request/RequestTest_Stage/Test.json | 18 + .../main/ets/Application/MyAbilityStage.ts | 9 + .../src/main/ets/MainAbility/MainAbility.ts | 68 + .../ets/TestRunner/OpenHarmonyTestRunner.ts | 77 ++ .../entry/src/main/ets/pages/index.ets | 38 + .../entry/src/main/ets/test/List.test.ets | 22 + .../main/ets/test/requestDownload.test.ets | 626 +++++++++ .../src/main/ets/test/requestUpload.test.ets | 208 +++ .../entry/src/main/module.json | 69 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/main_pages.json | 5 + .../signature/actsRequestStageTest.p7b | Bin 0 -> 3523 bytes request/RequestTest_ets/BUILD.gn | 39 + request/RequestTest_ets/Test.json | 22 + .../entry/src/main/config.json | 112 ++ .../entry/src/main/ets/MainAbility/app.ets | 33 + .../src/main/ets/MainAbility/pages/index.ets | 37 + .../entry/src/main/ets/TestAbility/app.ets | 33 + .../src/main/ets/TestAbility/pages/index.ets | 50 + .../ets/TestRunner/OpenHarmonyTestRunner.ts | 84 ++ .../entry/src/main/ets/test/List.test.ets | 24 + .../main/ets/test/requestDownload.test.ets | 839 ++++++++++++ .../src/main/ets/test/requestSystem.test.ets | 146 ++ .../src/main/ets/test/requestUpload.test.ets | 337 +++++ .../main/resources/base/element/string.json | 20 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../signature/ActsRequestETSApiTest.p7b | Bin 0 -> 3527 bytes theme/BUILD.gn | 21 + theme/screenlock_ets/BUILD.gn | 39 + theme/screenlock_ets/Test.json | 19 + .../screenlock_ets/entry/src/main/config.json | 101 ++ .../entry/src/main/ets/MainAbility/app.ets | 33 + .../src/main/ets/MainAbility/pages/index.ets | 38 + .../entry/src/main/ets/TestAbility/app.ets | 33 + .../src/main/ets/TestAbility/pages/index.ets | 50 + .../ets/TestRunner/OpenHarmonyTestRunner.ts | 78 ++ .../entry/src/main/ets/test/List.test.ets | 22 + .../main/ets/test/screenLockPromiseTest.ets | 135 ++ .../src/main/ets/test/screenLockTest.ets | 306 +++++ .../main/resources/base/element/string.json | 20 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../signature/openharmony_sx.p7b | Bin 0 -> 3499 bytes theme/wallpaper_ets/BUILD.gn | 39 + theme/wallpaper_ets/Test.json | 29 + .../wallpaper_ets/entry/src/main/config.json | 125 ++ .../entry/src/main/ets/MainAbility/app.ets | 33 + .../src/main/ets/MainAbility/pages/index.ets | 38 + .../entry/src/main/ets/TestAbility/app.ets | 33 + .../src/main/ets/TestAbility/pages/index.ets | 50 + .../ets/TestRunner/OpenHarmonyTestRunner.ts | 78 ++ .../entry/src/main/ets/test/List.test.ets | 20 + .../entry/src/main/ets/test/wallpaperTest.ets | 1200 +++++++++++++++++ .../main/resources/base/element/string.json | 20 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../signature/ActsWallpaperEtsAPITest.p7b | Bin 0 -> 3560 bytes time/BUILD.gn | 21 + time/dateTimeTest/AppScope/app.json | 15 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin 0 -> 6790 bytes time/dateTimeTest/BUILD.gn | 43 + time/dateTimeTest/Test.json | 18 + .../main/ets/Application/MyAbilityStage.ts | 9 + .../src/main/ets/MainAbility/MainAbility.ts | 66 + .../ets/TestRunner/OpenHarmonyTestRunner.ts | 71 + .../entry/src/main/ets/pages/index.ets | 40 + .../entry/src/main/ets/test/List.test.ets | 19 + .../ets/test/systemDateTimeJsunit.test.ets | 426 ++++++ time/dateTimeTest/entry/src/main/module.json | 45 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/main_pages.json | 5 + .../signature/ActsDateTimeAPITest.p7b | Bin 0 -> 3527 bytes time/timeTest/AppScope/app.json | 15 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin 0 -> 6790 bytes time/timeTest/BUILD.gn | 43 + time/timeTest/Test.json | 18 + .../main/ets/Application/MyAbilityStage.ts | 9 + .../src/main/ets/MainAbility/MainAbility.ts | 66 + .../ets/TestRunner/OpenHarmonyTestRunner.ts | 71 + .../entry/src/main/ets/pages/index.ets | 40 + .../entry/src/main/ets/test/List.test.ets | 19 + .../src/main/ets/test/systemTimeTest.ets | 541 ++++++++ time/timeTest/entry/src/main/module.json | 55 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/main_pages.json | 5 + time/timeTest/signature/ActsTimeAPITest.p7b | Bin 0 -> 3549 bytes 133 files changed, 10241 insertions(+) create mode 100644 inputmethod/BUILD.gn create mode 100644 inputmethod/InputMethodTest_Stage/AppScope/app.json create mode 100644 inputmethod/InputMethodTest_Stage/AppScope/resources/base/element/string.json create mode 100644 inputmethod/InputMethodTest_Stage/AppScope/resources/base/media/app_icon.png create mode 100644 inputmethod/InputMethodTest_Stage/BUILD.gn create mode 100644 inputmethod/InputMethodTest_Stage/Test.json create mode 100644 inputmethod/InputMethodTest_Stage/entry/src/main/ets/Application/AbilityStage.ts create mode 100644 inputmethod/InputMethodTest_Stage/entry/src/main/ets/ImExtAbility/ImExtAbility.ets create mode 100644 inputmethod/InputMethodTest_Stage/entry/src/main/ets/MainAbility/MainAbility.ts create mode 100644 inputmethod/InputMethodTest_Stage/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 inputmethod/InputMethodTest_Stage/entry/src/main/ets/pages/index/index.ets create mode 100644 inputmethod/InputMethodTest_Stage/entry/src/main/ets/pages/second/second.ets create mode 100644 inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/List.test.ets create mode 100644 inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/imeAbilityTest.test.ets create mode 100644 inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets create mode 100644 inputmethod/InputMethodTest_Stage/entry/src/main/module.json create mode 100644 inputmethod/InputMethodTest_Stage/entry/src/main/resources/base/element/string.json create mode 100644 inputmethod/InputMethodTest_Stage/entry/src/main/resources/base/media/icon.png create mode 100644 inputmethod/InputMethodTest_Stage/entry/src/main/resources/base/profile/main_pages.json create mode 100644 inputmethod/InputMethodTest_Stage/signature/ActInputMethodStageAPITest.p7b create mode 100644 inputmethod/InputMethodTest_ets/BUILD.gn create mode 100644 inputmethod/InputMethodTest_ets/Test.json create mode 100644 inputmethod/InputMethodTest_ets/entry/src/main/config.json create mode 100644 inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/app.ets create mode 100644 inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/index.ets create mode 100644 inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/input.ets create mode 100644 inputmethod/InputMethodTest_ets/entry/src/main/ets/TestAbility/app.ets create mode 100644 inputmethod/InputMethodTest_ets/entry/src/main/ets/TestAbility/pages/index.ets create mode 100644 inputmethod/InputMethodTest_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 inputmethod/InputMethodTest_ets/entry/src/main/ets/test/List.test.ets create mode 100644 inputmethod/InputMethodTest_ets/entry/src/main/ets/test/Utils.ets create mode 100644 inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets create mode 100644 inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets create mode 100644 inputmethod/InputMethodTest_ets/entry/src/main/resources/base/element/string.json create mode 100644 inputmethod/InputMethodTest_ets/entry/src/main/resources/base/media/icon.png create mode 100644 inputmethod/InputMethodTest_ets/signature/ActInputMethodEtsAPITest.p7b create mode 100644 request/BUILD.gn create mode 100644 request/RequestTest_Stage/AppScope/app.json create mode 100644 request/RequestTest_Stage/AppScope/resources/base/element/string.json create mode 100644 request/RequestTest_Stage/AppScope/resources/base/media/app_icon.png create mode 100644 request/RequestTest_Stage/BUILD.gn create mode 100644 request/RequestTest_Stage/Test.json create mode 100644 request/RequestTest_Stage/entry/src/main/ets/Application/MyAbilityStage.ts create mode 100644 request/RequestTest_Stage/entry/src/main/ets/MainAbility/MainAbility.ts create mode 100644 request/RequestTest_Stage/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 request/RequestTest_Stage/entry/src/main/ets/pages/index.ets create mode 100644 request/RequestTest_Stage/entry/src/main/ets/test/List.test.ets create mode 100644 request/RequestTest_Stage/entry/src/main/ets/test/requestDownload.test.ets create mode 100644 request/RequestTest_Stage/entry/src/main/ets/test/requestUpload.test.ets create mode 100644 request/RequestTest_Stage/entry/src/main/module.json create mode 100644 request/RequestTest_Stage/entry/src/main/resources/base/element/color.json create mode 100644 request/RequestTest_Stage/entry/src/main/resources/base/element/string.json create mode 100644 request/RequestTest_Stage/entry/src/main/resources/base/media/icon.png create mode 100644 request/RequestTest_Stage/entry/src/main/resources/base/profile/main_pages.json create mode 100644 request/RequestTest_Stage/signature/actsRequestStageTest.p7b create mode 100644 request/RequestTest_ets/BUILD.gn create mode 100644 request/RequestTest_ets/Test.json create mode 100644 request/RequestTest_ets/entry/src/main/config.json create mode 100644 request/RequestTest_ets/entry/src/main/ets/MainAbility/app.ets create mode 100644 request/RequestTest_ets/entry/src/main/ets/MainAbility/pages/index.ets create mode 100644 request/RequestTest_ets/entry/src/main/ets/TestAbility/app.ets create mode 100644 request/RequestTest_ets/entry/src/main/ets/TestAbility/pages/index.ets create mode 100644 request/RequestTest_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 request/RequestTest_ets/entry/src/main/ets/test/List.test.ets create mode 100644 request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets create mode 100644 request/RequestTest_ets/entry/src/main/ets/test/requestSystem.test.ets create mode 100644 request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets create mode 100644 request/RequestTest_ets/entry/src/main/resources/base/element/string.json create mode 100644 request/RequestTest_ets/entry/src/main/resources/base/media/icon.png create mode 100644 request/RequestTest_ets/signature/ActsRequestETSApiTest.p7b create mode 100644 theme/BUILD.gn create mode 100644 theme/screenlock_ets/BUILD.gn create mode 100644 theme/screenlock_ets/Test.json create mode 100644 theme/screenlock_ets/entry/src/main/config.json create mode 100644 theme/screenlock_ets/entry/src/main/ets/MainAbility/app.ets create mode 100644 theme/screenlock_ets/entry/src/main/ets/MainAbility/pages/index.ets create mode 100644 theme/screenlock_ets/entry/src/main/ets/TestAbility/app.ets create mode 100644 theme/screenlock_ets/entry/src/main/ets/TestAbility/pages/index.ets create mode 100644 theme/screenlock_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 theme/screenlock_ets/entry/src/main/ets/test/List.test.ets create mode 100644 theme/screenlock_ets/entry/src/main/ets/test/screenLockPromiseTest.ets create mode 100644 theme/screenlock_ets/entry/src/main/ets/test/screenLockTest.ets create mode 100644 theme/screenlock_ets/entry/src/main/resources/base/element/string.json create mode 100644 theme/screenlock_ets/entry/src/main/resources/base/media/icon.png create mode 100644 theme/screenlock_ets/signature/openharmony_sx.p7b create mode 100644 theme/wallpaper_ets/BUILD.gn create mode 100644 theme/wallpaper_ets/Test.json create mode 100644 theme/wallpaper_ets/entry/src/main/config.json create mode 100644 theme/wallpaper_ets/entry/src/main/ets/MainAbility/app.ets create mode 100644 theme/wallpaper_ets/entry/src/main/ets/MainAbility/pages/index.ets create mode 100644 theme/wallpaper_ets/entry/src/main/ets/TestAbility/app.ets create mode 100644 theme/wallpaper_ets/entry/src/main/ets/TestAbility/pages/index.ets create mode 100644 theme/wallpaper_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 theme/wallpaper_ets/entry/src/main/ets/test/List.test.ets create mode 100644 theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets create mode 100644 theme/wallpaper_ets/entry/src/main/resources/base/element/string.json create mode 100644 theme/wallpaper_ets/entry/src/main/resources/base/media/icon.png create mode 100644 theme/wallpaper_ets/signature/ActsWallpaperEtsAPITest.p7b create mode 100644 time/BUILD.gn create mode 100644 time/dateTimeTest/AppScope/app.json create mode 100644 time/dateTimeTest/AppScope/resources/base/element/string.json create mode 100644 time/dateTimeTest/AppScope/resources/base/media/app_icon.png create mode 100644 time/dateTimeTest/BUILD.gn create mode 100644 time/dateTimeTest/Test.json create mode 100644 time/dateTimeTest/entry/src/main/ets/Application/MyAbilityStage.ts create mode 100644 time/dateTimeTest/entry/src/main/ets/MainAbility/MainAbility.ts create mode 100644 time/dateTimeTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 time/dateTimeTest/entry/src/main/ets/pages/index.ets create mode 100644 time/dateTimeTest/entry/src/main/ets/test/List.test.ets create mode 100644 time/dateTimeTest/entry/src/main/ets/test/systemDateTimeJsunit.test.ets create mode 100644 time/dateTimeTest/entry/src/main/module.json create mode 100644 time/dateTimeTest/entry/src/main/resources/base/element/color.json create mode 100644 time/dateTimeTest/entry/src/main/resources/base/element/string.json create mode 100644 time/dateTimeTest/entry/src/main/resources/base/media/icon.png create mode 100644 time/dateTimeTest/entry/src/main/resources/base/profile/main_pages.json create mode 100644 time/dateTimeTest/signature/ActsDateTimeAPITest.p7b create mode 100644 time/timeTest/AppScope/app.json create mode 100644 time/timeTest/AppScope/resources/base/element/string.json create mode 100644 time/timeTest/AppScope/resources/base/media/app_icon.png create mode 100644 time/timeTest/BUILD.gn create mode 100644 time/timeTest/Test.json create mode 100644 time/timeTest/entry/src/main/ets/Application/MyAbilityStage.ts create mode 100644 time/timeTest/entry/src/main/ets/MainAbility/MainAbility.ts create mode 100644 time/timeTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 time/timeTest/entry/src/main/ets/pages/index.ets create mode 100644 time/timeTest/entry/src/main/ets/test/List.test.ets create mode 100644 time/timeTest/entry/src/main/ets/test/systemTimeTest.ets create mode 100644 time/timeTest/entry/src/main/module.json create mode 100644 time/timeTest/entry/src/main/resources/base/element/color.json create mode 100644 time/timeTest/entry/src/main/resources/base/element/string.json create mode 100644 time/timeTest/entry/src/main/resources/base/media/icon.png create mode 100644 time/timeTest/entry/src/main/resources/base/profile/main_pages.json create mode 100644 time/timeTest/signature/ActsTimeAPITest.p7b diff --git a/inputmethod/BUILD.gn b/inputmethod/BUILD.gn new file mode 100644 index 000000000..c14bb038c --- /dev/null +++ b/inputmethod/BUILD.gn @@ -0,0 +1,21 @@ +# 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("//build/ohos_var.gni") +group("inputmethod") { + testonly = true + deps = [ + "InputMethodTest_Stage:ActsImeAbilityTest", + "InputMethodTest_ets:ActsInputMethodEtsTest", + ] +} diff --git a/inputmethod/InputMethodTest_Stage/AppScope/app.json b/inputmethod/InputMethodTest_Stage/AppScope/app.json new file mode 100644 index 000000000..154fc890f --- /dev/null +++ b/inputmethod/InputMethodTest_Stage/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.acts.imeability.test", + "vendor":"huawei", + "versionCode":1000000, + "versionName":"1.0.0", + "debug":false, + "icon":"$media:icon", + "label":"$string:app_name", + "description":"$string:description_application", + "distributedNotificationEnabled":true, + "keepAlive":true, + "singleUser":true, + "minAPIVersion":8, + "targetAPIVersion":8, + "car":{ + "apiCompatibleVersion":8, + "singleUser":false + } + } +} diff --git a/inputmethod/InputMethodTest_Stage/AppScope/resources/base/element/string.json b/inputmethod/InputMethodTest_Stage/AppScope/resources/base/element/string.json new file mode 100644 index 000000000..ee69f9a86 --- /dev/null +++ b/inputmethod/InputMethodTest_Stage/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"ohosProject" + } + ] +} \ No newline at end of file diff --git a/inputmethod/InputMethodTest_Stage/AppScope/resources/base/media/app_icon.png b/inputmethod/InputMethodTest_Stage/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch 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_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;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{ + if(err){ + console.info('destroy001 destroy fail: ' + JSON.stringify(err)); + } + console.info("destroy001 inputMethodExtensionAbility destroy successfully." + JSON.stringify(data)); + }) + }catch(error){ + console.info('destroy001 destroy catch error: ' + JSON.stringify(error)); + } + + try{ + this.context.destroy().then((data) => { + console.info("destroy002 terminateSelf success:." + JSON.stringify(data)); + }).catch((err) => { + console.info('destroy002 terminateSelf fail: ' + JSON.stringify(err)); + }) + }catch(error){ + console.info('destroy002 destroy catch error: ' + JSON.stringify(error)); + } + } + + onDestroy() { + console.info("onDestroy: inputMethodExtensionAbility destroy."); + } +} diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/MainAbility/MainAbility.ts b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 000000000..ff7ec1c31 --- /dev/null +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + onCreate(want,launchParam){ + // Ability is creating, initialize resources for this ability + console.info("ImExtAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.info("ImExtAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.info("ImExtAbility onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + console.info("ImExtAbility onWindowStageCreate finish") + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.info("ImExtAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.info("ImExtAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.info("ImExtAbility onBackground") + } +}; \ No newline at end of file diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..57aad0b6a --- /dev/null +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.acts.imeability.test.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/pages/index/index.ets b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 000000000..e1942ec72 --- /dev/null +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,51 @@ +/* + * 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' + +@Entry +@Component +struct Index { + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => {}) + } + .width('100%') + .height('100%') + } + + aboutToAppear(){ + let abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + let abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } +} \ No newline at end of file diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/pages/second/second.ets b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 000000000..f9009a3e8 --- /dev/null +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/pages/second/second.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/List.test.ets b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/List.test.ets new file mode 100644 index 000000000..7e02a0725 --- /dev/null +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/List.test.ets @@ -0,0 +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. + */ +import imeAbilityTest from './imeAbilityTest.test' +import inputMethodStageJSUnit from './inputMethodStageJSUnit'; + + +export default function testsuite() { + imeAbilityTest(globalThis.abilityContext); + inputMethodStageJSUnit(); +} \ No newline at end of file diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/imeAbilityTest.test.ets b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/imeAbilityTest.test.ets new file mode 100644 index 000000000..3f125b529 --- /dev/null +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/imeAbilityTest.test.ets @@ -0,0 +1,113 @@ +/* + * 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 inputMethod from '@ohos.inputMethod' + +export default function imeAbilityTest(abilityContext) { + describe('imeAbilityTest', function () { + var prop = { + packageName: '', + methodId: '', + name:'', + id:'', + extra:{} + } + /** + * sleep function. + */ + function sleep(date, time){ + while(Date.now() - date <= time); + } + + + /** + * beforeEach: Prerequisites at the test case level, which are executed before each test case is executed. + */ + beforeAll(function () { + let inputM = inputMethod.getCurrentInputMethod() + console.info("====>beforeAll: switchInputMethod to: " + JSON.stringify(inputM)); + prop.packageName = inputM.packageName; + prop.methodId = inputM.methodId; + prop.name = inputM.packageName; + prop.id = inputM.methodId; + }); + + /** + * afterEach: Test case-level clearance conditions, which are executed after each test case is executed. + */ + afterAll(async function () { + console.info('====>afterAll: switchInputMethod to origionInput.' + JSON.stringify(prop)); + await inputMethod.switchInputMethod(prop).then((data)=>{ + console.info('====>afterAll switchInputMethod to origionInput :' + data); + expect(data == true).assertTrue(); + }).catch(err =>{ + console.info('====>afterAll switchInputMethod to origionInput error: ' + err); + }) + }); + + /** + * @tc.number SUB_InputMethod_IMEAbility_0001 + * @tc.desc Start a inputMethodExtension ability session. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_InputMethod_IMEAbility_0001', 0, async function (done) { + console.info('====>----------SUB_InputMethod_IMEAbility_0001 start-------------'); + let imExtAbilityProperty = { + packageName : "com.acts.imeability.test", + methodId : "com.acts.imeability.test.ImExtAbility", + name:"com.acts.imeability.test", + id:"com.acts.imeability.test.ImExtAbility", + extra:{} + } + + inputMethod.switchInputMethod(imExtAbilityProperty).then((data)=>{ + console.info('====>SUB_InputMethod_IMEAbility_0004 switchInputMethod to IME :' + data); + expect(data == true).assertTrue(); + }); + sleep(Date.now(), 3000); + console.info('====>----------SUB_InputMethod_IMEAbility_0001 end-------------'); + done(); + }) + + /** + * @tc.number SUB_InputMethod_IMEAbility_0002 + * @tc.desc Start a inputMethodExtension ability session + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_InputMethod_IMEAbility_0002', 0, async function (done) { + console.info('====>-----------SUB_InputMethod_IMEAbility_0002 start-------------'); + + let imExtAbilityProperty = { + packageName : "com.acts.imeability.test", + methodId : "com.acts.imeability.test.ImExtAbility", + name:"com.acts.imeability.test", + id:"com.acts.imeability.test.ImExtAbility", + extra:{} + } + + inputMethod.switchInputMethod(imExtAbilityProperty).then((data)=>{ + console.info('====>SUB_InputMethod_IMEAbility_0002 switchInputMethod to IME :' + data); + expect(data == true).assertTrue(); + }); + sleep(Date.now(), 2500); + console.info('====>-----------SUB_InputMethod_IMEAbility_0002 end-------------'); + done(); + }) + }) +} diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets new file mode 100644 index 000000000..933393f0a --- /dev/null +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets @@ -0,0 +1,613 @@ +/** + * 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 inputMethod from '@ohos.inputMethod'; +import subtype from '@ohos.InputMethodSubtype'; + +export default function inputMethodStageJSUnit() { + describe('inputMethodTest', function () { + console.info("====>************* settings Test start*************"); + /* + * @tc.number inputMethod_test_getController_001 + * @tc.name get inputMethod controller + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_getController_001', 0, async function (done) { + console.info("====>-----------------inputMethod_test_getController_001 start---------------------"); + try{ + let inputMethodControl = inputMethod.getController(); + console.info("====>inputMethod_test_getController_001 result:" + typeof inputMethodControl); + if(typeof inputMethodControl == "object" ){ + console.info("====>inputMethod_test_getController_001 getController success"); + expect(true).assertTrue(); + }else{ + console.info("====>inputMethod_test_getController_001 getController failed"); + expect().assertFail(); + }; + }catch(error){ + console.info("====>inputMethod_test_getController_001 getController error" + JSON.stringify(error)); + expect().assertFail(); + }; + + console.info("====>-----------------inputMethod_test_getController_001 end---------------------"); + done(); + }); + + /* + * @tc.number inputMethod_test_listInputMethodSubtype_001 + * @tc.name List subtype of the specified input method + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_listInputMethodSubtype_001', 0, async function (done) { + console.info("====>-----------------inputMethod_test_listInputMethodSubtype_001 start---------------------"); + let inputM = inputMethod.getCurrentInputMethod() + console.info("inputMethod_test_listInputMethodSubtype_001 getCurrentInputMethod: " + JSON.stringify(inputM)); + let inputMethodProperty = { + packageName:inputM.packageName, + methodId:inputM.methodId, + name:inputM.packageName, + id:inputM.methodId, + label: "", + icon: "", + iconId: 124, + extra:{} + } + + let inputMethodSetting = inputMethod.getSetting(); + console.info("====>inputMethod_test_listInputMethodSubtype_001 getSetting result:" + inputMethodSetting); + inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err, data) => { + try { + if(err){ + console.info("====>inputMethod_test_listInputMethodSubtype_001 failed" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info("====>inputMethod_test_listInputMethodSubtype_001 listInputMethodSubtype: " + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + } catch (error) { + console.info("====>inputMethod_test_listInputMethodSubtype_001 listInputMethodSubtype catch error" + JSON.stringify(error)); + done(); + } + }); + console.info("====>-----------------inputMethod_test_listInputMethodSubtype_001 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_listInputMethodSubtype_002 + * @tc.name List subtype of the specified input method + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_listInputMethodSubtype_002', 0, async function (done) { + console.info("====>-----------------inputMethod_test_listInputMethodSubtype_002 start---------------------"); + let inputM = inputMethod.getCurrentInputMethod() + console.info("inputMethod_test_listInputMethodSubtype_002 getCurrentInputMethod: " + JSON.stringify(inputM)); + let inputMethodProperty = { + packageName:inputM.packageName, + methodId:inputM.methodId, + name:inputM.packageName, + id:inputM.methodId, + label: "", + icon: "", + iconId: 124, + extra:{} + } + + let inputMethodSetting = inputMethod.getSetting(); + console.info("====>inputMethod_test_listInputMethodSubtype_002 getSetting result:" + inputMethodSetting); + inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err, data) => { + try { + if(err){ + console.info("====>inputMethod_test_listInputMethodSubtype_002 failed" + JSON.stringify(err)); + expect().assertFail(); + done() + }; + console.info("====>inputMethod_test_listInputMethodSubtype_002 listInputMethodSubtype:" + JSON.stringify(data)); + if(data.length >= 1){ + let inputMethodSubtype = data[0] + console.info("====>inputMethod_test_listInputMethodSubtype_002 inputMethodSubtype" + JSON.stringify(inputMethodSubtype)); + expect(inputMethodSubtype.id != null).assertTrue(); + expect(inputMethodSubtype.label != null).assertTrue(); + done(); + }else{ + console.info("====>inputMethod_test_listInputMethodSubtype_002 listInputMethodSubtype length less 1"); + expect().assertFail(); + done(); + }; + } catch (error) { + console.info("====>inputMethod_test_listInputMethodSubtype_002 listInputMethodSubtype catch error" + JSON.stringify(error)); + done(); + } + }); + console.info("====>-----------------inputMethod_test_listInputMethodSubtype_002 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_listInputMethodSubtype_003 + * @tc.name List subtype of the specified input method + * @tc.desc Function test + * @tc.level 2 + */ + + it('inputMethod_test_listInputMethodSubtype_003', 0, async function (done) { + console.info("====>-----------------inputMethod_test_listInputMethodSubtype_003 start---------------------"); + let inputM = inputMethod.getCurrentInputMethod() + console.info("inputMethod_test_listInputMethodSubtype_003 getCurrentInputMethod: " + JSON.stringify(inputM)); + let inputMethodProperty = { + packageName:inputM.packageName, + methodId:inputM.methodId, + name:inputM.packageName, + id:inputM.methodId, + label: "", + icon: "", + iconId: 124, + extra:{} + } + + try{ + let inputMethodSetting = inputMethod.getSetting(); + console.info("====>inputMethod_test_listInputMethodSubtype_003 getSetting result:" + inputMethodSetting); + inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => { + console.info("====>inputMethod_test_listInputMethodSubtype_003 listInputMethodSubtype: " + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + }).catch(err => { + console.info("====>inputMethod_test_listInputMethodSubtype_003 failed" + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + }catch(error){ + console.info("====>inputMethod_test_listInputMethodSubtype_003 listInputMethodSubtype catch error" + JSON.stringify(error)); + expect().assertFail(); + done(); + }; + console.info("====>-----------------inputMethod_test_listInputMethodSubtype_003 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_listInputMethodSubtype_004 + * @tc.name List subtype of the specified input method + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_listInputMethodSubtype_004', 0, async function (done) { + console.info("====>-----------------inputMethod_test_listInputMethodSubtype_004 start---------------------"); + let inputM = inputMethod.getCurrentInputMethod() + console.info("inputMethod_test_listInputMethodSubtype_004 getCurrentInputMethod: " + JSON.stringify(inputM)); + let inputMethodProperty = { + packageName:inputM.packageName, + methodId:inputM.methodId, + name:inputM.packageName, + id:inputM.methodId, + label: "", + icon: "", + iconId: 124, + extra:{} + } + + let inputMethodSetting = inputMethod.getSetting(); + console.info("====>inputMethod_test_listInputMethodSubtype_004 getSetting result:" + inputMethodSetting); + inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => { + try{ + console.info("====>inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype:" + JSON.stringify(data)); + if(data.length >= 1){ + let inputMethodSubtype = data[0] + console.info("====>inputMethod_test_listInputMethodSubtype_004 inputMethodSubtype" + JSON.stringify(inputMethodSubtype)); + expect(inputMethodSubtype.id != null).assertTrue(); + expect(inputMethodSubtype.label != null).assertTrue(); + done(); + }else{ + console.info("====>inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype length less 1"); + expect().assertFail(); + done(); + } + }catch(error){ + console.info("====>inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype catch error" + JSON.stringify(error)); + expect().assertFail(); + done(); + } + }).catch(err => { + console.info("====>inputMethod_test_listInputMethodSubtype_004 failed" + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info("====>-----------------inputMethod_test_listInputMethodSubtype_004 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_listCurrentInputMethodSubtype_001 + * @tc.name List subtype of the specified input method + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_listCurrentInputMethodSubtype_001', 0, async function (done) { + console.info("====>-----------------inputMethod_test_listCurrentInputMethodSubtype_001 start---------------------"); + let inputMethodSetting = inputMethod.getSetting(); + console.info("====>inputMethod_test_listCurrentInputMethodSubtype_001 getSetting result:" + inputMethodSetting); + inputMethodSetting.listCurrentInputMethodSubtype((err, data) => { + try { + if(err){ + console.info("====>inputMethod_test_listCurrentInputMethodSubtype_001 failed" + JSON.stringify(err)); + expect().assertFail(); + done(); + }; + console.info("====>inputMethod_test_listCurrentInputMethodSubtype_001 listCurrentInputMethodSubtype: " + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + } catch (error) { + console.info("====>inputMethod_test_listCurrentInputMethodSubtype_001 listCurrentInputMethodSubtype catch error" + JSON.stringify(error)); + done(); + } + }); + console.info("====>-----------------inputMethod_test_listCurrentInputMethodSubtype_001 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_listInputMethodSubtype_003 + * @tc.name List subtype of current input method + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_listCurrentInputMethodSubtype_002', 0, async function (done) { + console.info("====>-----------------inputMethod_test_listCurrentInputMethodSubtype_002 start---------------------"); + try{ + let inputMethodSetting = inputMethod.getSetting(); + console.info("====>inputMethod_test_listCurrentInputMethodSubtype_002 getSetting result:" + inputMethodSetting); + inputMethodSetting.listCurrentInputMethodSubtype().then((data) => { + console.info("====>inputMethod_test_listCurrentInputMethodSubtype_002 listCurrentInputMethodSubtype: " + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + }).catch(err => { + console.info("====>inputMethod_test_listCurrentInputMethodSubtype_002 failed" + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + }catch(error){ + console.info("====>inputMethod_test_listCurrentInputMethodSubtype_002 listCurrentInputMethodSubtype catch error" + JSON.stringify(error)); + expect().assertFail(); + done(); + }; + console.info("====>-----------------inputMethod_test_listCurrentInputMethodSubtype_002 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_getCurrentInputMethodSubtype_001 + * @tc.name Get the current input method subtype + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_getCurrentInputMethodSubtype_001', 0, async function (done) { + console.info("====>-----------------inputMethod_test_getCurrentInputMethodSubtype_001 start---------------------"); + try{ + let inputMethodSubtype = inputMethod.getCurrentInputMethodSubtype(); + console.info("====>inputMethod_test_getCurrentInputMethodSubtype_001 result:" + typeof inputMethodSubtype); + if(typeof inputMethodSubtype == "object" ){ + console.info("====>inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype success"); + expect(true).assertTrue(); + }else{ + console.info("====>inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype failed"); + expect().assertFail(); + }; + }catch(error){ + console.info("====>inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype error" + JSON.stringify(error)); + expect().assertFail(); + } + console.info("====>-----------------inputMethod_test_getCurrentInputMethodSubtype_001 end---------------------"); + done(); + }); + + /* + * @tc.number inputMethod_test_switchCurrentInputMethodAndSubtype_001 + * @tc.name Switch current input method subtype. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_switchCurrentInputMethodAndSubtype_001', 0, async function (done) { + console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_001 Test start*************"); + let inputM = inputMethod.getCurrentInputMethod() + console.info("inputMethod_test_switchCurrentInputMethodAndSubtype_001 getCurrentInputMethod: " + JSON.stringify(inputM)); + let inputMethodProperty = { + packageName:inputM.packageName, + methodId:inputM.methodId, + name:inputM.packageName, + id:inputM.methodId, + label: "", + icon: "", + iconId: 124, + extra:{} + } + let inputMS = inputMethod.getCurrentInputMethodSubtype() + console.info("inputMethod_test_switchCurrentInputMethodAndSubtype_001 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS)); + let inputMethodSubProperty : subtype = { + id: inputMS.id, + label: inputMS.label, + name: "", + mode: "lower", + locale: "", + language: "", + icon: "", + iconId: 0, + extra: {} + }; + + inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty, (err,data) => { + try { + if (err) { + console.error('inputMethod_test_switchCurrentInputMethodAndSubtype_001 err: ' + JSON.stringify(err)); + expect( err.code === 12800008 ).assertTrue(); + done(); + } + console.info("====>inputMethod_test_switchCurrentInputMethodAndSubtype_001 data: " + JSON.stringify(data)); + expect(data != null).assertTrue(); + done(); + } catch (error) { + console.error('inputMethod_test_switchCurrentInputMethodAndSubtype_001 catch error: ' + JSON.stringify(error)); + done(); + } + }); + console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_001 Test end*************"); + }); + + /* + * @tc.number inputMethod_test_switchCurrentInputMethodAndSubtype_002 + * @tc.name Switch current input method subtype. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_switchCurrentInputMethodAndSubtype_002', 0, async function (done) { + console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_002 Test start*************"); + let inputM = inputMethod.getCurrentInputMethod() + console.info("inputMethod_test_switchCurrentInputMethodAndSubtype_002 getCurrentInputMethod: " + JSON.stringify(inputM)); + let inputMethodProperty = { + packageName:inputM.packageName, + methodId:inputM.methodId, + name:inputM.packageName, + id:inputM.methodId, + label: "", + icon: "", + iconId: 124, + extra:{} + } + let inputMS = inputMethod.getCurrentInputMethodSubtype() + console.info("inputMethod_test_switchCurrentInputMethodAndSubtype_002 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS)); + let inputMethodSubProperty : subtype = { + id: inputMS.id, + label: inputMS.label, + name: "", + mode: "lower", + locale: "", + language: "", + icon: "", + iconId: 0, + extra: {} + }; + + try { + inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty).then((data) => { + console.info("====>inputMethod_test_switchCurrentInputMethodAndSubtype_002 data: " + JSON.stringify(data)); + expect(data != null).assertTrue(); + done(); + }).catch(err => { + console.error('inputMethod_test_switchCurrentInputMethodAndSubtype_002 err: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + }catch (error) { + console.error('inputMethod_test_switchCurrentInputMethodAndSubtype_002 catch error: ' + JSON.stringify(error)); + expect().assertFail(); + done(); + }; + console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_002 Test end*************"); + }); + + /* + * @tc.number inputMethod_test_switchCurrentInputMethodSubtype_001 + * @tc.name Switch current input method subtype. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_switchCurrentInputMethodSubtype_001', 0, async function (done) { + console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_001 Test start*************"); + let inputMS = inputMethod.getCurrentInputMethodSubtype() + console.info("inputMethod_test_switchCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS)); + let inputMethodSubProperty : subtype = { + id: inputMS.id, + label: inputMS.label, + name: "", + mode: "lower", + locale: "", + language: "", + icon: "", + iconId: 0, + extra: {} + }; + + inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty, (err,data) => { + try { + if (err) { + console.error('inputMethod_test_switchCurrentInputMethodSubtype_001 err: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }; + console.info("====>inputMethod_test_switchCurrentInputMethodSubtype_001 data: " + JSON.stringify(data)); + expect(data != null).assertTrue(); + done(); + } catch (error) { + console.error('inputMethod_test_switchCurrentInputMethodSubtype_001 catch error: ' + JSON.stringify(error)); + done(); + } + }); + console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_001 Test end*************"); + }); + + /* + * @tc.number inputMethod_test_switchCurrentInputMethodSubtype_002 + * @tc.name Switch current input method subtype. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_switchCurrentInputMethodSubtype_002', 0, async function (done) { + console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_002 Test start*************"); + let inputMS = inputMethod.getCurrentInputMethodSubtype() + console.info("inputMethod_test_switchCurrentInputMethodSubtype_002 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS)); + let inputMethodSubProperty : subtype = { + id: inputMS.id, + label: inputMS.label, + name: "", + mode: "lower", + locale: "", + language: "", + icon: "", + iconId: 0, + extra: {} + }; + + try { + inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty).then((data) => { + console.info("====>inputMethod_test_switchCurrentInputMethodSubtype_002 data: " + JSON.stringify(data)); + expect(data != null).assertTrue(); + done(); + }).catch(err => { + console.error('inputMethod_test_switchCurrentInputMethodSubtype_002 err: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + }catch (error) { + console.error('inputMethod_test_switchCurrentInputMethodSubtype_002 catch error: ' + JSON.stringify(error)); + expect().assertFail(); + done(); + }; + console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_002 Test end*************"); + done(); + }); + + /* + * @tc.number inputMethod_test_showOptionalInputMethods_001 + * @tc.name Show input method setting extension dialog + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_showOptionalInputMethods_001', 0, async function (done) { + console.info("====>-----------------inputMethod_test_showOptionalInputMethods_001 start---------------------"); + let inputMethodSetting = inputMethod.getSetting(); + console.info("====>inputMethod_test_showOptionalInputMethods_001 result:" + inputMethodSetting); + inputMethodSetting.showOptionalInputMethods((err, data) => { + try { + if(err){ + console.info("====>inputMethod_test_showOptionalInputMethods_001 showOptionalInputMethods faild: " + JSON.stringify(err)); + expect().assertFail(); + done(); + }; + console.info("====>inputMethod_test_showOptionalInputMethods_001 showOptionalInputMethods success data is : " + data); + expect(true).assertTrue(); + setTimeout(() => { + done(); + }, 1500); + } catch (error) { + console.info("====>inputMethod_test_showOptionalInputMethods_001 showOptionalInputMethods catch error: " + JSON.stringify(error)); + done(); + } + }); + console.info("====>-----------------inputMethod_test_showOptionalInputMethods_001 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_showOptionalInputMethods_002 + * @tc.name Show input method setting extension dialog + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_showOptionalInputMethods_002', 0, async function (done) { + console.info("====>-----------------inputMethod_test_showOptionalInputMethods_002 start---------------------"); + let inputMethodSetting = inputMethod.getSetting(); + try { + console.info("====>inputMethod_test_showOptionalInputMethods_002 result:" + JSON.stringify(inputMethodSetting)); + inputMethodSetting.showOptionalInputMethods().then((data) => { + console.info("====>inputMethod_test_showOptionalInputMethods_002 showOptionalInputMethods success data is: " + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + }).catch(err => { + console.info("====>inputMethod_test_showOptionalInputMethods_002 showOptionalInputMethods faild: " + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + } catch (error) { + console.info("====>inputMethod_test_showOptionalInputMethods_002 showOptionalInputMethods catch error: " + JSON.stringify(error)); + expect().assertFail(); + done(); + }; + console.info("====>-----------------inputMethod_test_showOptionalInputMethods_002 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_stopInputSession_002 + * @tc.name Stop input + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_stopInputSession_002', 0, async function (done) { + console.info("====>-----------------inputMethod_test_stopInputSession_002 start---------------------"); + try{ + let inputMethodCtrl = inputMethod.getController(); + console.info("====>inputMethod_test_stopInputSession_002 result:" + typeof inputMethodCtrl); + await inputMethodCtrl.stopInputSession().then((data) => { + console.info("====>inputMethod_test_stopInputSession_002 data:" + data); + expect().assertFail(); + done(); + }).catch((err) => { + expect(err.code).assertEqual(12800003) + done(); + }) + }catch(error){ + console.info("====>inputMethod_test_stopInputSession_002 catch error" + JSON.stringify(error)); + expect().assertFail(); + done(); + }; + console.info("====>-----------------inputMethod_test_stopInputSession_002 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_stopInputSession_001 + * @tc.name Stop input + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_stopInputSession_001', 0, async function (done) { + console.info("====>-----------------inputMethod_test_stopInputSession_001 start---------------------"); + let inputMethodCtrl = inputMethod.getController(); + console.debug("inputMethod_test_stopInputSession_001 result: " + typeof inputMethodCtrl); + inputMethodCtrl.stopInputSession((err)=>{ + try { + if(err){ + console.info("====>inputMethod_test_stopInputSession_001 faild: " + JSON.stringify(err)); + console.info("====>inputMethod_test_stopInputSession_001 faild: " + err.code); + console.info("====>inputMethod_test_stopInputSession_001 faild: " + typeof(err.code)); + expect(err.code).assertEqual(12800003); + done(); + }else{ + expect().assertFail(); + done(); + } + } catch (err) { + done(); + } + }) + }); + + }); +}; diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/module.json b/inputmethod/InputMethodTest_Stage/entry/src/main/module.json new file mode 100644 index 000000000..ebfbd6d84 --- /dev/null +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/module.json @@ -0,0 +1,64 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet", + "default", + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], + "abilities": [ + { + "name": "com.acts.imeability.test.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "com.acts.imeability.test.ImExtAbility", + "srcEntrance": "./ets/ImExtAbility/ImExtAbility.ets", + "label": "$string:ime_label", + "description": "$string:ime_description", + "type": "inputMethod" + } + ], + "requestPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.CONNECT_IME_ABILITY" + } + ] + } +} diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/resources/base/element/string.json b/inputmethod/InputMethodTest_Stage/entry/src/main/resources/base/element/string.json new file mode 100644 index 000000000..ea8ffb9ce --- /dev/null +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/resources/base/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsImeAbilityTest" + }, + { + "name": "ime_description", + "value": "input method extension ability." + }, + { + "name": "ime_label", + "value": "inputMethod extension ability services." + }, + { + "name": "ime_label_1", + "value": "inputMethod extension ability services_1." + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + } + ] +} diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/resources/base/media/icon.png b/inputmethod/InputMethodTest_Stage/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QL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XOrTV4wt)JP9}| zpb&q0BT1Io14+ZC=C0i~V&3_T%I!y274BM9FXVjOdwL3g2Jp&(P%jihA72x;Jic@L}`AXc~dz=Bb+UCo=`{+k^*-~4ptBxBWE9k0Lt%E;9luPk1i zd*$e=af`1%J^Rg~vDYsgJp00rnws?bZTn2TtaloA1l5JYQOKX7R!ife!M!6Bjy$9=mXIkVsbh`*On8 zsqwY;j)|HZZ`E!8V8x2u_aoCf^HY!9eD1V$S^WG9^tqUeU*`Wv|Jt-qi=mVZ7C|;c ze8_iBfk<-$Xq6SLkeaCyPBYjY!` zT0UXETN*w1`MLcQw~ZvQ!Ply{eC9&?=3n>xBp;XYB^dYNV_PSv4$u4h^!LDT&5Ex= TIMnv1y=PV=)_k&S_f!7^y48N@ literal 0 HcmV?d00001 diff --git a/inputmethod/InputMethodTest_ets/BUILD.gn b/inputmethod/InputMethodTest_ets/BUILD.gn new file mode 100644 index 000000000..4954a98af --- /dev/null +++ b/inputmethod/InputMethodTest_ets/BUILD.gn @@ -0,0 +1,38 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsInputMethodEtsTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":inputMethod_ets_assets", + ":inputMethod_ets_resources", + ":inputMethod_ets_test_assets", + ] + ets2abc = true + subsystem_name = "inputmethod" + part_name = "imf" + certificate_profile = "./signature/ActInputMethodEtsAPITest.p7b" + hap_name = "ActsInputMethodEtsTest" +} +ohos_js_assets("inputMethod_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_js_assets("inputMethod_ets_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} +ohos_resources("inputMethod_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/inputmethod/InputMethodTest_ets/Test.json b/inputmethod/InputMethodTest_ets/Test.json new file mode 100644 index 000000000..e72008206 --- /dev/null +++ b/inputmethod/InputMethodTest_ets/Test.json @@ -0,0 +1,19 @@ +{ + "description": "Configuration for inputMethod Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.acts.inputmethodtest", + "package-name": "com.acts.inputmethodtest", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsInputMethodEtsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/config.json b/inputmethod/InputMethodTest_ets/entry/src/main/config.json new file mode 100644 index 000000000..abe55f0a6 --- /dev/null +++ b/inputmethod/InputMethodTest_ets/entry/src/main/config.json @@ -0,0 +1,106 @@ +{ + "app": { + "bundleName": "com.acts.inputmethodtest", + "vendor": "open", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.acts.inputmethodtest", + "name": ".MyApplication", + "mainAbility": "com.acts.inputmethodtest.MainAbility", + "deviceType": [ + "tablet", + "default", + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "orientation": "unspecified", + "visible": true, + "srcPath": "TestAbility", + "name": ".TestAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "formsEnabled": false, + "label": "$string:TestAbility_label", + "type": "page", + "launchType": "standard" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.CONNECT_IME_ABILITY" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/input" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/app.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 000000000..08e6696db --- /dev/null +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,32 @@ +/** + * 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('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/index.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 000000000..1a788d8fa --- /dev/null +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,36 @@ +// @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. + */ +@Entry +@Component +struct MyComponent { + aboutToAppear() { + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('ACE ETS TEST') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/input.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/input.ets new file mode 100644 index 000000000..309eb39d4 --- /dev/null +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/input.ets @@ -0,0 +1,45 @@ +// @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. + */ + +@Entry +@Component +struct TextInputTest { + @State text: string = ''; + + build() { + Column() { + TextInput({ placeholder: 'input your word' }) + .type(InputType.Normal) + .key('TextInput') + .placeholderColor(Color.Blue) + .placeholderFont({ size: 40, weight: FontWeight.Normal, family: "sans-serif", style: FontStyle.Normal }) + .enterKeyType(EnterKeyType.Search) + .caretColor(Color.Green) + .height(60) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .fontFamily("cursive") + .fontStyle(FontStyle.Italic) + .fontColor(Color.Red) + .maxLength(20) + .onChange((value: string) => { + this.text = value + }) + Text(this.text) + } + } +} + diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/TestAbility/app.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 000000000..e6de87af1 --- /dev/null +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/TestAbility/pages/index.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 000000000..011878f2b --- /dev/null +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@system.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/inputmethod/InputMethodTest_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..57fdc77f0 --- /dev/null +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/List.test.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/List.test.ets new file mode 100644 index 000000000..1321a1d7f --- /dev/null +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,21 @@ +/** + * 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 inputMethodJSUnit from './inputMethodJSUnit'; +import inputMethodEngineJSUnit from './inputMethodEngineJSUnit'; + +export default function testsuite() { + inputMethodJSUnit(); + inputMethodEngineJSUnit(); +} \ No newline at end of file diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/Utils.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/Utils.ets new file mode 100644 index 000000000..4d2727406 --- /dev/null +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/Utils.ets @@ -0,0 +1,118 @@ +// @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. + */ + +export default class Utils { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("====>[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("====>[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } + + static async swipe(downX, downY, upX, upY, steps) { + console.info('====>start to swipe') + this.drags(downX, downY, upX, upY, steps, false) + } + + static async drag(downX, downY, upX, upY, steps) { + console.info('====>start to drag') + this.drags(downX, downY, upX, upY, steps, true) + } + + static async drags(downX, downY, upX, upY, steps, drag) { + let xStep; + let yStep; + let swipeSteps; + let ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('====>move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + let downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('====>down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('====>start to move') + if (drag) { + await this.sleep(500) + } + for (let i = 1;i <= swipeSteps; i++) { + let movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('====>move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('====>start to up') + if (drag) { + await this.sleep(100) + } + let upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('====>up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) + } +} + + + + diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets new file mode 100644 index 000000000..7322bb92a --- /dev/null +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets @@ -0,0 +1,717 @@ +/** + * 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 inputMethodEngine from '@ohos.inputMethodEngine'; +import Utils from './Utils'; +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; + +export default function inputMethodEngineJSUnit() { + describe('appInfoTest_input_1', function () { + let mKeyboardDelegate = null; + let inputMethodEngineObject = inputMethodEngine.getInputMethodEngine(); + let textInputClient = null; + let kbController = null; + let KeyboardDelegate = null; + + console.info("====>************* inputMethodEngine Test start*************"); + beforeEach(async function (done) { + let options = { + uri: 'pages/input', + } + try { + router.clear(); + let pages = router.getState(); + if (!("input" == pages.name)) { + let result = await router.push(options); + await Utils.sleep(1000); + } + done(); + } catch (err) { + console.error("push input page error: " + err); + done(); + } + }); + + afterEach(async function () { + console.info("====>inputMethodEngine afterEach start:" + inputMethodEngineObject); + await Utils.sleep(1000); + }); + + it('inputMethodEngine_testOff_000', 0 , async function (done) { + inputMethodEngineObject.off('inputStart', (kbController, textInputClient) => { + console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController)); + console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient)); + }); + inputMethodEngineObject.off('keyboardShow', () => { + console.info("====>inputMethodEngine beforeEach keyboardShow:"); + }); + inputMethodEngineObject.off('keyboardHide', () => { + console.info("====>inputMethodEngine beforeEach keyboardHide:"); + }); + KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); + KeyboardDelegate.off('keyDown', (keyEvent) => { + console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode); + expect(keyEvent.keyCode).assertEqual('1'); + + console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); + expect(keyEvent.keyAction).assertEqual('1'); + + }); + KeyboardDelegate.off('keyUp', (keyEvent) => { + console.info("====>inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode); + expect(keyEvent.keyCode).assertEqual('1'); + console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); + expect(keyEvent.keyAction).assertEqual('0'); + + }); + KeyboardDelegate.off('cursorContextChange', (x, y, height) => { + console.info("====>inputMethodEngine beforeEach cursorContextChange x:" + x); + console.info("====>inputMethodEngine beforeEach cursorContextChange y:" + y); + console.info("====>inputMethodEngine beforeEach cursorContextChange height:" + height); + }); + KeyboardDelegate.off('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { + console.info("====>inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin); + console.info("====>inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd); + console.info("====>inputMethodEngine beforeEach selectionChange newBegin:" + newBegin); + console.info("====>inputMethodEngine beforeEach selectionChange newEnd:" + newEnd); + }); + KeyboardDelegate.off('textChange', (text) => { + console.info("====>inputMethodEngine beforeEach textChange:" + text); + }); + done(); + }); + + it('inputMethodEngine_test_000', 0, async function (done) { + inputMethodEngineObject.on('inputStart', (kbController, textInputClient) => { + console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController)); + console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient)); + textInputClient = textInputClient; + kbController = kbController; + }); + inputMethodEngineObject.on('keyboardShow', () => { + console.info("====>inputMethodEngine beforeEach keyboardShow:"); + }); + inputMethodEngineObject.on('keyboardHide', () => { + console.info("====>inputMethodEngine beforeEach keyboardHide:"); + }); + mKeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); + mKeyboardDelegate.on('keyDown', (keyEvent) => { + console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode); + expect(keyEvent.keyCode).assertEqual('1'); + + console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); + expect(keyEvent.keyAction).assertEqual('1'); + + + }); + mKeyboardDelegate.on('keyUp', (keyEvent) => { + console.info("====>inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode); + expect(keyEvent.keyCode).assertEqual('1'); + console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); + expect(keyEvent.keyAction).assertEqual('0'); + + }); + mKeyboardDelegate.on('cursorContextChange', (x, y, height) => { + console.info("====>inputMethodEngine beforeEach cursorContextChange x:" + x); + console.info("====>inputMethodEngine beforeEach cursorContextChange y:" + y); + console.info("====>inputMethodEngine beforeEach cursorContextChange height:" + height); + }); + mKeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { + console.info("====>inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin); + console.info("====>inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd); + console.info("====>inputMethodEngine beforeEach selectionChange newBegin:" + newBegin); + console.info("====>inputMethodEngine beforeEach selectionChange newEnd:" + newEnd); + }); + mKeyboardDelegate.on('textChange', (text) => { + console.info("====>inputMethodEngine beforeEach textChange:" + text); + }); + done(); + }); + + it('inputMethodEngine_test_001', 0, async function (done) { + let keyType = inputMethodEngine.ENTER_KEY_TYPE_UNSPECIFIED; + console.info("====>inputMethodEngine_test_001 result:" + keyType); + expect(keyType).assertEqual(0); + done(); + }); + + it('inputMethodEngine_test_002', 0, async function (done) { + let keyType = inputMethodEngine.ENTER_KEY_TYPE_GO; + console.info("====>inputMethodEngine_test_002 result:" + keyType); + expect(keyType).assertEqual(2); + done(); + }); + + it('inputMethodEngine_test_003', 0, async function (done) { + let keyType = inputMethodEngine.ENTER_KEY_TYPE_SEARCH; + console.info("====>inputMethodEngine_test_003 result:" + keyType); + expect(keyType).assertEqual(3); + done(); + }); + + it('inputMethodEngine_test_004', 0, async function (done) { + let keyType = inputMethodEngine.ENTER_KEY_TYPE_SEND; + console.info("====>inputMethodEngine_test_004 result:" + keyType); + expect(keyType).assertEqual(4); + done(); + }); + + it('inputMethodEngine_test_005', 0, async function (done) { + let keyType = inputMethodEngine.ENTER_KEY_TYPE_NEXT; + console.info("====>inputMethodEngine_test_005 result:" + keyType); + expect(keyType).assertEqual(5); + done(); + }); + + it('inputMethodEngine_test_006', 0, async function (done) { + let keyType = inputMethodEngine.ENTER_KEY_TYPE_DONE; + console.info("====>inputMethodEngine_test_006 result:" + keyType); + expect(keyType).assertEqual(6); + done(); + }); + + it('inputMethodEngine_test_007', 0, async function (done) { + let keyType = inputMethodEngine.ENTER_KEY_TYPE_PREVIOUS; + console.info("====>inputMethodEngine_test_007 result:" + keyType); + expect(keyType).assertEqual(7); + done(); + }); + + it('inputMethodEngine_test_008', 0, async function (done) { + let keyType = inputMethodEngine.PATTERN_NULL; + console.info("====>inputMethodEngine_test_008 result:" + keyType); + expect(keyType).assertEqual(-1); + done(); + }); + + it('inputMethodEngine_test_009', 0, async function (done) { + let keyType = inputMethodEngine.PATTERN_TEXT; + console.info("====>inputMethodEngine_test_009 result:" + keyType); + expect(keyType).assertEqual(0); + done(); + }); + + it('inputMethodEngine_test_010', 0, async function (done) { + let keyType = inputMethodEngine.PATTERN_NUMBER; + console.info("====>inputMethodEngine_test_010 result:" + keyType); + expect(keyType).assertEqual(2); + done(); + }); + + it('inputMethodEngine_test_011', 0, async function (done) { + let keyType = inputMethodEngine.PATTERN_PHONE; + console.info("====>inputMethodEngine_test_011 result:" + keyType); + expect(keyType).assertEqual(3); + done(); + }); + + it('inputMethodEngine_test_012', 0, async function (done) { + let keyType = inputMethodEngine.PATTERN_DATETIME; + console.info("====>inputMethodEngine_test_012 result:" + keyType); + expect(keyType).assertEqual(4); + done(); + }); + + it('inputMethodEngine_test_013', 0, async function (done) { + let keyType = inputMethodEngine.PATTERN_EMAIL; + console.info("====>inputMethodEngine_test_013 result:" + keyType); + expect(keyType).assertEqual(5); + done(); + }); + + it('inputMethodEngine_test_014', 0, async function (done) { + let keyType = inputMethodEngine.PATTERN_URI; + console.info("====>inputMethodEngine_test_014 result:" + keyType); + expect(keyType).assertEqual(6); + done(); + }); + + it('inputMethodEngine_test_015', 0, async function (done) { + let keyType = inputMethodEngine.PATTERN_PASSWORD; + console.info("====>inputMethodEngine_test_015 result:" + keyType); + expect(keyType).assertEqual(7); + done(); + }); + + it('inputMethodEngine_test_016', 0, async function (done) { + let keyType = inputMethodEngine.FLAG_SELECTING; + console.info("====>inputMethodEngine_test_016 result:" + keyType); + expect(keyType).assertEqual(2); + done(); + }); + + it('inputMethodEngine_test_017', 0, async function (done) { + let keyType = inputMethodEngine.FLAG_SINGLE_LINE; + console.info("====>inputMethodEngine_test_017 result:" + keyType); + expect(keyType).assertEqual(1); + done(); + }); + + it('inputMethodEngine_test_018', 0, async function (done) { + let keyType = inputMethodEngine.DISPLAY_MODE_PART; + console.info("====>inputMethodEngine_test_018 result:" + keyType); + expect(keyType).assertEqual(0); + done(); + }); + + it('inputMethodEngine_test_019', 0, async function (done) { + let keyType = inputMethodEngine.DISPLAY_MODE_FULL; + console.info("====>inputMethodEngine_test_019 result:" + keyType); + expect(keyType).assertEqual(1); + done(); + }); + + it('inputMethodEngine_test_020', 0, async function (done) { + let keyType = inputMethodEngine.OPTION_ASCII; + console.info("====>inputMethodEngine_test_020 result:" + keyType); + expect(keyType).assertEqual(20); + done(); + }); + + it('inputMethodEngine_test_021', 0, async function (done) { + let keyType = inputMethodEngine.OPTION_NONE; + console.info("====>inputMethodEngine_test_021 result:" + keyType); + expect(keyType).assertEqual(0); + done(); + }); + + it('inputMethodEngine_test_022', 0, async function (done) { + let keyType = inputMethodEngine.OPTION_AUTO_CAP_CHARACTERS; + console.info("====>inputMethodEngine_test_022 result:" + keyType); + expect(keyType).assertEqual(2); + done(); + }); + + it('inputMethodEngine_test_023', 0, async function (done) { + let keyType = inputMethodEngine.OPTION_AUTO_CAP_SENTENCES; + console.info("====>inputMethodEngine_test_023 result:" + keyType); + expect(keyType).assertEqual(8); + done(); + }); + + it('inputMethodEngine_test_024', 0, async function (done) { + let keyType = inputMethodEngine.OPTION_AUTO_WORDS; + console.info("====>inputMethodEngine_test_024 result:" + keyType); + expect(keyType).assertEqual(4); + done(); + }); + + it('inputMethodEngine_test_025', 0, async function (done) { + let keyType = inputMethodEngine.OPTION_MULTI_LINE; + console.info("====>inputMethodEngine_test_025 result:" + keyType); + expect(keyType).assertEqual(1); + done(); + }); + + it('inputMethodEngine_test_026', 0, async function (done) { + let keyType = inputMethodEngine.OPTION_NO_FULLSCREEN; + console.info("====>inputMethodEngine_test_026 result:" + keyType); + expect(keyType).assertEqual(10); + done(); + }); + + it('inputMethodEngine_test_027', 0, async function (done) { + + let rect = await Utils.getComponentRect('TextInput') + console.info("====>[inputMethodEngine_test_027] rectInfo is " + rect); + console.info("====>[inputMethodEngine_test_027] rectInfo is " + JSON.stringify(rect)); + let x_value = rect.left + (rect.right - rect.left) / 10 + + let y_value = rect.top + (rect.bottom - rect.top) / 10 + console.info("====>[inputMethodEngine_test_027] onTouch location is: " + "[x]=== " + x_value + " [y]===" + y_value); + let point: TouchObject = { + id: 1, + x: x_value, + y: y_value, + type: TouchType.Move, + screenX: rect.left + (rect.right - rect.left) / 10, + screenY: rect.left + (rect.right - rect.left) / 10, + } + console.info('====>[inputMethodEngine_test_027] testSendTouchEvent ' + sendTouchEvent(point)); + await Utils.sleep(1000) + console.info('====>[inputMethodEngine_test_027] END'); + done(); + }); + + it('inputMethodEngine_test_028', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + textInputClient.sendKeyFunction(0, (value) => { + console.info("====>inputMethodEngine_test_028 textInputClient sendKeyFunction:" + value); + expect(value).assertEqual(true); + }); + } + done(); + }); + + it('inputMethodEngine_test_029', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + let promise = textInputClient.sendKeyFunction(0); + promise.then(res => { + console.info("====>inputMethodEngine_test_029 listInputMethod promise result-----" + JSON.stringify(res)); + expect(res).assertEqual(true); + }).catch(err => { + console.info("====>inputMethodEngine_test_029 listInputMethod promise error----" + JSON.stringify(err)); + expect().assertFail(); + }); + } + done(); + }); + + it('inputMethodEngine_test_030', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + textInputClient.deleteForward(1, (value) => { + console.info("====>inputMethodEngine_test_030 deleteForward:" + value); + expect(value).assertEqual(true); + }); + } + done(); + }); + + it('inputMethodEngine_test_031', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + let promise = textInputClient.deleteForward(1); + promise.then(res => { + console.info("====>inputMethodEngine_test_031 deleteForward promise result-----" + JSON.stringify(res)); + expect(res).assertEqual(true); + }).catch(err => { + console.info("====>inputMethodEngine_test_031 deleteForward promise error----" + JSON.stringify(err)); + expect().assertFail(); + }); + } + done(); + }); + + it('inputMethodEngine_test_032', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + textInputClient.deleteBackward(1, (value) => { + console.info("====>inputMethodEngine_test_032 deleteBackward:" + value); + expect(value).assertEqual(true); + }); + } + done(); + }); + + it('inputMethodEngine_test_033', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + let promise = textInputClient.deleteBackward(1); + promise.then(res => { + console.info("====>inputMethodEngine_test_033 deleteBackward promise result-----" + JSON.stringify(res)); + expect(res).assertEqual(true); + }).catch(err => { + console.info("====>inputMethodEngine_test_033 deleteBackward promise error----" + JSON.stringify(err)); + expect().assertFail(); + }); + } + done(); + }); + + it('inputMethodEngine_test_034', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + textInputClient.InsertText('test', (value) => { + console.info("====>inputMethodEngine_test_034 InsertText:" + value); + expect(value).assertEqual(true); + }); + } + done(); + }); + + it('inputMethodEngine_test_035', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + let promise = textInputClient.InsertText('test'); + promise.then(res => { + console.info("====>inputMethodEngine_test_035 InsertText promise result-----" + JSON.stringify(res)); + expect(res).assertEqual(true); + }).catch(err => { + console.info("====>inputMethodEngine_test_035 InsertText promise error----" + JSON.stringify(err)); + expect().assertFail(); + }); + } + done(); + }); + + it('inputMethodEngine_test_036', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + textInputClient.getForward(1, (value) => { + console.info("====>inputMethodEngine_test_036 getForward:" + value); + expect(value).assertEqual(true); + }); + } + done(); + }); + + it('inputMethodEngine_test_037', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + let promise = textInputClient.getForward(1); + promise.then(res => { + console.info("====>inputMethodEngine_test_037 getForward promise result-----" + JSON.stringify(res)); + expect(res).assertEqual(true); + }).catch(err => { + console.info("====>inputMethodEngine_test_037 getForward promise error----" + JSON.stringify(err)); + expect().assertFail(); + }); + } + done(); + }); + + it('inputMethodEngine_test_038', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + textInputClient.getEditorAttribute(1, (editorAttribute) => { + console.info("====>inputMethodEngine_test_038 getEditorAttribute:" + editorAttribute); + expect(editorAttribute.inputPattern).assertEqual(1); + expect(editorAttribute.enterKeyType).assertEqual(1); + }); + } + done(); + }); + + it('inputMethodEngine_test_039', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + let promise = textInputClient.getEditorAttribute(); + promise.then(res => { + console.info("====>inputMethodEngine_test_039 getEditorAttribute promise result-----" + JSON.stringify(res)); + expect(res.inputPattern).assertEqual(1); + expect(res.enterKeyType).assertEqual(1); + }).catch(err => { + console.info("====>inputMethodEngine_test_039 getEditorAttribute promise error----" + JSON.stringify(err)); + expect().assertFail(); + }); + } + done(); + }); + + it('inputMethodEngine_test_040', 0, async function (done) { + if (kbController == null) { + expect(kbController == null).assertEqual(true); + } else { + kbController.hideKeyboard(() => { + console.info("====>inputMethodEngine_test_040 hideKeyboard"); + expect(1 == 1).assertTrue(); + }); + } + done(); + }); + + it('inputMethodEngine_test_041', 0, async function (done) { + if (kbController == null) { + expect(kbController == null).assertEqual(true); + } else { + let promise = kbController.hideKeyboard(); + promise.then(res => { + console.info("====>inputMethodEngine_test_041 hideKeyboard promise result-----" + JSON.stringify(res)); + expect(1 == 1).assertTrue(); + }).catch(err => { + console.info("====>inputMethodEngine_test_041 hideKeyboard promise error----" + JSON.stringify(err)); + expect().assertFail(); + }); + } + done(); + }); + + it('inputMethodEngine_test_042', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + textInputClient.getBackward(1, (value) => { + console.info("====>inputMethodEngine_test_042 getBackward:" + value); + expect(value).assertEqual(true); + }); + } + done(); + }); + + it('inputMethodEngine_test_043', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + let promise = textInputClient.getBackward(1); + promise.then(res => { + console.info("====>inputMethodEngine_test_043 getBackward promise result-----" + JSON.stringify(res)); + expect(res).assertEqual(true); + }).catch(err => { + console.info("====>inputMethodEngine_test_043 getBackward promise error----" + JSON.stringify(err)); + expect().assertFail(); + }); + } + done(); + }); + + it('inputMethodEngine_test_044', 0, async function (done) { + let keyType = inputMethodEngine.WINDOW_TYPE_INPUT_METHOD_FLOAT; + console.error("inputMethodEngine_test_044 result:" + keyType); + expect(keyType == 2105).assertTrue(); + done(); + }); + + it('inputMethodEngine_test_045', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + textInputClient.moveCursor(inputMethodEngine.CURSOR_UP, (value) => { + console.info("====>inputMethodEngine_test_045 moveCursor:" + value); + expect(value == null).assertEqual(true); + }); + } + done(); + }); + + it('inputMethodEngine_test_046', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + textInputClient.moveCursor(inputMethodEngine.CURSOR_DOWN, (value) => { + console.info("====>inputMethodEngine_test_046 moveCursor:" + value); + expect(value == null).assertEqual(true); + }); + } + done(); + }) + + it('inputMethodEngine_test_047', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + textInputClient.moveCursor(inputMethodEngine.CURSOR_LEFT).then(res => { + console.info("====>inputMethodEngine_test_047 moveCursor promise result-----" + JSON.stringify(res)); + expect(res == null).assertEqual(true); + }).catch(err => { + console.info("====>inputMethodEngine_test_047 moveCursor promise error----" + JSON.stringify(err)); + expect().assertFail(); + }); + } + done(); + }) + + it('inputMethodEngine_test_048', 0, async function (done) { + if (textInputClient == null) { + expect(textInputClient == null).assertEqual(true); + } else { + textInputClient.moveCursor(inputMethodEngine.CURSOR_RIGHT).then(res => { + console.info("====>inputMethodEngine_test_048 moveCursor promise result-----" + JSON.stringify(res)); + expect(res == null).assertEqual(true); + }).catch(err => { + console.info("====>inputMethodEngine_test_048 moveCursor promise error----" + JSON.stringify(err)); + expect().assertFail(); + }); + } + done(); + }) + + it('inputMethodEngine_test_049', 0, async function (done) { + if (kbController == null) { + expect(kbController == null).assertEqual(true); + } else { + kbController.hide(() => { + console.info("====>inputMethodEngine_test_049 hideKeyboard:"); + expect(1 == 1).assertTrue(); + }); + } + done(); + }); + + it('inputMethodEngine_test_050', 0, async function (done) { + if (kbController == null) { + expect(kbController == null).assertEqual(true); + } else { + let promise = kbController.hide(); + promise.then(res => { + console.info("====>inputMethodEngine_test_050 hideKeyboard promise result-----" + JSON.stringify(res)); + expect(1 == 1).assertTrue(); + }).catch(err => { + console.info("====>inputMethodEngine_test_050 hideKeyboard promise error----" + JSON.stringify(err)); + expect().assertFail(); + }); + } + done(); + }); + + /* + * @tc.number inputMethodEngine_test_getInputMethodAbility_001 + * @tc.name InputMethodAbility object of the current input method. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethodEngine_test_getInputMethodAbility_001', 0, async function (done) { + console.info("====>-----------------inputMethodEngine_test_getInputMethodAbility_001 start---------------------"); + try{ + let inputMethodAbility = inputMethodEngine.getInputMethodAbility(); + console.info("====>inputMethodEngine_test_getInputMethodAbility_001 result:" + typeof inputMethodAbility); + if(typeof inputMethodAbility == "object" ){ + console.info("====>inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype success"); + expect(true).assertTrue(); + }else{ + console.info("====>inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype failed"); + expect().assertFail(); + }; + }catch(error){ + console.info("====>inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype error" + JSON.stringify(error)); + expect().assertFail(); + } + console.info("====>-----------------inputMethodEngine_test_getInputMethodAbility_001 end---------------------"); + done(); + }); + + /* + * @tc.number inputMethodEngine_test_getKeyboardDelegate_001 + * @tc.name KeyboardDelegate object of the current input method. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethodEngine_test_getKeyboardDelegate_001', 0, async function (done) { + console.info("====>-----------------inputMethodEngine_test_getKeyboardDelegate_001 start---------------------"); + try{ + let inputMethodAbility = inputMethodEngine.getKeyboardDelegate(); + console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 result:" + typeof inputMethodAbility); + if(typeof inputMethodAbility == "object" ){ + console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype success"); + expect(true).assertTrue(); + }else{ + console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype failed"); + expect().assertFail(); + }; + }catch(error){ + console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype error" + JSON.stringify(error)); + expect().assertFail(); + } + console.info("====>-----------------inputMethodEngine_test_getKeyboardDelegate_001 end---------------------"); + done(); + }); + + }) +} diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets new file mode 100644 index 000000000..d1214bb56 --- /dev/null +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets @@ -0,0 +1,343 @@ +/** + * 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 inputMethod from '@ohos.inputMethod'; + +export default function inputMethodJSUnit() { + describe('appInfoTest_input_2', function () { + console.info("====>************* settings Test start*************"); + it('inputmethoh_test_001', 0, async function (done) { + let inputMethodSetting = inputMethod.getInputMethodSetting(); + console.info("====>inputmethoh_test_001 result:" + JSON.stringify(inputMethodSetting)); + inputMethodSetting.listInputMethod((arr) => { + console.info("====>appInfoTest_input_2 listInputMethod result---" + JSON.stringify(arr)); + expect(1 == 1).assertTrue(); + done(); + }); + }); + + it('inputmethoh_test_002', 0, async function (done) { + let inputMethodSetting = inputMethod.getInputMethodSetting(); + console.info("====>inputmethoh_test_002 result:" + JSON.stringify(inputMethodSetting)); + inputMethodSetting.listInputMethod().then(inputMethodProperty => { + if (inputMethodProperty.length > 0) { + let obj = inputMethodProperty[0] + console.info("====>inputmethoh_test_002 listInputMethod obj---" + JSON.stringify(obj)); + expect(obj.packageName != null).assertTrue(); + expect(obj.methodId != null).assertTrue(); + } else { + console.info("====>inputmethoh_test_002 listInputMethod is null"); + expect().assertFail() + } + done(); + }).catch(err => { + console.info("====>inputmethoh_test_002 listInputMethod is err: " + JSON.stringify(err)); + done(); + }); + }); + + it('inputmethoh_test_003', 0, async function (done) { + let inputMethodSetting = inputMethod.getInputMethodSetting(); + console.info("====>inputmethoh_test_003 result:" + JSON.stringify(inputMethodSetting)); + setTimeout(() => { + inputMethodSetting.displayOptionalInputMethod((err) => { + try { + if (err) { + console.info("====>inputmethoh_test_003 displayOptionalInputMethod err:" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + expect(true).assertTrue(); + console.info("====>inputmethoh_test_003 displayOptionalInputMethod---"); + done(); + } catch (err) { + console.info("====>inputmethoh_test_004 displayOptionalInputMethod throw_err: " + JSON.stringify(err)); + done(); + } + }); + }, 500) + }); + + it('inputmethoh_test_004', 0, async function (done) { + let inputMethodSetting = inputMethod.getInputMethodSetting(); + console.info("====>inputmethoh_test_004 result:" + JSON.stringify(inputMethodSetting)); + setTimeout(() => { + inputMethodSetting.displayOptionalInputMethod().then(() => { + console.info("====>inputmethoh_test_004 displayOptionalInputMethod is called"); + expect(true).assertTrue() + done(); + }).catch(err => { + console.info("====>inputmethoh_test_004 displayOptionalInputMethod is err: " + JSON.stringify(err)); + expect().assertFail() + done(); + }); + }, 500) + }); + + it('inputmethoh_test_005', 0, async function (done) { + let inputMethodCtrl = inputMethod.getInputMethodController(); + console.info("====>inputmethoh_test_005 result:" + JSON.stringify(inputMethodCtrl)); + inputMethodCtrl.stopInput((res) => { + console.info("====>inputmethoh_test_005 stopInput result----" + res); + done(); + }); + }); + + it('inputmethoh_test_006', 0, async function (done) { + let inputMethodCtrl = inputMethod.getInputMethodController(); + console.info("====>inputmethoh_test_006 result:" + JSON.stringify(inputMethodCtrl)); + inputMethodCtrl.stopInput().then(() => { + expect().assertFail(); + done(); + }).catch((err) => { + console.info("====>inputmethoh_test_006 stopInput is err: " + JSON.stringify(err)); + expect().assertEqual(); + done(); + }); + }); + + /* + * @tc.number: inputmethod_test_MAX_TYPE_NUM_001 + * @tc.name: inputMethod::MAX_TYPE_NUM + * @tc.desc: Verify Max_ TYPE_ NUM + */ + it('inputmethod_test_MAX_TYPE_NUM_001', 0, async function (done) { + console.info("====>************* inputmethod_test_MAX_TYPE_NUM_001 Test start*************"); + let inputMethodSetting = inputMethod.MAX_TYPE_NUM; + console.info("====>inputmethod_test_001 result:" + inputMethodSetting); + expect(inputMethodSetting !== null).assertTrue(); + console.info("====>************* inputmethod_test_MAX_TYPE_NUM_001 Test end*************"); + done(); + }); + + /* + * @tc.number inputmethod_test_switchInputMethod_001 + * @tc.name Test Indicates the input method which will replace the current one. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputmethod_test_switchInputMethod_001', 0, async function (done) { + console.info("====>************* inputmethod_test_switchInputMethod_001 Test start*************"); + let inputM = inputMethod.getCurrentInputMethod() + console.info("inputmethod_test_switchInputMethod_001 getCurrentInputMethod: " + JSON.stringify(inputM)); + let inputMethodProperty = { + packageName: inputM.packageName, + methodId: inputM.methodId, + name: inputM.packageName, + id: inputM.methodId, + extra: {} + } + inputMethod.switchInputMethod(inputMethodProperty).then(data => { + console.info("====>inputmethod_test_switchInputMethod_001 data:" + data) + expect(data == true).assertTrue(); + console.info("====>************* inputmethod_test_switchInputMethod_001 Test end*************"); + done(); + }).catch(err => { + console.info("====>inputmethod_test_switchInputMethod_001 err:" + err) + expect().assertFail(); + done(); + }); + }); + + /* + * @tc.number inputmethod_test_switchInputMethod_002 + * @tc.name Test Indicates the input method which will replace the current one. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputmethod_test_switchInputMethod_002', 0, async function (done) { + console.info("====>************* inputmethod_test_switchInputMethod_002 Test start*************"); + let inputM = inputMethod.getCurrentInputMethod() + console.info("inputmethod_test_switchInputMethod_002 getCurrentInputMethod: " + JSON.stringify(inputM)); + let inputMethodProperty = { + packageName: inputM.packageName, + methodId: inputM.methodId, + name: inputM.packageName, + id: inputM.methodId, + extra: {} + } + inputMethod.switchInputMethod(inputMethodProperty, (err, data) => { + try { + if (err) { + console.info("====>inputmethod_test_switchInputMethod_002 error:" + err); + expect().assertFail(); + done(); + } + console.info("====>inputmethod_test_switchInputMethod_002 data:" + data) + console.info("====>************* inputmethod_test_switchInputMethod_002 Test end*************"); + expect(data == true).assertTrue(); + done(); + } catch (err) { + console.info("====>inputmethod_test_switchInputMethod_002 catch error:" + err); + done(); + } + }); + }); + + /* + * @tc.number inputmethod_test_showSoftKeyboard_001 + * @tc.name Test Indicates the input method which will show softboard with calback. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputmethod_test_showSoftKeyboard_001', 0, async function (done) { + let inputMethodCtrl = inputMethod.getInputMethodController() + inputMethodCtrl.showSoftKeyboard((err) => { + try { + expect(err.code).assertEqual(12800003) + console.info("====>************* inputmethod_test_showSoftKeyboard_001 Test end*************"); + done(); + } catch (err) { + expect().assertFail() + done(); + } + }); + }); + + /* + * @tc.number inputmethod_test_showSoftKeyboard_002 + * @tc.name Test Indicates the input method which will show softboard with Promise. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputmethod_test_showSoftKeyboard_002', 0, async function (done) { + let inputMethodCtrl = inputMethod.getInputMethodController() + inputMethodCtrl.showSoftKeyboard().then(() => { + expect().assertFail() + done(); + }).catch((err) => { + console.info('====>showSoftKeyboard promise failed : ' + JSON.stringify(err)) + console.info('====>showSoftKeyboard typeof(err.code): ' + typeof(err.code)) + console.info('====>showSoftKeyboard typeof(err.code): ' + err.code) + expect(err.code).assertEqual(12800003) + console.info("====>************* inputmethod_test_showSoftKeyboard_002 Test end*************"); + done(); + }) + }); + + /* + * @tc.number inputmethod_test_hideSoftKeyboard_001 + * @tc.name Test Indicates the input method which will hide softboard with calback. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputmethod_test_hideSoftKeyboard_001', 0, async function (done) { + let inputMethodCtrl = inputMethod.getInputMethodController() + inputMethodCtrl.hideSoftKeyboard((err) => { + try { + console.info('====>hideSoftKeyboard callbacek failed : ' + JSON.stringify(err)) + expect(err.code).assertEqual(12800003) + console.info("====>************* inputmethod_test_hideSoftKeyboard_001 Test end*************"); + done(); + } catch (err) { + expect().assertFail(); + done(); + } + }) + }); + + /* + * @tc.number inputmethod_test_hideSoftKeyboard_002 + * @tc.name Test Indicates the input method which will hide softboard with Promise. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputmethod_test_hideSoftKeyboard_002', 0, async function (done) { + let inputMethodCtrl = inputMethod.getInputMethodController() + inputMethodCtrl.hideSoftKeyboard().then(() => { + expect().assertFail(); + done(); + }).catch((err) => { + console.info('====>hideSoftKeyboard promise failed : ' + JSON.stringify(err)) + expect(err.code).assertEqual(12800003); + console.info("====>************* inputmethod_test_hideSoftKeyboard_002 Test end*************"); + done(); + }) + }); + + /* + * @tc.number inputmethod_test_getCurrentInputMethod_001 + * @tc.name return The InputMethodProperty object of the current input method. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputmethod_test_getCurrentInputMethod_001', 0, async function (done) { + let currentIme = inputMethod.getCurrentInputMethod(); + console.info("====>inputmethod_test_getCurrentInputMethod_001 currentIme---" + JSON.stringify(currentIme)); + console.info(currentIme.packageName); + console.info(currentIme.methodId); + expect(currentIme.packageName !== null).assertTrue(); + expect(currentIme.methodId !== null).assertTrue(); + console.info("====>************* inputmethod_test_getCurrentInputMethod_001 Test end*************"); + done(); + }); + + /* + * @tc.number inputmethod_test_getInputMethods_001 + * @tc.name param enable : + * if true, collect enabled input methods. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputmethod_test_getInputMethods_001', 0, async function (done) { + let inputMethodSetting = inputMethod.getInputMethodSetting(); + console.info("====>inputmethod_test_getInputMethods_001 result:" + JSON.stringify(inputMethodSetting)); + inputMethodSetting.getInputMethods(true, (err, arr) => { + try { + if (err) { + console.error("inputmethod_test_getInputMethods_001 failed because: " + JSON.stringify(err)); + expect().assertFail(); + done(); + } + ; + console.info("====>inputmethod_test_getInputMethods_001 listInputMethod result---" + JSON.stringify(arr)); + expect(arr != null).assertTrue(); + console.info("====>************* inputmethod_test_getInputMethods_001 Test end*************"); + done(); + } catch (err) { + console.error("inputmethod_test_getInputMethods_001 catch error: " + err); + done(); + } + }); + }); + + /* + * @tc.number inputmethod_test_getInputMethods_002 + * @tc.name param enable : + * if false, collect disabled input methods. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputmethod_test_getInputMethods_002', 0, async function (done) { + let inputMethodSetting = inputMethod.getInputMethodSetting(); + console.info("====>inputmethod_test_getInputMethods_002 result:" + JSON.stringify(inputMethodSetting)); + inputMethodSetting.getInputMethods(false, (err, arr) => { + try { + if (err) { + console.error("inputmethod_test_getInputMethods_002 failed because: " + JSON.stringify(err)); + expect().assertFail(); + } + ; + console.info("====>inputmethod_test_getInputMethods_002 listInputMethod result---" + JSON.stringify(arr)); + expect(arr != null).assertTrue(); + done(); + } catch (err) { + console.error("inputmethod_test_getInputMethods_002 catch error: " + err); + done(); + } + }); + }); + }); +}; diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/resources/base/element/string.json b/inputmethod/InputMethodTest_ets/entry/src/main/resources/base/element/string.json new file mode 100644 index 000000000..9d5dbe2a5 --- /dev/null +++ b/inputmethod/InputMethodTest_ets/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + }, + { + "name":"string_hello", + "value":"Hello" + }, + { + "name":"string_world", + "value":"World" + }, + { + "name":"message_arrive", + "value":"We will arrive at %s." + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/resources/base/media/icon.png b/inputmethod/InputMethodTest_ets/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{Gm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-@efQAzEtk4)xHMi+hw@tXys^G=|9YP^ z;kB{ZQ-$(CKnWzDREfOym9*=Yhc=$*Jh*0G<&NuCzdrs@{o(2NESqQQ@7lh3nts#q z7kTw8)>|n)q6D)apZ!bzjyD8+;9Or)Yq~$b7E)t z@v0ri$jK`-kViD+(a;EwrZdkk9E;={W^a@jA*LF`XdcPtwNb<$pwP@sA06HJM7e42 zeJ^k8{>KOCO_l1iQy=~OEpa)%Z&&`8dq1w6`pSt1wZA)L-nJy(x$@|epTzg4c0B#6 z3v?WO=b^c^txpX;@xmihH*EiW<;s%J-&j9$<;A6U9juyh@!U(NANX4D+3E-M7;*Yu zj{F}S`(AMy(_vKMJisVH?Btzw%YQ3=y!6S7_2KT_M{75oeYWK2iPE!+gC#9P4W9Q_ zE}Ie_w10N|+~5swo;xuSiq(;EytKPs*z6jdqrdc2=bjhWtt)vUdh@BW?6hz0eb=#C z7&xC(J!0<7EHeK!YNcCaO~T6kpfJ+ zVianSV%QX6LqsgFEgEagKCs~Gs2b6!E0XV}G}9-KTYTo+`OQz}|3$Alwm~sa_E;;) zRuRE6{C#lUl}@fylYmgp%sajJ?oX<^?+jlY_u=5%r3!rMnW0OszBsM0PqVG1r~I?+ p%8KhRd{sPg%EY6{n}03%vb6iae~OaRw+goKO>2s&Ii!2T{{S(+Yoq`G literal 0 HcmV?d00001 diff --git a/request/BUILD.gn b/request/BUILD.gn new file mode 100644 index 000000000..49c17cc8d --- /dev/null +++ b/request/BUILD.gn @@ -0,0 +1,21 @@ +# 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("//build/ohos_var.gni") +group("request") { + testonly = true + deps = [ + "RequestTest_Stage:ActsRequestStageTest", + "RequestTest_ets:ActsRequestETSApiTest", + ] +} diff --git a/request/RequestTest_Stage/AppScope/app.json b/request/RequestTest_Stage/AppScope/app.json new file mode 100644 index 000000000..403c65552 --- /dev/null +++ b/request/RequestTest_Stage/AppScope/app.json @@ -0,0 +1,15 @@ +{ + "app": { + "bundleName": "com.acts.request.test", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "keepAlive":true, + "singleUser":true, + "minAPIVersion":9, + "targetAPIVersion":9 + } +} diff --git a/request/RequestTest_Stage/AppScope/resources/base/element/string.json b/request/RequestTest_Stage/AppScope/resources/base/element/string.json new file mode 100644 index 000000000..066e1ff18 --- /dev/null +++ b/request/RequestTest_Stage/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsTimeAPITest" + } + ] +} diff --git a/request/RequestTest_Stage/AppScope/resources/base/media/app_icon.png b/request/RequestTest_Stage/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch 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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QD4Kcm)`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 { + if (err.code) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/request/RequestTest_Stage/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/request/RequestTest_Stage/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..c085dc5e0 --- /dev/null +++ b/request/RequestTest_Stage/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a MainAbility ' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand("echo \"123456\" > /data/app/el2/100/base/com.acts.requesttest.test/haps/entry_test/cache/test.txt", + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/request/RequestTest_Stage/entry/src/main/ets/pages/index.ets b/request/RequestTest_Stage/entry/src/main/ets/pages/index.ets new file mode 100644 index 000000000..e79e73a09 --- /dev/null +++ b/request/RequestTest_Stage/entry/src/main/ets/pages/index.ets @@ -0,0 +1,38 @@ +/** + * 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 hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + + @State message: string = 'REQUEST TEST' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/request/RequestTest_Stage/entry/src/main/ets/test/List.test.ets b/request/RequestTest_Stage/entry/src/main/ets/test/List.test.ets new file mode 100644 index 000000000..c4e084fa5 --- /dev/null +++ b/request/RequestTest_Stage/entry/src/main/ets/test/List.test.ets @@ -0,0 +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. + */ + +import requestUploadJSUnit from './requestUpload.test'; +import requestDownloadJSUnit from './requestDownload.test'; + +export default function testsuite() { + requestDownloadJSUnit() + requestUploadJSUnit() +} \ No newline at end of file diff --git a/request/RequestTest_Stage/entry/src/main/ets/test/requestDownload.test.ets b/request/RequestTest_Stage/entry/src/main/ets/test/requestDownload.test.ets new file mode 100644 index 000000000..b50ebc73f --- /dev/null +++ b/request/RequestTest_Stage/entry/src/main/ets/test/requestDownload.test.ets @@ -0,0 +1,626 @@ +/* + * 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 request from "@ohos.request"; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function requestDownloadJSUnit() { + describe('requestDownloadJSUnit', function () { + console.info('====>################################request download Test start'); + + /** + * beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed. + */ + beforeAll(function () { + console.info('====>beforeAll: Prerequisites are executed.'); + }); + + /** + * beforeEach: Prerequisites at the test case level, which are executed before each test case is executed. + */ + beforeEach(function () { + console.info('====>beforeEach: Prerequisites is executed.'); + }); + + /** + * afterEach: Test case-level clearance conditions, which are executed after each test case is executed. + */ + afterEach(function () { + console.info('====>afterEach: Test case-level clearance conditions is executed.'); + }); + + /** + * afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed. + */ + afterAll(function () { + console.info('====>afterAll: Test suite-level cleanup condition is executed'); + }); + + let downloadTask; + + /** + * @tc.number SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 + * @tc.desc Starts a download session. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001', 0, async function (done) { + console.info("-----------------------SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 is starting-----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001.txt`) + let downloadFileConfig = { + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', + header: { + headers: 'http' + }, + enableMetered: false, + enableRoaming: false, + description: 'XTS download test!', + networkType: request.NETWORK_WIFI, + filePath: downloadFilePath, + title: 'XTS download test!', + background: false + } + request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 downloadTask: " + downloadTask); + try{ + expect(true).assertEqual(downloadTask != undefined); + await downloadTask.delete() + }catch(e){ + console.info("====>SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 except error: " + e); + } + console.info("-----------------------SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 end-----------------------"); + done(); + }); + }); + + /** + * @tc.number SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 + * @tc.desc Starts a download session. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001', 0, async function (done) { + console.info("-----------------------SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 is starting-----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001.txt`) + let downloadFileConfig = { + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', + header: { + headers: 'http' + }, + enableMetered: false, + enableRoaming: false, + description: 'XTS download test!', + networkType: request.NETWORK_WIFI, + filePath: downloadFilePath, + title: 'XTS download test!', + background: false + } + try{ + request.downloadFile(globalThis.abilityContext, downloadFileConfig).then(async (data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 downloadTask: " + downloadTask); + expect(true).assertEqual(downloadTask != undefined); + await downloadTask.delete() + done(); + }).catch(err => { + console.error("====>SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 error: " + err); + done(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 catch error: " + err); + done(); + } + + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DELETE_0001 + * @tc.desc Delete the download task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DELETE_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_delete_0001 is starting-----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_DELETE_0001.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_DELETE_0001.txt`) + let downloadFileConfig = { + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', + header: { + headers: 'http' + }, + enableMetered: false, + enableRoaming: false, + description: 'XTS download test!', + networkType: request.NETWORK_WIFI, + filePath: downloadFilePath, + title: 'XTS download test!', + background: false + } + request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 downloadTask: " + downloadTask); + try { + expect(downloadTask != undefined).assertEqual(true); + downloadTask.delete((err, data) => { + try{ + if (err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Failed to delete the download task.'); + expect().assertFail(); + } + console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Download task delete success.'); + expect(typeof data == "boolean").assertTrue(); + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 delete throw error' + err); + } + done(); + }); + } catch (error) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 delete catch error' + error); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DELETE_0002 + * @tc.desc Delete the download task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DELETE_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 is starting-----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_DELETE_0002.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_DELETE_0002.txt`) + let downloadFileConfig = { + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', + header: { + headers: 'http' + }, + enableMetered: false, + enableRoaming: false, + description: 'XTS download test!', + networkType: request.NETWORK_WIFI, + filePath: downloadFilePath, + title: 'XTS download test!', + background: false + } + request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 downloadTask: " + downloadTask); + try { + expect(downloadTask != undefined).assertEqual(true); + downloadTask.delete().then(data => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Download task delete success.'); + expect(data).assertEqual(true); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 end-----------------------"); + done(); + }).catch((err) => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Failed to delete the download task.'); + expect().assertFail(); + done(); + }) + } catch (error) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 delete catch error'); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 + * @tc.desc Suspend the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 is starting-----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001.txt`) + let downloadFileConfig = { + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', + header: { + headers: 'http' + }, + enableMetered: false, + enableRoaming: false, + description: 'XTS download test!', + networkType: request.NETWORK_WIFI, + filePath: downloadFilePath, + title: 'XTS download test!', + background: false + } + request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.suspend((err, data) => { + try{ + if (err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Failed to suspend the download task.'); + expect().assertFail(); + } + console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Download task suspend success.'); + expect(data == true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 throw_error: " + JSON.stringify(err)); + } + done(); + }); + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + JSON.stringify(err)); + done(); + } + }) + + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 + * @tc.desc Suspend the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 is starting-----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002.txt`) + let downloadFileConfig = { + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', + header: { + headers: 'http' + }, + enableMetered: false, + enableRoaming: false, + description: 'XTS download test!', + networkType: request.NETWORK_WIFI, + filePath: downloadFilePath, + title: 'XTS download test!', + background: false + } + request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.suspend().then(data => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 Download task suspend success.'); + expect(data == true).assertTrue(); + done(); + }).catch((err) => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 throw_err:' + JSON.stringify(err)); + done(); + }) + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 suspend catch error' + JSON.stringify(err)); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 + * @tc.desc Restore the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 is starting-----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_RESTORE_0001.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_RESTORE_0001.txt`) + let downloadFileConfig = { + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', + header: { + headers: 'http' + }, + enableMetered: false, + enableRoaming: false, + description: 'XTS download test!', + networkType: request.NETWORK_WIFI, + filePath: downloadFilePath, + title: 'XTS download test!', + background: false + } + request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.restore((err, data) => { + try{ + if (err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Failed to restore the download task.'); + expect().assertFail(); + } + console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Download restore success.'); + expect(data == true).assertTrue(); + }catch(err){ + console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 throw_err:' + JSON.stringify(err)); + } + done(); + }); + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + JSON.stringify(err)); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 + * @tc.desc Restore the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_RESTORE_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 is starting-----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_RESTORE_0002.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_RESTORE_0002.txt`) + let downloadFileConfig = { + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', + header: { + headers: 'http' + }, + enableMetered: false, + enableRoaming: false, + description: 'XTS download test!', + networkType: request.NETWORK_WIFI, + filePath: downloadFilePath, + title: 'XTS download test!', + background: false + } + request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.restore().then(data => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Download task restore.'); + expect(data == true).assertTrue(); + done(); + }).catch((err) => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Failed to restore the download task.'); + done(); + }); + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 restore catch error' +JSON.stringify(err)); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 + * @tc.desc Get the download task info + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001', 0, async function (done) { + console.info("====>---------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 is starting---------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001.txt`) + let downloadFileConfig = { + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', + header: { + headers: 'http' + }, + enableMetered: false, + enableRoaming: false, + description: 'XTS download test!', + networkType: request.NETWORK_WIFI, + filePath: downloadFilePath, + title: 'XTS download test!', + background: false + } + request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.getTaskInfo((err, data) => { + try{ + if (err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Failed to getTaskInfo the download task.'); + expect().assertFail(); + } + console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Download getTaskInfo success.'); + expect(typeof data == "object").assertTrue(); + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 throw_error' +JSON.stringify(err)); + } + done(); + }); + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + JSON.stringify(err)); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 + * @tc.desc Get the download task info + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002', 0, async function (done) { + console.info("====>-------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 is starting----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002.txt`) + let downloadFileConfig = { + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', + header: { + headers: 'http' + }, + enableMetered: false, + enableRoaming: false, + description: 'XTS download test!', + networkType: request.NETWORK_WIFI, + filePath: downloadFilePath, + title: 'XTS download test!', + background: false + } + request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.getTaskInfo().then(data => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Download task getTaskInfo success.'); + expect(typeof data == "object").assertTrue(); + done(); + }).catch((err) => { + console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Failed to getTaskInfo the download task.'); + done(); + }); + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 getTaskInfo catch error' + JSON.stringify(err)); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 + * @tc.desc Get mimetype of the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001', 0, async function (done) { + console.info("====>---------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 is starting---------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001.txt`) + let downloadFileConfig = { + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', + header: { + headers: 'http' + }, + enableMetered: false, + enableRoaming: false, + description: 'XTS download test!', + networkType: request.NETWORK_WIFI, + filePath: downloadFilePath, + title: 'XTS download test!', + background: false + } + request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('progress',(data1, data2) => { + try{ + if (data1 > 0){ + downloadTask.getTaskMimeType(async (err, data)=>{ + try{ + if(err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 err:'+ JSON.stringify(err)); + expect().assertFail(); + done(); + } + if (data) { + console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 data:' + JSON.stringify(data)); + expect(typeof data == "string").assertTrue(); + } else { + console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 error: " + JSON.stringify(err)); + expect().assertFail(); + } + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 throw_error: " + JSON.stringify(err)); + } + setTimeout(()=>{ + done(); + },1000) + }); + } + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 error: " + JSON.stringify(err)); + done(); + } + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 error: " + JSON.stringify(err)); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 + * @tc.desc Get mimetype of the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002', 0, async function (done) { + console.info("====>-------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 is starting----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002.txt`) + let downloadFileConfig = { + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', + header: { + headers: 'http' + }, + enableMetered: false, + enableRoaming: false, + description: 'XTS download test!', + networkType: request.NETWORK_WIFI, + filePath: downloadFilePath, + title: 'XTS download test!', + background: false + } + request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('progress', async (data1, data2) => { + try{ + if(data1 > 0){ + let data = await downloadTask.getTaskMimeType() + console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 data:' + JSON.stringify(data)); + expect(typeof data == "string").assertTrue(); + } + setTimeout(()=>{ + done(); + },1000) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 throw_error: " + JSON.stringify(err)); + done(); + } + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 error: " + JSON.stringify(err)); + done(); + } + }) + }); + }); +} \ No newline at end of file diff --git a/request/RequestTest_Stage/entry/src/main/ets/test/requestUpload.test.ets b/request/RequestTest_Stage/entry/src/main/ets/test/requestUpload.test.ets new file mode 100644 index 000000000..0ae3541cf --- /dev/null +++ b/request/RequestTest_Stage/entry/src/main/ets/test/requestUpload.test.ets @@ -0,0 +1,208 @@ +/* + * 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 request from "@ohos.request"; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function requestUploadJSUnit() { + describe('requestUploadJSUnit', function () { + console.info('====>################################request upload Test start'); + + /** + * beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed. + */ + beforeAll(function () { + console.info('====>beforeAll: Prerequisites are executed.'); + }); + + /** + * beforeEach: Prerequisites at the test case level, which are executed before each test case is executed. + */ + beforeEach(function () { + console.info('====>beforeEach: Prerequisites is executed.'); + }); + + /** + * afterEach: Test case-level clearance conditions, which are executed after each test case is executed. + */ + afterEach(function () { + console.info('====>afterEach: Test case-level clearance conditions is executed.'); + }); + + /** + * afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed. + */ + afterAll(function () { + console.info('====>afterAll: Test suite-level cleanup condition is executed'); + }); + + /** + * sleep function. + */ + function sleep(date, time){ + while(Date.now() - date <= time); + } + + let uploadTask; + let RequestData = { + name: 'name', + value: '123' + } + + let File = { + filename: 'test', + name: 'test', + uri: 'internal://cache/test.txt', + type: 'txt' + } + + let uploadConfig = { + url: 'http://127.0.0.1', + header: { + headers: 'http' + }, + method: 'POST', + files: [File], + data: [RequestData] + }; + + /** + * @tc.number SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 + * @tc.desc Starts a upload task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001', 0, async function (done) { + console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 is starting-----------------------"); + try { + request.uploadFile(globalThis.abilityContext, uploadConfig, (err, data)=>{ + uploadTask = data; + console.info("====>SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 uploadFile: " + uploadTask); + try{ + expect(true).assertEqual(uploadTask != undefined); + }catch(e){ + console.info("====>SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 except error: " + e); + } + }); + } catch (err) { + console.error("====>SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 error: " + err); + }; + setTimeout(()=>{ + console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 end-----------------------"); + done(); + }, 10000); + }); + + /** + * @tc.number SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 + * @tc.desc Starts a upload task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001', 0, async function (done) { + console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 is starting-----------------------"); + try{ + request.uploadFile(globalThis.abilityContext, uploadConfig).then(data => { + uploadTask = data; + console.info("====>SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 uploadFile: " + uploadTask); + try{ + expect(true).assertEqual(uploadTask != undefined); + }catch(e){ + console.info("====>SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 except error: " + e); + } + }).catch(err => { + console.error("====>SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 error: " + err); + expect().assertFail(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 catch error: " + err); + } + setTimeout(()=>{ + console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 end-----------------------"); + done(); + }, 10000); + }); + + /** + * @tc.number SUB_REQUEST_UPLOAD_API_DELETE_0001 + * @tc.desc Delete the upload task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_UPLOAD_API_DELETE_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 is starting-----------------------"); + request.uploadFile(globalThis.abilityContext, uploadConfig, (err, data) => { + try{ + uploadTask = data; + console.info("====>SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask: " + uploadTask); + expect(uploadTask != undefined).assertEqual(true); + uploadTask.delete((err, data) => { + try{ + if (err) { + console.error('====>SUB_REQUEST_UPLOAD_API_DELETE_0001 Failed to delete the uploadTask task.'); + expect().assertFail(); + done(); + } + console.info('====>SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask task delete success.'); + expect(typeof data == "boolean").assertTrue(); + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 end-----------------------"); + done(); + }catch(err){ + console.error('====>SUB_REQUEST_UPLOAD_API_DELETE_0001 delete error' + err); + done(); + } + }); + } catch (error) { + console.error('====>SUB_REQUEST_UPLOAD_API_DELETE_0001 delete catch error' + error); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_UPLOAD_API_DELETE_0002 + * @tc.desc Delete the upload task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_UPLOAD_API_DELETE_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 is starting-----------------------"); + request.uploadFile(globalThis.abilityContext, uploadConfig, (err, data) => { + uploadTask = data; + console.info("====>SUB_REQUEST_UPLOAD_API_DELETE_0002 uploadTask: " + uploadTask); + try{ + expect(uploadTask != undefined).assertEqual(true); + uploadTask.delete().then(data => { + console.info('====>SUB_REQUEST_UPLOAD_API_DELETE_0002 delete data:' + JSON.stringify(data)); + expect(data).assertEqual(true); + done(); + }).catch((err) => { + console.info('====>SUB_REQUEST_UPLOAD_API_DELETE_0002 Failed to delete the uploadTask task.'); + expect().assertFail(); + done(); + }) + }catch(err){ + console.error('====>SUB_REQUEST_UPLOAD_API_DELETE_0002 delete catch err'); + done(); + } + }) + }); + }) +} diff --git a/request/RequestTest_Stage/entry/src/main/module.json b/request/RequestTest_Stage/entry/src/main/module.json new file mode 100644 index 000000000..6a33270ff --- /dev/null +++ b/request/RequestTest_Stage/entry/src/main/module.json @@ -0,0 +1,69 @@ +{ + "module": { + "name": "entry_test", + "type": "entry", + "srcEntrance": "./ets/Application/MyAbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet", + "default", + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name":"ohos.permission.INTERNET", + "reason":"need use ohos.permission.INTERNET." + }, + {"name": "ohos.permission.WRITE_MEDIA", + "reason": "need use ohos.permission.WRITE_MEDIA", + "usedScene": { + "ability": [ + "com.acts.request.test.MainAbility" + ], + "when":"always" + } + }, + {"name": "ohos.permission.READ_MEDIA", + "reason": "need use ohos.permission.WRITE_MEDIA", + "usedScene": { + "ability": [ + "com.acts.request.test.MainAbility" + ], + "when":"always" + } + } + ] + } +} \ No newline at end of file diff --git a/request/RequestTest_Stage/entry/src/main/resources/base/element/color.json b/request/RequestTest_Stage/entry/src/main/resources/base/element/color.json new file mode 100644 index 000000000..62a137a61 --- /dev/null +++ b/request/RequestTest_Stage/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/request/RequestTest_Stage/entry/src/main/resources/base/element/string.json b/request/RequestTest_Stage/entry/src/main/resources/base/element/string.json new file mode 100644 index 000000000..03bb7d00f --- /dev/null +++ b/request/RequestTest_Stage/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "ActsTimeAPITest" + } + ] +} \ No newline at end of file diff --git a/request/RequestTest_Stage/entry/src/main/resources/base/media/icon.png b/request/RequestTest_Stage/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch 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|A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UtL9?&*fj4@Yc;w=p~9hJCnZKeIs|m zhv(M{es@T=ePN(x*~x{^1@=eU-~EdLR3E&se!8^$ozA_-HcZ&qc5~UXw3}yJvX|Xj zH1A+u=B?gSmsi~uR&KKba)>xRmLoraV~-WLAvX-qnE)s*@Lv2`;gVm|Hx})?RphMO zbyB+d%Hgz==hLq&u&0&vXe&Qows^d=Q}@le-p(-}_nsdG#p=W}er8uuaEqaHn()p$ zH66#-txG%RncY1$Hu3Ijm-H)xJ*&to0TaE_@qzfQ*%$JW7zc$Un*%>LfcvSmao|QB z{AJVX0^=Th*`)9g7`y*H!~qi@7%7R!NO&p23lT_x49MZ72xdKu@{t^V)}%%IFYN2; z{cPsA85b@P|Hz*6Dt2(#4Bm5&-|C$=X1-AihCR5+xqJ;!akF00eAY{jI$AV^@z}{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/request/RequestTest_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/request/RequestTest_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..c814bb927 --- /dev/null +++ b/request/RequestTest_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,84 @@ +// @ts-nocheck +/** + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + abilityDelegator.executeShellCommand("echo 123456 > /data/app/el2/100/base/com.acts.requesttest/haps/entry/cache/test.txt", + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/request/RequestTest_ets/entry/src/main/ets/test/List.test.ets b/request/RequestTest_ets/entry/src/main/ets/test/List.test.ets new file mode 100644 index 000000000..de2cdf52c --- /dev/null +++ b/request/RequestTest_ets/entry/src/main/ets/test/List.test.ets @@ -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. + */ + +import requestUploadJSUnit from './requestUpload.test'; +import requestDownloadJSUnit from './requestDownload.test'; +import requestSystemJSUnit from './requestSystem.test'; + +export default function testsuite() { + requestUploadJSUnit() + requestDownloadJSUnit() + requestSystemJSUnit() +} \ No newline at end of file diff --git a/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets b/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets new file mode 100644 index 000000000..eb1a01e8a --- /dev/null +++ b/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets @@ -0,0 +1,839 @@ +/* + * 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 request from "@ohos.request"; +import featureAbility from '@ohos.ability.featureAbility' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"; + +export default function requestDownloadJSUnit() { + describe('requestDownloadTest', function () { + console.info('====>################################request download Test start'); + + /** + * beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed. + */ + beforeAll(async function () { + console.info('====>beforeAll: Prerequisites are executed.'); + }); + + /** + * beforeEach: Prerequisites at the test case level, which are executed before each test case is executed. + */ + beforeEach(async function () { + console.info('====>beforeEach: Prerequisites is executed.'); + await setDownLoadConfig() + }); + + /** + * afterEach: Test case-level clearance conditions, which are executed after each test case is executed. + */ + afterEach(function () { + console.info('====>afterEach: Test case-level clearance conditions is executed.'); + }); + + /** + * afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed. + */ + afterAll(function () { + console.info('====>afterAll: Test suite-level cleanup condition is executed'); + }); + + let downloadTask; + let downloadConfig + async function setDownLoadConfig(){ + let downloadFilePath = await featureAbility.getContext().getFilesDir() + downloadConfig = { + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', + header: { + headers: 'http' + }, + enableMetered: false, + enableRoaming: false, + description: 'XTS download test!', + networkType: request.NETWORK_WIFI, + filePath: `${downloadFilePath}/`, + title: 'XTS download test!', + background: false + } + } + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 + * @tc.desc alled when the current download session is in process. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001.txt' + request.download(downloadConfig, (err, data)=>{ + try{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 downloadTask: " + JSON.stringify(downloadTask) ); + expect(true).assertEqual(downloadTask != undefined); + downloadTask.on('progress', (data1, data2) => { + try{ + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data1 =" + data1); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data2 =" + data2); + expect(true).assertEqual(data1 != undefined); + expect(true).assertEqual(data2 != undefined); + if (data1 == data2){ + done(); + } + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 throw_error: " + err); + done(); + } + }); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 error: " + err); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 + * @tc.desc Called when the current download session complete、pause or remove. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002.txt' + request.download(downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 downloadTask: " + downloadTask); + try{ + expect(true).assertEqual(downloadTask != undefined); + downloadTask.on('complete', async () => { + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 task completed.') + expect(true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 throw_error: " + err); + } + await downloadTask.remove() + done(); + }); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 error: " + err); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 + * @tc.desc Called when the current download session complete、pause or remove. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003.txt' + request.download(downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 downloadTask: " + downloadTask); + try{ + expect(true).assertEqual(downloadTask != undefined); + downloadTask.on('pause', async () => { + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 task completed.') + expect(true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 throw_error: " + err); + } + await downloadTask.remove() + done(); + }); + downloadTask.on('progress', (data1, data2) => { + if(data1 > 0){ + downloadTask.pause() + } + }); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 error: " + err); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 + * @tc.desc Called when the current download session complete、pause or remove. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004.txt' + request.download(downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('remove', () => { + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 remove completed') + expect(true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 throw_error: " + err); + } + done(); + }); + downloadTask.on('progress', (data1, data2) => { + if(data1 > 0){ + downloadTask.remove() + } + }); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 error: " + err); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 + * @tc.desc Called when the current download session fails. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005.txt' + downloadConfig.url += 'xxxxxxxxxx' + request.download(downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('fail', async()=>{ + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 fail completed') + expect(true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 throw_error: " + err); + } + await downloadTask.remove() + done(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 error: " + err); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 + * @tc.desc Called when the current download session fails. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006.txt' + request.download(downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('complete', async () => { + try{ + request.download(downloadConfig, (err, data)=>{ + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 second throw_error: " + err); + expect(err.code).assertEqual(13400002) + await downloadTask.remove() + done(); + } + }); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 error: " + err); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 + * @tc.desc alled when the current download session is in process. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001.txt' + request.download(downloadConfig, (err, data)=>{ + try{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 downloadTask: " + downloadTask); + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('progress', (data1, data2) => {}); + downloadTask.off('progress', async (data1, data2) => { + try{ + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 on data1 =" + data1); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 on data2 =" + data2); + expect(data1).assertEqual(0); + expect(data2).assertEqual(0); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 off_err: " + err); + } + await downloadTask.remove() + done(); + }); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 error: " + err); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 + * @tc.desc alled when the current download session complete、pause or remove. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002.txt' + request.download(downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.off('complete',async () => { + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 task complete.') + expect(true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 off_err: " + err); + } + await downloadTask.remove() + done(); + }); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 error: " + err); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 + * @tc.desc alled when the current download session complete、pause or remove. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003.txt' + request.download( downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.off('pause', async () => { + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 task complete.') + expect(true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 off_err: " + err); + } + await downloadTask.remove() + done(); + }); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 error: " + err); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 + * @tc.desc alled when the current download session complete、pause or remove. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004.txt' + request.download( downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.off('remove', async (data) => { + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 remove data:' +JSON.stringify(data)) + expect(true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 off_err: " + err); + } + await downloadTask.remove() + done(); + }); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 error: " + err); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 + * @tc.desc Called when the current download session fails. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005.txt' + request.download( downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('fail', (data) => {}); + downloadTask.off('fail', async (data) => { + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 fail_data:' + JSON.stringify(data)) + expect(data).assertEqual(0) + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 end-----------------------"); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 fail_error: " + err); + } + await downloadTask.remove() + done(); + }); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 error: " + err); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 + * @tc.desc Deletes a download session and the downloaded files. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_REMOVE_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMOVE_0001.txt' + request.download( downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.remove((err, data)=>{ + try{ + if(err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 Failed to remove the download task.'); + expect().assertFail(); + } + if (data) { + console.info('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 removed data:' + JSON.stringify(data)); + expect(data == true).assertTrue(); + } else { + console.error('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 Failed to remove the download task.'); + expect().assertFail(); + } + }catch(err){ + console.info('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 remove_throw_err:' + JSON.stringify(err)) + } + done(); + }); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 error: " + err); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 + * @tc.desc Deletes a download session and the downloaded files. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_REMOVE_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMOVE_0002.txt' + request.download( downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.remove().then(data => { + if (data) { + console.info('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 removed data:' + JSON.stringify(data)); + expect(data == true).assertTrue(); + } else { + console.error('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 Failed to remove the download task.'); + expect().assertFail(); + } + done(); + }).catch((err) => { + console.error('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 Failed to remove the download task.'); + done(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 error: " + err); + done(); + } + }) + + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 + * @tc.desc Pause a download session. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_PAUSE_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_PAUSE_0001.txt' + request.download( downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 downloadTask: " + downloadTask); + expect(downloadTask != undefined).assertEqual(true); + try{ + downloadTask.pause(async ()=>{ + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 Download task pause success.'); + expect(true).assertTrue(); + }catch(err){ + console.info('====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 pause_throw_err:' + JSON.stringify(err)) + } + await downloadTask.remove() + done(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 error: " + JSON.stringify(err)); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 + * @tc.desc Pause a download session. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_PAUSE_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_PAUSE_0002.txt' + request.download( downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.pause().then(async () => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 Download task pause success.'); + expect(true).assertTrue(); + await downloadTask.remove() + done(); + }).catch((err) => { + console.error("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 throw_error: " + JSON.stringify(err)); + done(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 error: " + JSON.stringify(err)); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 + * @tc.desc Resume a paused download session. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_REMUSE_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMUSE_0001.txt' + request.download( downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 downloadTask: " + downloadTask); + expect(downloadTask != undefined).assertEqual(true); + try{ + downloadTask.resume(async ()=>{ + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 Download task resume success.'); + expect(true).assertTrue(); + }catch(err){ + console.info('====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 pause_throw_err:' + JSON.stringify(err)) + } + await downloadTask.remove() + done(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 error: " + JSON.stringify(err)); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 + * @tc.desc Resume a paused download session. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_REMUSE_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMUSE_0002.txt' + request.download( downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.resume().then(async () => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 Download task resume success.'); + expect(true).assertTrue(); + await downloadTask.remove() + done() + }).catch((err) => { + console.error("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 throw_error: " + JSON.stringify(err)); + done(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 error: " + JSON.stringify(err)); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_QUERY_0001 + * @tc.desc Queries download information of a session, which is defined in DownloadSession.DownloadInfo. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_QUERY_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0001 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERY_0001.txt' + request.download( downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.query(async (err, downloadInfo)=>{ + try{ + if(err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 Failed to query: ' + JSON.stringify(err)); + expect().assertFail(); + } else { + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.description); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadedBytes); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadId); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.failedReason); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.fileName); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.filePath); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.pausedReason); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.status); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.targetURI); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTitle); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTotalBytes); + expect(true).assertTrue(); + } + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 throw_error: " + JSON.stringify(err)); + } + await downloadTask.remove() + done(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 error: " + JSON.stringify(err)); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_QUERY_0002 + * @tc.desc Queries download information of a session, which is defined in DownloadSession.DownloadInfo. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_QUERY_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0002 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERY_0002.txt' + request.download( downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.query().then(async (downloadInfo)=>{ + try{ + if(err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 Failed to query: ' + JSON.stringify(err)); + expect().assertFail(); + } else { + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.description); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.downloadedBytes); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.downloadId); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.failedReason); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.fileName); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.filePath); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.pausedReason); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.status); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.targetURI); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.downloadTitle); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.downloadTotalBytes); + expect(true).assertTrue(); + } + await downloadTask.remove() + done(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 error: " + JSON.stringify(err)); + done(); + } + }).catch((err)=>{ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 catch_error: " + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 error: " + JSON.stringify(err)); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 + * @tc.desc Queries the MIME type of the download file. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001', 0, async function (done) { + console.info("====>---------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 is starting---------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001.txt' + request.download( downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('progress', async (data1, data2)=>{ + try{ + if (data1 > 0 && downloadTask != null){ + downloadTask.queryMimeType((err, data) => { + try{ + if(err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 return_err:'+ JSON.stringify(err)); + expect().assertFail(); + done(); + } + if (data) { + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 data:' + JSON.stringify(data)); + expect(typeof data == "string").assertTrue(); + } else { + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 data_error: " + JSON.stringify(err)); + expect().assertFail(); + } + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 throw_error: " + JSON.stringify(err)); + } + }); + } + if (data1 == data2){ + downloadTask = null + await downloadTask.remove() + done(); + } + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 error: " + JSON.stringify(err)); + done(); + } + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 error: " + JSON.stringify(err)); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 + * @tc.desc Queries the MIME type of the download file. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002', 0, async function (done) { + console.info("====>-------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 is starting----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002.txt' + request.download( downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('progress', async (data1, data2) => { + try{ + if(data1 > 0 && downloadTask != null){ + let data = await downloadTask.queryMimeType() + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 Download task queryMimeType.'); + expect(typeof data == "string").assertTrue(); + } + if(data1 == data2){ + downloadTask = null + await downloadTask.remove() + done(); + } + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 throw_error: " + JSON.stringify(err)); + done(); + } + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 error: " + JSON.stringify(err)); + done(); + } + }) + }); + }) +} diff --git a/request/RequestTest_ets/entry/src/main/ets/test/requestSystem.test.ets b/request/RequestTest_ets/entry/src/main/ets/test/requestSystem.test.ets new file mode 100644 index 000000000..1c52426b5 --- /dev/null +++ b/request/RequestTest_ets/entry/src/main/ets/test/requestSystem.test.ets @@ -0,0 +1,146 @@ +/** + * 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 request from '@system.request'; +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"; + +export default function requestSystemJSUnit() { + describe('requestSystemJSUnit', function () { + console.info('====>****************start requestSystemTest*****************') + + /** + * @tc.name: ohos.SUB_REQUESTSYSTEM_UPLOAD_API_0001 + * @tc.desc: Upload files. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level: Level 1 + */ + it('SUB_REQUESTSYSTEM_UPLOAD_API_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUESTSYSTEM_UPLOAD_API_0001 start-----------------------"); + let UploadResponse = { + code: 200, + data: '', + headers: {RequestMethod: 'POST', + StatusCode: 200 } + } + let UploadRequestOptions = { + url: 'http://www.path.com', + method: 'POST', + files: [ + { + uri: 'internal://cache/path/to/file.txt', + name: 'file', + filename: 'file.txt', + }, + ], + data:[ + { + name: 'name1', + value: 'value', + }, + ], + success: function(UploadResponse) { + console.info('====>SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload success, code:' + UploadResponse.code); + }, + fail: function(data, code) { + console.info('====>SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload fail'); + }, + complete: function (){ + console.info('====>SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload complete'); + } + } + try{ + let result = request.upload(UploadRequestOptions); + console.info('====>SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload err:' + result); + expect(true).assertEqual(true); + }catch(err){ + console.info('====>SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload err:' + err); + } + console.info("====>-----------------------SUB_REQUESTSYSTEM_UPLOAD_API_0001 end-----------------------"); + done(); + }); + + /** + * @tc.name: ohos.SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 + * @tc.desc: This API is used to download files. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level: Level 1 + */ + it('SUB_REQUESTSYSTEM_DOWNLOAD_API_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 start-----------------------"); + let DownloadResponse = { + token: "Hm_lpvt_1d6c34c1bc067f5746a5fca18d1c24ab" + } + + let DownloadRequestOptions = { + url: 'http://www.path.com', + filename: 'requestSystenTest', + header: '', + description: 'this is requeSystem download response', + success: function(DownloadResponse) { + console.info('====>SUB_REQUESTSYSTEM_DOWNLOAD_API_0001call success callback success: ' + DownloadResponse.token); + }, + fail: function(data, code) { + console.info('====>SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 handling fail'); + }, + complete: function (){ + console.info('====>SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 download complete'); + } + } + try{ + let result = request.download(DownloadRequestOptions); + console.info('====>SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 upload err:' + result); + expect(result == null).assertEqual(true); + }catch(err){ + console.info('====>SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 download complete' + err); + } + console.info("====>-----------------------SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 end-----------------------"); + done(); + }); + + /** + * @tc.name: ohos.SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 + * @tc.desc: Listens to download task status. + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level: Level 1 + */ + it('SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 start-----------------------"); + let OnDownloadCompleteResponse = { + uri: "http://www.path.com" + } + let OnDownloadCompleteOptions = { + token: 'token-index', + success: function(OnDownloadCompleteResponse) { + console.info('====>SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 download success,uri:' + + OnDownloadCompleteResponse.uri); + }, + fail: function(data, code) { + console.info('====>SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 download fail'); + }, + complete: function (){ + console.info('====>SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 download complete'); + } + } + let result = request.onDownloadComplete(OnDownloadCompleteOptions); + console.info('====>SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 upload err:' + result); + expect(result == null).assertEqual(true); + console.info("====>-----------------------SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 end-----------------------"); + done(); + }); + }) +} diff --git a/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets b/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets new file mode 100644 index 000000000..2fe8649b7 --- /dev/null +++ b/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets @@ -0,0 +1,337 @@ +/* + * 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 request from "@ohos.request"; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"; + +export default function requestUploadJSUnit() { + describe('requestUploadTest', function () { + console.info('====>################################request upload Test start'); + + /** + * beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed. + */ + beforeAll(function () { + console.info('====>beforeAll: Prerequisites are executed.'); + }); + + /** + * beforeEach: Prerequisites at the test case level, which are executed before each test case is executed. + */ + beforeEach(function () { + console.info('====>beforeEach: Prerequisites is executed.'); + }); + + /** + * afterEach: Test case-level clearance conditions, which are executed after each test case is executed. + */ + afterEach(function () { + console.info('====>afterEach: Test case-level clearance conditions is executed.'); + }); + + /** + * afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed. + */ + afterAll(function () { + console.info('====>afterAll: Test suite-level cleanup condition is executed'); + }); + + /** + * sleep function. + */ + function sleep(date, time){ + while(Date.now() - date <= time); + } + + let uploadTask; + let RequestData = { + name: 'name', + value: '123' + } + + let File = { + filename: 'test', + name: 'test', + uri: 'internal://cache/test.txt', + type: 'txt' + } + + let uploadConfig = { + url: 'http://127.0.0.1', + header: { + headers: 'http' + }, + method: 'POST', + files: [File], + data: [RequestData] + }; + + /** + * @tc.number SUB_REQUEST_UPLOAD_API_0001 + * @tc.name Test requestUploadTest type = TIMER_TYPE_REALTIME + * @tc.desc Test requestUploadTest API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_REQUEST_UPLOAD_API_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0001 is starting-----------------------"); + try { + console.info("====>SUB_REQUEST_UPLOAD_API_0001 request.NETWORK_MOBILE:" + request.NETWORK_MOBILE); + expect(request.NETWORK_MOBILE).assertEqual(1); + console.info("====>SUB_REQUEST_UPLOAD_API_0001 request.NETWORK_WIFI:" + request.NETWORK_WIFI); + expect(request.NETWORK_WIFI).assertEqual(65536); + console.info("====>SUB_REQUEST_UPLOAD_API_0001 request.ERROR_CANNOT_RESUME:" + request.ERROR_CANNOT_RESUME); + expect(request.ERROR_CANNOT_RESUME).assertEqual(0); + console.info("====>SUB_REQUEST_UPLOAD_API_0001 request.ERROR_DEVICE_NOT_FOUND:" + request.ERROR_DEVICE_NOT_FOUND); + expect(request.ERROR_DEVICE_NOT_FOUND).assertEqual(1); + } catch (err) { + expect().assertFail(); + console.error("====>SUB_REQUEST_UPLOAD_API_0001 error: " + err); + } + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0001 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_UPLOAD_API_0002 + * @tc.name Test requestUploadTest type = TIMER_TYPE_REALTIME + * @tc.desc Test requestUploadTest API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_REQUEST_UPLOAD_API_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0002 is starting-----------------------"); + try { + console.info("====>SUB_REQUEST_UPLOAD_API_0002 request.ERROR_FILE_ALREADY_EXISTS:" + request.ERROR_FILE_ALREADY_EXISTS); + expect(request.ERROR_FILE_ALREADY_EXISTS).assertEqual(2); + console.info("====>SUB_REQUEST_UPLOAD_API_0002 request.ERROR_FILE_ERROR:" + request.ERROR_FILE_ERROR); + expect(request.ERROR_FILE_ERROR).assertEqual(3); + console.info("====>SUB_REQUEST_UPLOAD_API_0002 request.ERROR_HTTP_DATA_ERROR:" + request.ERROR_HTTP_DATA_ERROR); + expect(request.ERROR_HTTP_DATA_ERROR).assertEqual(4); + console.info("====>SUB_REQUEST_UPLOAD_API_0002 request.ERROR_INSUFFICIENT_SPACE:" + request.ERROR_INSUFFICIENT_SPACE); + expect(request.ERROR_INSUFFICIENT_SPACE).assertEqual(5); + } catch (err) { + expect().assertFail(); + console.error("====>SUB_REQUEST_UPLOAD_API_0002 error: " + err); + } + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0002 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_UPLOAD_API_0003 + * @tc.name Test requestUploadTest type = TIMER_TYPE_REALTIME + * @tc.desc Test requestUploadTest API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_REQUEST_UPLOAD_API_0003', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0003 is starting-----------------------"); + try { + console.info("====>SUB_REQUEST_UPLOAD_API_0003 request.ERROR_TOO_MANY_REDIRECTS:" + request.ERROR_TOO_MANY_REDIRECTS); + expect(request.ERROR_TOO_MANY_REDIRECTS).assertEqual(6); + console.info("====>SUB_REQUEST_UPLOAD_API_0003 request.ERROR_UNHANDLED_HTTP_CODE:" + request.ERROR_UNHANDLED_HTTP_CODE); + expect(request.ERROR_UNHANDLED_HTTP_CODE).assertEqual(7); + console.info("====>SUB_REQUEST_UPLOAD_API_0003 request.ERROR_UNKNOWN:" + request.ERROR_UNKNOWN); + expect(request.ERROR_UNKNOWN).assertEqual(8); + console.info("====>SUB_REQUEST_UPLOAD_API_0003 request.PAUSED_QUEUED_FOR_WIFI:" + request.PAUSED_QUEUED_FOR_WIFI); + expect(request.PAUSED_QUEUED_FOR_WIFI).assertEqual(0); + } catch (err) { + expect().assertFail(); + console.error("====>SUB_REQUEST_UPLOAD_API_0003 error: " + err); + } + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0003 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_UPLOAD_API_0004 + * @tc.name Test requestUploadTest type = TIMER_TYPE_REALTIME + * @tc.desc Test requestUploadTest API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_REQUEST_UPLOAD_API_0004', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0004 is starting-----------------------"); + try { + console.info("====>SUB_REQUEST_UPLOAD_API_0004 request.PAUSED_UNKNOWN:" + request.PAUSED_UNKNOWN); + expect(request.PAUSED_UNKNOWN).assertEqual(4); + console.info("====>SUB_REQUEST_UPLOAD_API_0004 request.PAUSED_WAITING_FOR_NETWORK:" + request.PAUSED_WAITING_FOR_NETWORK); + expect(request.PAUSED_WAITING_FOR_NETWORK).assertEqual(1); + console.info("====>SUB_REQUEST_UPLOAD_API_0004 request.PAUSED_WAITING_TO_RETRY:" + request.PAUSED_WAITING_TO_RETRY); + expect(request.PAUSED_WAITING_TO_RETRY).assertEqual(2); + console.info("====>SUB_REQUEST_UPLOAD_API_0004 request.PAUSED_BY_USER:" + request.PAUSED_BY_USER); + expect(request.PAUSED_BY_USER).assertEqual(3); + } catch (err) { + expect().assertFail(); + console.error("====>SUB_REQUEST_UPLOAD_API_0004 error: " + err); + } + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0004 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_UPLOAD_API_0005 + * @tc.name Test requestUploadTest type = TIMER_TYPE_REALTIME + * @tc.desc Test requestUploadTest API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_REQUEST_UPLOAD_API_0005', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0005 is starting-----------------------"); + try { + console.info("====>SUB_REQUEST_UPLOAD_API_0005 request.SESSION_FAILED:" + request.SESSION_FAILED); + expect(request.SESSION_FAILED).assertEqual(4); + console.info("====>SUB_REQUEST_UPLOAD_API_0005 request.SESSION_PAUSED:" + request.SESSION_PAUSED); + expect(request.SESSION_PAUSED).assertEqual(3); + console.info("====>SUB_REQUEST_UPLOAD_API_0005 request.SESSION_PENDING:" + request.SESSION_PENDING); + expect(request.SESSION_PENDING).assertEqual(2); + console.info("====>SUB_REQUEST_UPLOAD_API_0005 request.SESSION_RUNNING:" + request.SESSION_RUNNING); + expect(request.SESSION_RUNNING).assertEqual(1); + console.info("====>SUB_REQUEST_UPLOAD_API_0005 request.SESSION_SUCCESSFUL:" + request.SESSION_SUCCESSFUL); + expect(request.SESSION_SUCCESSFUL).assertEqual(0); + } catch (err) { + expect().assertFail(); + console.error("====>SUB_REQUEST_UPLOAD_API_0005 error: " + err); + } + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0005 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_UPLOAD_API_0006 + * @tc.name Test requestUploadTest type = TIMER_TYPE_REALTIME + * @tc.desc Test requestUploadTest API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_REQUEST_UPLOAD_API_0006', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0006 is starting-----------------------"); + try { + console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_PERMISSION:" + request.EXCEPTION_PERMISSION); + expect(request.EXCEPTION_PERMISSION).assertEqual(201); + console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_PARAMCHECK:" + request.EXCEPTION_PARAMCHECK); + expect(request.EXCEPTION_PARAMCHECK).assertEqual(401); + console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_UNSUPPORTED:" + request.EXCEPTION_UNSUPPORTED); + expect(request.EXCEPTION_UNSUPPORTED).assertEqual(801); + console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_FILEIO:" + request.EXCEPTION_FILEIO); + expect(request.EXCEPTION_FILEIO).assertEqual(13400001); + console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_FILEPATH:" + request.EXCEPTION_FILEPATH); + expect(request.EXCEPTION_FILEPATH).assertEqual(13400002); + console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_SERVICE:" + request.EXCEPTION_SERVICE); + expect(request.EXCEPTION_SERVICE).assertEqual(13400003); + console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_OTHERS:" + request.EXCEPTION_OTHERS); + expect(request.EXCEPTION_OTHERS).assertEqual(13499999); + console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.ERROR_OFFLINE:" + request.ERROR_OFFLINE); + expect(request.ERROR_OFFLINE).assertEqual(9); + console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.ERROR_UNSUPPORTED_NETWORK_TYPE:" + request.ERROR_UNSUPPORTED_NETWORK_TYPE); + expect(request.ERROR_UNSUPPORTED_NETWORK_TYPE).assertEqual(10); + } catch (err) { + expect().assertFail(); + console.error("====>SUB_REQUEST_UPLOAD_API_0006 error: " + err); + } + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0006 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_UPLOAD_API_CALLBACK_0001 + * @tc.name Test requestUploadTest type = TIMER_TYPE_REALTIME + * @tc.desc Test requestUploadTest API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_REQUEST_UPLOAD_API_CALLBACK_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_CALLBACK_0001 is starting-----------------------"); + try { + console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 uploadConfig = " + JSON.stringify(uploadConfig)); + request.upload(uploadConfig, (err, data) => { + uploadTask = data; + console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 progress uploadTask =" + JSON.stringify(uploadTask)); + expect(uploadTask != undefined).assertEqual(true); + + uploadTask.on('progress', function (data1, data2) { + console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 on data1 =" + data1); + console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 on data2 =" + data2); + }); + + uploadTask.off('progress', function (data1, data2) { + console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 off data1 =" + data1); + console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 off data2 =" + data2); + }); + + uploadTask.remove((err, data) => { + console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 remove =" + data); + }); + }); + } catch (err) { + console.error("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 error: " + err); + expect().assertFail(); + } + sleep(Date.now(), 20000); + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_CALLBACK_0001 end-----------------------"); + done(); + }); + + /** + * @tc.number : SUB_REQUEST_UPLOAD_API_PROMISE_0001 + * @tc.name : Use getEntries get the value by mixing the string key + * @tc.desc : Mixed strings value can be obtained correctly + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_REQUEST_UPLOAD_API_PROMISE_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0001 is starting-----------------------"); + try { + console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 UploadConfig = " + JSON.stringify(uploadConfig)); + request.upload(uploadConfig).then((data) => { + uploadTask = data; + console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 uploadTask = " + uploadTask); + expect(true).assertEqual((uploadTask != undefined) || (uploadTask != "") || (uploadTask != {})); + + uploadTask.on('headerReceive', (header) => { + console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 header = " + header); + expect(true).assertEqual((header != undefined) || (header != "") || (header != {})); + }); + + uploadTask.off('headerReceive', (header) => { + console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 header = " + header); + expect(true).assertEqual((header != undefined) || (header != "") || (header != {})); + }); + + uploadTask.remove().then((result)=>{ + console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 remove result = " + result); + expect(result).assertEqual(true); + }); + }); + } catch (e) { + console.error("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 error: " + JSON.stringify(e)); + expect(true).assertFail(true); + } + sleep(Date.now(), 20000); + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0001 end-----------------------"); + done(); + }); + }) +} diff --git a/request/RequestTest_ets/entry/src/main/resources/base/element/string.json b/request/RequestTest_ets/entry/src/main/resources/base/element/string.json new file mode 100644 index 000000000..498677efb --- /dev/null +++ b/request/RequestTest_ets/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/request/RequestTest_ets/entry/src/main/resources/base/media/icon.png b/request/RequestTest_ets/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch 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$u5H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@VEnt|f5Xh!F|Ln!$mS)tTV4lc zFUGb1X~3>VHaD(YdmF5rRk=KVVQcRBqSjOR@aA+LMT-DA+pKY%H$2Iu*Lg|%}Z{Iq{&PR7`%eb@iX5q*a z7v7Y8aG+%K+(_NRV{@O2>}hO$|4(L6yYKUr6V+Aw+ur+R&B(P|ZY^Axee2Asu?st2 znYphhuk-rx%S(ThTQ|7?*^8W>h>`yTV^1WvUMGyimj);?2w(hV>HOcbH(%M^In`Ic z{g`_Fm4n&GF63O9 zYR}6}iysVsc)7`xK)mh2l}H3eJrpw2p@ICN$RCJ64b&=)0 zt+UN1v(~#BvHV4E?d;qZIeiSh^Ti2|@$jG`(C^_%E|%(nPCPd44{e?A^gZ(R_T3-c zbD^Vl?++aMW_RAYejndBlY3?_Hh4MjvVB7S-eLMqXxWhsmv4EVt7-i+eyw12+PRCS LIUNh4=41Z@NK9-D literal 0 HcmV?d00001 diff --git a/theme/BUILD.gn b/theme/BUILD.gn new file mode 100644 index 000000000..163c39526 --- /dev/null +++ b/theme/BUILD.gn @@ -0,0 +1,21 @@ +# 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("//build/ohos_var.gni") +group("theme") { + testonly = true + deps = [ + "screenlock_ets:ActsScreenLockETSApiTest", + "wallpaper_ets:ActsWallpaperETSApiTest", + ] +} diff --git a/theme/screenlock_ets/BUILD.gn b/theme/screenlock_ets/BUILD.gn new file mode 100644 index 000000000..715afe2f9 --- /dev/null +++ b/theme/screenlock_ets/BUILD.gn @@ -0,0 +1,39 @@ +# 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("//build/ohos.gni") +import("//test/xts/tools/build/suite.gni") +ohos_js_hap_suite("ActsScreenLockETSApiTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":screenLock_ets_assets", + ":screenLock_ets_resources", + ":screenLock_ets_test_assets", + ] + ets2abc = true + subsystem_name = "theme" + part_name = "screenlock_mgr" + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsScreenLockETSApiTest" +} + +ohos_js_assets("screenLock_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_js_assets("screenLock_ets_resources") { + source_dir = "./entry/src/main/ets/TestAbility" +} +ohos_resources("screenLock_ets_test_assets") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/theme/screenlock_ets/Test.json b/theme/screenlock_ets/Test.json new file mode 100644 index 000000000..406968a98 --- /dev/null +++ b/theme/screenlock_ets/Test.json @@ -0,0 +1,19 @@ +{ + "description": "Configuration for screenlock js api Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.acts.theme.screenlocktest", + "package-name": "com.acts.theme.screenlocktest", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsScreenLockETSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/theme/screenlock_ets/entry/src/main/config.json b/theme/screenlock_ets/entry/src/main/config.json new file mode 100644 index 000000000..bd5497a32 --- /dev/null +++ b/theme/screenlock_ets/entry/src/main/config.json @@ -0,0 +1,101 @@ +{ + "app": { + "bundleName": "com.acts.theme.screenlocktest", + "vendor": "open", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.acts.theme.screenlocktest", + "name": ".MyApplication", + "mainAbility": "com.acts.theme.screenlocktest.MainAbility", + + "deviceType": [ + "tablet", + "default", + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "orientation": "unspecified", + "visible": true, + "srcPath": "TestAbility", + "name": ".TestAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "formsEnabled": false, + "label": "$string:TestAbility_label", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/theme/screenlock_ets/entry/src/main/ets/MainAbility/app.ets b/theme/screenlock_ets/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 000000000..2e4e48f73 --- /dev/null +++ b/theme/screenlock_ets/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,33 @@ +// @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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from 'hypium/index' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/theme/screenlock_ets/entry/src/main/ets/MainAbility/pages/index.ets b/theme/screenlock_ets/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 000000000..eb4afee1d --- /dev/null +++ b/theme/screenlock_ets/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,38 @@ +// @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. + */ + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + } + + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('SCREENLOCK ETS TEST') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/theme/screenlock_ets/entry/src/main/ets/TestAbility/app.ets b/theme/screenlock_ets/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 000000000..2e4e48f73 --- /dev/null +++ b/theme/screenlock_ets/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,33 @@ +// @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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from 'hypium/index' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/theme/screenlock_ets/entry/src/main/ets/TestAbility/pages/index.ets b/theme/screenlock_ets/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 000000000..b2497c3b2 --- /dev/null +++ b/theme/screenlock_ets/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,50 @@ +// @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 router from '@system.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/theme/screenlock_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/theme/screenlock_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..07cb0b784 --- /dev/null +++ b/theme/screenlock_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +// @ts-nocheck +/** + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/theme/screenlock_ets/entry/src/main/ets/test/List.test.ets b/theme/screenlock_ets/entry/src/main/ets/test/List.test.ets new file mode 100644 index 000000000..fd10a4e7c --- /dev/null +++ b/theme/screenlock_ets/entry/src/main/ets/test/List.test.ets @@ -0,0 +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. + */ + +import screenLockJSUnit from './screenLockTest'; +import ScreenLockPromiseTest from './screenLockPromiseTest'; + +export default function testsuite() { + screenLockJSUnit(); + ScreenLockPromiseTest() +} \ No newline at end of file diff --git a/theme/screenlock_ets/entry/src/main/ets/test/screenLockPromiseTest.ets b/theme/screenlock_ets/entry/src/main/ets/test/screenLockPromiseTest.ets new file mode 100644 index 000000000..ad6c49af3 --- /dev/null +++ b/theme/screenlock_ets/entry/src/main/ets/test/screenLockPromiseTest.ets @@ -0,0 +1,135 @@ +// @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 screenLock from '@ohos.screenLock'; +import { describe, expect, it, beforeEach} from "hypium/index"; + +const SLEEP_TIME = 1000; + +export default function ScreenLockPromiseTest(){ + describe('ScreenLockServicePromiseTest', function () { + console.info("-----------------------ScreenlockPromiseTest is starting-----------------------"); + + let result = false + beforeEach(async function (done) { + result = await screenLock.isScreenLocked(); + done(); + }); + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_Promise_001 + * @tc.name Set to locked screen, query the lock screen state is locked state + * @tc.desc Test ScreenLock API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MISC_THEME_screenLock_API_Promise_001", 0, async function (done) { + console.info("------------------start SUB_MISC_THEME_screenLock_API_Promise_001-------------------"); + try { + screenLock.isScreenLocked().then((data) => { + console.info("SUB_MISC_THEME_screenLock_API_Promise_001 isScreenLocked result is " + data); + expect(data == result).assertTrue() + console.info("------------------end SUB_MISC_THEME_screenLock_API_Promise_001-------------------"); + done(); + }) + } catch (error) { + console.info("SUB_MISC_THEME_screenLock_API_Promise_001 test_setScreenLocked : error = " + error); + expect().assertFail(); + done(); + } + + }); + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_Promise_002 + * @tc.name Set to locked screen, query the lock screen state is locked state + * @tc.desc Test ScreenLock API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MISC_THEME_screenLock_API_Promise_002", 0, async function (done) { + console.info("------------------start SUB_MISC_THEME_screenLock_API_Promise_002-------------------"); + try { + screenLock.isScreenLocked().then((data) => { + console.info("SUB_MISC_THEME_screenLock_API_Promise_002 isScreenLocked result is " + data); + expect(data == result).assertTrue(); + console.info("------------------end SUB_MISC_THEME_screenLock_API_Promise_002-------------------"); + done(); + }); + } catch (error) { + console.info("SUB_MISC_THEME_screenLock_API_Promise_002 test_setScreenLocked : error = " + error); + expect().assertFail(); + done(); + } + + }); + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_Promise_003 + * @tc.name Set to locked screen, query the lock screen state is locked state + * @tc.desc Test ScreenLock API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MISC_THEME_screenLock_API_Promise_003", 0, async function (done) { + console.info("------------------start SUB_MISC_THEME_screenLock_API_Promise_003-------------------"); + try { + screenLock.isSecureMode().then((data) => { + console.info("SUB_MISC_THEME_screenLock_API_Promise_003 isScreenLocked result is " + data); + expect(data == false).assertTrue(); + console.info("------------------end SUB_MISC_THEME_screenLock_API_Promise_003-------------------"); + done(); + }); + } catch (error) { + console.info("SUB_MISC_THEME_screenLock_API_Promise_003 isScreenLocked TRUE: error = " + error); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_Promise_004 + * @tc.name Set to locked screen, query the lock screen state is locked state + * @tc.desc Test ScreenLock API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MISC_THEME_screenLock_API_Promise_004", 0, async function (done) { + console.info("------------------start SUB_MISC_THEME_screenLock_API_Promise_004-------------------"); + try { + screenLock.unlockScreen().then((data) => { + let currentResult = screenLock.isLocked() + expect(currentResult).assertEqual(false) + console.info("====>SUB_MISC_THEME_screenLock_API_Promise_004 success."); + console.info('====>-------------SUB_MISC_THEME_screenLock_API_Promise_004 end----------------------'); + done(); + }).catch( err => { + console.info("====>SUB_MISC_THEME_screenLock_API_Promise_004 failed because: " + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + } catch (error) { + console.info("====>SUB_MISC_THEME_screenLock_API_Promise_004: error = " + error); + expect(true).assertTrue(); + } + console.info("------------------end SUB_MISC_THEME_screenLock_API_Promise_004-------------------"); + done(); + }); + }) +} diff --git a/theme/screenlock_ets/entry/src/main/ets/test/screenLockTest.ets b/theme/screenlock_ets/entry/src/main/ets/test/screenLockTest.ets new file mode 100644 index 000000000..c4f6a9db7 --- /dev/null +++ b/theme/screenlock_ets/entry/src/main/ets/test/screenLockTest.ets @@ -0,0 +1,306 @@ +/* + * 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 screenLock from '@ohos.screenLock'; +import { describe, expect, it, beforeEach} from "hypium/index"; + +export default function screenLockJSUnit() { + const INTERACTIVE_STATE_END_SLEEP = 0; + const INTERACTIVE_STATE_USERID = 2; + const INTERACTIVE_STATE_BEGIN_SLEEP = 3; + + describe('ScreenLockServiceTest', function () { + console.info("====>-----------------------ScreenlockTest is starting-----------------------"); + + let result = false + beforeEach(async function (done) { + result = await screenLock.isScreenLocked(); + done(); + }); + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_0012 + * @tc.name Test unlock() to Unlocks the screen. + * @tc.desc Function test + * @tc.level 0 + */ + it('SUB_MISC_THEME_screenLock_API_0012', 0, async function (done) { + console.info('====>-------------SUB_MISC_THEME_screenLock_API_0012 start----------------------'); + try{ + screenLock.unlock((err, data) => { + try{ + if (err) { + console.info("====>SUB_MISC_THEME_screenLock_API_0012 failed because: " + JSON.stringify(err)); + expect().assertFail(); + done(); + } + let currentResult = screenLock.isLocked() + expect(currentResult).assertEqual(false) + console.info("====>SUB_MISC_THEME_screenLock_API_0012 success."); + console.info('====>-------------SUB_MISC_THEME_screenLock_API_0012 end----------------------'); + done(); + }catch(err){ + console.info('====>SUB_MISC_THEME_screenLock_API_0012 throw_err : ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + }catch(err){ + console.info('====>SUB_MISC_THEME_screenLock_API_0012 catch err : ' + JSON.stringify(err)); + expect(err.code).assertEqual(201); + done(); + } + }) + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_0013 + * @tc.name Test unlock() to Unlocks the screen. + * @tc.desc Function test + * @tc.level 0 + */ + it('SUB_MISC_THEME_screenLock_API_0013', 0, async function (done) { + console.info('====>-------------SUB_MISC_THEME_screenLock_API_0013 start----------------------'); + try{ + screenLock.unlock().then((data) => { + let currentResult = screenLock.isLocked() + expect(currentResult).assertEqual(false) + console.info("====>SUB_MISC_THEME_screenLock_API_0013 success."); + console.info('====>-------------SUB_MISC_THEME_screenLock_API_0013 end----------------------'); + done(); + }).catch( err => { + console.info("====>SUB_MISC_THEME_screenLock_API_0013 failed because: " + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + }catch(err){ + console.info('====>SUB_MISC_THEME_screenLock_API_0013 catch err : ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_0001 + * @tc.name Set to locked screen, query the lock screen state is locked state + * @tc.desc Test ScreenLock API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MISC_THEME_screenLock_API_0001", 0, async function (done) { + console.info("====>------------------start SUB_MISC_THEME_screenLock_API_0001-------------------"); + try { + screenLock.isScreenLocked((err, data) => { + try{ + if(err){ + console.info("====>SUB_MISC_THEME_screenLock_API_0001 failed because: " + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info("====>SUB_MISC_THEME_screenLock_API_0001 screen's status is " + data); + expect(data == result).assertTrue(); + console.info("====>------------------end SUB_MISC_THEME_screenLock_API_0001-------------------"); + done(); + + }catch(err){ + console.info("====>logMessage SUB_MISC_THEME_screenLock_API_0001 throw_err = " + err); + expect().assertFail(); + done(); + } + }); + } catch (err) { + console.info("====>logMessage SUB_MISC_THEME_screenLock_API_0001: err = " + err); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_0002 + * @tc.name Set to locked screen, query the lock screen state is locked state + * @tc.desc Test ScreenLock API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MISC_THEME_screenLock_API_0002", 0, async function (done) { + console.info("====>------------------start SUB_MISC_THEME_screenLock_API_0002-------------------"); + try { + screenLock.isScreenLocked((err, data) => { + try{ + console.info("====>SUB_MISC_THEME_screenLock_API_0002 screen's status is " + data); + expect(data == result).assertTrue(); + console.info("====>------------------end SUB_MISC_THEME_screenLock_API_0002-------------------"); + done(); + }catch(err){ + console.info("====>logMessage SUB_MISC_THEME_screenLock_API_0002 throw_err = " + err); + expect().assertFail(); + done(); + } + }); + } catch (err) { + console.info("====>logMessage SUB_MISC_THEME_screenLock_API_0002: err = " + err); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_0003 + * @tc.name Set to locked screen, query the lock screen state is locked state + * @tc.desc Test ScreenLock API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MISC_THEME_screenLock_API_0003", 0, async function (done) { + console.info("====>------------------start SUB_MISC_THEME_screenLock_API_0003-------------------"); + try { + screenLock.isSecureMode((err, data) => { + try{ + console.info("====>SUB_MISC_THEME_screenLock_API_0003 secureMode's result is " + data); + expect(data == result).assertTrue(); + console.info("====>------------------end SUB_MISC_THEME_screenLock_API_0003-------------------"); + done(); + }catch(err){ + console.info("====>logMessage SUB_MISC_THEME_screenLock_API_0003 throw_err = " + err); + expect().assertFail(); + done(); + } + }); + } catch (err) { + console.info("====>logMessage SUB_MISC_THEME_screenLock_API_0003: err = " + err); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_0004 + * @tc.name Set to locked screen, query the lock screen state is locked state + * @tc.desc Test ScreenLock API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MISC_THEME_screenLock_API_0004", 0, async function (done) { + console.info("------------------start SUB_MISC_THEME_screenLock_API_0004-------------------"); + try { + screenLock.unlockScreen((err) => { + console.info("SUB_MISC_THEME_screenLock_API_0004: send unlockScreen issue success"); + try{ + if (err) { + console.info("====>SUB_MISC_THEME_screenLock_API_0004 failed because: " + JSON.stringify(err)); + expect().assertFail(); + done(); + } + let currentResult = screenLock.isLocked() + expect(currentResult).assertEqual(false) + console.info("====>SUB_MISC_THEME_screenLock_API_0004 success."); + console.info('====>-------------SUB_MISC_THEME_screenLock_API_0004 end----------------------'); + done(); + }catch(err){ + console.info('====>SUB_MISC_THEME_screenLock_API_0004 throw_err : ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + }); + } catch (error) { + console.info("SUB_MISC_THEME_screenLock_API_0004: error = " + error); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_0007 + * @tc.name Set to locked screen, query the lock screen state is locked state + * @tc.desc Test ScreenLock API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MISC_THEME_screenLock_API_0007", 0, async function (done) { + console.info("====>------------------start SUB_MISC_THEME_screenLock_API_0007-------------------"); + try { + screenLock.isScreenLocked((err, data) => { + try{ + console.info("====>SUB_MISC_THEME_screenLock_API_0007: isScreenLocked is successful, result is " + data); + expect(data == result).assertTrue(); + console.info("====>------------------end SUB_MISC_THEME_screenLock_API_0007-------------------"); + done(); + }catch(err){ + console.info("====>logMessage SUB_MISC_THEME_screenLock_API_0007 throw_err = " + err); + expect().assertFail(); + done(); + } + }); + } catch (err) { + console.info("====>logMessage SUB_MISC_THEME_screenLock_API_0007: err = " + err); + expect().assertFail(); + done(); + } + + }); + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_0010 + * @tc.name Test isLocked() to Checks whether the screen is currently locked. + * @tc.desc Function test + * @tc.level 0 + */ + it('SUB_MISC_THEME_screenLock_API_0010', 0, async function (done) { + console.info('====>-------------SUB_MISC_THEME_screenLock_API_0010 start----------------------'); + let lock = null; + try{ + lock = await screenLock.isLocked() + console.info('====>SUB_MISC_THEME_screenLock_API_0010 data : ' + JSON.stringify(lock)); + expect(lock).assertEqual(result); + console.info('====>-------------SUB_MISC_THEME_screenLock_API_0010 end----------------------'); + done() + }catch(err){ + console.info('====>SUB_MISC_THEME_screenLock_API_0010 err : ' + JSON.stringify(err)); + expect().assertFail(); + done() + } + }); + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_0011 + * @tc.name Test isSecure() to Checks whether the screen lock of the current device is secure. + * @tc.desc Function test + * @tc.level 0 + */ + it('SUB_MISC_THEME_screenLock_API_0011', 0, async function (done) { + console.info('====>-------------SUB_MISC_THEME_screenLock_API_0011 start----------------------'); + let secured = null; + try{ + secured = screenLock.isSecure() + console.info('====>SUB_MISC_THEME_screenLock_API_0011 data : ' + JSON.stringify(secured)); + if (typeof secured == "boolean") { + expect(true).assertTrue(); + console.info('====>-------------SUB_MISC_THEME_screenLock_API_0011 end----------------------'); + done() + }else{ + expect().assertFail(); + done() + } + }catch(err){ + console.info('====>SUB_MISC_THEME_screenLock_API_0011 err : ' + JSON.stringify(err)); + expect().assertFail(); + done() + } + }); + }); +} diff --git a/theme/screenlock_ets/entry/src/main/resources/base/element/string.json b/theme/screenlock_ets/entry/src/main/resources/base/element/string.json new file mode 100644 index 000000000..498677efb --- /dev/null +++ b/theme/screenlock_ets/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/theme/screenlock_ets/entry/src/main/resources/base/media/icon.png b/theme/screenlock_ets/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch 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=obwdg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)d)>J8Tdyx!l6C!b z>*OUjpPPFif6~qF6PH&0AgkK!1XMq9dMHQ!4~{)l-1?m`B5xX?g&=tT*Q&*T8!jKoI(|0$@&b33xyw-X*^)(Ly&cA{&vbW;{HXivFep~Xo?!W%CE<-^ z$5h#^gEhO}U9%?Z?ZB)HqY~q9zj)EKBHXo-x*W1|D?INNy*lfY0wf_oA<3SC*9zc& zEN$#PQTyIt+I?Wmy&FuX2!XMm?mYr9{+^MUjtqr|B0LZgH9QuJ<;q$x^L|u}NX0qJ zzaGIlj#Q1?IOi`%cTX5UFSq;U!EN2~gLAGA-=#Wwy9ErqcajUmdVmXaX3PifbBx6K z={vLLhi82;YROwV*US&V-PdzDZsnfZABB_CIy<_8Ip=C-e?MXOs%7I3&AuyITT0F* O_s$;pBflpz9{V4>DrPYN literal 0 HcmV?d00001 diff --git a/theme/wallpaper_ets/BUILD.gn b/theme/wallpaper_ets/BUILD.gn new file mode 100644 index 000000000..46487916a --- /dev/null +++ b/theme/wallpaper_ets/BUILD.gn @@ -0,0 +1,39 @@ +# 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("//build/ohos.gni") +import("//test/xts/tools/build/suite.gni") +ohos_js_hap_suite("ActsWallpaperETSApiTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":wallPaper_ets_assets", + ":wallPaper_ets_resources", + ":wallPaper_ets_test_assets", + ] + ets2abc = true + subsystem_name = "theme" + part_name = "wallpaper_mgr" + certificate_profile = "./signature/ActsWallpaperEtsAPITest.p7b" + hap_name = "ActsWallpaperETSApiTest" +} + +ohos_js_assets("wallPaper_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_js_assets("wallPaper_ets_resources") { + source_dir = "./entry/src/main/ets/TestAbility" +} +ohos_resources("wallPaper_ets_test_assets") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/theme/wallpaper_ets/Test.json b/theme/wallpaper_ets/Test.json new file mode 100644 index 000000000..87fa69645 --- /dev/null +++ b/theme/wallpaper_ets/Test.json @@ -0,0 +1,29 @@ +{ + "description": "Configuration for wallpaper js api Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.acts.theme.wallpapertest", + "package-name": "com.acts.theme.wallpapertest", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsWallpaperETSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "PushKit", + "pre-push": [ + "mount -o rw,remount /", + "mkdir -p /data/app/el2/100/base/com.acts.theme.wallpapertest/haps" + ], + "push": [ + "./resource/wallpaper/wp.png ->/data/app/el2/100/base/com.acts.theme.wallpapertest/haps/wp.png" + ] + } + ] +} diff --git a/theme/wallpaper_ets/entry/src/main/config.json b/theme/wallpaper_ets/entry/src/main/config.json new file mode 100644 index 000000000..632ef1bab --- /dev/null +++ b/theme/wallpaper_ets/entry/src/main/config.json @@ -0,0 +1,125 @@ +{ + "app": { + "bundleName": "com.acts.theme.wallpapertest", + "vendor": "open", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.acts.theme.wallpapertest", + "name": ".MyApplication", + "mainAbility": "com.acts.theme.wallpapertest.MainAbility", + + "deviceType": [ + "tablet", + "default", + "phone", + "tv", + "wearable" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "orientation": "unspecified", + "visible": true, + "srcPath": "TestAbility", + "name": ".TestAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "formsEnabled": false, + "label": "$string:TestAbility_label", + "type": "page", + "launchType": "standard" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.SET_WALLPAPER", + "reason": "need use ohos.permission.SET_WALLPAPER", + "usedScene": { + "ability": [ + "com.acts.theme.wallpapertest.MainAbility" + ], + "when": "inuse" + } + }, + { + "name": "ohos.permission.GET_WALLPAPER", + "reason": "need use ohos.permission.GET_WALLPAPER", + "usedScene": { + "ability": [ + "com.acts.theme.wallpapertest.MainAbility" + ], + "when": "inuse" + } + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/theme/wallpaper_ets/entry/src/main/ets/MainAbility/app.ets b/theme/wallpaper_ets/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 000000000..2e4e48f73 --- /dev/null +++ b/theme/wallpaper_ets/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,33 @@ +// @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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from 'hypium/index' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/theme/wallpaper_ets/entry/src/main/ets/MainAbility/pages/index.ets b/theme/wallpaper_ets/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 000000000..f76e64e54 --- /dev/null +++ b/theme/wallpaper_ets/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,38 @@ +// @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. + */ + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + } + + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('WALLPAPER ETS TEST') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/theme/wallpaper_ets/entry/src/main/ets/TestAbility/app.ets b/theme/wallpaper_ets/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 000000000..2e4e48f73 --- /dev/null +++ b/theme/wallpaper_ets/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,33 @@ +// @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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from 'hypium/index' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/theme/wallpaper_ets/entry/src/main/ets/TestAbility/pages/index.ets b/theme/wallpaper_ets/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 000000000..b2497c3b2 --- /dev/null +++ b/theme/wallpaper_ets/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,50 @@ +// @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 router from '@system.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/theme/wallpaper_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/theme/wallpaper_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..07cb0b784 --- /dev/null +++ b/theme/wallpaper_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +// @ts-nocheck +/** + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/theme/wallpaper_ets/entry/src/main/ets/test/List.test.ets b/theme/wallpaper_ets/entry/src/main/ets/test/List.test.ets new file mode 100644 index 000000000..11551f27a --- /dev/null +++ b/theme/wallpaper_ets/entry/src/main/ets/test/List.test.ets @@ -0,0 +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. + */ + +import wallpaperJSUnit from './wallpaperTest'; + +export default function testsuite() { + wallpaperJSUnit(); +} \ No newline at end of file diff --git a/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets b/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets new file mode 100644 index 000000000..d01fd887c --- /dev/null +++ b/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets @@ -0,0 +1,1200 @@ +/* + * 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 wallpaper from '@ohos.wallpaper'; +import image from '@ohos.multimedia.image'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; + +const WALLPAPER_SYSTEM = 0; +const WALLPAPER_LOCKSCREEN = 1; +let imageSourceSystem = '/data/storage/el2/base/haps/wp.png'; +let imageSourceLockscreen = '/data/storage/el2/base/haps/wp.png'; + +export default function wallpaperJSUnit() { + describe('WallpaperJsunitTest', function () { + + /* + * @tc.number testWALLPAPER_SYSTEM + * @tc.name Test WALLPAPER_SYSTEM value + * @tc.desc Function test + * @tc.level 0 + */ + it('testWALLPAPER_SYSTEM', 0, async function (done) { + console.info('--------------testWALLPAPER_SYSTEM start-----------------'); + console.info('wallpaperXTS ===> testWALLPAPER_SYSTEM : ' + + JSON.stringify(wallpaper.WallpaperType.WALLPAPER_SYSTEM)); + expect(wallpaper.WallpaperType.WALLPAPER_SYSTEM == 0).assertTrue(); + done(); + console.info('--------------testWALLPAPER_SYSTEM end-----------------'); + }); + + /* + * @tc.number testWALLPAPER_LOCKSCREEN + * @tc.name Test WALLPAPER_LOCKSCREEN value + * @tc.desc Function test + * @tc.level 0 + */ + it('testWALLPAPER_LOCKSCREEN', 0, async function (done) { + console.info('--------------testWALLPAPER_LOCKSCREEN start-----------------'); + console.info('wallpaperXTS ===> testWALLPAPER_LOCKSCREEN : ' + + JSON.stringify(wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN)); + expect(wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN == 1).assertTrue(); + done(); + console.info('--------------testWALLPAPER_LOCKSCREEN end-----------------'); + }); + + /* + * @tc.number testGetColorsCallbackSystem101 + * @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetColorsCallbackSystem101', 0, async function (done) { + console.info('--------------testGetColorsCallbackSystem101 start-----------------'); + wallpaper.getColors(WALLPAPER_SYSTEM, (err, RgbaColors) => { + let RgbaColor = { + red: 152, + green: 182, + blue: 211, + alpha: 255 + } + try { + if (err) { + console.info('====>testGetColorsCallbackSystem101 fail: ' + JSON.stringify(err)); + expect(null).assertFail(); + done(); + } + console.info('====>testGetColorsCallbackSystem101 succesful RgbaColors: ' + JSON.stringify(RgbaColors)); + expect(Number.isInteger(RgbaColors[0].red)).assertTrue(); + expect(Number.isInteger(RgbaColors[0].green)).assertTrue(); + expect(Number.isInteger(RgbaColors[0].blue)).assertTrue(); + expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue(); + done(); + } catch (err) { + console.info('====>testGetColorsCallbackSystem101 catch err: ' + JSON.stringify(err)); + done(); + }; + }); + console.info('--------------testGetColorsCallbackSystem101 end-----------------'); + }); + + /* + * @tc.number testGetColorsPromiseSystem101 + * @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetColorsPromiseSystem101', 0, async function (done) { + console.info('--------------testGetColorsPromiseSystem101 start-----------------'); + await wallpaper.getColors(WALLPAPER_SYSTEM).then((RgbaColors) => { + console.info('====>testGetColorsPromiseSystem101 succesful RgbaColors: ' + JSON.stringify(RgbaColors)); + expect(Number.isInteger(RgbaColors[0].red)).assertTrue(); + expect(Number.isInteger(RgbaColors[0].green)).assertTrue(); + expect(Number.isInteger(RgbaColors[0].blue)).assertTrue(); + expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue(); + done(); + }).catch((err) => { + console.info('====>testGetColorsPromiseSystem101 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info('--------------testGetColorsPromiseSystem101 end-----------------'); + }); + + /* + * @tc.number testGetColorsCallbackLock102 + * @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetColorsCallbackLock102', 0, async function (done) { + console.info('--------------testGetColorsCallbackLock102 start-----------------'); + wallpaper.getColors(WALLPAPER_LOCKSCREEN, (err, RgbaColors) => { + try { + if (err) { + console.info('====>testGetColorsCallbackLock102 fail: ' + JSON.stringify(err)); + expect(null).assertFail(); + done(); + } + console.info('====>testGetColorsCallbackLock102 succesful RgbaColors: ' + JSON.stringify(RgbaColors)); + expect(Number.isInteger(RgbaColors[0].red)).assertTrue(); + expect(Number.isInteger(RgbaColors[0].green)).assertTrue(); + expect(Number.isInteger(RgbaColors[0].blue)).assertTrue(); + expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue(); + done(); + } catch (err) { + console.info('====>testGetColorsCallbackLock102 catch err: ' + JSON.stringify(err)); + done(); + }; + }); + console.info('--------------testGetColorsCallbackLock102 end-----------------'); + }); + + /* + * @tc.number testGetColorsPromiseLock102 + * @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetColorsPromiseLock102', 0, async function (done) { + console.info('--------------testGetColorsPromiseLock102 start-----------------'); + await wallpaper.getColors(WALLPAPER_LOCKSCREEN).then((RgbaColors) => { + console.info('====>testGetColorsPromiseLock102 succesful RgbaColors: ' + JSON.stringify(RgbaColors)); + expect(Number.isInteger(RgbaColors[0].red)).assertTrue(); + expect(Number.isInteger(RgbaColors[0].green)).assertTrue(); + expect(Number.isInteger(RgbaColors[0].blue)).assertTrue(); + expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue(); + done(); + }).catch((err) => { + console.info('====>testGetColorsPromiseLock102 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info('--------------testGetColorsPromiseLock102 end-----------------'); + }) + + /* + * @tc.number testGetIdCallbackSystem101 + * @tc.name Test getId() to the ID of the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetIdCallbackSystem101', 0, async function (done) { + console.info('--------------testGetIdCallbackSystem101 start-----------------'); + wallpaper.getId(WALLPAPER_SYSTEM, (err, data) => { + try { + if (err) { + console.info('====>testGetIdCallbackSystem101 err : ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info('====>testGetIdCallbackSystem101 successful data: ' + JSON.stringify(data)); + expect(Number.isInteger(data)).assertTrue(); + done(); + } catch (err) { + console.info('====>testGetIdCallbackSystem101 catch err : ' + JSON.stringify(err)); + done(); + } + }); + console.info('--------------testGetIdCallbackSystem101 end-----------------'); + }); + + /* + * @tc.number testGetIdPromiseSystem101 + * @tc.name Test getId() to the ID of the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetIdPromiseSystem101', 0, async function (done) { + console.info('--------------testGetIdCallbackSystem101 start-----------------'); + await wallpaper.getId(WALLPAPER_SYSTEM).then((data) => { + console.info('====>testGetIdCallbackSystem101 data : ' + JSON.stringify(data)); + expect(Number.isInteger(data)).assertTrue(); + done(); + }).catch((err) => { + console.info('====>testGetIdCallbackSystem101 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info('--------------testGetIdCallbackSystem101 end-----------------'); + }) + + /* + * @tc.number testGetIdCallbackLock102 + * @tc.name Test getId() to the ID of the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetIdCallbackLock102', 0, async function (done) { + console.info('--------------testGetIdCallbackLock102 start-----------------'); + wallpaper.getId(WALLPAPER_LOCKSCREEN, (err, data) => { + try { + if (err) { + console.info('====>testGetIdCallbackLock102 err : ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info('====>testGetIdCallbackLock102 successful data: ' + JSON.stringify(data)); + expect(Number.isInteger(data)).assertTrue(); + done(); + } catch (err) { + console.info('====>testGetIdCallbackLock102 catch err : ' + JSON.stringify(err)); + done(); + } + }); + console.info('--------------testGetIdCallbackLock102 end-----------------'); + }); + + /* + * @tc.number testGetIdPromiseLock102 + * @tc.name Test getId() to the ID of the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetIdPromiseLock102', 0, async function (done) { + console.info('--------------testGetIdPromiseLock102 start-----------------'); + await wallpaper.getId(WALLPAPER_LOCKSCREEN).then((data) => { + console.info('====>testGetIdPromiseLock102 data : ' + JSON.stringify(data)); + expect(Number.isInteger(data)).assertTrue(); + done(); + }).catch((err) => { + console.info('====>testGetIdPromiseLock102 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info('--------------testGetIdPromiseLock102 end-----------------'); + }); + + + + /* + * @tc.number testGetMinHeightCallback101 + * @tc.name Test getMinHeight() to the minimum width of the wallpaper. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetMinHeightCallback101', 0, async function (done) { + console.info('--------------testGetMinHeightCallback101 start-----------------'); + wallpaper.getMinHeight((err, data) => { + try { + if (err) { + console.info('====>testGetMinHeightCallback101 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info('====>testGetMinHeightCallback101 successful data: ' + JSON.stringify(data)); + expect(Number.isInteger(data)).assertTrue(); + done(); + } catch (err) { + console.info('====>testGetMinHeightCallback101 catch err : ' + JSON.stringify(err)); + done(); + } + }); + console.info('--------------testGetMinHeightCallback101 end-----------------'); + }); + + /* + * @tc.number testGetMinHeightPromise101 + * @tc.name Test getMinHeight() to the minimum width of the wallpaper. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetMinHeightPromise101', 0, async function (done) { + console.info('--------------testGetMinHeightPromise101 start-----------------'); + await wallpaper.getMinHeight().then((data) => { + console.info('====>testGetMinHeightPromise101 successful data : ' + JSON.stringify(data)); + expect(Number.isInteger(data)).assertTrue(); + done(); + }).catch((err) => { + console.info('====>testGetMinHeightPromise101 err : ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info('--------------testGetMinHeightPromise101 end-----------------'); + }); + + /* + * @tc.number testGetMinWidthCallback101 + * @tc.name Test getMinHeight() to the minimum width of the wallpaper. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetMinWidthCallback101', 0, async function (done) { + console.info('--------------testGetMinWidthCallback101 start-----------------'); + wallpaper.getMinWidth((err, data) => { + try { + if (err) { + console.info('====>testGetMinWidthCallback101 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info('====>testGetMinWidthCallback101 successful data: ' + JSON.stringify(data)); + expect(Number.isInteger(data)).assertTrue(); + done(); + } catch (err) { + console.info('====>testGetMinWidthCallback101 catch err : ' + JSON.stringify(err)); + done(); + } + }); + console.info('--------------testGetMinWidthCallback101 end-----------------'); + }); + + /* + * @tc.number testGetMinWidthPromise101 + * @tc.name Test getMinHeight() to the minimum width of the wallpaper. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetMinWidthPromise101', 0, async function (done) { + console.info('--------------testGetMinWidthPromise101 start-----------------'); + await wallpaper.getMinWidth().then((data) => { + console.info('====>testGetMinWidthPromise101 successful data : ' + JSON.stringify(data)); + expect(Number.isInteger(data)).assertTrue(); + done(); + }).catch((err) => { + console.info('====>testGetMinWidthPromise101 err : ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info('--------------testGetMinWidthPromise101 end-----------------'); + }); + + /* + * @tc.number testIsChangePermittedCallback101 + * @tc.name Test isChangePermitted() to checks whether to allow the application to change the + wallpaper for the current user. + * @tc.desc Function test + * @tc.level 0 + */ + it('testIsChangePermittedCallback101', 0, async function (done) { + console.info('--------------testIsChangePermittedCallback101 start-----------------'); + wallpaper.isChangePermitted((err, data) => { + try { + if (err) { + console.info('====>testIsChangePermittedCallback101 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info('====>testIsChangePermittedCallback101 successful data: ' + JSON.stringify(data)); + expect(typeof data == "boolean").assertTrue(); + done(); + } catch (err) { + console.info('====>testIsChangePermittedCallback101 catch err : ' + JSON.stringify(err)); + done(); + } + }) + console.info('--------------testIsChangePermittedCallback101 end-----------------'); + }); + + /* + * @tc.number testIsChangePermittedPromise101 + * @tc.name Test isChangePermitted() to checks whether to allow the application to change the + wallpaper for the current user. + * @tc.desc Function test + * @tc.level 0 + */ + it('testIsChangePermittedPromise101', 0, async function (done) { + console.info('--------------testIsChangePermittedPromise101 start-----------------'); + await wallpaper.isChangePermitted().then((data) => { + console.info('====>testIsChangePermittedPromise101 successful data : ' + JSON.stringify(data)); + expect(typeof data == "boolean").assertTrue(); + done(); + }).catch((err) => { + console.info('====>testIsChangePermittedPromise101 err : ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info('--------------testIsChangePermittedPromise101 end-----------------'); + }); + + /* + * @tc.number testIsOperationAllowedCallback101 + * @tc.name Test isOperationAllowed() to checks whether a user is allowed to set wallpapers. + * @tc.desc Function test + * @tc.level 0 + */ + it('testIsOperationAllowedCallback101', 0, async function (done) { + console.info('--------------testIsOperationAllowedCallback101 start-----------------'); + wallpaper.isOperationAllowed((err, data) => { + try { + if (err) { + console.info('====>testIsOperationAllowedCallback101 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info('====>testIsOperationAllowedCallback101 successful data: ' + JSON.stringify(data)); + expect(typeof data == "boolean").assertTrue(); + done(); + } catch (err) { + console.info('====>testIsOperationAllowedCallback101 catch err : ' + JSON.stringify(err)); + done(); + } + }) + console.info('--------------testIsOperationAllowedCallback101 end-----------------'); + }); + + /* + * @tc.number testIsOperationAllowedPromise101 + * @tc.name Test isOperationAllowed() to checks whether a user is allowed to set wallpapers. + * @tc.desc Function test + * @tc.level 0 + */ + it('testIsOperationAllowedPromise101', 0, async function (done) { + console.info('--------------testIsOperationAllowedPromise101 start-----------------'); + await wallpaper.isOperationAllowed().then((data) => { + console.info('====>testIsOperationAllowedPromise101 successful data : ' + JSON.stringify(data)); + expect(typeof data == "boolean").assertTrue(); + done(); + }).catch((err) => { + console.info('====>testIsOperationAllowedPromise101 err : ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info('--------------testIsOperationAllowedPromise101 end-----------------'); + }); + + /* + * @tc.number testResetCallbackSystem101 + * @tc.name Test reset() to removes a wallpaper of the specified type and restores the default one. + * @tc.desc Function test + * @tc.level 0 + */ + it('testResetCallbackSystem101', 0, async function (done) { + console.info('--------------testResetCallbackSystem101 start-----------------'); + wallpaper.reset(WALLPAPER_SYSTEM, (err, data) => { + try { + if (err) { + console.info('====>testResetCallbackSystem101 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info('====>testResetCallbackSystem101 successful data: ' + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + } catch (err) { + console.info('====>testResetCallbackSystem101 catch err : ' + JSON.stringify(err)); + done(); + } + }) + console.info('--------------testResetCallbackSystem101 end-----------------'); + }); + + /* + * @tc.number testResetPromiseSystem101 + * @tc.name Test reset() to removes a wallpaper of the specified type and restores the default one. + * @tc.desc Function test + * @tc.level 0 + */ + it('testResetPromiseSystem101', 0, async function (done) { + console.info('--------------testResetPromiseSystem101 start-----------------'); + await wallpaper.reset(WALLPAPER_SYSTEM).then((data) => { + console.info('====>testResetPromiseSystem101 successful data : ' + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + }).catch((err) => { + console.info('====>testResetPromiseSystem101 err : ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info('--------------testResetPromiseSystem101 end-----------------'); + }); + + /* + * @tc.number testResetCallbackLock102 + * @tc.name Test reset() to removes a wallpaper of the specified type and restores the default one. + * @tc.desc Function test + * @tc.level 0 + */ + it('testResetCallbackLock102', 0, async function (done) { + console.info('--------------testResetCallbackLock102 start-----------------'); + wallpaper.reset(WALLPAPER_LOCKSCREEN, (err, data) => { + try { + if (err) { + console.info('====>testResetCallbackLock102 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info('====>testResetCallbackLock102 successful data: ' + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + } catch (err) { + console.info('====>testResetCallbackLock102 catch err : ' + JSON.stringify(err)); + done(); + } + }) + console.info('--------------testResetCallbackLock102 end-----------------'); + }); + + /* + * @tc.number testResetPromiseLock102 + * @tc.name Test reset() to removes a wallpaper of the specified type and restores the default one. + * @tc.desc Function test + * @tc.level 0 + */ + it('testResetPromiseLock102', 0, async function (done) { + console.info('--------------testResetPromiseLock102 start-----------------'); + await wallpaper.reset(WALLPAPER_LOCKSCREEN).then((data) => { + console.info('====>testResetPromiseLock102 successful data : ' + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + }).catch((err) => { + console.info('====>testResetPromiseLock102 err : ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info('--------------testResetPromiseLock102 end-----------------'); + }); + + /* + * @tc.number testSetWallpaperURLPromiseLock104 + * @tc.name Test setPixelMap() to sets a wallpaper of the specified type based on the uri path from a + JPEG or PNG file or the pixel map of a PNG file. + * @tc.desc Function test + * @tc.level 0 + */ + it('testSetWallpaperURLPromiseLock104', 0, async function (done) { + console.info('--------------------testSetWallpaperURLPromiseLock104 start------------------' ); + await wallpaper.setWallpaper(imageSourceLockscreen, WALLPAPER_LOCKSCREEN).then((data) => { + console.info('====>testSetWallpaperURLPromiseLock104 successful data : ' + data); + expect(true).assertTrue(); + done(); + }).catch((err) => { + console.info('====>testSetWallpaperURLPromiseLock104 fail: ' + err); + expect().assertFail(); + done(); + }); + console.info('--------------------testSetWallpaperURLPromiseLock104 end------------------' ); + }); + + /* + * @tc.number testSetWallpaperURLCallbackSystem103 + * @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a + JPEG or PNG file or the pixel map of a PNG file. + * @tc.desc Function test + * @tc.level 0 + */ + it('testSetWallpaperURLCallbackSystem103', 0, async function (done) { + console.info('--------------------testSetWallpaperURLCallbackSystem103 start------------------' ); + wallpaper.setWallpaper(imageSourceSystem, WALLPAPER_SYSTEM, (err, data) => { + try{ + if (err) { + console.info('====->testSetWallpaperURLCallbackSystem103 err : ' + err); + expect().assertFail(); + done(); + } + console.info('====>testSetWallpaperURLCallbackSystem103 successful data: ' + data); + expect(true).assertTrue(); + done(); + }catch(error){ + console.info('testSetWallpaperURLCallbackSystem103 catch error: ' + error); + done(); + } + }); + console.info('--------------------testSetWallpaperURLCallbackSystem103 end------------------' ); + }); + + /* + * @tc.number testSetWallpaperURLPromiseSystem103 + * @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a + JPEG or PNG file or the pixel map of a PNG file. + * @tc.desc Function test + * @tc.level 0 + */ + it('testSetWallpaperURLPromiseSystem103', 0, async function (done) { + console.info('--------------------testSetWallpaperURLPromiseSystem103 start------------------' ); + await wallpaper.setWallpaper(imageSourceLockscreen, WALLPAPER_LOCKSCREEN).then((data) => { + console.info('====>testSetWallpaperURLPromiseSystem103 successful data : ' + data); + expect(true).assertTrue(); + done(); + }).catch((err) => { + console.info('====>testSetWallpaperURLPromiseSystem103 fail: ' + err); + expect().assertFail(); + done(); + }); + console.info('--------------------testSetWallpaperURLPromiseSystem103 end------------------' ); + }); + + /* + * @tc.number testSetWallpaperURLCallbackLock104 + * @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a + JPEG or PNG file or the pixel map of a PNG file. + * @tc.desc Function test + * @tc.level 0 + */ + it('testSetWallpaperURLCallbackLock104', 0, async function (done) { + console.info('--------------------testSetWallpaperURLCallbackLock104 start------------------' ); + wallpaper.setWallpaper(imageSourceSystem, WALLPAPER_LOCKSCREEN, (err, data) => { + try{ + if (err) { + console.info('====->testSetWallpaperURLCallbackLock104 err : ' + err); + expect().assertFail(); + done(); + } + console.info('====>testSetWallpaperURLCallbackLock104 successful data: ' + data); + expect(true).assertTrue(); + done(); + }catch(error){ + console.info('testSetWallpaperURLCallbackLock104 catch error: ' + error); + done(); + } + }); + console.info('--------------------testSetWallpaperURLCallbackLock104 end------------------' ); + }); + + /* + * @tc.number testOnCallback101 + * @tc.name Test on_colorChange to registers a listener for wallpaper color changes to + receive notifications about the changes. + * @tc.desc Function test + * @tc.level 0 + */ + it('testOnCallback101', 0, async function (done) { + console.info('--------------testOnCallback101 start-----------------'); + let wallpaperPath = "/data/storage/el2/base/haps/wp.png"; + await wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN) + try { + wallpaper.on('colorChange', async (colors, wallpaperType) => { + try { + console.info('====>testOnCallback101 colors: ' + JSON.stringify(colors)); + console.info('====>testOnCallback101 wallpaperType: ' + JSON.stringify(wallpaperType)); + expect(colors != null).assertTrue(); + expect(wallpaperType != null).assertTrue(); + wallpaper.off('colorChange') + console.info('====>testOnCallback101 off'); + done(); + } catch (err) { + console.info('====>testOnCallback101 setImage or other err : ' + JSON.stringify(err)); + done(); + } + }); + } catch (err) { + console.info('====>testOnCallback101 catch err : ' + JSON.stringify(err)); + done(); + } + await wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN) + console.info('====>testOnCallback10 setImage successful'); + console.info('--------------testOnCallback101 end-----------------'); + }); + + /* + * @tc.number testOffCallback101 + * @tc.name Test on_colorChange to registers a listener for wallpaper color changes to + receive notifications about the changes. + * @tc.desc Function test + * @tc.level 0 + */ + it('testOffCallback101', 0, async function (done) { + console.info('--------------testOffCallback101 start-----------------'); + let wallpaperPath = "/data/storage/el2/base/haps/wp.png"; + let callbackTimes = 0; + await wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM) + try { + wallpaper.on('colorChange', async (colors, wallpaperType) => { + try { + console.info('====>testOffCallback101 colors: ' + JSON.stringify(colors)); + console.info('====>testOffCallback101 wallpaperType: ' + JSON.stringify(wallpaperType)); + callbackTimes = callbackTimes + 1; + console.info('====>testOffCallback101 on callbackTime: ' + callbackTimes); + expect(callbackTimes == 1).assertTrue(); + wallpaper.off('colorChange'); + setTimeout(() => { + done(); + }, 3000) + } catch (err) { + console.info('====>testOffCallback101 setImage or other err : ' + JSON.stringify(err)); + done(); + } + }); + } catch (err) { + console.info('====>testOffCallback101 catch err : ' + JSON.stringify(err)); + done(); + } + await wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM) + await wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM) + await wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM) + console.info('====>testOffCallback101 setImage successful'); + console.info('--------------testOffCallback101 end-----------------'); + }); + + /* + * @tc.number testGetFileCallback101 + * @tc.name Obtains a file of the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetFileCallback101', 0, async function (done) { + console.info('--------------testGetFileCallback101 start-----------------'); + wallpaper.getFile(WALLPAPER_SYSTEM, (err, data) => { + try { + if (err) { + console.info('====>testGetFileCallback101 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info('====>testGetFileCallback101 successful data: ' + JSON.stringify(data)); + expect(Number.isInteger(data)).assertTrue(); + done(); + } catch (err) { + console.info('====>testGetFileCallback101 catch err : ' + JSON.stringify(err)); + done(); + } + }); + console.info('--------------testGetFileCallback101 end-----------------'); + }); + + /* + * @tc.number testGetFilePromise101 + * @tc.name Obtains a file of the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetFilePromise101', 0, async function (done) { + console.info('--------------testGetFilePromise101 start-----------------'); + await wallpaper.getFile(WALLPAPER_LOCKSCREEN).then((data) => { + console.info('====>testGetFilePromise101 successful data : ' + JSON.stringify(data)); + expect(Number.isInteger(data)).assertTrue(); + done(); + }).catch((err) => { + console.info('====>testGetFilePromise101 err : ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info('--------------testGetFilePromise101 end-----------------'); + }); + + /* + * @tc.number testGetColorsSync101 + * @tc.name Test getColorsSync() to obtains the wallpaper colors for the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetColorsSync101', 0, async function (done) { + console.info('------------------testGetColorsSync101 start----------------------'); + let colors = null; + try{ + colors = wallpaper.getColorsSync(WALLPAPER_SYSTEM) + console.info('wallpaperXTS ===> testGetColorsSync101 data : ' + JSON.stringify(colors)); + if (colors.length >= 1) { + expect(true).assertTrue(); + done() + }else{ + expect().assertFail(); + done() + } + }catch(err){ + console.info('wallpaperXTS ===> testGetColorsSync101 err : ' + JSON.stringify(err)); + expect().assertFail(); + done() + } + console.info('------------------testGetColorsSync101 end----------------------'); + done() + }) + + /* + * @tc.number testGetColorsSync102 + * @tc.name Test getColorsSync() to obtains the wallpaper colors for the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetColorsSync102', 0, async function (done) { + console.info('------------------testGetColorsSync102 start----------------------'); + let colors = null; + try{ + colors = wallpaper.getColorsSync(WALLPAPER_LOCKSCREEN) + console.info('====>testGetColorsSync102 data : ' + JSON.stringify(colors)); + if (colors.length >= 1) { + expect(true).assertTrue(); + done() + }else{ + expect().assertFail(); + done() + } + }catch(err){ + console.info('====>testGetColorsSync102 err : ' + JSON.stringify(err)); + expect().assertFail(); + done() + } + console.info('------------------testGetColorsSync102 end----------------------'); + }) + + /* + * @tc.number testGetIdSync101 + * @tc.name Test getIdSync() to Obtains the ID of the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetIdSync101', 0, async function (done) { + console.info('------------------testGetIdSync101 start----------------------'); + let number = null; + try{ + number = wallpaper.getIdSync(WALLPAPER_SYSTEM) + console.info('====>testGetIdSync101 data : ' + JSON.stringify(number)); + if (typeof number == "number") { + expect(true).assertTrue(); + done() + }else{ + expect().assertFail(); + done() + } + }catch(err){ + console.info('====>testGetIdSync101 err : ' + JSON.stringify(err)); + expect().assertFail(); + done() + } + console.info('------------------testGetIdSync101 end----------------------'); + }) + + /* + * @tc.number testGetIdSync102 + * @tc.name Test getIdSync() to Obtains the ID of the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetIdSync102', 0, async function (done) { + console.info('------------------testGetIdSync102 start----------------------'); + let number = null; + try{ + number = wallpaper.getIdSync(WALLPAPER_LOCKSCREEN) + console.info('====>testGetIdSync102 data : ' + JSON.stringify(number)); + if (typeof number == "number") { + expect(true).assertTrue(); + done() + }else{ + expect().assertFail(); + done() + } + }catch(err){ + console.info('====>testGetIdSync102 err : ' + JSON.stringify(err)); + expect().assertFail(); + done() + } + console.info('------------------testGetIdSync102 end----------------------'); + }) + + /* + * @tc.number testGetFileSync101 + * @tc.name Test getFileSync() to Obtains a file of the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetFileSync101', 0, async function (done) { + console.info('------------------testGetFileSync101 start----------------------'); + let number = null; + try{ + number = wallpaper.getFileSync(WALLPAPER_SYSTEM) + console.info('====>testGetFileSync101 data : ' + JSON.stringify(number)); + if (typeof number == "number") { + expect(true).assertTrue(); + done() + }else{ + expect().assertFail(); + done() + } + }catch(err){ + console.info('====>testGetFileSync101 err : ' + JSON.stringify(err)); + expect().assertFail(); + done() + } + console.info('------------------testGetFileSync101 end----------------------'); + }) + + /* + * @tc.number testGetFileSync102 + * @tc.name Test getFileSync() to Obtains a file of the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetFileSync102', 0, async function (done) { + console.info('------------------testGetFileSync102 start----------------------'); + let number = null; + try{ + number = wallpaper.getFileSync(WALLPAPER_LOCKSCREEN) + console.info('====>testGetFileSync102 data : ' + JSON.stringify(number)); + if (typeof number == "number") { + expect(true).assertTrue(); + done() + }else{ + expect().assertFail(); + done() + } + }catch(err){ + console.info('====>testGetFileSync102 err : ' + JSON.stringify(err)); + expect().assertFail(); + done() + } + console.info('------------------testGetFileSync102 end----------------------'); + }) + + /* + * @tc.number testGetFileSync103 + * @tc.name Test getFileSync() to Obtains a file of the wallpaper of the specified type. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetFileSync103', 0, async function (done) { + console.info('------------------testGetFileSync103 start----------------------'); + let number = null; + try{ + number = wallpaper.getFileSync(3) + console.info('====>testGetFileSync103 data : ' + JSON.stringify(number)); + if (typeof number == "number") { + expect(true).assertTrue(); + done() + }else{ + expect().assertFail(); + done() + } + }catch(err){ + console.info('====>testGetFileSync103 err : ' + JSON.stringify(err)); + console.info('====>testGetFileSync103 (err.code : ' + err.code); + expect(err.code == "401").assertTrue(); + done() + } + console.info('------------------testGetFileSync103 end----------------------'); + }) + + /* + * @tc.number testGetMinHeightSync101 + * @tc.name Test getMinHeightSync() to Obtains the minimum height of the wallpaper. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetMinHeightSync101', 0, async function (done) { + console.info('------------------testGetMinHeightSync101 start----------------------'); + let number = null; + try{ + number = wallpaper.getMinHeightSync() + console.info('====>testGetMinHeightSync101 data : ' + JSON.stringify(number)); + if (typeof number == "number") { + expect(true).assertTrue(); + done() + }else{ + expect().assertFail(); + done() + } + }catch(err){ + console.info('====>testGetMinHeightSync101 err : ' + JSON.stringify(err)); + expect().assertFail(); + done() + } + console.info('------------------testGetMinHeightSync101 end----------------------'); + done() + }) + + /* + * @tc.number testGetMinWidthSync101 + * @tc.name Test getMinWidthSync() to Obtains the minimum width of the wallpaper. + * @tc.desc Function test + * @tc.level 0 + */ + it('testGetMinWidthSync101', 0, async function (done) { + console.info('------------------testGetMinWidthSync101 start----------------------'); + let number = null; + try{ + number = wallpaper.getMinWidthSync() + console.info('====>testGetMinWidthSync101 data : ' + JSON.stringify(number)); + if (typeof number == "number") { + expect(true).assertTrue(); + done() + }else{ + expect().assertFail(); + done() + } + }catch(err){ + console.info('====>testGetMinWidthSync101 err : ' + JSON.stringify(err)); + expect().assertFail(); + done() + } + console.info('------------------testGetMinWidthSync101 end----------------------'); + }) + + /* + * @tc.number testIsChangeAllowed101 + * @tc.name Test isChangeAllowed() to Checks whether to allow the application to change the wallpaper for the current user. + * @tc.desc Function test + * @tc.level 0 + */ + it('testIsChangeAllowed101', 0, async function (done) { + console.info('------------------testIsChangeAllowed101 start----------------------'); + let allow = null; + try{ + allow = wallpaper.isChangeAllowed() + console.info('====>testIsChangeAllowed101 data : ' + JSON.stringify(allow)); + if (typeof allow == "boolean") { + expect(true).assertTrue(); + done() + }else{ + expect().assertFail(); + done() + } + }catch(err){ + console.info('====>testIsChangeAllowed101 err : ' + JSON.stringify(err)); + expect().assertFail(); + done() + } + console.info('------------------testIsChangeAllowed101 end----------------------'); + }) + + /* + * @tc.number testIsChangeAllowed101 + * @tc.name Test isUserChangeAllowed() to Checks whether a user is allowed to set wallpapers. + * @tc.desc Function test + * @tc.level 0 + */ + it('testIsUserChangeAllowed101', 0, async function (done) { + console.info('------------------testIsUserChangeAllowed101 start----------------------'); + let allow = null; + try{ + allow = wallpaper.isUserChangeAllowed() + console.info('====>testIsUserChangeAllowed101 data : ' + JSON.stringify(allow)); + if (typeof allow == "boolean") { + expect(true).assertTrue(); + done() + }else{ + expect().assertFail(); + done() + } + }catch(err){ + console.info('====>testIsUserChangeAllowed101 err : ' + JSON.stringify(err)); + expect().assertFail(); + done() + } + console.info('------------------testIsUserChangeAllowed101 end----------------------'); + done() + }) + + /* + * @tc.number testRestoreCallback101 + * @tc.name Test restore() to removes a wallpaper of the specified type and restores the default one. + * @tc.desc Function test + * @tc.level 0 + */ + it('testRestoreCallback101', 0, async function (done) { + console.info('------------------testRestoreCallback101 start----------------------'); + wallpaper.restore(WALLPAPER_LOCKSCREEN, function (err, data) { + try{ + console.info('====>testRestoreCallback101 data : ' + data); + if (err) { + console.info('====>testRestoreCallback101 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info('====>testRestoreCallback101 restore success'); + expect(true).assertTrue(); + done(); + }catch(err){ + console.info('====>testRestoreCallback101 catch err : ' + JSON.stringify(err)); + done(); + } + }); + console.info('------------------testRestoreCallback101 end----------------------'); + }) + + /* + * @tc.number testRestorePromise101 + * @tc.name Test restore() to removes a wallpaper of the specified type and restores the default one. + * @tc.desc Function test + * @tc.level 0 + */ + it('testRestorePromise101', 0, async function (done) { + console.info('------------------testRestorePromise101 start----------------------'); + await wallpaper.restore(WALLPAPER_SYSTEM).then((data) => { + console.info('====>testRestorePromise101 data : ' + JSON.stringify(data)); + console.info('====>testRestorePromise101 restore success'); + expect(true).assertTrue(); + done() + }).catch((err) => { + console.info('====>testRestorePromise101 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info('------------------testRestorePromise101 end----------------------'); + }) + + /* + * @tc.number testSetImageCallBack101 + * @tc.name Test setImage() to removes a wallpaper of the specified type and restores the default one. + * @tc.desc Function test + * @tc.level 0 + */ + it('testSetImageCallBack101', 0, async function (done) { + console.info('------------------testSetImageCallBack101 start----------------------'); + let wallpaperPath = "/data/storage/el2/base/haps/wp.png"; + wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + try{ + if (error) { + console.error(`====>testSetImageCallBack101 failed to setImage because: ` + JSON.stringify(error)); + expect().assertFail(); + done(); + } + console.log(`====>testSetImageCallBack101 success to setImage.`); + expect(true).assertTrue(); + done(); + }catch(err){ + console.info('====>testSetImageCallBack101 catch err : ' + JSON.stringify(err)); + done(); + } + }); + console.info('------------------testSetImageCallBack101 end----------------------'); + }) + + /* + * @tc.number testSetImageCallBack102 + * @tc.name Test setImage() to removes a wallpaper of the specified type and restores the default one. + * @tc.desc Function test + * @tc.level 0 + */ + it('testSetImageCallBack102', 0, async function (done) { + console.info('------------------testSetImageCallBack102 start----------------------'); + let wallpaperPath = "/data/storage/el2/base/haps/wp.png"; + wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN, (error, data) => { + try{ + if (error) { + console.error(`====>testSetImageCallBack102 failed to setImage because: ` + JSON.stringify(error)); + expect().assertFail(); + done(); + } + console.log(`====>testSetImageCallBack102 success to setImage.`); + expect(true).assertTrue(); + done(); + }catch(err){ + console.info('====>testSetImageCallBack102 catch err : ' + JSON.stringify(err)); + done(); + } + }); + console.info('------------------testSetImageCallBack102 end----------------------'); + }) + + /* + * @tc.number testSetImagePromise101 + * @tc.name Test setImage() to removes a wallpaper of the specified type and restores the default one. + * @tc.desc Function test + * @tc.level 0 + */ + it('testSetImagePromise101', 0, async function (done) { + console.info('------------------testSetImagePromise101 start----------------------'); + let wallpaperPath = "/data/storage/el2/base/haps/wp.png"; + await wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`====>testSetImagePromise101 success to setImage.`); + expect(true).assertTrue(); + done(); + }).catch(err => { + expect().assertFail(); + console.log(`====>testSetImagePromise101 promise fail: ` + JSON.stringify(err)); + }); + console.info('------------------testSetImagePromise101 end----------------------'); + }) + + /* + * @tc.number testSetImagePromise102 + * @tc.name Test setImage() to removes a wallpaper of the specified type and restores the default one. + * @tc.desc Function test + * @tc.level 0 + */ + it('testSetImagePromise102', 0, async function (done) { + console.info('------------------testSetImagePromise102 start----------------------'); + let wallpaperPath = "/data/storage/el2/base/haps/wp.png"; + await wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then((data) => { + console.log(`====>testSetImagePromise102 success to setImage.`); + expect(true).assertTrue(); + done(); + }).catch(err => { + console.log(`====>testSetImagePromise102 promise catch: ` + JSON.stringify(err)); + expect().assertFail(); + done() + }); + console.info('------------------testSetImagePromise102 end----------------------'); + }) + }); +}; diff --git a/theme/wallpaper_ets/entry/src/main/resources/base/element/string.json b/theme/wallpaper_ets/entry/src/main/resources/base/element/string.json new file mode 100644 index 000000000..498677efb --- /dev/null +++ b/theme/wallpaper_ets/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/theme/wallpaper_ets/entry/src/main/resources/base/media/icon.png b/theme/wallpaper_ets/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch 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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6N?xRrd5h$fp+CDas$8<}b7kFu%d@%9d}zFW!9MkZ@UhJ4~an`hD$^PwB-X7jP zS+EHBr9kiq70BD)2;1&mz5Ybop2v4q^xm}m$mqSb`=&m!_)dMUeanX1)XyA$gOkq) zyDRv$QZV!RnZM!g-#%l6WBlgj=X)Llb@ydW-=&E&iOrey>&}DK^BY%YPi&oZyt4N& zIk~GC;)sSgIx~o)sm!bQ4A0~Sc5et7A$qN5D2_z&#xUY_AT<4%&knACVUm8wqi=5R z`1lj_jtcqdDbId&j9-H9+@|R9`|yK%DyMyW_Ry&n->X|T`2anPoPH7`{|Cl? zlH7)!FtSh)V5A^^@`0KqPw}5W{D*IALmkf@G(2;9f9b&!Wv3SgN*m8uT0ZDrd`qa$ z`rqSc`zE||_QW_yRtH9M!gICB4UWE9>WeS7ZGU6cs?yhDclA%q-*#!~`?lrDGb`xR z2{*qy_@?gJyWXop@{+j_WOu_$35ed1HV&SsL+?L5VKDjX{ij5RK--mDlLXv$RVXP& z#==7p9*DpIsu3g5dcd4(Rym@QmrK8}?5BzjXMS+L{z~t;)(a1Pq_cHvm+skmiD-0x z8a)ecx_XjJ*yY-_vplww86g^zbVP_pgxz55Sr*!xzCwA?Z0 l*s>izoIde&KYnNeS@&%B8{-t#Qx_)u@xpf_|4hz2`ae1=c(nik literal 0 HcmV?d00001 diff --git a/time/BUILD.gn b/time/BUILD.gn new file mode 100644 index 000000000..cf1161ba1 --- /dev/null +++ b/time/BUILD.gn @@ -0,0 +1,21 @@ +# 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("//build/ohos_var.gni") +group("time") { + testonly = true + deps = [ + "dateTimeTest:ActsDateTimeAPITest", + "timeTest:ActsTimeAPITest", + ] +} diff --git a/time/dateTimeTest/AppScope/app.json b/time/dateTimeTest/AppScope/app.json new file mode 100644 index 000000000..800aff1b9 --- /dev/null +++ b/time/dateTimeTest/AppScope/app.json @@ -0,0 +1,15 @@ +{ + "app": { + "bundleName": "com.acts.dateTime.test", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "keepAlive":true, + "singleUser":true, + "minAPIVersion":9, + "targetAPIVersion":9 + } +} diff --git a/time/dateTimeTest/AppScope/resources/base/element/string.json b/time/dateTimeTest/AppScope/resources/base/element/string.json new file mode 100644 index 000000000..adc1e65b8 --- /dev/null +++ b/time/dateTimeTest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsDateTimeAPITest" + } + ] +} diff --git a/time/dateTimeTest/AppScope/resources/base/media/app_icon.png b/time/dateTimeTest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch 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=aaq8k3N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f7M!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 { + if (err.code) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/time/dateTimeTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/time/dateTimeTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..127844c9b --- /dev/null +++ b/time/dateTimeTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,71 @@ +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; + +var abilityDelegator = undefined; +var abilityDelegatorArguments = undefined; + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]); + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}`; + } + } + return targetParams.trim(); +} + +async function onAbilityCreateCallback() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'; + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback); + var cmd = 'aa start -d 0 -a MainAbility ' + ' -b ' + abilityDelegatorArguments.bundleName; + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters); + var debug = abilityDelegatorArguments.parameters['-D']; + if (debug == 'true') + { + cmd += ' -D'; + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/time/dateTimeTest/entry/src/main/ets/pages/index.ets b/time/dateTimeTest/entry/src/main/ets/pages/index.ets new file mode 100644 index 000000000..6a23c90b5 --- /dev/null +++ b/time/dateTimeTest/entry/src/main/ets/pages/index.ets @@ -0,0 +1,40 @@ + +// @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 hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + + @State message: string = 'TIME ETS TEST' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/time/dateTimeTest/entry/src/main/ets/test/List.test.ets b/time/dateTimeTest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 000000000..4e009d9e8 --- /dev/null +++ b/time/dateTimeTest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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 systemDateTimeJsunit from './systemDateTimeJsunit.test'; + +export default function testsuite() { + systemDateTimeJsunit(); +} \ No newline at end of file diff --git a/time/dateTimeTest/entry/src/main/ets/test/systemDateTimeJsunit.test.ets b/time/dateTimeTest/entry/src/main/ets/test/systemDateTimeJsunit.test.ets new file mode 100644 index 000000000..6e8ca22f4 --- /dev/null +++ b/time/dateTimeTest/entry/src/main/ets/test/systemDateTimeJsunit.test.ets @@ -0,0 +1,426 @@ +/* + * 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 systemDateTime from "@ohos.systemDateTime"; + +export default function systemDateTimeJsunit() { + describe('systemDateTimeTest', function () { + console.info('====>---------------systemDateTimeTest start-----------------------'); + + /** + * @tc.number SUB_systemDateTime_getCurrentTime_JS_API_0001 + * @tc.name Test systemTimeDate.getCurrentTime + * @tc.desc Obtains the number of milliseconds that have elapsed since the Unix epoch. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemDateTime_getCurrentTime_JS_API_0001", 0, async function (done) { + console.info("====>----------SUB_systemDateTime_getCurrentTime_JS_API_0001 start----------------"); + systemDateTime.getCurrentTime(true, (error, data) => { + try { + if (error) { + console.error('====>SUB_systemDateTime_getCurrentTime_JS_API_0001 fail: ' + JSON.stringify(error)); + expect().assertFail(); + done(); + }; + console.info('====>systemDateTime.getCurrentTime success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + } catch (error) { + console.error('====>SUB_systemDateTime_getCurrentTime_JS_API_0001 catch error: ' + JSON.stringify(error)); + done(); + } + console.info("====>----------SUB_systemDateTime_getCurrentTime_JS_API_0001 end-----------------"); + }); + }); + + /** + * @tc.number SUB_systemDateTime_getCurrentTime_JS_API_0002 + * @tc.name Test systemTimeDate.getCurrentTime + * @tc.desc Obtains the number of milliseconds that have elapsed since the Unix epoch. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemDateTime_getCurrentTime_JS_API_0002", 0, async function (done) { + console.info("====>-----SUB_systemDateTime_getCurrentTime_JS_API_0002 start----------------"); + await systemDateTime.getCurrentTime(false).then((data) => { + console.info('====>SUB_systemDateTime_getCurrentTime_JS_API_0002 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + }).catch(err => { + console.error('====>SUB_systemDateTime_getCurrentTime_JS_API_0002 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info("====>-----SUB_systemDateTime_getCurrentTime_JS_API_0002 end------------"); + }); + + /** + * @tc.number SUB_systemDateTime_getCurrentTime_JS_API_0003 + * @tc.name Test systemTimeDate.getCurrentTime + * @tc.desc Obtains the number of milliseconds that have elapsed since the Unix epoch. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemDateTime_getCurrentTime_JS_API_0003", 0, async function (done) { + console.info("====>-----SUB_systemDateTime_getCurrentTime_JS_API_0003 start----------------"); + await systemDateTime.getCurrentTime().then((data) => { + console.info('====>SUB_systemDateTime_getCurrentTime_JS_API_0003 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + }).catch(err => { + console.error('====>SUB_systemDateTime_getCurrentTime_JS_API_0003 fail: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info("====>-----SUB_systemDateTime_getCurrentTime_JS_API_0003 end------------"); + }); + + /** + * @tc.number SUB_systemDateTime_getCurrentTime_JS_API_0004 + * @tc.name Test systemTimeDate.getCurrentTime + * @tc.desc Obtains the number of milliseconds that have elapsed since the Unix epoch. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemDateTime_getCurrentTime_JS_API_0004", 0, async function (done) { + console.info("====>----------SUB_systemDateTime_getCurrentTime_JS_API_0004 start----------------"); + systemDateTime.getCurrentTime((error, data) => { + try { + if (error) { + console.error('====>SUB_systemDateTime_getCurrentTime_JS_API_0004 fail: ' + JSON.stringify(error)); + expect().assertFail(); + done(); + }; + console.info('====>systemDateTime.getCurrentTime success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + } catch (error) { + console.error('====>SUB_systemDateTime_getCurrentTime_JS_API_0004 catch error: ' + JSON.stringify(error)); + done(); + } + console.info("====>----------SUB_systemDateTime_getCurrentTime_JS_API_0004 end-----------------"); + }); + }); + + /** + * @tc.number SUB_systemDateTime_getRealActiveTime_JS_API_0001 + * @tc.name Test systemTimeDate.getCurrentTime + * @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemDateTime_getRealActiveTime_JS_API_0001", 0, async function (done) { + console.info("====>----------SUB_systemDateTime_getRealActiveTime_JS_API_0001 start----------------"); + systemDateTime.getRealActiveTime(true, (error, data) => { + try { + if (error) { + console.error('====>SUB_systemDateTime_getRealActiveTime_JS_API_0001 fail: ' + JSON.stringify(error)); + expect().assertFail(); + done(); + }; + console.info('====>SUB_systemDateTime_getRealActiveTime_JS_API_0001 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + } catch (error) { + console.error('====>SUB_systemDateTime_getRealActiveTime_JS_API_0001 catch err: ' + JSON.stringify(error)); + done(); + } + console.info("====>----------SUB_systemDateTime_getRealActiveTime_JS_API_0001 end-----------------"); + }); + }); + + /** + * @tc.number SUB_systemDateTime_getRealActiveTime_JS_API_0002 + * @tc.name Test systemTimeDate.getCurrentTime + * @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemDateTime_getRealActiveTime_JS_API_0002", 0, async function (done) { + console.info("====>-----SUB_systemDateTime_getRealActiveTime_JS_API_0002 start----------------"); + await systemDateTime.getRealActiveTime(false).then((data) => { + console.log('SUB_systemDateTime_getRealActiveTime_JS_API_0002 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + }).catch(err => { + console.error('====>SUB_systemDateTime_getRealActiveTime_JS_API_0002 err: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info("====>-----SUB_systemDateTime_getRealActiveTime_JS_API_0002 end------------"); + }); + + /** + * @tc.number SUB_systemDateTime_getRealActiveTime_JS_API_0003 + * @tc.name Test systemTimeDate.getCurrentTime + * @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemDateTime_getRealActiveTime_JS_API_0003", 0, async function (done) { + console.info("====>-----SUB_systemDateTime_getRealActiveTime_JS_API_0003 start----------------"); + await systemDateTime.getRealActiveTime().then((data) => { + console.log('SUB_systemDateTime_getRealActiveTime_JS_API_0003 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + }).catch(err => { + console.error('====>SUB_systemDateTime_getRealActiveTime_JS_API_0003 err: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + console.info("====>-----SUB_systemDateTime_getRealActiveTime_JS_API_0003 end------------"); + }); + + /** + * @tc.number SUB_systemDateTime_getRealActiveTime_JS_API_0004 + * @tc.name Test systemTimeDate.getCurrentTime + * @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemDateTime_getRealActiveTime_JS_API_0004", 0, async function (done) { + console.info("====>----------SUB_systemDateTime_getRealActiveTime_JS_API_0004 start----------------"); + systemDateTime.getRealActiveTime((error, data) => { + try { + if (error) { + console.error('====>SUB_systemDateTime_getRealActiveTime_JS_API_0004 fail: ' + JSON.stringify(error)); + expect().assertFail(); + done(); + }; + console.info('====>SUB_systemDateTime_getRealActiveTime_JS_API_0004 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + } catch (error) { + console.error('====>SUB_systemDateTime_getRealActiveTime_JS_API_0004 catch err: ' + JSON.stringify(error)); + done(); + } + console.info("====>----------SUB_systemDateTime_getRealActiveTime_JS_API_0004 end-----------------"); + }); + }); + + /** + * @tc.number SUB_systemDateTime_getRealTime_JS_API_0001 + * @tc.name Test systemTimeDate.getCurrentTime + * @tc.desc Obtains the number of milliseconds elapsed since the system was booted, including deep sleep time. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemDateTime_getRealTime_JS_API_0001", 0, async function (done) { + console.info("====>----------SUB_systemDateTime_getRealTime_JS_API_0001 start----------------"); + systemDateTime.getRealTime(true, (error, data) => { + try { + if (error) { + console.error('SUB_systemDateTime_getRealTime_JS_API_0001 fail: ' + JSON.stringify(error)); + expect().assertFail(); + done(); + }; + console.info('====>SUB_systemDateTime_getRealTime_JS_API_0001 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + } catch (error) { + console.error('====>SUB_systemDateTime_getRealTime_JS_API_0001 catch err: ' + JSON.stringify(error)); + done(); + } + console.info("====>----------SUB_systemDateTime_getRealTime_JS_API_0001 end-----------------"); + }); + }); + + /** + * @tc.number SUB_systemDateTime_getRealTime_JS_API_0002 + * @tc.name Test systemTimeDate.getCurrentTime + * @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemDateTime_getRealTime_JS_API_0002", 0, async function (done) { + console.info("====>-----SUB_systemDateTime_getRealTime_JS_API_0002 start----------------"); + await systemDateTime.getRealTime(false).then((data) => { + console.info('====>SUB_systemDateTime_getRealTime_JS_API_0002 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + }).catch(error => { + console.error('====>SUB_systemDateTime_getRealTime_JS_API_0002 err: ' + JSON.stringify(error)); + expect().assertFail(); + done(); + }); + console.info("====>-----SUB_systemDateTime_getRealTime_JS_API_0002 end------------"); + }); + + /** + * @tc.number SUB_systemDateTime_getRealTime_JS_API_0003 + * @tc.name Test systemTimeDate.getCurrentTime + * @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemDateTime_getRealTime_JS_API_0003", 0, async function (done) { + console.info("====>-----SUB_systemDateTime_getRealTime_JS_API_0003 start----------------"); + await systemDateTime.getRealTime().then((data) => { + console.info('====>SUB_systemDateTime_getRealTime_JS_API_0003 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + }).catch(error => { + console.error('====>SUB_systemDateTime_getRealTime_JS_API_0003 err: ' + JSON.stringify(error)); + expect().assertFail(); + done(); + }); + console.info("====>-----SUB_systemDateTime_getRealTime_JS_API_0003 end------------"); + }); + + /** + * @tc.number SUB_systemDateTime_getRealTime_JS_API_0004 + * @tc.name Test systemTimeDate.getCurrentTime + * @tc.desc Obtains the number of milliseconds elapsed since the system was booted, including deep sleep time. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemDateTime_getRealTime_JS_API_0004", 0, async function (done) { + console.info("====>----------SUB_systemDateTime_getRealTime_JS_API_0004 start----------------"); + systemDateTime.getRealTime((error, data) => { + try { + if (error) { + console.error('SUB_systemDateTime_getRealTime_JS_API_0004 fail: ' + JSON.stringify(error)); + expect().assertFail(); + done(); + }; + console.info('====>SUB_systemDateTime_getRealTime_JS_API_0004 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + } catch (error) { + console.error('====>SUB_systemDateTime_getRealTime_JS_API_0004 catch err: ' + JSON.stringify(error)); + done(); + } + console.info("====>----------SUB_systemDateTime_getRealTime_JS_API_0004 end-----------------"); + }); + }); + + /** + * @tc.number SUB_systemDateTime_getDate_JS_API_0100 + * @tc.name Test systemTimeDate.setDate true value + * @tc.desc Test systemTimeDate_setDate API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemDateTime_getDate_JS_API_0100', 0, async function (done) { + console.info("====>SUB_systemDateTime_getDate_JS_API_0100 start"); + await systemDateTime.getDate().then((data) => { + console.info("====>SUB_systemDateTime_getDate_JS_API_0100 getDate: " + data); + expect(data != null).assertTrue(); + done(); + }).catch(error => { + console.info("====>SUB_systemDateTime_getDate_JS_API_0100 getDate fail: " + error); + expect().assertFail(); + done(); + }) + console.info("====>SUB_systemDateTime_getDate_JS_API_0100 end"); + + }); + + /** + * @tc.number SUB_systemDateTime_getDate_JS_API_0200 + * @tc.name Test systemTimeDate.setDate true value + * @tc.desc Test systemTimeDate_setDate API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemDateTime_getDate_JS_API_0200', 0, async function (done) { + console.info("====>SUB_systemDateTime_getDate_JS_API_0200 start"); + systemDateTime.getDate((err, data) => { + try{ + if(err){ + console.info("====>SUB_systemDateTime_getDate_JS_API_0200 getTimezone fail: " + err); + expect().assertFail(); + done(); + } + console.info("====>SUB_systemDateTime_getDate_JS_API_0200 getTimezone success: " + data); + expect(data != null).assertTrue(); + done(); + }catch(error){ + console.info("====>SUB_systemDateTime_getDate_JS_API_0200 catch error " + error); + done(); + } + }) + console.info("====>SUB_systemDateTime_getDate_JS_API_0200 end"); + }); + + + /** + * @tc.number SUB_systemDateTime_getTimezone_JS_API_0100 + * @tc.name Test systemTime.SUB_systemDateTime_getTimezone_JS_API_0100 true value + * @tc.desc Test systemTimeDate_setTimezone API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemDateTime_getTimezone_JS_API_0100', 0, async function (done) { + console.info("====>SUB_systemDateTime_getTimezone_JS_API_0100 start"); + await systemDateTime.getTimezone().then( data => { + console.info("====>SUB_systemDateTime_getTimezone_JS_API_0100 getTimezone success: " + data); + expect(data != null).assertTrue(); + done(); + }).catch(error => { + console.info("====>SUB_systemDateTime_getTimezone_JS_API_0100 getTimezone fail: " + error); + expect().assertFail(); + done(); + }); + console.info("====>SUB_systemDateTime_getTimezone_JS_API_0100 end"); + }); + + /** + * @tc.number SUB_systemDateTime_getTimezone_JS_API_0200 + * @tc.name Test systemTimeDate.setTimezone true value + * @tc.desc Test systemTimeDate_setTimezone API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemDateTime_getTimezone_JS_API_0200', 0, async function (done) { + console.info("====>SUB_systemDateTime_getTimezone_JS_API_0200 start"); + systemDateTime.getTimezone((err, data) => { + try{ + if(err){ + console.info("====>SUB_systemDateTime_getTimezone_JS_API_0200 getTimezone fail: " + err); + expect().assertFail(); + done(); + } + console.info("====>SUB_systemDateTime_getTimezone_JS_API_0200 getTimezone success: " + data); + expect(data != null).assertTrue(); + done(); + }catch(error){ + console.info("====>SUB_systemDateTime_getTimezone_JS_API_0200 catch error " + error); + done(); + } + }) + console.info("====>SUB_systemDateTime_getTimezone_JS_API_0200 end"); + }); + + }); +}; diff --git a/time/dateTimeTest/entry/src/main/module.json b/time/dateTimeTest/entry/src/main/module.json new file mode 100644 index 000000000..f68134834 --- /dev/null +++ b/time/dateTimeTest/entry/src/main/module.json @@ -0,0 +1,45 @@ +{ + "module": { + "name": "entry_test", + "type": "entry", + "srcEntrance": "./ets/Application/MyAbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet", + "default", + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/time/dateTimeTest/entry/src/main/resources/base/element/color.json b/time/dateTimeTest/entry/src/main/resources/base/element/color.json new file mode 100644 index 000000000..62a137a61 --- /dev/null +++ b/time/dateTimeTest/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/time/dateTimeTest/entry/src/main/resources/base/element/string.json b/time/dateTimeTest/entry/src/main/resources/base/element/string.json new file mode 100644 index 000000000..276031920 --- /dev/null +++ b/time/dateTimeTest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "ActsDateTimeAPITest" + } + ] +} \ No newline at end of file diff --git a/time/dateTimeTest/entry/src/main/resources/base/media/icon.png b/time/dateTimeTest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch 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^|N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;jyo6bbx9w zQ7C8pWcgSyx^3h?7IhVk{@aiZm0f2ao_pY%?D-u^91Ig3hD#(r%jGg@ZW|ac%ERQN z{#9PCGv{@OyK+OEmymj=9JIA`NwraNc*Cu)aN&c&VVmYdAcfl(u?nP zw%NcL;}iVD&(S{o4DZ%28CVMl{>sr! z15{6_J9$=-%$p@A%Fia3g%u0eURGER z-<-x?^1;!{xd)U(*0#KT!R`L&sWlz5(m%cRiCc~@A@J3)mB{8D?N<*pUUzm59d_3D z!YhBrM{Imf@!9^(9oHL2U7tE}N&IZ#BjfD}w|Rjs7r(L*0kgnx5hw*BaI%3+_zXmn zB&Q#e#>~jyu>HY#Jz2ILAFVFlv$}yFc6{LUWONqrO99`&7emK?;I}@pYTfDjeXr~) z?i{@I)->k(-uYZGQ<^ zo=h75+l=+ZHnprPd@# zd}j8(l8HZFINJU4PfFKDA0P*i(=TG=|G?NUlG}hAMi$HhloUkI{8qp458UNvcKu=WY_+aJA{P!b|ogJNi=*A15S(nCpUMA1Q+}u+7L(S`teOd~oC9?#OJubXCK={6l zvF}Fh|Ga4rfw8xrH+eEhu-$qTNx(z5g}iKNxNs?|fp8rP&kutdG=Q=@RykB8FVrVW z?BzxC(j6;~Z$D^!>HDA8wRG=`M3z6VZ2#h`@VEQH;M+I3R9*p$(!xPER$Td7YB$T* zUUAO-XPSPtXR>tc$X7qvlRNLi;?%WTX<_kr+qFZNj-8u(*h;rOlK14>^OW6>D$^ZJ M%v7ck-u>SH0Qr$<^8f$< literal 0 HcmV?d00001 diff --git a/time/timeTest/AppScope/app.json b/time/timeTest/AppScope/app.json new file mode 100644 index 000000000..6802f440a --- /dev/null +++ b/time/timeTest/AppScope/app.json @@ -0,0 +1,15 @@ +{ + "app": { + "bundleName": "com.acts.time.test", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "keepAlive":true, + "singleUser":true, + "minAPIVersion":9, + "targetAPIVersion":9 + } +} diff --git a/time/timeTest/AppScope/resources/base/element/string.json b/time/timeTest/AppScope/resources/base/element/string.json new file mode 100644 index 000000000..066e1ff18 --- /dev/null +++ b/time/timeTest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsTimeAPITest" + } + ] +} diff --git a/time/timeTest/AppScope/resources/base/media/app_icon.png b/time/timeTest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch 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 za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r!;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 { + if (err.code) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/time/timeTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/time/timeTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..1b7461ea5 --- /dev/null +++ b/time/timeTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,71 @@ +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a MainAbility ' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/time/timeTest/entry/src/main/ets/pages/index.ets b/time/timeTest/entry/src/main/ets/pages/index.ets new file mode 100644 index 000000000..6a23c90b5 --- /dev/null +++ b/time/timeTest/entry/src/main/ets/pages/index.ets @@ -0,0 +1,40 @@ + +// @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 hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + + @State message: string = 'TIME ETS TEST' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/time/timeTest/entry/src/main/ets/test/List.test.ets b/time/timeTest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 000000000..c7910c174 --- /dev/null +++ b/time/timeTest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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 systemTimeJsunit from './systemTimeTest'; + +export default function testsuite() { + systemTimeJsunit(); +} \ No newline at end of file diff --git a/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets b/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets new file mode 100644 index 000000000..2983a27d0 --- /dev/null +++ b/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets @@ -0,0 +1,541 @@ +// @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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import systemTime from "@ohos.systemTime"; + +export default function systemTimeJsunit() { + describe('systemTimeTest', function () { + console.info('====>---------------systemTimeTest start-----------------------'); + /** + * beforeEach: Prerequisites at the test case level, which are executed before each test case is executed. + */ + + var dates; + var zone; + beforeEach(async function (done) { + let currentTime = new Date().getTime() + dates = currentTime + console.info("====>beforeEach data " + dates); + + systemTime.getTimezone().then( data => { + console.info("====>beforeEach data " + data); + zone = data + done() + }).catch(error => { + console.info("====>beforeEach error " + error); + }); + }); + + /** + * afterEach: Test case-level clearance conditions, which are executed after each test case is executed. + */ + afterEach(async function (done) { + systemTime.setTimezone(zone).then( data => { + console.info("====>afterEach zone " + zone); + done() + }).catch(error => { + console.info("====>afterEach error " + error); + }); + }); + + /** + * @tc.number SUB_systemTime_getCurrentTime_JS_API_0001 + * @tc.name Test systemTime.getCurrentTime + * @tc.desc Obtains the number of milliseconds that have elapsed since the Unix epoch. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemTime_getCurrentTime_JS_API_0001", 0, async function (done) { + console.info("====>----------UB_systemTime_getCurrentTime_JS_API_0001 start----------------"); + systemTime.getCurrentTime(true, (error, data) => { + try { + if (error) { + console.error('====>UB_systemTime_getCurrentTime_JS_API_0001 fail: ' + JSON.stringify(error)); + expect().assertFail(); + done(); + }; + console.info('====>SystemTime.getCurrentTime success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + } catch (error) { + console.error('====>UB_systemTime_getCurrentTime_JS_API_0001 catch error: ' + JSON.stringify(error)); + done(); + } + console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0100 end-----------------"); + }); + }); + + /** + * @tc.number SUB_systemTime_getCurrentTime_JS_API_0002 + * @tc.name Test systemTime.getCurrentTime + * @tc.desc Obtains the number of milliseconds that have elapsed since the Unix epoch. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemTime_getCurrentTime_JS_API_0002", 0, async function (done) { + console.info("====>-----SUB_systemTime_getCurrentTime_JS_API_0002 start----------------"); + await systemTime.getCurrentTime(false).then((data) => { + console.info('====>SUB_systemTime_getCurrentTime_JS_API_0002 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + }).catch(err => { + console.error('====>SUB_systemTime_getCurrentTime_JS_API_0002 fail: ' + JSON.stringify(err)); + expect().assertFail() + done(); + }); + console.info("====>-----SUB_systemTime_getCurrentTime_JS_API_0002 end------------"); + }); + + /** + * @tc.number SUB_systemTime_getRealActiveTime_JS_API_0001 + * @tc.name Test systemTime.getCurrentTime + * @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemTime_getRealActiveTime_JS_API_0001", 0, async function (done) { + console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0001 start----------------"); + systemTime.getRealActiveTime(true, (error, data) => { + try { + if (error) { + console.error('====>SUB_systemTime_getRealActiveTime_JS_API_0001 fail: ' + JSON.stringify(error)); + expect().assertFail() + done(); + }; + console.info('====>SUB_systemTime_getRealActiveTime_JS_API_0001 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + } catch (error) { + console.error('====>SUB_systemTime_getRealActiveTime_JS_API_0001 catch err: ' + JSON.stringify(error)); + done(); + } + console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0001 end-----------------"); + }); + }); + + /** + * @tc.number SUB_systemTime_getRealActiveTime_JS_API_0002 + * @tc.name Test systemTime.getCurrentTime + * @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemTime_getRealActiveTime_JS_API_0002", 0, async function (done) { + console.info("====>-----SUB_systemTime_getRealActiveTime_JS_API_0002 start----------------"); + await systemTime.getRealActiveTime(false).then((data) => { + console.log('SUB_systemTime_getRealActiveTime_JS_API_0002 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + }).catch(err => { + console.error('====>SUB_systemTime_getRealActiveTime_JS_API_0002 err: ' + JSON.stringify(err)); + expect().assertFail() + done(); + }); + console.info("====>-----SUB_systemTime_getRealActiveTime_JS_API_0002 end------------"); + }); + + /** + * @tc.number SUB_systemTime_getRealTime_JS_API_0001 + * @tc.name Test systemTime.getCurrentTime + * @tc.desc Obtains the number of milliseconds elapsed since the system was booted, including deep sleep time. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemTime_getRealTime_JS_API_0001", 0, async function (done) { + console.info("====>----------SUB_systemTime_getRealTime_JS_API_0001 start----------------"); + systemTime.getRealTime(true, (error, data) => { + try { + if (error) { + console.error('SUB_systemTime_getRealTime_JS_API_0001 fail: ' + JSON.stringify(error)); + expect().assertFail(); + done(); + }; + console.info('====>SUB_systemTime_getRealTime_JS_API_0001 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + } catch (error) { + console.error('====>SUB_systemTime_getRealTime_JS_API_0001 catch err: ' + JSON.stringify(error)); + done(); + } + console.info("====>----------SUB_systemTime_getRealTime_JS_API_0001 end-----------------"); + }); + }); + + /** + * @tc.number SUB_systemTime_getRealTime_JS_API_0002 + * @tc.name Test systemTime.getCurrentTime + * @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it("SUB_systemTime_getRealTime_JS_API_0002", 0, async function (done) { + console.info("====>-----SUB_systemTime_getRealTime_JS_API_0002 start----------------"); + await systemTime.getRealTime(false).then((data) => { + console.info('====>SUB_systemTime_getRealTime_JS_API_0002 success data : ' + JSON.stringify(data)); + expect(data != null).assertEqual(true); + done(); + }).catch(error => { + console.error('====>SUB_systemTime_getRealTime_JS_API_0002 err: ' + JSON.stringify(error)); + expect().assertFail(); + done(); + }); + console.info("====>-----SUB_systemTime_getRealTime_JS_API_0002 end------------"); + }); + + /** + * @tc.number SUB_systemTime_setTime_JS_API_0100 + * @tc.name Test systemTime.setTime + * @tc.desc Test systemTime_setTime API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemTime_setTime_JS_API_0100', 0, async function (done) { + console.info("====>SUB_systemTime_setTime_JS_API_0100 start"); + let currentTime = new Date().getTime() + 2000 + systemTime.setTime(currentTime, (err, data) => { + try{ + if(err){ + console.info("====>SUB_systemTime_setTime_JS_API_0100 setTime fail: " + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info('====>SUB_systemTime_setTime_JS_API_0100 success: ' + data); + expect(true).assertTrue(); + done(); + }catch(err){ + console.info("====>SUB_systemTime_setTime_JS_API_0100 catch error: " + JSON.stringify(err)); + done(); + } + }); + console.info("====>SUB_systemTime_setTime_JS_API_0100 end"); + }); + + /** + * @tc.number SUB_systemTime_setTime_JS_API_0200 + * @tc.name Test systemTime.setTime Invalid value + * @tc.desc Test systemTime_setTime API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemTime_setTime_JS_API_0200', 0, async function (done) { + console.info("====>SUB_systemTime_setTime_JS_API_0200 start"); + try{ + systemTime.setTime(15222).then(() => { + console.debug('====>SUB_systemTime_setTime_JS_API_0200 setTime fail') + expect().assertFail(); + done(); + }).catch((err)=>{ + console.debug('====>SUB_systemTime_setTime_JS_API_0200 setTime err:' + JSON.stringify(err)) + expect(true).assertTrue(); + console.debug('====>SUB_systemTime_setTime_JS_API_0200 end'); + done(); + }) + }catch(err){ + console.debug('====>SUB_systemTime_setTime_JS_API_0200 setTime throw_err' + JSON.stringify(err)) + expect(err.code).assertEqual('401'); + done(); + } + }); + + /** + * @tc.number SUB_systemTime_setTime_JS_API_0300 + * @tc.name Test systemTime.setTime3 + * @tc.desc Test systemTime_setTime API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemTime_setTime_JS_API_0300', 0, async function (done) { + console.info("====>SUB_systemTime_setTime_JS_API_0300 start"); + let currentTime = new Date().getTime() + 2000 + await systemTime.setTime(currentTime).then(() => { + console.info('====>SUB_systemTime_setTime_JS_API_0300 success') + expect(true).assertTrue(); + done(); + }).catch((err)=>{ + console.debug('====>SUB_systemTime_setTime_JS_API_0300 setTime fail:' + JSON.stringify(err)) + expect().assertFail(); + done(); + }) + console.info("====>SUB_systemTime_setTime_JS_API_0300 end"); + }); + + /** + * @tc.number SUB_systemTime_setTime_JS_API_0400 + * @tc.name Test systemTime.setTime4 Invalid value + * @tc.desc Test systemTime_setTime API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemTime_setTime_JS_API_0400', 0, async function (done) { + console.info("====>SUB_systemTime_setTime_JS_API_0400 start"); + try{ + systemTime.setTime(18, (err, data) => { + console.info("====>SUB_systemTime_setTime_JS_API_0400 data: " + data); + console.info("====>SUB_systemTime_setTime_JS_API_0400 error: " + err); + console.info('====>SUB_systemTime_setTime_JS_API_0400 end'); + expect(true).assertTrue(); + done(); + }) + }catch(err) { + expect().assertFail(); + done(); + }; + }); + + /** + * @tc.number SUB_systemTime_setDate_JS_API_0200 + * @tc.name Test systemTime.setDate Invalid value + * @tc.desc Test systemTime_setDate API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemTime_setDate_JS_API_0200', 0, async function (done) { + console.info("====>SUB_systemTime_setDate_JS_API_0200 start"); + systemTime.setDate(0).then(data => { + console.info("====>SUB_systemTime_setDate_JS_API_0200 data " + data); + expect().assertFail(); + done(); + }).catch(error => { + console.info("====>SUB_systemTime_setDate_JS_API_0200 error " + error); + expect(true).assertTrue(); + done(); + }); + }); + + /** + * @tc.number SUB_systemTime_setDate_JS_API_0400 + * @tc.name Test systemTime.setDate true value + * @tc.desc Test systemTime_setDate API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemTime_setDate_JS_API_0400', 0, async function (done) { + console.info("====>SUB_systemTime_setDate_JS_API_0400 start"); + let date = new Date("Tue Oct 13 2020 11:13:00 GMT+0800"); + systemTime.setDate(date, (error, data) => { + try { + if(error){ + console.info("====>SUB_systemTime_setDate_JS_API_0400 setDate fail: " + JSON.stringify(error)); + expect().assertFail(); + done(); + } + systemTime.getDate().then(async (data) => { + try { + console.info("====>SUB_systemTime_setDate_JS_API_0400 getDate: " + data); + console.info("====>SUB_systemTime_setDate_JS_API_0400 setTime: " + dates); + console.info("====>SUB_systemTime_setDate_JS_API_0400 getDate: " + JSON.stringify(data).slice(1,17)); + expect(JSON.stringify(data).slice(1,17) == '2020-10-13T03:13').assertTrue(); + await systemTime.setTime(dates + 1000) + done(); + } catch (err) { + console.info("====>SUB_systemTime_setDate_JS_API_0400 catch err: " + err); + done(); + } + }) + } catch (err) { + console.info("====>SUB_systemTime_setDate_JS_API_0400 catch error " + JSON.stringify(err)); + done(); + } + }); + }); + + /** + * @tc.number SUB_systemTime_setDate_JS_API_0500 + * @tc.name Test systemTime.setDate true value + * @tc.desc Test systemTime_setDate API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemTime_setDate_JS_API_0500', 0, async function (done) { + console.info("====>SUB_systemTime_setDate_JS_API_0500 start"); + let date = new Date("Tue Oct 13 2020 11:13:00 GMT+0800"); + await systemTime.setDate(date).then( () => { + console.info("====>SUB_systemTime_setDate_JS_API_0500 successful "); + systemTime.getDate().then(async data => { + try { + console.info("====>SUB_systemTime_setDate_JS_API_0500 getDate: " + data); + console.info("====>SUB_systemTime_setDate_JS_API_0500 setTime: " + dates); + console.info("====>SUB_systemTime_setDate_JS_API_0500 getDate: " + JSON.stringify(data).slice(1,17)); + expect(JSON.stringify(data).slice(1,17) == '2020-10-13T03:13').assertTrue(); + await systemTime.setTime(dates + 1000) + done(); + } catch (err) { + console.info("====>SUB_systemTime_setDate_JS_API_0500 catch err: " + err); + done(); + } + }) + }).catch(error => { + console.info("====>SUB_systemTime_setDate_JS_API_0500 setDate fail: " + JSON.stringify(error)); + expect().assertFail(); + done(); + }); + }); + + /** + * @tc.number SUB_systemTime_setTimezone_JS_API_0100 + * @tc.name Test systemTime.setTimezone Invalid value + * @tc.desc Test systemTime_setTimezone API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemTime_setTimezone_JS_API_0100', 0, async function (done) { + console.info("====>SUB_systemTime_setTimezone_JS_API_0100 start"); + systemTime.setTimezone('Asia, Shanghai').then(data => { + console.info("====>SUB_systemTime_setTimezone_JS_API_0100 data " + data); + expect().assertFail(); + done(); + }).catch(error => { + console.info("====>SUB_systemTime_setTimezone_JS_API_0100 error " + error); + expect(true).assertTrue(); + done(); + }); + }); + + /** + * @tc.number SUB_systemTime_setTimezone_JS_API_0200 + * @tc.name Test systemTime.setTimezone Invalid value + * @tc.desc Test systemTime_setTimezone API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemTime_setTimezone_JS_API_0200', 0, async function (done) { + console.info("====>SUB_systemTime_setTimezone_JS_API_0200 start"); + systemTime.setTimezone('Beijing,China').then(data => { + console.info("====>SUB_systemTime_setTimezone_JS_API_0200 data " + data); + expect().assertFail(); + done(); + }).catch(error => { + console.info("====>SUB_systemTime_setTimezone_JS_API_0200 error " + error); + expect(true).assertTrue(); + done(); + }); + }); + + /** + * @tc.number SUB_systemTime_setTimezone_JS_API_0300 + * @tc.name Test systemTime.setTimezone Invalid value + * @tc.desc Test systemTime_setTimezone API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemTime_setTimezone_JS_API_0300', 0, async function (done) { + console.info("====>SUB_systemTime_setTimezone_JS_API_0300 start"); + systemTime.setTimezone('Baker Island, U.S.A.').then(data => { + console.info("====>SUB_systemTime_setTimezone_JS_API_0300 data " + data); + expect().assertFail(); + done(); + }).catch(error => { + console.info("====>SUB_systemTime_setTimezone_JS_API_0300 error " + error); + expect(true).assertTrue(); + done(); + }); + }); + + /** + * @tc.number SUB_systemTime_setTimezone_JS_API_0400 + * @tc.name Test systemTime.setTimezone true value + * @tc.desc Test systemTime_setTimezone API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemTime_setTimezone_JS_API_0400', 0, function (done) { + console.info("====>SUB_systemTime_setTimezone_JS_API_0400 start"); + systemTime.setTimezone('Asia/Jakarta',async (err) => { + try{ + if(err){ + console.info("====>SUB_systemTime_setTimezone_JS_API_0400 setTimezone fail: " + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info("====>SUB_systemTime_setTimezone_JS_API_0400 success "); + systemTime.getTimezone().then( data => { + try { + console.info("====>SUB_systemTime_setTimezone_JS_API_0400 getTimezone " + data); + expect(data == 'Asia/Jakarta').assertTrue(); + done(); + } catch (error) { + console.info("====>SUB_systemTime_setTimezone_JS_API_0400 getTimezone catch error " + error); + done(); + } + }).catch(error => { + console.info("====>SUB_systemTime_setTimezone_JS_API_0400 error " + error); + done(); + }); + }catch(err){ + console.info("====>SUB_systemTime_setTimezone_JS_API_0400 error " + err); + done(); + } + }) + }); + + /** + * @tc.number SUB_systemTime_setTimezone_JS_API_0500 + * @tc.name Test systemTime.setTimezone true value + * @tc.desc Test systemTime_setTimezone API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_systemTime_setTimezone_JS_API_0500', 0, async function (done) { + console.info("====>SUB_systemTime_setTimezone_JS_API_0500 start"); + try{ + await systemTime.setTimezone('Europe/Moscow').then(() => { + console.info("====>SUB_systemTime_setTimezone_JS_API_0500 promise successful " ); + systemTime.getTimezone().then( data => { + try { + console.info("====>SUB_systemTime_setTimezone_JS_API_0500 getTimezone " + data); + expect(data == 'Europe/Moscow').assertTrue(); + done(); + } catch (error) { + console.info("====>SUB_systemTime_setTimezone_JS_API_0500 getTimezone catch error " + error); + done(); + } + }).catch(error => { + console.info("====>SUB_systemTime_setTimezone_JS_API_0500 error " + error); + expect().assertFail(); + done(); + }); + }).catch(error => { + console.info("====>SUB_systemTime_setTimezone_JS_API_0500 error " + error.code); + expect().assertFail(); + done(); + }); + }catch(err){ + console.info("====>SUB_systemTime_setTimezone_JS_API_0500 catch error: " + err.code); + expect().assertFail(); + done(); + }; + }); + }); +}; diff --git a/time/timeTest/entry/src/main/module.json b/time/timeTest/entry/src/main/module.json new file mode 100644 index 000000000..6fe24d93b --- /dev/null +++ b/time/timeTest/entry/src/main/module.json @@ -0,0 +1,55 @@ +{ + "module": { + "name": "entry_test", + "type": "entry", + "srcEntrance": "./ets/Application/MyAbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet", + "default", + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name":"ohos.permission.SET_TIME", + "reason":"need use ohos.permission.SET_TIME." + }, + { + "name":"ohos.permission.SET_TIME_ZONE", + "reason":"need use ohos.permission.SET_TIME_ZONE." + } + ] + } +} \ No newline at end of file diff --git a/time/timeTest/entry/src/main/resources/base/element/color.json b/time/timeTest/entry/src/main/resources/base/element/color.json new file mode 100644 index 000000000..62a137a61 --- /dev/null +++ b/time/timeTest/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/time/timeTest/entry/src/main/resources/base/element/string.json b/time/timeTest/entry/src/main/resources/base/element/string.json new file mode 100644 index 000000000..03bb7d00f --- /dev/null +++ b/time/timeTest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "ActsTimeAPITest" + } + ] +} \ No newline at end of file diff --git a/time/timeTest/entry/src/main/resources/base/media/icon.png b/time/timeTest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrd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