diff --git a/interfaces/inner_api/security_component/src/sec_comp_client.cpp b/interfaces/inner_api/security_component/src/sec_comp_client.cpp index 0e20ceeabdc73b9da67c79848333a199d7dc165b..9ce69afbcedf75f9dfa13a1e2bb5003e6d35a3ec 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_client.cpp +++ b/interfaces/inner_api/security_component/src/sec_comp_client.cpp @@ -52,7 +52,7 @@ SecCompClient::~SecCompClient() int32_t SecCompClient::RegisterSecurityComponent(SecCompType type, const std::string& componentInfo, int32_t& scId) { - auto proxy = GetProxy(true); + auto proxy = GetProxy(true);111 if (proxy == nullptr) { SC_LOG_ERROR(LABEL, "Proxy is null"); return SC_SERVICE_ERROR_VALUE_INVALID; diff --git a/interfaces/inner_api/security_component/test/BUILD.gn b/interfaces/inner_api/security_component/test/BUILD.gn index 0aabcdc2703c15c74ddd94b5a1a5d4c06d4d58af..a5bb319d71a179fbbde22ea2faec8317acb746ef 100644 --- a/interfaces/inner_api/security_component/test/BUILD.gn +++ b/interfaces/inner_api/security_component/test/BUILD.gn @@ -49,26 +49,26 @@ ohos_unittest("sec_comp_sdk_test") { ] } -ohos_unittest("sec_comp_register_test") { +ohos_unittest("sec_comp_sdk_mock_test") { subsystem_name = "security" part_name = "security_component" module_out_path = part_name + "/" + part_name include_dirs = [ "${sec_comp_root_dir}/frameworks/common/include", + "${sec_comp_root_dir}/frameworks/enhance_adapter/include", "${sec_comp_root_dir}/frameworks/security_component/include", "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", ] sources = [ - "unittest/src/location_button_sample_build.cpp", - "unittest/src/sec_comp_register_callback_test.cpp", + "${sec_comp_root_dir}/interfaces/inner_api/security_component/test/mock/src/sec_comp_enhance_adapter.cpp", + "unittest/src/sec_comp_kit_mock_test.cpp", ] configs = [ "${sec_comp_root_dir}/config:coverage_flags" ] cflags_cc = [ "-DHILOG_ENABLE" ] deps = [ - "${sec_comp_root_dir}/frameworks:libsecurity_component_framework", "${sec_comp_root_dir}/interfaces/inner_api/security_component:libsecurity_component_sdk", ] @@ -81,7 +81,7 @@ ohos_unittest("sec_comp_register_test") { ] } -ohos_unittest("sec_comp_report_click_without_hmac_test") { +ohos_unittest("sec_comp_register_test") { subsystem_name = "security" part_name = "security_component" module_out_path = part_name + "/" + part_name @@ -93,8 +93,8 @@ ohos_unittest("sec_comp_report_click_without_hmac_test") { ] sources = [ - "unittest/src/location_button_sample_build.cpp", - "unittest/src/sec_comp_report_click_without_hmac_test.cpp", + "unittest/src/sec_comp_register_callback_test.cpp", + "unittest/src/test_common.cpp", ] configs = [ "${sec_comp_root_dir}/config:coverage_flags" ] cflags_cc = [ "-DHILOG_ENABLE" ] @@ -125,8 +125,8 @@ ohos_unittest("sec_comp_register_without_callback_test") { ] sources = [ - "unittest/src/location_button_sample_build.cpp", "unittest/src/sec_comp_register_without_callback_test.cpp", + "unittest/src/test_common.cpp", ] configs = [ "${sec_comp_root_dir}/config:coverage_flags" ] cflags_cc = [ "-DHILOG_ENABLE" ] @@ -158,8 +158,8 @@ ohos_unittest("sec_comp_register_challenge_test") { ] sources = [ - "unittest/src/location_button_sample_build.cpp", "unittest/src/sec_comp_register_challenge_test.cpp", + "unittest/src/test_common.cpp", ] configs = [ "${sec_comp_root_dir}/config:coverage_flags" ] cflags_cc = [ "-DHILOG_ENABLE" ] @@ -183,9 +183,9 @@ group("unittest") { testonly = true deps = [ ":sec_comp_sdk_test", + ":sec_comp_sdk_mock_test", ":sec_comp_register_challenge_test", ":sec_comp_register_test", ":sec_comp_register_without_callback_test", - ":sec_comp_report_click_without_hmac_test" ] } diff --git a/test/security_component/entry/src/main/ets/test/List.test.ets b/interfaces/inner_api/security_component/test/mock/include/sec_comp_enhance_adapter.h similarity index 45% rename from test/security_component/entry/src/main/ets/test/List.test.ets rename to interfaces/inner_api/security_component/test/mock/include/sec_comp_enhance_adapter.h index 904320805ee5cd026499cfbf1a409dde2976578e..36bbaaa5505326ec3ccfee16d805f99c58c90a87 100644 --- a/test/security_component/entry/src/main/ets/test/List.test.ets +++ b/interfaces/inner_api/security_component/test/mock/include/sec_comp_enhance_adapter.h @@ -1,28 +1,36 @@ -/** - * Copyright (c) 2023 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 pasteComponentTest from './PasteComponentTest.test.ets'; -import locationComponentTest from './LocationComponentTest.test.ets'; -import locationComponentTest_1 from './LocationComponentTest_1.test.ets'; -import saveComponentTest from './SaveComponentTest.test.ets'; -import saveComponentTest_1 from './SaveComponentTest_1.test.ets'; - -export default function testsuite() { - pasteComponentTest(); - locationComponentTest(); - locationComponentTest_1(); - saveComponentTest(); - saveComponentTest_1(); -} \ No newline at end of file +/* + * Copyright (c) 2023 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. + */ +#ifndef SECURITY_COMPONENT_ENHANCE_ADAPTER_H +#define SECURITY_COMPONENT_ENHANCE_ADAPTER_H +#include +#include "parcel.h" +#include "sec_comp_info.h" + +namespace OHOS { +namespace Security { +namespace SecurityComponent { +struct SecCompEnhanceAdapter { + static int32_t SetEnhanceCfg(uint8_t* cfg, uint32_t cfgLen); + static int32_t GetPointerEventEnhanceData(void* data, uint32_t dataLen, + uint8_t* enhanceData, uint32_t& enHancedataLen); + static int32_t CheckExtraInfo(const SecCompClickEvent& touchInfo); + + static int32_t EnableInputEnhance(); + static int32_t DisableInputEnhance(); +}; +} // namespace SecurityComponent +} // namespace Security +} // namespace OHOS +#endif // SECURITY_COMPONENT_ENHANCE_ADAPTER_H diff --git a/interfaces/inner_api/security_component/test/mock/src/sec_comp_enhance_adapter.cpp b/interfaces/inner_api/security_component/test/mock/src/sec_comp_enhance_adapter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7c5538ef39a91bf4a393e73ae15ff7bb29591ff5 --- /dev/null +++ b/interfaces/inner_api/security_component/test/mock/src/sec_comp_enhance_adapter.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2023 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. + */ +#include "sec_comp_enhance_adapter.h" +#include "sec_comp_err.h" +#include "sec_comp_log.h" + +namespace OHOS { +namespace Security { +namespace SecurityComponent { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "MockSecCompEnhanceAdapter"}; +} + +int32_t SecCompEnhanceAdapter::SetEnhanceCfg(uint8_t* cfg, uint32_t cfgLen) +{ + SC_LOG_DEBUG(LABEL, "SetEnhanceCfg success"); + return SC_OK; +} + +int32_t SecCompEnhanceAdapter::GetPointerEventEnhanceData(void* data, uint32_t dataLen, + uint8_t* enhanceData, uint32_t& enHancedataLen) +{ + SC_LOG_DEBUG(LABEL, "GetPointerEventEnhanceData success"); + return SC_OK; +} + +int32_t SecCompEnhanceAdapter::CheckExtraInfo(const SecCompClickEvent& touchInfo) +{ + SC_LOG_DEBUG(LABEL, "CheckExtraInfo success"); + return SC_OK; +} + +int32_t SecCompEnhanceAdapter::EnableInputEnhance() +{ + SC_LOG_DEBUG(LABEL, "EnableInputEnhance success"); + return SC_OK; +} + +int32_t SecCompEnhanceAdapter::DisableInputEnhance() +{ + SC_LOG_DEBUG(LABEL, "DisableInputEnhance success"); + return SC_OK; +} + +bool SecCompEnhanceAdapter::EnhanceDataPreprocess(std::string& componentInfo) +{ + SC_LOG_DEBUG(LABEL, "EnhanceDataPreprocess success"); + return true; +} + +bool SecCompEnhanceAdapter::EnhanceDataPreprocess(int32_t scId, std::string& componentInfo) +{ + SC_LOG_DEBUG(LABEL, "EnhanceDataPreprocess success"); + return true; +} + +void SecCompEnhanceAdapter::RegisterScIdEnhance(int32_t scId) +{ + SC_LOG_DEBUG(LABEL, "RegisterScIdEnhance success"); +} + +void SecCompEnhanceAdapter::UnregisterScIdEnhance(int32_t scId) +{ + SC_LOG_DEBUG(LABEL, "UnregisterScIdEnhance success"); +} + +void SecCompEnhanceAdapter::StartEnhanceService() +{ + SC_LOG_DEBUG(LABEL, "StartEnhanceService success"); +} + +void SecCompEnhanceAdapter::ExistEnhanceService() +{ + SC_LOG_DEBUG(LABEL, "ExistEnhanceService success"); +} + +void SecCompEnhanceAdapter::NotifyProcessDied(int32_t pid) +{ + SC_LOG_DEBUG(LABEL, "NotifyProcessDied success"); +} + +int32_t SecCompEnhanceAdapter::CheckComponentInfoEnhnace(int32_t pid, + std::shared_ptr& compInfo, const nlohmann::json& jsonComponent) +{ + SC_LOG_DEBUG(LABEL, "CheckComponentInfoEnhnace success"); + return SC_OK; +} + +sptr SecCompEnhanceAdapter::GetEnhanceRemoteObject() +{ + SC_LOG_DEBUG(LABEL, "GetEnhanceRemoteObject success"); + return nullptr; +} +} // namespace SecurityComponent +} // namespace Security +} // namespace OHOS diff --git a/interfaces/inner_api/security_component/test/unittest/src/location_button_test.cpp b/interfaces/inner_api/security_component/test/unittest/src/location_button_test.cpp index ef7503ae2e55710b103f182aeee5665bc329ebdf..3986fcbc7672e4918575d767b4a59c9697f58785 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/location_button_test.cpp +++ b/interfaces/inner_api/security_component/test/unittest/src/location_button_test.cpp @@ -13,9 +13,11 @@ * limitations under the License. */ #include "location_button_test.h" + #include #include "sec_comp_log.h" #include "sec_comp_err.h" +#include "test_common_param.h" using namespace testing::ext; using namespace OHOS; @@ -24,64 +26,6 @@ using namespace OHOS::Security::SecurityComponent; namespace { static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "LocationButtonTest"}; - -static const std::string WRONG_TYPE = "wrongType"; -static constexpr float TEST_SIZE = 100.0; -static constexpr double TEST_COORDINATE = 100.0; -static constexpr double TEST_DIMENSION = 100.0; -static constexpr uint32_t TEST_COLOR_YELLOW = 0x7ffff00; -static constexpr uint32_t TEST_COLOR_RED = 0xff0000; -static constexpr uint32_t TEST_COLOR_BLUE = 0x0000ff; -static constexpr uint32_t TEST_DIFF_COLOR = 0; - -static void BuildLocationComponentInfo(nlohmann::json& jsonComponent) -{ - jsonComponent[JsonTagConstants::JSON_SC_TYPE] = LOCATION_COMPONENT; - jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json { - {JsonTagConstants::JSON_RECT_X, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_Y, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_WIDTH, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_HEIGHT, TEST_COORDINATE } - }; - jsonComponent[JsonTagConstants::JSON_NODE_ID] = 0; - jsonComponent[JsonTagConstants::JSON_WINDOW_RECT] = nlohmann::json { - {JsonTagConstants::JSON_RECT_X, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_Y, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_WIDTH, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_HEIGHT, TEST_COORDINATE } - }; - nlohmann::json jsonPadding = nlohmann::json { - { JsonTagConstants::JSON_PADDING_TOP_TAG, TEST_DIMENSION }, - { JsonTagConstants::JSON_PADDING_RIGHT_TAG, TEST_DIMENSION }, - { JsonTagConstants::JSON_PADDING_BOTTOM_TAG, TEST_DIMENSION }, - { JsonTagConstants::JSON_PADDING_LEFT_TAG, TEST_DIMENSION }, - }; - - jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json { - { JsonTagConstants::JSON_FONT_SIZE_TAG, TEST_SIZE }, - { JsonTagConstants::JSON_ICON_SIZE_TAG, TEST_SIZE }, - { JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, TEST_SIZE }, - { JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding }, - }; - - jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json { - { JsonTagConstants::JSON_FONT_COLOR_TAG, TEST_COLOR_RED }, - { JsonTagConstants::JSON_ICON_COLOR_TAG, TEST_COLOR_BLUE }, - { JsonTagConstants::JSON_BG_COLOR_TAG, TEST_COLOR_YELLOW } - }; - - jsonComponent[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json { - { JsonTagConstants::JSON_BORDER_WIDTH_TAG, TEST_SIZE }, - }; - jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json { - { JsonTagConstants::JSON_PARENT_EFFECT_TAG, false }, - }; - jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json { - { JsonTagConstants::JSON_TEXT_TAG, LocationDesc::SELECT_LOCATION }, - { JsonTagConstants::JSON_ICON_TAG, LocationIcon::LINE_ICON }, - { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, - }; -} } void LocationButtonTest::SetUpTestCase() @@ -107,7 +51,7 @@ void LocationButtonTest::TearDown() HWTEST_F(LocationButtonTest, FromJson001, TestSize.Level1) { nlohmann::json jsonComponent; - BuildLocationComponentInfo(jsonComponent); + TestCommon::BuildLocationComponentInfo(jsonComponent); LocationButton comp; ASSERT_TRUE(comp.FromJson(jsonComponent)); } @@ -134,7 +78,7 @@ HWTEST_F(LocationButtonTest, FromJson002, TestSize.Level1) HWTEST_F(LocationButtonTest, FromJson003, TestSize.Level1) { nlohmann::json jsonComponent; - BuildLocationComponentInfo(jsonComponent); + TestCommon::BuildLocationComponentInfo(jsonComponent); LocationButton comp; ASSERT_TRUE(comp.FromJson(jsonComponent)); @@ -160,7 +104,7 @@ HWTEST_F(LocationButtonTest, FromJson004, TestSize.Level1) jsonComponent[JsonTagConstants::JSON_RECT] = wrongJson; ASSERT_FALSE(comp.FromJson(jsonComponent)); - BuildLocationComponentInfo(jsonComponent); + TestCommon::BuildLocationComponentInfo(jsonComponent); ASSERT_TRUE(comp.FromJson(jsonComponent)); jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json { @@ -206,7 +150,7 @@ HWTEST_F(LocationButtonTest, FromJson005, TestSize.Level1) { nlohmann::json jsonComponent; LocationButton comp; - BuildLocationComponentInfo(jsonComponent); + TestCommon::BuildLocationComponentInfo(jsonComponent); ASSERT_TRUE(comp.FromJson(jsonComponent)); nlohmann::json jsonPadding = nlohmann::json { @@ -251,7 +195,7 @@ HWTEST_F(LocationButtonTest, FromJson006, TestSize.Level1) { nlohmann::json jsonComponent; LocationButton comp; - BuildLocationComponentInfo(jsonComponent); + TestCommon::BuildLocationComponentInfo(jsonComponent); ASSERT_TRUE(comp.FromJson(jsonComponent)); nlohmann::json jsonPadding = nlohmann::json { @@ -293,7 +237,7 @@ HWTEST_F(LocationButtonTest, FromJson007, TestSize.Level1) { nlohmann::json jsonComponent; LocationButton comp; - BuildLocationComponentInfo(jsonComponent); + TestCommon::BuildLocationComponentInfo(jsonComponent); ASSERT_TRUE(comp.FromJson(jsonComponent)); nlohmann::json jsonPadding = nlohmann::json { @@ -335,7 +279,7 @@ HWTEST_F(LocationButtonTest, FromJson008, TestSize.Level1) { nlohmann::json jsonComponent; LocationButton comp; - BuildLocationComponentInfo(jsonComponent); + TestCommon::BuildLocationComponentInfo(jsonComponent); ASSERT_TRUE(comp.FromJson(jsonComponent)); jsonComponent[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json { @@ -343,7 +287,7 @@ HWTEST_F(LocationButtonTest, FromJson008, TestSize.Level1) }; ASSERT_FALSE(comp.FromJson(jsonComponent)); - BuildLocationComponentInfo(jsonComponent); + TestCommon::BuildLocationComponentInfo(jsonComponent); jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json { { JsonTagConstants::JSON_PARENT_EFFECT_TAG, WRONG_TYPE }, }; @@ -359,7 +303,7 @@ HWTEST_F(LocationButtonTest, FromJson008, TestSize.Level1) HWTEST_F(LocationButtonTest, FromJson009, TestSize.Level1) { nlohmann::json jsonComponent; - BuildLocationComponentInfo(jsonComponent); + TestCommon::BuildLocationComponentInfo(jsonComponent); LocationButton button; ASSERT_TRUE(button.FromJson(jsonComponent)); @@ -394,7 +338,7 @@ HWTEST_F(LocationButtonTest, FromJson009, TestSize.Level1) HWTEST_F(LocationButtonTest, FromJson010, TestSize.Level1) { nlohmann::json jsonComponent; - BuildLocationComponentInfo(jsonComponent); + TestCommon::BuildLocationComponentInfo(jsonComponent); LocationButton button; ASSERT_TRUE(button.FromJson(jsonComponent)); @@ -428,8 +372,8 @@ HWTEST_F(LocationButtonTest, FromJson010, TestSize.Level1) */ HWTEST_F(LocationButtonTest, FromJson011, TestSize.Level1) { -nlohmann::json jsonComponent; - BuildLocationComponentInfo(jsonComponent); + nlohmann::json jsonComponent; + TestCommon::BuildLocationComponentInfo(jsonComponent); LocationButton button; ASSERT_TRUE(button.FromJson(jsonComponent)); @@ -486,7 +430,7 @@ nlohmann::json jsonComponent; HWTEST_F(LocationButtonTest, ToJsonStr001, TestSize.Level1) { nlohmann::json jsonComponent; - BuildLocationComponentInfo(jsonComponent); + TestCommon::BuildLocationComponentInfo(jsonComponent); LocationButton button; ASSERT_TRUE(button.FromJson(jsonComponent)); @@ -502,7 +446,7 @@ HWTEST_F(LocationButtonTest, ToJsonStr001, TestSize.Level1) HWTEST_F(LocationButtonTest, CompareComponentBasicInfo001, TestSize.Level1) { nlohmann::json jsonComponent; - BuildLocationComponentInfo(jsonComponent); + TestCommon::BuildLocationComponentInfo(jsonComponent); LocationButton button; ASSERT_FALSE(button.CompareComponentBasicInfo(nullptr, true)); @@ -520,7 +464,7 @@ HWTEST_F(LocationButtonTest, CompareLocationButton001, TestSize.Level1) LocationButton button2; nlohmann::json jsonComponent; - BuildLocationComponentInfo(jsonComponent); + TestCommon::BuildLocationComponentInfo(jsonComponent); ASSERT_TRUE(button1.FromJson(jsonComponent)); ASSERT_TRUE(button2.FromJson(jsonComponent)); @@ -551,7 +495,7 @@ HWTEST_F(LocationButtonTest, CompareLocationButton002, TestSize.Level1) { nlohmann::json jsonComponent; LocationButton comp1; - BuildLocationComponentInfo(jsonComponent); + TestCommon::BuildLocationComponentInfo(jsonComponent); ASSERT_TRUE(comp1.FromJson(jsonComponent)); LocationButton comp2 = comp1; diff --git a/interfaces/inner_api/security_component/test/unittest/src/paste_button_test.cpp b/interfaces/inner_api/security_component/test/unittest/src/paste_button_test.cpp index 625c4acebcd80e1432943020717745b1498cfab3..78428b8ee3056440e1a5f2d486ecae41b46210c6 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/paste_button_test.cpp +++ b/interfaces/inner_api/security_component/test/unittest/src/paste_button_test.cpp @@ -13,9 +13,11 @@ * limitations under the License. */ #include "paste_button_test.h" + #include #include "sec_comp_err.h" #include "sec_comp_log.h" +#include "test_common_param.h" using namespace testing::ext; using namespace OHOS; @@ -24,64 +26,6 @@ using namespace OHOS::Security::SecurityComponent; namespace { static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "PasteButtonTest"}; - -static const std::string WRONG_TYPE = "wrongType"; -static constexpr float TEST_SIZE = 100.0; -static constexpr double TEST_COORDINATE = 100.0; -static constexpr double TEST_DIMENSION = 100.0; -static constexpr uint32_t TEST_COLOR_YELLOW = 0x7ffff00; -static constexpr uint32_t TEST_COLOR_RED = 0xff0000; -static constexpr uint32_t TEST_COLOR_BLUE = 0x0000ff; -static constexpr uint32_t TEST_DIFF_COLOR = 0; - -static void BuildPasteComponentInfo(nlohmann::json& jsonComponent) -{ - jsonComponent[JsonTagConstants::JSON_SC_TYPE] = PASTE_COMPONENT; - jsonComponent[JsonTagConstants::JSON_NODE_ID] = 0; - jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json { - {JsonTagConstants::JSON_RECT_X, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_Y, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_WIDTH, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_HEIGHT, TEST_COORDINATE } - }; - jsonComponent[JsonTagConstants::JSON_WINDOW_RECT] = nlohmann::json { - {JsonTagConstants::JSON_RECT_X, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_Y, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_WIDTH, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_HEIGHT, TEST_COORDINATE } - }; - nlohmann::json jsonPadding = nlohmann::json { - { JsonTagConstants::JSON_PADDING_TOP_TAG, TEST_DIMENSION }, - { JsonTagConstants::JSON_PADDING_RIGHT_TAG, TEST_DIMENSION }, - { JsonTagConstants::JSON_PADDING_BOTTOM_TAG, TEST_DIMENSION }, - { JsonTagConstants::JSON_PADDING_LEFT_TAG, TEST_DIMENSION }, - }; - - jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json { - { JsonTagConstants::JSON_FONT_SIZE_TAG, TEST_SIZE }, - { JsonTagConstants::JSON_ICON_SIZE_TAG, TEST_SIZE }, - { JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, TEST_SIZE }, - { JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding }, - }; - - jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json { - { JsonTagConstants::JSON_FONT_COLOR_TAG, TEST_COLOR_RED }, - { JsonTagConstants::JSON_ICON_COLOR_TAG, TEST_COLOR_BLUE }, - { JsonTagConstants::JSON_BG_COLOR_TAG, TEST_COLOR_YELLOW } - }; - - jsonComponent[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json { - { JsonTagConstants::JSON_BORDER_WIDTH_TAG, TEST_SIZE }, - }; - jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json { - { JsonTagConstants::JSON_PARENT_EFFECT_TAG, false }, - }; - jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json { - { JsonTagConstants::JSON_TEXT_TAG, PasteDesc::PASTE }, - { JsonTagConstants::JSON_ICON_TAG, PasteIcon::LINE_ICON }, - { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, - }; -} } void PasteButtonTest::SetUpTestCase() @@ -106,8 +50,8 @@ void PasteButtonTest::TearDown() */ HWTEST_F(PasteButtonTest, FromJson010, TestSize.Level1) { -nlohmann::json jsonComponent; - BuildPasteComponentInfo(jsonComponent); + nlohmann::json jsonComponent; + TestCommon::BuildPasteComponentInfo(jsonComponent); PasteButton button; ASSERT_TRUE(button.FromJson(jsonComponent)); @@ -167,7 +111,7 @@ HWTEST_F(PasteButtonTest, ComparePasteButton001, TestSize.Level1) PasteButton button2; nlohmann::json jsonComponent; - BuildPasteComponentInfo(jsonComponent); + TestCommon::BuildPasteComponentInfo(jsonComponent); ASSERT_TRUE(button1.FromJson(jsonComponent)); ASSERT_TRUE(button2.FromJson(jsonComponent)); @@ -198,7 +142,7 @@ HWTEST_F(PasteButtonTest, ComparePasteButton002, TestSize.Level1) { nlohmann::json jsonComponent; PasteButton comp1; - BuildPasteComponentInfo(jsonComponent); + TestCommon::BuildPasteComponentInfo(jsonComponent); ASSERT_TRUE(comp1.FromJson(jsonComponent)); PasteButton comp2 = comp1; @@ -251,4 +195,4 @@ HWTEST_F(PasteButtonTest, ComparePasteButton002, TestSize.Level1) comp1.iconColor_.value = TEST_COLOR_BLUE; ASSERT_TRUE(comp1.CompareComponentBasicInfo(&comp2, true)); -} \ No newline at end of file +} diff --git a/interfaces/inner_api/security_component/test/unittest/src/save_button_test.cpp b/interfaces/inner_api/security_component/test/unittest/src/save_button_test.cpp index 8771c78b7015ac2b04dc478cefe19c7f35b27ec6..fd7a62fafebfb6145303bda073ac11f9c6bacefe 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/save_button_test.cpp +++ b/interfaces/inner_api/security_component/test/unittest/src/save_button_test.cpp @@ -13,9 +13,11 @@ * limitations under the License. */ #include "save_button_test.h" + #include #include "sec_comp_log.h" #include "sec_comp_err.h" +#include "test_common_param.h" using namespace testing::ext; using namespace OHOS; @@ -24,63 +26,6 @@ using namespace OHOS::Security::SecurityComponent; namespace { static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SaveButtonTest"}; - -static constexpr float TEST_SIZE = 100.0; -static constexpr double TEST_COORDINATE = 100.0; -static constexpr double TEST_DIMENSION = 100.0; -static constexpr uint32_t TEST_COLOR_YELLOW = 0x7ffff00; -static constexpr uint32_t TEST_COLOR_RED = 0xff0000; -static constexpr uint32_t TEST_COLOR_BLUE = 0x0000ff; -static constexpr uint32_t TEST_DIFF_COLOR = 0; - -static void BuildSaveComponentInfo(nlohmann::json& jsonComponent) -{ - jsonComponent[JsonTagConstants::JSON_SC_TYPE] = SAVE_COMPONENT; - jsonComponent[JsonTagConstants::JSON_NODE_ID] = 0; - jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json { - {JsonTagConstants::JSON_RECT_X, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_Y, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_WIDTH, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_HEIGHT, TEST_COORDINATE } - }; - jsonComponent[JsonTagConstants::JSON_WINDOW_RECT] = nlohmann::json { - {JsonTagConstants::JSON_RECT_X, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_Y, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_WIDTH, TEST_COORDINATE }, - {JsonTagConstants::JSON_RECT_HEIGHT, TEST_COORDINATE } - }; - nlohmann::json jsonPadding = nlohmann::json { - { JsonTagConstants::JSON_PADDING_TOP_TAG, TEST_DIMENSION }, - { JsonTagConstants::JSON_PADDING_RIGHT_TAG, TEST_DIMENSION }, - { JsonTagConstants::JSON_PADDING_BOTTOM_TAG, TEST_DIMENSION }, - { JsonTagConstants::JSON_PADDING_LEFT_TAG, TEST_DIMENSION }, - }; - - jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json { - { JsonTagConstants::JSON_FONT_SIZE_TAG, TEST_SIZE }, - { JsonTagConstants::JSON_ICON_SIZE_TAG, TEST_SIZE }, - { JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, TEST_SIZE }, - { JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding }, - }; - - jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json { - { JsonTagConstants::JSON_FONT_COLOR_TAG, TEST_COLOR_RED }, - { JsonTagConstants::JSON_ICON_COLOR_TAG, TEST_COLOR_BLUE }, - { JsonTagConstants::JSON_BG_COLOR_TAG, TEST_COLOR_YELLOW } - }; - - jsonComponent[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json { - { JsonTagConstants::JSON_BORDER_WIDTH_TAG, TEST_SIZE }, - }; - jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json { - { JsonTagConstants::JSON_PARENT_EFFECT_TAG, false }, - }; - jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json { - { JsonTagConstants::JSON_TEXT_TAG, SaveDesc::DOWNLOAD }, - { JsonTagConstants::JSON_ICON_TAG, SaveIcon::LINE_ICON }, - { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, - }; -} } void SaveButtonTest::SetUpTestCase() @@ -105,8 +50,8 @@ void SaveButtonTest::TearDown() */ HWTEST_F(SaveButtonTest, FromJson010, TestSize.Level1) { -nlohmann::json jsonComponent; - BuildSaveComponentInfo(jsonComponent); + nlohmann::json jsonComponent; + TestCommon::BuildSaveComponentInfo(jsonComponent); SaveButton button; ASSERT_TRUE(button.FromJson(jsonComponent)); @@ -166,7 +111,7 @@ HWTEST_F(SaveButtonTest, CompareSaveButton001, TestSize.Level1) SaveButton button2; nlohmann::json jsonComponent; - BuildSaveComponentInfo(jsonComponent); + TestCommon::BuildSaveComponentInfo(jsonComponent); ASSERT_TRUE(button1.FromJson(jsonComponent)); ASSERT_TRUE(button2.FromJson(jsonComponent)); @@ -197,7 +142,7 @@ HWTEST_F(SaveButtonTest, CompareSaveButton002, TestSize.Level1) { nlohmann::json jsonComponent; SaveButton comp1; - BuildSaveComponentInfo(jsonComponent); + TestCommon::BuildSaveComponentInfo(jsonComponent); ASSERT_TRUE(comp1.FromJson(jsonComponent)); SaveButton comp2 = comp1; @@ -250,4 +195,4 @@ HWTEST_F(SaveButtonTest, CompareSaveButton002, TestSize.Level1) comp1.iconColor_.value = TEST_COLOR_BLUE; ASSERT_TRUE(comp1.CompareComponentBasicInfo(&comp2, true)); -} \ No newline at end of file +} diff --git a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_mock_test.cpp b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_mock_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..209f86462abfdf472ea123834125626854d047b3 --- /dev/null +++ b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_mock_test.cpp @@ -0,0 +1,298 @@ +/* + * Copyright (c) 2023 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. + */ +#include "sec_comp_service_test.h" +#include "ipc_skeleton.h" +#include "iservice_registry.h" +#include "location_button.h" +#include "mock_system_ability_proxy.h" +#include "mock_app_mgr_proxy.h" +#include "paste_button.h" +#include "save_button.h" +#include "sec_comp_err.h" +#include "sec_comp_log.h" +#include "sec_comp_tool.h" +#include "sec_comp_enhance_adapter.h" +#include "system_ability.h" +#include "test_common_param.h" +#include "token_setproc.h" + +using namespace testing::ext; +using namespace OHOS; +using namespace OHOS::Security::SecurityComponent; +using namespace OHOS::Security::AccessToken; + +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompServiceTest"}; +// static AccessTokenID g_selfTokenId = 0; +} + +void SecCompServiceTest::SetUpTestCase() +{} + +void SecCompServiceTest::TearDownTestCase() +{} + +void SecCompServiceTest::SetUp() +{ + SC_LOG_INFO(LABEL, "setup"); + // if (secCompService_ != nullptr) { + // return; + // } + // SecCompService* ptr = new (std::nothrow) SecCompService(SA_ID, true); + // secCompService_ = sptr(ptr); + // ASSERT_NE(nullptr, secCompService_); + // secCompService_->appStateObserver_ = new (std::nothrow) AppStateObserver(); + // ASSERT_TRUE(secCompService_->appStateObserver_ != nullptr); + // g_selfTokenId = GetSelfTokenID(); +} + +void SecCompServiceTest::TearDown() +{ + // if (secCompService_ != nullptr) { + // secCompService_->appStateObserver_ = nullptr; + // } + // secCompService_ = nullptr; + // EXPECT_EQ(0, SetSelfTokenID(g_selfTokenId)); +} + +/** + * @tc.name: RegisterSecurityComponent001 + * @tc.desc: Test register security component check touch info failed + * @tc.type: FUNC + * @tc.require: AR000HO9J7 + */ +HWTEST_F(SecCompServiceTest, RegisterSecurityComponent001, TestSize.Level1) +{ + nlohmann::json jsonRes; + TestCommon::BuildSaveComponentInfo(jsonRes); + std::string saveInfo = jsonRes.dump(); + int32_t scId; + // secCompService_->state_ = ServiceRunningState::STATE_RUNNING; + // secCompService_->Initialize(); + + // ASSERT_EQ(SetSelfTokenID(HAP_TOKEN_ID), 0); + // AppExecFwk::AppStateData stateData = { + // .uid = getuid() + // }; + // secCompService_->appStateObserver_->AddProcessToForegroundSet(stateData); + // register security component ok + EXPECT_EQ(secCompService_->RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId), + SC_OK); + struct SecCompClickEvent touch = { + .touchX = 100, + .touchY = 100, + .timestamp = static_cast( + std::chrono::high_resolution_clock::now().time_since_epoch().count()) + }; + EXPECT_EQ(secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touch, nullptr), + SC_SERVICE_ERROR_CLICK_EVENT_INVALID); + EXPECT_EQ(secCompService_->UnregisterSecurityComponent(scId), SC_OK); +} + +/** + * @tc.name: RegisterSecurityComponent002 + * @tc.desc: Test register security component permission grant failed + * @tc.type: FUNC + * @tc.require: AR000HO9J7 + */ +HWTEST_F(SecCompServiceTest, RegisterSecurityComponent002, TestSize.Level1) +{ + nlohmann::json jsonRes; + TestCommon::BuildSaveComponentInfo(jsonRes); + std::string saveInfo = jsonRes.dump(); + int32_t scId; + // secCompService_->state_ = ServiceRunningState::STATE_RUNNING; + // secCompService_->Initialize(); + + // ASSERT_EQ(SetSelfTokenID(0), 0); + // AppExecFwk::AppStateData stateData = { + // .uid = getuid() + // }; + secCompService_->appStateObserver_->AddProcessToForegroundSet(stateData); + // register security component ok + EXPECT_EQ(secCompService_->RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId), + SC_OK); + struct SecCompClickEvent touch = { + .touchX = 100, + .touchY = 100, + .timestamp = static_cast( + std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TIME_CONVERSION_UNIT + }; + EXPECT_EQ(secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touch, nullptr), + SC_SERVICE_ERROR_PERMISSION_OPER_FAIL); + EXPECT_EQ(secCompService_->UnregisterSecurityComponent(scId), SC_OK); +} + +/** + * @tc.name: ReportSecurityComponentClickEvent003 + * @tc.desc: Test register security component + * @tc.type: FUNC + * @tc.require: AR000HO9J7 + */ +HWTEST_F(SecCompServiceTest, ReportSecurityComponentClickEvent003, TestSize.Level1) +{ + nlohmann::json jsonRes; + TestCommon::BuildSaveComponentInfo(jsonRes); + std::string saveInfo = jsonRes.dump(); + int32_t scId; + // secCompService_->state_ = ServiceRunningState::STATE_RUNNING; + // secCompService_->Initialize(); + + // ASSERT_EQ(SetSelfTokenID(HAP_TOKEN_ID), 0); + // AppExecFwk::AppStateData stateData = { + // .uid = getuid() + // }; + // secCompService_->appStateObserver_->AddProcessToForegroundSet(stateData); + // register security component ok + EXPECT_EQ(secCompService_->RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId), + SC_OK); + struct SecCompClickEvent touchInfo = { + .touchX = 100, + .touchY = 100, + .timestamp = static_cast( + std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TIME_CONVERSION_UNIT + }; + + ASSERT_EQ(SC_OK, + secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr)); + + ASSERT_TRUE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); + + ASSERT_FALSE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); + + ASSERT_EQ(secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr), + SC_OK); + sleep(6); + ASSERT_FALSE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); + EXPECT_EQ(secCompService_->UnregisterSecurityComponent(scId), SC_OK); +} + +/** + * @tc.name: ReportSecurityComponentClickEvent004 + * @tc.desc: Test report security component click with save button + * @tc.type: FUNC + * @tc.require: AR000HO9IN + */ +HWTEST_F(SecCompServiceTest, ReportSecurityComponentClickEvent004, TestSize.Level1) +{ + nlohmann::json jsonRes; + TestCommon::BuildSaveComponentInfo(jsonRes); + std::string saveInfo = jsonRes.dump(); + int32_t scId; + // secCompService_->state_ = ServiceRunningState::STATE_RUNNING; + // secCompService_->Initialize(); + + // ASSERT_EQ(SetSelfTokenID(HAP_TOKEN_ID), 0); + // AppExecFwk::AppStateData stateData = { + // .uid = getuid() + // }; + secCompService_->appStateObserver_->AddProcessToForegroundSet(stateData); + // register security component ok + EXPECT_EQ(secCompService_->RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId), + SC_OK); + struct SecCompClickEvent touchInfo = { + .touchX = 100, + .touchY = 100, + .timestamp = static_cast( + std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TIME_CONVERSION_UNIT + }; + + ASSERT_EQ(secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr), + SC_OK); + ASSERT_EQ(secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr), + SC_OK); + + ASSERT_TRUE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); + ASSERT_TRUE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); + ASSERT_FALSE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); + + ASSERT_EQ(secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr), + SC_OK); + sleep(3); + touchInfo.timestamp = static_cast( + std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TIME_CONVERSION_UNIT; + ASSERT_EQ(secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr), + SC_OK); + sleep(3); + ASSERT_TRUE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); + ASSERT_FALSE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); + + touchInfo.timestamp = static_cast( + std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TIME_CONVERSION_UNIT; + ASSERT_EQ(secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr), + SC_OK); + sleep(3); + touchInfo.timestamp = static_cast( + std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TIME_CONVERSION_UNIT;; + ASSERT_EQ(secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr), + SC_OK); + ASSERT_TRUE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); + sleep(3); + ASSERT_TRUE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); + ASSERT_FALSE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); +} + +/** + * @tc.name: ReportSecurityComponentClickEvent005 + * @tc.desc: Test report security component click twice with save button + * @tc.type: FUNC + * @tc.require: AR000HO9J7 + */ +HWTEST_F(SecCompServiceTest, ReportSecurityComponentClickEvent005, TestSize.Level1) +{ + nlohmann::json jsonRes; + TestCommon::BuildSaveComponentInfo(jsonRes); + std::string saveInfo = jsonRes.dump(); + int32_t scId; + // secCompService_->state_ = ServiceRunningState::STATE_RUNNING; + // secCompService_->Initialize(); + + // ASSERT_EQ(SetSelfTokenID(HAP_TOKEN_ID), 0); + // AppExecFwk::AppStateData stateData = { + // .uid = getuid() + // }; + // secCompService_->appSta2teObserver_->AddProcessToForegroundSet(stateData); + // register security component ok + EXPECT_EQ(secCompService_->RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId), + SC_OK); + struct SecCompClickEvent touchInfo = { + .touchX = 100, + .touchY = 100, + .timestamp = static_cast( + std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TIME_CONVERSION_UNIT + }; + + ASSERT_EQ(secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr), + SC_OK); + sleep(3); + touchInfo.timestamp = static_cast( + std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TIME_CONVERSION_UNIT; + ASSERT_EQ(secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr), + SC_OK); + sleep(6); + ASSERT_FALSE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); + + touchInfo.timestamp = static_cast( + std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TIME_CONVERSION_UNIT; + ASSERT_EQ(secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr), + SC_OK); + ASSERT_TRUE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); + ASSERT_EQ(secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr), + SC_OK); + sleep(3); + ASSERT_TRUE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); + ASSERT_FALSE(secCompService_->ReduceAfterVerifySavePermission(HAP_TOKEN_ID)); +} diff --git a/interfaces/inner_api/security_component/test/unittest/src/location_button_sample_build.h b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_mock_test.h similarity index 69% rename from interfaces/inner_api/security_component/test/unittest/src/location_button_sample_build.h rename to interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_mock_test.h index 9bde8927e0d48848b3093570ffddce1dadfe6c5a..3bd124102c671cb161bfa59bced2f511397809f5 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/location_button_sample_build.h +++ b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_mock_test.h @@ -12,20 +12,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef SECURITY_COMPONENT_KIT_TEST +#define SECURITY_COMPONENT_KIT_TEST -#ifndef LOCATION_BUTTON_SAMPLE_BUILD_H -#define LOCATION_BUTTON_SAMPLE_BUILD_H -#include "location_button.h" +#include +#include "sec_comp_kit.h" namespace OHOS { namespace Security { namespace SecurityComponent { - -class LocationButtonSampleBuild { +class SecCompKitTest : public testing::Test { public: - static void BuildLocationComponentInfo(nlohmann::json& jsonComponent); + static void SetUpTestCase(); + + static void TearDownTestCase(); + + void SetUp() override; + + void TearDown() override; }; } // namespace SecurityComponent } // namespace Security } // namespace OHOS -#endif // LOCATION_BUTTON_SAMPLE_BUILD_H +#endif // SECURITY_COMPONENT_KIT_TEST \ No newline at end of file diff --git a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp index c43a610b1d2d319ad2966ca12c99be41b0a4f9c0..3534cd1c7847ce0c4e292ae68cf52b1fbcda067e 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp +++ b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ #include "sec_comp_kit_test.h" + #include "location_button.h" #define private public #include "sec_comp_caller_authorization.h" @@ -21,6 +22,7 @@ #include "sec_comp_info.h" #include "sec_comp_log.h" #include "sec_comp_tool.h" +#include "test_common_param.h" using namespace testing::ext; using namespace OHOS::Security::SecurityComponent; @@ -28,11 +30,6 @@ using namespace OHOS::Security::SecurityComponent; namespace { static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompKitTest"}; -static constexpr float TEST_SIZE = 100.0; -static constexpr double TEST_COORDINATE = 100.0; -static constexpr double TEST_DIMENSION = 100.0; -static constexpr uint32_t TEST_COLOR = 0xffffffff; -static constexpr size_t MAX_CALLER_SIZE = 10; static void TestInCallerNotCheckList() { @@ -174,4 +171,3 @@ HWTEST_F(SecCompKitTest, TestCallerCheck002, TestSize.Level1) SecCompCallerAuthorization::GetInstance().kitCallerList_.clear(); SecCompCallerAuthorization::GetInstance().isInit_ = false; } - diff --git a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp index e90704811ea325c66b05057c6b7e50c60a3d5342..03bda10f65fd659c283df95a69d38ec067e1b6e0 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp +++ b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp @@ -13,7 +13,6 @@ * limitations under the License. */ #include - #include "i_sec_comp_probe.h" #include "location_button.h" #include "location_button_sample_build.h" @@ -26,6 +25,7 @@ #include "sec_comp_log.h" #include "sec_comp_tool.h" #include "sec_comp_ui_register.h" +#include "test_common_param.h" using namespace testing::ext; using namespace OHOS::Security::SecurityComponent; @@ -97,7 +97,7 @@ HWTEST_F(SecCompRegisterCallbackTest, Register001, TestSize.Level1) { SC_LOG_INFO(LABEL, "Register001."); nlohmann::json jsonRes; - LocationButtonSampleBuild::BuildLocationComponentInfo(jsonRes); + TestCommon::BuildLocationComponentInfo(jsonRes); std::string locationInfo = jsonRes.dump(); g_probe.mockComponentInfo = locationInfo; g_probe.mockRes = 0; @@ -120,7 +120,7 @@ HWTEST_F(SecCompRegisterCallbackTest, Register002, TestSize.Level1) SC_LOG_INFO(LABEL, "Register002."); nlohmann::json jsonRes; - LocationButtonSampleBuild::BuildLocationComponentInfo(jsonRes); + TestCommon::BuildLocationComponentInfo(jsonRes); std::string locationInfo = jsonRes.dump(); g_probe.mockComponentInfo = locationInfo; g_probe.mockRes = -1; @@ -142,7 +142,7 @@ HWTEST_F(SecCompRegisterCallbackTest, Register003, TestSize.Level1) SC_LOG_INFO(LABEL, "Register003."); nlohmann::json jsonRes; - LocationButtonSampleBuild::BuildLocationComponentInfo(jsonRes); + TestCommon::BuildLocationComponentInfo(jsonRes); std::string locationInfo = jsonRes.dump(); g_probe.mockComponentInfo = locationInfo; g_probe.mockRes = 0; @@ -150,4 +150,3 @@ HWTEST_F(SecCompRegisterCallbackTest, Register003, TestSize.Level1) int32_t scId; ASSERT_EQ(SC_OK, SecCompKit::RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId)); } - diff --git a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_challenge_test.cpp b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_challenge_test.cpp index c7e0273d2e504e8419e657370e747579e1456c9b..3a319522a760af532a3981b5c197d844e8ac609e 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_challenge_test.cpp +++ b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_challenge_test.cpp @@ -13,7 +13,6 @@ * limitations under the License. */ #include - #include "i_sec_comp_probe.h" #include "location_button.h" #include "location_button_sample_build.h" @@ -28,6 +27,7 @@ #include "sec_comp_log.h" #include "sec_comp_tool.h" #include "sec_comp_ui_register.h" +#include "test_common_param.h" using namespace testing::ext; using namespace OHOS::Security::SecurityComponent; @@ -99,7 +99,7 @@ void SecCompRegisterChallengeTest::TearDown() HWTEST_F(SecCompRegisterChallengeTest, RegisterWithoutPreprocess001, TestSize.Level1) { nlohmann::json jsonRes; - LocationButtonSampleBuild::BuildLocationComponentInfo(jsonRes); + TestCommon::BuildLocationComponentInfo(jsonRes); std::string locationInfo = jsonRes.dump(); SecCompEnhanceAdapter::InitEnhanceHandler(SEC_COMP_ENHANCE_CLIENT_INTERFACE); @@ -109,3 +109,30 @@ HWTEST_F(SecCompRegisterChallengeTest, RegisterWithoutPreprocess001, TestSize.Le ASSERT_EQ(-1, scId); } +/** + * @tc.name: ReportClickWithoutHmac001 + * @tc.desc: test report click event without hmac data + * @tc.type: FUNC + * @tc.require: AR000HO9JM + */ +HWTEST_F(SecCompReportClickWithoutHmacTest, ReportClickWithoutHmac001, TestSize.Level1) +{ + system("param set sec.comp.enhance 1"); + nlohmann::json jsonRes; + TestCommon::BuildLocationComponentInfo(jsonRes); + std::string locationInfo = jsonRes.dump(); + g_probe.mockComponentInfo = locationInfo; + g_probe.mockRes = 0; + + int32_t scId; + ASSERT_EQ(SC_OK, SecCompKit::RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId)); + ASSERT_NE(-1, scId); + + struct SecCompClickEvent touch = { + .touchX = TEST_COORDINATE, + .touchY = TEST_COORDINATE, + .timestamp = static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()) + }; + EXPECT_EQ(SC_OK, SecCompKit::ReportSecurityComponentClickEvent(scId, locationInfo, touch, nullptr)); + system("param set sec.comp.enhance 0"); +} diff --git a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_without_callback_test.cpp b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_without_callback_test.cpp index 8c835ca8521ca52f5f360f7c0853b9adfc95579e..3b2213c6cc707935f8badf5893667fcbad615237 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_without_callback_test.cpp +++ b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_without_callback_test.cpp @@ -26,6 +26,7 @@ #include "sec_comp_log.h" #include "sec_comp_tool.h" #include "sec_comp_ui_register.h" +#include "test_common_param.h" using namespace testing::ext; using namespace OHOS::Security::SecurityComponent; @@ -84,7 +85,7 @@ void SecCompRegisterWithoutCallbackTest::TearDown() HWTEST_F(SecCompRegisterWithoutCallbackTest, RegisterWithoutCallback001, TestSize.Level1) { nlohmann::json jsonRes; - LocationButtonSampleBuild::BuildLocationComponentInfo(jsonRes); + TestCommon::BuildLocationComponentInfo(jsonRes); std::string locationInfo = jsonRes.dump(); int32_t scId; @@ -102,7 +103,7 @@ HWTEST_F(SecCompRegisterWithoutCallbackTest, RegisterWithoutCallback001, TestSiz HWTEST_F(SecCompRegisterWithoutCallbackTest, RegisterWithoutCallback002, TestSize.Level1) { nlohmann::json jsonRes; - LocationButtonSampleBuild::BuildLocationComponentInfo(jsonRes); + TestCommon::BuildLocationComponentInfo(jsonRes); std::string locationInfo = jsonRes.dump(); int32_t scId; diff --git a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_report_click_without_hmac_test.cpp b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_report_click_without_hmac_test.cpp deleted file mode 100644 index 7c59fb21f0f2ea7afe8ae55b58914352a7197e29..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_report_click_without_hmac_test.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ -#include - -#include "i_sec_comp_probe.h" -#include "location_button.h" -#include "location_button_sample_build.h" -#define private public -#include "sec_comp_caller_authorization.h" -#undef private -#include "sec_comp_err.h" -#include "sec_comp_info.h" -#include "sec_comp_kit.h" -#include "sec_comp_log.h" -#include "sec_comp_tool.h" -#include "sec_comp_ui_register.h" - -using namespace testing::ext; -using namespace OHOS::Security::SecurityComponent; - -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompReportClickWithoutHmacTest"}; -static constexpr double TEST_COORDINATE = 100.0; - -class MockUiSecCompProbe : public ISecCompProbe { -public: - int32_t GetComponentInfo(int32_t nodeId, std::string& componentInfo) override - { - componentInfo = mockComponentInfo; - return mockRes; - } - std::string mockComponentInfo; - int32_t mockRes; -}; - -static MockUiSecCompProbe g_probe; -static void InitUiRegister() -{ - std::vector callerList; - SecCompUiRegister registerCallback(callerList, &g_probe); - SecCompCallerAuthorization::GetInstance().kitCallerList_.clear(); - SecCompCallerAuthorization::GetInstance().isInit_ = false; -} -} // namespace - -class SecCompReportClickWithoutHmacTest : public testing::Test { -public: - static void SetUpTestCase(); - - static void TearDownTestCase(); - - void SetUp() override; - - void TearDown() override; -}; - -void SecCompReportClickWithoutHmacTest::SetUpTestCase() -{ - InitUiRegister(); - SC_LOG_INFO(LABEL, "SecCompReportClickWithoutHmacTest."); -} - -void SecCompReportClickWithoutHmacTest::TearDownTestCase() -{ - SC_LOG_INFO(LABEL, "SecCompReportClickWithoutHmacTest."); -} - -void SecCompReportClickWithoutHmacTest::SetUp() -{ - SC_LOG_INFO(LABEL, "SetUp ok."); -} - -void SecCompReportClickWithoutHmacTest::TearDown() -{ - SC_LOG_INFO(LABEL, "TearDown."); -} - -/** - * @tc.name: ReportClickWithoutHmac001 - * @tc.desc: test report click event without hmac data - * @tc.type: FUNC - * @tc.require: AR000HO9JM - */ -HWTEST_F(SecCompReportClickWithoutHmacTest, ReportClickWithoutHmac001, TestSize.Level1) -{ - nlohmann::json jsonRes; - LocationButtonSampleBuild::BuildLocationComponentInfo(jsonRes); - std::string locationInfo = jsonRes.dump(); - g_probe.mockComponentInfo = locationInfo; - g_probe.mockRes = 0; - - int32_t scId; - ASSERT_EQ(SC_OK, SecCompKit::RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId)); - ASSERT_NE(-1, scId); - - struct SecCompClickEvent touch = { - .touchX = TEST_COORDINATE, - .touchY = TEST_COORDINATE, - .timestamp = static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()) - }; - EXPECT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, - SecCompKit::ReportSecurityComponentClickEvent(scId, locationInfo, touch, nullptr)); -} diff --git a/interfaces/inner_api/security_component/test/unittest/src/location_button_sample_build.cpp b/interfaces/inner_api/security_component/test/unittest/src/test_common.cpp similarity index 38% rename from interfaces/inner_api/security_component/test/unittest/src/location_button_sample_build.cpp rename to interfaces/inner_api/security_component/test/unittest/src/test_common.cpp index 6cdb68d20c056bf4f20a045acdc622b826481606..862d3829e2ad002342628668c5215bb098808bf0 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/location_button_sample_build.cpp +++ b/interfaces/inner_api/security_component/test/unittest/src/test_common.cpp @@ -12,20 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "location_button_sample_build.h" +#include "test_common.h" namespace OHOS { namespace Security { namespace SecurityComponent { -static const std::string WRONG_TYPE = "wrongType"; -static constexpr float TEST_SIZE = 100.0; -static constexpr double TEST_COORDINATE = 100.0; -static constexpr double TEST_DIMENSION = 100.0; -static constexpr uint32_t TEST_COLOR_YELLOW = 0xffffff00; -static constexpr uint32_t TEST_COLOR_RED = 0xffff0000; -static constexpr uint32_t TEST_COLOR_BLUE = 0xff0000ff; -void LocationButtonSampleBuild::BuildLocationComponentInfo(nlohmann::json& jsonComponent) +void TestCommon::BuildLocationComponentInfo(nlohmann::json& jsonComponent) { jsonComponent[JsonTagConstants::JSON_SC_TYPE] = LOCATION_COMPONENT; jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json { @@ -73,6 +66,104 @@ void LocationButtonSampleBuild::BuildLocationComponentInfo(nlohmann::json& jsonC { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, }; } + +void TestCommon::BuildSaveComponentInfo(nlohmann::json& jsonComponent) +{ + jsonComponent[JsonTagConstants::JSON_SC_TYPE] = SAVE_COMPONENT; + jsonComponent[JsonTagConstants::JSON_NODE_ID] = 0; + jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json { + {JsonTagConstants::JSON_RECT_X, TEST_COORDINATE }, + {JsonTagConstants::JSON_RECT_Y, TEST_COORDINATE }, + {JsonTagConstants::JSON_RECT_WIDTH, TEST_COORDINATE }, + {JsonTagConstants::JSON_RECT_HEIGHT, TEST_COORDINATE } + }; + jsonComponent[JsonTagConstants::JSON_WINDOW_RECT] = nlohmann::json { + {JsonTagConstants::JSON_RECT_X, TEST_COORDINATE }, + {JsonTagConstants::JSON_RECT_Y, TEST_COORDINATE }, + {JsonTagConstants::JSON_RECT_WIDTH, TEST_COORDINATE }, + {JsonTagConstants::JSON_RECT_HEIGHT, TEST_COORDINATE } + }; + nlohmann::json jsonPadding = nlohmann::json { + { JsonTagConstants::JSON_PADDING_TOP_TAG, TEST_DIMENSION }, + { JsonTagConstants::JSON_PADDING_RIGHT_TAG, TEST_DIMENSION }, + { JsonTagConstants::JSON_PADDING_BOTTOM_TAG, TEST_DIMENSION }, + { JsonTagConstants::JSON_PADDING_LEFT_TAG, TEST_DIMENSION }, + }; + + jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json { + { JsonTagConstants::JSON_FONT_SIZE_TAG, TEST_SIZE }, + { JsonTagConstants::JSON_ICON_SIZE_TAG, TEST_SIZE }, + { JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, TEST_SIZE }, + { JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding }, + }; + + jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json { + { JsonTagConstants::JSON_FONT_COLOR_TAG, TEST_COLOR_RED }, + { JsonTagConstants::JSON_ICON_COLOR_TAG, TEST_COLOR_BLUE }, + { JsonTagConstants::JSON_BG_COLOR_TAG, TEST_COLOR_YELLOW } + }; + + jsonComponent[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json { + { JsonTagConstants::JSON_BORDER_WIDTH_TAG, TEST_SIZE }, + }; + jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json { + { JsonTagConstants::JSON_PARENT_EFFECT_TAG, false }, + }; + jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json { + { JsonTagConstants::JSON_TEXT_TAG, SaveDesc::DOWNLOAD }, + { JsonTagConstants::JSON_ICON_TAG, SaveIcon::LINE_ICON }, + { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, + }; +} + +void TestCommon::BuildPasteComponentInfo(nlohmann::json& jsonComponent) +{ + jsonComponent[JsonTagConstants::JSON_SC_TYPE] = PASTE_COMPONENT; + jsonComponent[JsonTagConstants::JSON_NODE_ID] = 0; + jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json { + {JsonTagConstants::JSON_RECT_X, TEST_COORDINATE }, + {JsonTagConstants::JSON_RECT_Y, TEST_COORDINATE }, + {JsonTagConstants::JSON_RECT_WIDTH, TEST_COORDINATE }, + {JsonTagConstants::JSON_RECT_HEIGHT, TEST_COORDINATE } + }; + jsonComponent[JsonTagConstants::JSON_WINDOW_RECT] = nlohmann::json { + {JsonTagConstants::JSON_RECT_X, TEST_COORDINATE }, + {JsonTagConstants::JSON_RECT_Y, TEST_COORDINATE }, + {JsonTagConstants::JSON_RECT_WIDTH, TEST_COORDINATE }, + {JsonTagConstants::JSON_RECT_HEIGHT, TEST_COORDINATE } + }; + nlohmann::json jsonPadding = nlohmann::json { + { JsonTagConstants::JSON_PADDING_TOP_TAG, TEST_DIMENSION }, + { JsonTagConstants::JSON_PADDING_RIGHT_TAG, TEST_DIMENSION }, + { JsonTagConstants::JSON_PADDING_BOTTOM_TAG, TEST_DIMENSION }, + { JsonTagConstants::JSON_PADDING_LEFT_TAG, TEST_DIMENSION }, + }; + + jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json { + { JsonTagConstants::JSON_FONT_SIZE_TAG, TEST_SIZE }, + { JsonTagConstants::JSON_ICON_SIZE_TAG, TEST_SIZE }, + { JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, TEST_SIZE }, + { JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding }, + }; + + jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json { + { JsonTagConstants::JSON_FONT_COLOR_TAG, TEST_COLOR_RED }, + { JsonTagConstants::JSON_ICON_COLOR_TAG, TEST_COLOR_BLUE }, + { JsonTagConstants::JSON_BG_COLOR_TAG, TEST_COLOR_YELLOW } + }; + + jsonComponent[JsonTagConstants::JSON_BORDER_TAG] = nlohmann::json { + { JsonTagConstants::JSON_BORDER_WIDTH_TAG, TEST_SIZE }, + }; + jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json { + { JsonTagConstants::JSON_PARENT_EFFECT_TAG, false }, + }; + jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json { + { JsonTagConstants::JSON_TEXT_TAG, PasteDesc::PASTE }, + { JsonTagConstants::JSON_ICON_TAG, PasteIcon::LINE_ICON }, + { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, + }; +} } // namespace SecurityComponent } // namespace Security } // namespace OHOS diff --git a/test/security_component/entry/src/main/ets/TestAbility/pages/index.ets b/interfaces/inner_api/security_component/test/unittest/src/test_common.h similarity index 38% rename from test/security_component/entry/src/main/ets/TestAbility/pages/index.ets rename to interfaces/inner_api/security_component/test/unittest/src/test_common.h index 441f24058499e3ea4c4c3d96a776f02192e02549..d572400df93e9cd5ab859855e69bf7580f5db72e 100644 --- a/test/security_component/entry/src/main/ets/TestAbility/pages/index.ets +++ b/interfaces/inner_api/security_component/test/unittest/src/test_common.h @@ -1,48 +1,40 @@ -/* - * Copyright (c) 2023 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 '@ohos.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 +/* + * Copyright (c) 2023 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. + */ +#ifndef TEST_COMMON_H +#define TEST_COMMON_H + +namespace OHOS { +namespace Security { +namespace SecurityComponent { +static const std::string WRONG_TYPE = "wrongType"; +static constexpr float TEST_SIZE = 100.0; +static constexpr double TEST_COORDINATE = 100.0; +static constexpr double TEST_DIMENSION = 100.0; +static constexpr uint32_t TEST_COLOR = 0xffffffff; +static constexpr uint32_t TEST_COLOR_YELLOW = 0xffffff00; +static constexpr uint32_t TEST_COLOR_RED = 0xffff0000; +static constexpr uint32_t TEST_COLOR_BLUE = 0xff0000ff; +static constexpr uint32_t TEST_DIFF_COLOR = 0; +static constexpr size_t MAX_CALLER_SIZE = 10; +class TestCommon { +public: + static void BuildLocationComponentInfo(nlohmann::json& jsonComponent); + static void BuildSaveComponentInfo(nlohmann::json& jsonComponent); + static void BuildPasteComponentInfo(nlohmann::json& jsonComponent); +}; +} // namespace SecurityComponent +} // namespace Security +} // namespace OHOS +#endif // TEST_COMMON_H diff --git a/services/security_component_service/sa/test/unittest/src/app_state_observer_test.cpp b/services/security_component_service/sa/test/unittest/src/app_state_observer_test.cpp index 4923cdb83f168b09662c888907b0e539383e142e..4d5b3369bd6b08e58ef25825332bb09e781a536f 100644 --- a/services/security_component_service/sa/test/unittest/src/app_state_observer_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/app_state_observer_test.cpp @@ -15,6 +15,7 @@ #include "app_state_observer_test.h" #include "sec_comp_log.h" #include "sec_comp_err.h" +#include "test_common_param.h" using namespace testing::ext; using namespace OHOS; @@ -23,11 +24,6 @@ using namespace OHOS::Security::SecurityComponent; namespace { static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "AppStateObserverTest"}; - -static constexpr int32_t TEST_UID = 1; -static constexpr int32_t TEST_UID_2 = 2; -static constexpr int32_t TEST_PID = 1; -static constexpr int32_t TEST_PID_2 = 2; } void AppStateObserverTest::SetUpTestCase() @@ -60,13 +56,13 @@ void AppStateObserverTest::TearDown() */ HWTEST_F(AppStateObserverTest, IsProcessForeground001, TestSize.Level1) { - ASSERT_FALSE(observer_->IsProcessForeground(TEST_PID, TEST_UID)); + ASSERT_FALSE(observer_->IsProcessForeground(TEST_PID_1, TEST_UID_1)); AppExecFwk::AppStateData stateData = { - .pid = TEST_PID, - .uid = TEST_UID, + .pid = TEST_PID_1, + .uid = TEST_UID_1, }; observer_->AddProcessToForegroundSet(stateData); - ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID, TEST_UID)); + ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID_1, TEST_UID_1)); } /** @@ -78,12 +74,12 @@ HWTEST_F(AppStateObserverTest, IsProcessForeground001, TestSize.Level1) HWTEST_F(AppStateObserverTest, AddProcessToForegroundSet001, TestSize.Level1) { AppExecFwk::AppStateData stateData = { - .pid = TEST_PID, - .uid = TEST_UID, + .pid = TEST_PID_1, + .uid = TEST_UID_1, }; observer_->AddProcessToForegroundSet(stateData); observer_->AddProcessToForegroundSet(stateData); - ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID, TEST_UID)); + ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID_1, TEST_UID_1)); AppExecFwk::ProcessData procData = { .pid = TEST_PID_2, @@ -103,14 +99,14 @@ HWTEST_F(AppStateObserverTest, AddProcessToForegroundSet001, TestSize.Level1) HWTEST_F(AppStateObserverTest, RemoveProcessFromForegroundSet001, TestSize.Level1) { AppExecFwk::ProcessData procData = { - .pid = TEST_PID, - .uid = TEST_UID, + .pid = TEST_PID_1, + .uid = TEST_UID_1, }; observer_->AddProcessToForegroundSet(procData); - ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID, TEST_UID)); + ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID_1, TEST_UID_1)); observer_->RemoveProcessFromForegroundSet(procData); observer_->RemoveProcessFromForegroundSet(procData); - ASSERT_FALSE(observer_->IsProcessForeground(TEST_PID, TEST_UID)); + ASSERT_FALSE(observer_->IsProcessForeground(TEST_PID_1, TEST_UID_1)); } /** @@ -122,14 +118,14 @@ HWTEST_F(AppStateObserverTest, RemoveProcessFromForegroundSet001, TestSize.Level HWTEST_F(AppStateObserverTest, RemoveProcessFromForegroundSet002, TestSize.Level1) { AppExecFwk::ProcessData procData = { - .pid = TEST_PID, - .uid = TEST_UID, + .pid = TEST_PID_1, + .uid = TEST_UID_1, }; observer_->AddProcessToForegroundSet(procData); - ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID, TEST_UID)); + ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID_1, TEST_UID_1)); procData.pid = TEST_PID_2; observer_->RemoveProcessFromForegroundSet(procData); - ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID, TEST_UID)); + ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID_1, TEST_UID_1)); } /** @@ -146,14 +142,14 @@ HWTEST_F(AppStateObserverTest, OnProcessStateChanged001, TestSize.Level1) ASSERT_EQ(observer_->foregrandProcList_.size(), static_cast(0)); processData.state = AppExecFwk::AppProcessState::APP_STATE_FOREGROUND; - processData.pid = TEST_PID; + processData.pid = TEST_PID_1; observer_->OnProcessStateChanged(processData); - ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID, TEST_UID)); + ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID_1, TEST_UID_1)); processData.state = AppExecFwk::AppProcessState::APP_STATE_BACKGROUND; - processData.pid = TEST_PID; + processData.pid = TEST_PID_1; observer_->OnProcessStateChanged(processData); - ASSERT_FALSE(observer_->IsProcessForeground(TEST_PID, TEST_UID)); + ASSERT_FALSE(observer_->IsProcessForeground(TEST_PID_1, TEST_UID_1)); } /** @@ -166,9 +162,9 @@ HWTEST_F(AppStateObserverTest, OnProcessDied001, TestSize.Level1) { AppExecFwk::ProcessData processData; processData.state = AppExecFwk::AppProcessState::APP_STATE_FOREGROUND; - processData.pid = TEST_PID; + processData.pid = TEST_PID_1; observer_->OnProcessStateChanged(processData); - ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID, TEST_UID)); + ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID_1, TEST_UID_1)); // if last process died, the sec_comp service will exit. processData.pid = TEST_PID_2; @@ -176,7 +172,7 @@ HWTEST_F(AppStateObserverTest, OnProcessDied001, TestSize.Level1) ASSERT_TRUE(observer_->IsProcessForeground(TEST_PID_2, TEST_UID_2)); // notify process 1 died - processData.pid = TEST_PID; + processData.pid = TEST_PID_1; observer_->OnProcessDied(processData); - ASSERT_FALSE(observer_->IsProcessForeground(TEST_PID, TEST_UID)); + ASSERT_FALSE(observer_->IsProcessForeground(TEST_PID_1, TEST_UID_1)); } diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_entity_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_entity_test.cpp index 66d2831b294ff79601e4955bae1d60add2e7b11d..59f53b5e83f5a081edf318bf412ea75f8c08ed67 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_entity_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_entity_test.cpp @@ -19,6 +19,7 @@ #include "save_button.h" #include "sec_comp_err.h" #include "sec_comp_tool.h" +#include "test_common_param.h" using namespace testing::ext; using namespace OHOS; @@ -28,9 +29,6 @@ using namespace OHOS::Security::AccessToken; namespace { static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompEntityTest"}; -static constexpr double TEST_COORDINATE = 100.0; -static constexpr double TEST_DIFF_COORDINATE = 200.0; -static constexpr uint64_t TIME_CONVERSION_UNIT = 1000; } void SecCompEntityTest::SetUpTestCase() diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp index ac86c7feb30145510cd8e3e4eb4f612393a7ff33..51aeb7a6c0e62dc41e38bf8bec4652bb1f9723e1 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp @@ -14,14 +14,15 @@ */ #include "sec_comp_info_helper_test.h" +#include "display.h" +#include "display_info.h" +#include "display_manager.h" #include "location_button.h" #include "paste_button.h" #include "save_button.h" #include "sec_comp_log.h" #include "sec_comp_err.h" -#include "display.h" -#include "display_info.h" -#include "display_manager.h" +#include "test_common_param.h" using namespace testing::ext; using namespace OHOS; @@ -30,18 +31,6 @@ using namespace OHOS::Security::SecurityComponent; namespace { static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompInfoHelperTest"}; - -static constexpr float TEST_SIZE = 100.0; -static constexpr double TEST_DIMENSION = 100.0; -static constexpr double TEST_INVALID_DIMENSION = -100.0; -static constexpr uint32_t TEST_COLOR_YELLOW = 0xff7fff00; -static constexpr uint32_t TEST_COLOR_RED = 0xffff0000; -static constexpr uint32_t TEST_COLOR_BLUE = 0xff0000ff; -static constexpr uint32_t TEST_COLOR_INVALID = 0x66000000; -static constexpr uint32_t TEST_COLOR_BLACK = 0x00000000; -static constexpr uint32_t TEST_COLOR_WHITE = 0xffffffff; -static constexpr uint32_t QUARTER = 4; -static constexpr double ZERO_OFFSET = 0.0F; static double g_curScreenWidth = 0.0F; static double g_curScreenHeight = 0.0F; static double g_testWidth = 0.0F; diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp index 737c9388c8de0eeaee0391a8f6c2674ea034b90d..bc2fb8962b0592a59121e882798eee06a2c769ae 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp @@ -18,6 +18,7 @@ #include "location_button.h" #include "save_button.h" #include "sec_comp_err.h" +#include "test_common_param.h" using namespace testing::ext; using namespace OHOS; @@ -28,26 +29,6 @@ namespace { static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompManagerTest"}; -static constexpr double TEST_SIZE = 100.0; -static constexpr uint32_t TEST_INVALID_SIZE = 0; -static constexpr double TEST_COORDINATE = 100.0; -static constexpr uint32_t TEST_COLOR = 0xffffffff; -static constexpr uint32_t TEST_COLOR_YELLOW = 0xff7fff00; -static constexpr uint32_t TEST_COLOR_RED = 0xffff0000; -static constexpr uint32_t TEST_COLOR_BLUE = 0xff0000ff; - -static constexpr int32_t TEST_PID_1 = 1; -static constexpr int32_t TEST_PID_2 = 2; -static constexpr int32_t TEST_PID_3 = 3; - -static constexpr AccessTokenID TEST_TOKEN_ID = 1; -static constexpr int32_t TEST_SC_ID_1 = 1; -static constexpr int32_t TEST_SC_ID_2 = 2; -static constexpr int32_t TEST_INVALID_SC_ID = -1; - -static constexpr int32_t MAX_INT_NUM = 0x7fffffff; -static constexpr int32_t SC_ID_START = 1000; - static LocationButton BuildInvalidLocationComponent() { LocationButton button; @@ -58,9 +39,9 @@ static LocationButton BuildInvalidLocationComponent() button.padding_.bottom = TEST_INVALID_SIZE; button.padding_.left = TEST_INVALID_SIZE; button.textIconSpace_ = TEST_INVALID_SIZE; - button.fontColor_.value = TEST_COLOR; - button.iconColor_.value = TEST_COLOR; - button.bgColor_.value = TEST_COLOR; + button.fontColor_.value = TEST_COLOR_WHITE; + button.iconColor_.value = TEST_COLOR_WHITE; + button.bgColor_.value = TEST_COLOR_WHITE; button.borderWidth_ = TEST_INVALID_SIZE; button.type_ = LOCATION_COMPONENT; button.rect_.x_ = TEST_COORDINATE; diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_service_mock_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_service_mock_test.cpp index c430ebec42f25856ef2fe3ac965e0348a7a7af2b..e9926c36b36d9827e6962247bf71fadd027c2007 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_service_mock_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_service_mock_test.cpp @@ -25,6 +25,7 @@ #include "sec_comp_tool.h" #include "sec_comp_enhance_adapter.h" #include "system_ability.h" +#include "test_common_param.h" #include "token_setproc.h" using namespace testing::ext; @@ -35,15 +36,6 @@ using namespace OHOS::Security::AccessToken; namespace { static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompServiceTest"}; - -static constexpr uint32_t HAP_TOKEN_ID = 537715419; -static constexpr int32_t SA_ID = 3506; -static constexpr double TEST_COORDINATE = 100.0; -static constexpr double TEST_SIZE = 100.0; -static constexpr uint32_t TEST_COLOR_YELLOW = 0xff7fff00; -static constexpr uint32_t TEST_COLOR_RED = 0xffff0000; -static constexpr uint32_t TEST_COLOR_BLUE = 0xff0000ff; -static constexpr uint64_t TIME_CONVERSION_UNIT = 1000; static AccessTokenID g_selfTokenId = 0; static std::string BuildSaveComponentInfo() diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp index 5b6fe8eae2385291d3566907dba00372317d3822..29dc6c75c6386eaf213cb680d4ece07815f6bd37 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp @@ -24,6 +24,7 @@ #include "sec_comp_log.h" #include "sec_comp_tool.h" #include "system_ability.h" +#include "test_common_param.h" #include "token_setproc.h" using namespace testing::ext; @@ -34,17 +35,7 @@ using namespace OHOS::Security::AccessToken; namespace { static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompServiceTest"}; - -static constexpr uint32_t HAP_TOKEN_ID = 537715419; -static constexpr int32_t SA_ID = 3506; -static constexpr int32_t TEST_SC_ID = 1; static AccessTokenID g_selfTokenId = 0; -static constexpr double TEST_COORDINATE = 100.0; -static constexpr double TEST_SIZE = 100.0; -static constexpr uint32_t TEST_COLOR_YELLOW = 0xff7fff00; -static constexpr uint32_t TEST_COLOR_RED = 0xffff0000; -static constexpr uint32_t TEST_COLOR_BLUE = 0xff0000ff; -static constexpr uint64_t TIME_CONVERSION_UNIT = 1000; static std::string BuildLocationComponentInfo() { diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp index d29720da6719fa09df0278f40855e820dcf77a3a..868d8b2eff827abbfd5ed70b7012630ce0595fb2 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp @@ -17,6 +17,7 @@ #include "sec_comp_log.h" #include "sec_comp_err.h" #include "sec_comp_click_event_parcel.h" +#include "test_common_param.h" using namespace testing::ext; using namespace OHOS; diff --git a/services/security_component_service/sa/test/unittest/src/test_common_param.h b/services/security_component_service/sa/test/unittest/src/test_common_param.h new file mode 100644 index 0000000000000000000000000000000000000000..52d2d21c2c7e3939c8bf0802a44ec24c0d3eb01c --- /dev/null +++ b/services/security_component_service/sa/test/unittest/src/test_common_param.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 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. + */ +#ifndef TEST_COMMON_PARAM_H +#define TEST_COMMON_PARAM_H + +namespace OHOS { +namespace Security { +namespace SecurityComponent { +static constexpr int32_t TEST_UID_1 = 1; +static constexpr int32_t TEST_UID_2 = 2; +static constexpr int32_t TEST_PID_1 = 1; +static constexpr int32_t TEST_PID_2 = 2; +static constexpr int32_t TEST_PID_3 = 3; +static constexpr int32_t TEST_SC_ID_1 = 1; +static constexpr int32_t TEST_SC_ID_2 = 2; +static constexpr int32_t TEST_INVALID_SC_ID = -1; +static constexpr int32_t SC_ID_START = 1000; +static constexpr int32_t SA_ID = 3506; + +static constexpr float TEST_SIZE = 100.0; +static constexpr uint32_t TEST_INVALID_SIZE = 0; +static constexpr double TEST_COORDINATE = 100.0; +static constexpr double TEST_DIFF_COORDINATE = 200.0; +static constexpr double TEST_DIMENSION = 100.0; +static constexpr double ZERO_OFFSET = 0.0F; +static constexpr uint32_t QUARTER = 4; + +static constexpr uint32_t TEST_COLOR_INVALID = 0x66000000; +static constexpr uint32_t TEST_COLOR_BLACK = 0x00000000; +static constexpr uint32_t TEST_COLOR_WHITE = 0xffffffff; +static constexpr uint32_t TEST_COLOR_YELLOW = 0xff7fff00; +static constexpr uint32_t TEST_COLOR_RED = 0xffff0000; +static constexpr uint32_t TEST_COLOR_BLUE = 0xff0000ff; + +static constexpr uint64_t TIME_CONVERSION_UNIT = 1000; +static constexpr int32_t MAX_INT_NUM = 0x7fffffff; +static constexpr uint32_t HAP_TOKEN_ID = 537715419; +static constexpr uint32_t TEST_TOKEN_ID = 1; +} // namespace SecurityComponent +} // namespace Security +} // namespace OHOS +#endif // TEST_COMMON_PARAM_H diff --git a/test/dts/README_zh.md b/test/dts/README_zh.md deleted file mode 100644 index bd543706331391254da30b3776b65be88f3001ad..0000000000000000000000000000000000000000 --- a/test/dts/README_zh.md +++ /dev/null @@ -1,47 +0,0 @@ -# 安全控件管理服务 - -## 简介 - -安全控件是OpenHarmony提供的一组系统实现的ArkUI基础组件。当用户点击了这类组件后,应用将被授予临时授权,应用开发者仅需要像使用Button等组件那样集成到应用自己的页面即可。 -安全控件管理服务主要提供如下功能: - -- 提供应用安全控件的注册、临时授权、取消注册等Native接口实现。 -- 负责安全控件的合法性检查,只有合法的安全控件才能授权成功。 -- 提供其他SA查询临时授权的Native接口实现。提供安全增强相关接口及适配层,供厂商定制安全增强功能使用。 - -## 目录 - -``` -/base/security/security_component -├── frameworks # 框架层,基础功能代码存放目录 -│ ├── common # 框架公共代码存放目录 -│ ├── enhance_adapter # 能力增强适配代码存放目录 -│ └── security_component # 安全控件服务框架代码存放目录 -├── interfaces # 接口层 -│ └── inner_api # 内部接口层 -│ ├── enhance_kits # 安全控件配置接口代码存放目录 -│ └── security_component # 安全控件服务接口层代码存放目录 -└── services # 服务层 - └── security_component_service/sa - └── sa_main # 安全控件服务侧代码存放目录 - -``` - -## 使用 -### 接口说明 - -| **接口申明** | **接口描述** | -| --- | --- | -| int32_t RegisterSecurityComponent(SecCompType type, const std::string& componentInfo, int32_t& scId); | 注册安全控件 | -| int32_t UpdateSecurityComponent(int32_t scId, const std::string& componentInfo); | 更新安全控件信息 | -| int32_t UnregisterSecurityComponent(int32_t scId); | 取消注册安全控件 | -| int32_t ReportSecurityComponentClickEvent(int32_t scId, const std::string& componentInfo, const SecCompClickEvent& touchInfo); | 上报点击事件,申请临时授权 | -| int32_t SetEnhanceCfg(SecCompEnhanceCfgBase* cfg); | 设置安全控件增强的配置,供多模服务使用 | -| int32_t GetPointerEventEnhanceData(void* data, uint32_t dataLen, uint8_t* enhanceData, uint32_t& enHancedataLen); | 获取点击事件的安全增强数据,供多模服务使用 | -| bool ReduceAfterVerifySavePermission(AccessToken::AccessTokenID tokenId); | 校验后取消保存控件权限 | - -## 相关仓 - -**[arkui\_ace\_engine](https://gitee.com/openharmony/arkui_ace_engine/blob/master/README_zh.md)** - -**[multimodalinput\_input](https://gitee.com/openharmony/multimodalinput_input/blob/master/README_zh.md)** diff --git a/test/dts/location_button.d.ts b/test/dts/location_button.d.ts deleted file mode 100644 index 1f0deafc0bfff7dd0aff9eddbdb271e90881c5f4..0000000000000000000000000000000000000000 --- a/test/dts/location_button.d.ts +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -/** - * Enumerates the icon styles. - * - * @enum { number } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare enum LocationIconStyle { - /** - * Icon filled with the specified color. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - FULL_FILLED = 0, - - /** - * Icon rendered as lines. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - LINES = 1 -} - -/** - * Enumerates the text that can be displayed on the location button. - * - * @enum { number } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare enum LocationDescription { - /** - * Current Location - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - CURRENT_LOCATION = 0, - - /** - * Add Location - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - ADD_LOCATION = 1, - - /** - * Select Location - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - SELECT_LOCATION = 2, - - /** - * Share Location - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - SHARE_LOCATION = 3, - - /** - * Send Location - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - SEND_LOCATION = 4, - - /** - * Locating - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - LOCATING = 5, - - /** - * Location - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - LOCATION = 6, - - /** - * Send Current Location - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - SEND_CURRENT_LOCATION = 7, - - /** - * Relocation - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - RELOCATION = 8, - - /** - * Punch In - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - PUNCH_IN = 9, - - /** - * Current Position - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - CURRENT_POSITION = 10 -} - -/** - * Declares the interface for setting the location button options. - * - * @interface LocationButtonOptions - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare interface LocationButtonOptions { - /** - * Style of the icon to be drawn. - * - * @type { ?LocationIconStyle } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - icon?: LocationIconStyle; - - /** - * Text to be displayed on the button. - * - * @type { ?LocationDescription } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - text?: LocationDescription; - - /** - * Type of the button. - * - * @type { ?ButtonType } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - buttonType?: ButtonType; -} - -/** - * Enumerates the click event results of the location button. - * - * @enum { number } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare enum LocationButtonOnClickResult { - /** - * Success. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - SUCCESS = 0, - - /** - * Failure because the application is not temporarily authorized for accessing location data. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - TEMPORARY_AUTHORIZATION_FAILED = 1 -} - -/** - * Defines the interface for setting a location button. - * - * @interface LocationButtonInterface - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -interface LocationButtonInterface { - /** - * Creates a location button. - * - * @returns { LocationButtonAttribute } TReturns the attribute of the location button. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - (): LocationButtonAttribute; - - /** - * Creates a location button with the specified composition. - * If an attribute is not set, the corresponding element will not be drawn. - * - * @param { LocationButtonOptions } options - Indicates the options of the location button. - * @returns { LocationButtonAttribute } Returns the attribute of the location button. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - (options: LocationButtonOptions): LocationButtonAttribute; -} - -/** - * Defines the attributes of the location button. - * - * @extends SecurityComponentMethod - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare class LocationButtonAttribute extends SecurityComponentMethod { - /** - * Called when the location button is clicked. - * - * @param { (event: ClickEvent, result: LocationButtonOnClickResult) => void } event - Indicates the - * click event result. - * @returns { LocationButtonAttribute } Returns the attribute of the location button. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - onClick(event: (event: ClickEvent, result: LocationButtonOnClickResult) => void): LocationButtonAttribute; -} - -/** - * Defines a button that interacts with the security component service to - * request the authorization for accessing location data. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare const LocationButton: LocationButtonInterface; - -/** - * Defines a location button instance for secure access. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare const LocationButtonInstance: LocationButtonAttribute; diff --git a/test/dts/paste_button.d.ts b/test/dts/paste_button.d.ts deleted file mode 100644 index 50c06eb9f5a3b11dd2800604c8e4ad3f104a8ce9..0000000000000000000000000000000000000000 --- a/test/dts/paste_button.d.ts +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -/** - * Enumerates the icon styles. - * - * @enum { number } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare enum PasteIconStyle { - /** - * Icon rendered as lines. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - LINES = 0 -} - -/** - * Enumerates the text that can be displayed on the paste button. - * - * @enum { number } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare enum PasteDescription { - /** - * Paste - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - PASTE = 0 -} - -/** - * Declares the interface for setting the paste button options. - * - * @interface PasteButtonOptions - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare interface PasteButtonOptions { - /** - * Style of the icon to be drawn. - * - * @type { ?PasteIconStyle } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - icon?: PasteIconStyle; - - /** - * Text to be displayed on the button. - * - * @type { ?PasteDescription } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - text?: PasteDescription; - - /** - * Type of the button. - * - * @type { ?ButtonType } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - buttonType?: ButtonType; -} - -/** - * Enumerates the click event results of the paste button. - * - * @enum { number } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare enum PasteButtonOnClickResult { - /** - * Success. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - SUCCESS = 0, - - /** - * Failure because the application is not temporarily authorized for accessing the current pasteboard data. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - TEMPORARY_AUTHORIZATION_FAILED = 1 -} - -/** - * Defines the interface for setting a paste button. - * - * @interface PasteButtonInterface - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -interface PasteButtonInterface { - /** - * Creates a paste button. - * - * @returns { PasteButtonAttribute } Returns the attribute of the paste button. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - (): PasteButtonAttribute; - - /** - * Creates a paste button with the specified composition. - * If an attribute is not set, the corresponding element will not be drawn. - * - * @param { PasteButtonOptions } options - Indicates the options of the paste button. - * @returns { PasteButtonAttribute } Returns the attribute of the paste button. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - (options: PasteButtonOptions): PasteButtonAttribute; -} - -/** - * Defines the attributes of the paste button. - * - * @extends SecurityComponentMethod - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare class PasteButtonAttribute extends SecurityComponentMethod { - /** - * Called when the paste button is clicked. - * - * @param { (event: ClickEvent, result: PasteButtonOnClickResult) => void } event - Indicates the - * click event result. - * @returns { PasteButtonAttribute } Returns the attribute of the paste button. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - onClick(event: (event: ClickEvent, result: PasteButtonOnClickResult) => void): PasteButtonAttribute; -} - -/** - * Defines a button that interacts with the security component service to - * request the permission for accessing the current pasteboard data. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare const PasteButton: PasteButtonInterface; - -/** - * Defines a paste button instance for secure access. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare const PasteButtonInstance: PasteButtonAttribute; diff --git a/test/dts/save_button.d.ts b/test/dts/save_button.d.ts deleted file mode 100644 index 61addc9bb4b2cf798a9f5f005d5326c0640e6e4e..0000000000000000000000000000000000000000 --- a/test/dts/save_button.d.ts +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -/** - * Enumerates the icon styles. - * - * @enum { number } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare enum SaveIconStyle { - /** - * Icon filled with the specified color. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - FULL_FILLED = 0, - - /** - * Icon rendered as lines. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - LINES = 1 -} - -/** - * Enumerates the text that can be displayed on the save button. - * - * @enum { number } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare enum SaveDescription { - /** - * Download - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - DOWNLOAD = 0, - - /** - * Download File - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - DOWNLOAD_FILE = 1, - - /** - * Save - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - SAVE = 2, - - /** - * Save Image - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - SAVE_IMAGE = 3, - - /** - * Save File - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - SAVE_FILE = 4, - - /** - * Download and Share - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - DOWNLOAD_AND_SHARE = 5, - - /** - * Receive - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - RECEIVE = 6, - - /** - * Continue to Receive - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - CONTINUE_TO_RECEIVE = 7 -} - -/** - * Declares the interface for setting the save button options. - * - * @interface SaveButtonOptions - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare interface SaveButtonOptions { - /** - * Style of the icon to be drawn. - * - * @type { ?SaveIconStyle } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - icon?: SaveIconStyle; - - /** - * Text to be displayed on the button. - * - * @type { ?SaveDescription } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - text?: SaveDescription; - - /** - * Type of the button. - * - * @type { ?ButtonType } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - buttonType?: ButtonType; -} - -/** - * Enumerates the click event results of the save button. - * - * @enum { number } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare enum SaveButtonOnClickResult { - /** - * Success. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - SUCCESS = 0, - - /** - * Failure because the application is not temporarily authorized for saving files. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - TEMPORARY_AUTHORIZATION_FAILED = 1 -} - -/** - * Defines the interface for setting a save button. - * - * @interface SaveButtonInterface - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -interface SaveButtonInterface { - /** - * Creates a save button. - * - * @returns { SaveButtonAttribute } Returns the attribute of the save button. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - (): SaveButtonAttribute; - - /** - * Creates a save button with the specified composition. - * If an attribute is not set, the corresponding element will not be drawn. - * - * @param { SaveButtonOptions } options - Indicates the options of the save button. - * @returns { SaveButtonAttribute } Returns the attribute of the save button. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - (options: SaveButtonOptions): SaveButtonAttribute; -} - -/** - * Defines the attributes of the save button. - * - * @extends SecurityComponentMethod - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare class SaveButtonAttribute extends SecurityComponentMethod { - /** - * Called when the save button is clicked. - * - * @param { (event: ClickEvent, result: SaveButtonOnClickResult) => void } event - Indicates the - * click event result. - * @returns { SaveButtonAttribute } Returns the attribute of the save button. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - onClick(event: (event: ClickEvent, result: SaveButtonOnClickResult) => void): SaveButtonAttribute; -} - -/** - * Defines a button that interacts with the security component service to - * request the permission for saving files in the media library. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare const SaveButton: SaveButtonInterface; - -/** - * Defines a save button instance for secure access. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare const SaveButtonInstance: SaveButtonAttribute; diff --git a/test/dts/security_component.d.ts b/test/dts/security_component.d.ts deleted file mode 100644 index 8cac844e59f174d373b7c3afa3a182c66badc10b..0000000000000000000000000000000000000000 --- a/test/dts/security_component.d.ts +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -/** - * Enumerates the layout direction of the icon and text. - * - * @enum { number } - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare enum SecurityComponentLayoutDirection { - /** - * Horizontal layout. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - HORIZONTAL = 0, - - /** - * Vertical layout. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - VERTICAL = 1 -} - -/** - * Defines the method of a security component. - * - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -declare class SecurityComponentMethod { - /** - * Icon size. - * - * @param { Dimension } value - Indicates the size of the icon. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - iconSize(value: Dimension): T; - - /** - * Layout direction of the icon and text. - * - * @param { SecurityComponentLayoutDirection } value - Indicates the layout direction of the icon and text. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - layoutDirection(value: SecurityComponentLayoutDirection): T; - - /** - * Position of the security component. - * - * @param { Position } value - Indicates the position of the security component. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - position(value: Position): T; - - /** - * Anchor of the security component for positioning. The top start edge of the component is used as - * the reference point for offset. - * - * @param { Position } value - Indicates the anchor of the component when it is positioned. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - markAnchor(value: Position): T; - - /** - * Coordinate offset relative to the layout position. - * Setting this attribute does not affect the layout of the parent container. - * The position is adjusted only during drawing. - * - * @param { Position } value - Indicates the offset value. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - offset(value: Position): T; - - /** - * Font size of the inner text. - * - * @param { Dimension } value - Indicates the font size of the text in the security component. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - fontSize(value: Dimension): T; - - /** - * Font style of the inner text. - * - * @param { FontStyle } value - Indicates the font style of the text in the security component. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - fontStyle(value: FontStyle): T; - - /** - * Font weight of the inner text. - * - * @param { number | FontWeight | string } value - Indicates the font weight of the text in the security component. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - fontWeight(value: number | FontWeight | string): T; - - /** - * Font family of the inner text. - * - * @param { string | Resource } value - Indicates the font family of the text in the security component. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - fontFamily(value: string | Resource): T; - - /** - * Font color of the inner text. - * - * @param { ResourceColor } value - Indicates the font color of the text in the security component. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - fontColor(value: ResourceColor): T; - - /** - * Color of the icon. - * - * @param { ResourceColor } value - Indicates the icon color in the security component. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - iconColor(value: ResourceColor): T; - - /** - * Background color. - * - * @param { ResourceColor } value - Indicates the background color of the security component. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - backgroundColor(value: ResourceColor): T; - - /** - * Style of the border. - * - * @param { BorderStyle } value - Indicates the border style of the security component. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - borderStyle(value: BorderStyle): T; - - /** - * Width of the border. - * - * @param { Dimension } value - Indicates the border width of the security component. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - borderWidth(value: Dimension): T; - - /** - * Color of the border. - * - * @param { ResourceColor } value - Indicates the border color of the security component. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - borderColor(value: ResourceColor): T; - - /** - * Radius of the border. - * - * @param { Dimension } value - Indicates the border radius of the security component. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - borderRadius(value: Dimension): T; - - /** - * Padding between the background border and icon/inner text. - * - * @param { Padding | Dimension } value - Indicates the padding of the security component. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - padding(value: Padding | Dimension): T; - - /** - * Space between the inner text and icon. - * - * @param { Dimension } value - Indicates the space between the inner text and icon. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ - textIconSpace(value: Dimension): T; - - /** - * Key. User can set an key to the component to identify it. - * - * @param { string } value - identify the key of the component. - * @returns { T } Returns the attribute of the security component. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @systemapi - * @since 10 - * @test - */ - key(value: string): T; -} diff --git a/test/security_component/AppScope/app.json b/test/security_component/AppScope/app.json deleted file mode 100644 index bbf7eccf17bd8e0cad21558178d9eb4b2db8b0cf..0000000000000000000000000000000000000000 --- a/test/security_component/AppScope/app.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "app": { - "bundleName": "com.example.securitycomponent", - "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": 10, - "targetAPIVersion": 10, - "car": { - "apiCompatibleVersion": 10, - "singleUser": false - } - } -} \ No newline at end of file diff --git a/test/security_component/AppScope/resources/base/element/string.json b/test/security_component/AppScope/resources/base/element/string.json deleted file mode 100644 index 633100a6d90763bfac9d20aaae683119d7320e9c..0000000000000000000000000000000000000000 --- a/test/security_component/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string":[ - { - "name":"app_name", - "value":"ohosProject" - } - ] -} \ No newline at end of file diff --git a/test/security_component/AppScope/resources/base/media/app_icon.png b/test/security_component/AppScope/resources/base/media/app_icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/test/security_component/AppScope/resources/base/media/app_icon.png and /dev/null differ diff --git a/test/security_component/BUILD.gn b/test/security_component/BUILD.gn deleted file mode 100644 index a1a2d698b86aa0e63b4286d0db956ca9b980db2d..0000000000000000000000000000000000000000 --- a/test/security_component/BUILD.gn +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2023 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("ActsSecComponentTest") { - hap_profile = "entry/src/main/module.json" - js_build_mode = "debug" - deps = [ - ":security_component_assets", - ":security_component_resources", - ] - ets2abc = true - certificate_profile = "signature/openharmony_sx.p7b" - hap_name = "ActsSecComponentTest" - subsystem_name = "security" - part_name = "access_token" -} - -ohos_app_scope("security_app_profile") { - app_profile = "AppScope/app.json" - sources = [ "AppScope/resources" ] -} -ohos_js_assets("security_component_assets") { - source_dir = "entry/src/main/ets" -} -ohos_resources("security_component_resources") { - sources = [ "entry/src/main/resources" ] - deps = [ ":security_app_profile" ] - hap_profile = "entry/src/main/module.json" -} diff --git a/test/security_component/Test.json b/test/security_component/Test.json deleted file mode 100644 index c6f2985fba59fb576c6cef756b8f615362cb617f..0000000000000000000000000000000000000000 --- a/test/security_component/Test.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "description": "Configuration for hjunit demo Tests", - "driver": { - "type": "OHJSUnitTest", - "test-timeout": "1200000", - "bundle-name": "com.example.securitycomponent", - "module-name": "phone", - "shell-timeout": "1200000", - "testcase-timeout": "180000" - }, - "kits": [ - { - "test-file-name": [ - "ActsSecComponentTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/test/security_component/entry/src/main/ets/Application/AbilityStage.ts b/test/security_component/entry/src/main/ets/Application/AbilityStage.ts deleted file mode 100644 index e86b53ef3a883a615d98994b39ec736482ba2cf7..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/Application/AbilityStage.ts +++ /dev/null @@ -1,9 +0,0 @@ -import AbilityStage from "@ohos.app.ability.AbilityStage" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; - } -} diff --git a/test/security_component/entry/src/main/ets/MainAbility/MainAbility.ts b/test/security_component/entry/src/main/ets/MainAbility/MainAbility.ts deleted file mode 100644 index ced3a8306a1d434790a6c8802fde12f8f683383b..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/MainAbility/MainAbility.ts +++ /dev/null @@ -1,37 +0,0 @@ -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.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; - } - - onDestroy() { - // Ability is destroying, release resources for this ability - console.log("[Demo] MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage) - globalThis.windowStage = windowStage - globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) - } - - onWindowStageDestroy() { - //Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy") - } - - onForeground() { - // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground") - } - - onBackground() { - // Ability has back to background - console.log("[Demo] MainAbility onBackground") - } -}; \ No newline at end of file diff --git a/test/security_component/entry/src/main/ets/MainAbility/pages/index/index.ets b/test/security_component/entry/src/main/ets/MainAbility/pages/index/index.ets deleted file mode 100644 index 17615a7525b220d2e0e683d1bd7eff5b08ca1d60..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/MainAbility/pages/index/index.ets +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2023 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 '@ohos.router'; -import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; -import { Hypium } from '@ohos/hypium' -import testsuite from '../../../test/List.test' - - -@Entry -@Component -struct Index { - - aboutToAppear(){ - console.info("start run testcase!!!!") - var abilityDelegator: any - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - var abilityDelegatorArguments: any - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - console.info('start run testcase!!!') - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - } - - build() { - Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('SecButton Test') - .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%') - } -} \ No newline at end of file diff --git a/test/security_component/entry/src/main/ets/MainAbility/pages/locationButton.ets b/test/security_component/entry/src/main/ets/MainAbility/pages/locationButton.ets deleted file mode 100644 index ef207ffc2a6c157005d881b0abc8a7e298dda374..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/MainAbility/pages/locationButton.ets +++ /dev/null @@ -1,241 +0,0 @@ -/** - * Copyright (c) 2023 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 events_emitter from '@ohos.events.emitter' - -@Entry -@Component -struct locationButton { - @State bgType: ButtonType = ButtonType.Normal - @State iconSize: number = 16 - @State direct: SecurityComponentLayoutDirection = 0 - @State positionX: number = 0 - @State positionY: number = 0 - @State anchorX: number = 0 - @State anchorY: number = 0 - @State offsetX: number = 0 - @State offsetY: number = 0 - @State fontSize: number = 16 - @State fontStyle: FontStyle = FontStyle.Normal - @State fontWeight: FontWeight = FontWeight.Medium - @State fontFamily: string = 'HarmonyOS Sans' - @State fontColor: number = 0xffffffff - @State iconColor: number = 0xffffffff - @State bgColor: number = 0xff007dff - @State borderSty: BorderStyle = BorderStyle.Dashed - @State borderWid: number = 0 - @State borderCol: number = 0xffffffff - @State borderRad: number = 0 - @State left: number = 24 - @State right: number = 24 - @State top: number = 8 - @State bottom: number = 8 - @State middle: number = 4 - @State clipSet: boolean = false - @State columnWidth: string = '100%' - @State columnHeight: string = '100%' - private stateChangeCallBack = (eventData) => { - if (eventData != null) { - console.debug("====>page_locationButton page state change called:" + JSON.stringify(eventData)); - if (eventData.data.bgType != null) { - this.bgType = eventData.data.bgType; - } - if (eventData.data.iconSize != null) { - this.iconSize = eventData.data.iconSize; - } - if (eventData.data.direct != null) { - this.direct = eventData.data.direct; - } - if (eventData.data.positionX != null) { - this.positionX = eventData.data.positionX; - } - if (eventData.data.positionY != null) { - this.positionY = eventData.data.positionY; - } - if (eventData.data.anchorX != null) { - this.anchorX = eventData.data.anchorX; - } - if (eventData.data.anchorY != null) { - this.anchorY = eventData.data.anchorY; - } - if (eventData.data.offsetX != null) { - this.offsetX = eventData.data.offsetX; - } - if (eventData.data.offsetY != null) { - this.offsetY = eventData.data.offsetY; - } - if (eventData.data.fontSize != null) { - this.fontSize = eventData.data.fontSize; - } - if (eventData.data.fontStyle != null) { - this.fontStyle = eventData.data.fontStyle; - } - if (eventData.data.fontWeight != null) { - this.fontWeight = eventData.data.fontWeight; - } - if (eventData.data.fontFamily != null) { - this.fontFamily = eventData.data.fontFamily; - } - if (eventData.data.fontColor != null) { - this.fontColor = eventData.data.fontColor; - } - if (eventData.data.iconColor != null) { - this.iconColor = eventData.data.iconColor; - } - if (eventData.data.bgColor != null) { - this.bgColor = eventData.data.bgColor; - } - if (eventData.data.borderSty != null) { - this.borderSty = eventData.data.borderSty; - } - if (eventData.data.borderWid != null) { - this.borderWid = eventData.data.borderWid; - } - if (eventData.data.borderCol != null) { - this.borderCol = eventData.data.borderCol; - } - if (eventData.data.borderRad != null) { - this.borderRad = eventData.data.borderRad; - } - if (eventData.data.left != null) { - this.left = eventData.data.left; - } - if (eventData.data.right != null) { - this.right = eventData.data.right; - } - if (eventData.data.top != null) { - this.top = eventData.data.top; - } - if (eventData.data.bottom != null) { - this.bottom = eventData.data.bottom; - } - if (eventData.data.middle != null) { - this.middle = eventData.data.middle; - } - if (eventData.data.clipSet != null) { - this.clipSet = eventData.data.clipSet; - } - if (eventData.data.columnWidth != null) { - this.columnWidth = eventData.data.columnWidth; - } - if (eventData.data.columnHeight != null) { - this.columnHeight = eventData.data.columnHeight; - } - } - } - - onPageShow() { - console.debug('====>page_locationButton page show called'); - var stateChangeEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(stateChangeEvent, this.stateChangeCallBack); - } - - onPageHide() { - console.debug('====>page_locationButton page hide called'); - events_emitter.off(1); - } - - build() { - Row() { - Column() { - LocationButton({ icon: LocationIconStyle.FULL_FILLED, text: LocationDescription.CURRENT_LOCATION, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: LocationButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_locationButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_locationButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(this.direct) - .position({ x: this.positionX, y: this.positionY }) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: this.offsetY }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor(this.fontColor) - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keyLocation") - Button() { - Text('--------------------') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 200, - bottom:60 - }).backgroundColor('#00000000') - LocationButton({ icon: LocationIconStyle.FULL_FILLED, text: LocationDescription.CURRENT_LOCATION, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: LocationButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_LocationButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_LocationButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(this.direct) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: this.offsetY }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor(this.fontColor) - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keyLocation1") - }.width(this.columnWidth).height(this.columnHeight).clip(this.clipSet) - }.height('100%') - } -} diff --git a/test/security_component/entry/src/main/ets/MainAbility/pages/locationButton_1.ets b/test/security_component/entry/src/main/ets/MainAbility/pages/locationButton_1.ets deleted file mode 100644 index 9fe207ca42dd9a1f393fb077a84ee12b3cbe75b5..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/MainAbility/pages/locationButton_1.ets +++ /dev/null @@ -1,432 +0,0 @@ -/** - * Copyright (c) 2023 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 events_emitter from '@ohos.events.emitter' - -@Entry -@Component -struct locationButton_1 { - @State bgType: ButtonType = ButtonType.Normal - @State iconSize: number = 16 - @State positionX: number = 0 - @State positionY: number = 0 - @State anchorX: number = 0 - @State anchorY: number = 0 - @State offsetX: number = 0 - @State offsetY: number = 0 - @State fontSize: number = 16 - @State fontStyle: FontStyle = FontStyle.Normal - @State fontWeight: FontWeight = FontWeight.Medium - @State fontFamily: string = 'HarmonyOS Sans' - @State fontColor: number = 0xffffffff - @State iconColor: number = 0xffffffff - @State bgColor: number = 0x7dff - @State borderSty: BorderStyle = BorderStyle.Dashed - @State borderWid: number = 0 - @State borderCol: number = 0xffffffff - @State borderRad: number = 0 - @State left: number = 24 - @State right: number = 24 - @State top: number = 8 - @State bottom: number = 8 - @State middle: number = 4 - @State heightValue: number = 4 - marginValue = {top:30, bottom:30, left:10, right:10} - - build() { - Column() { - Row() { - LocationButton({ icon: LocationIconStyle.LINES, text: LocationDescription.ADD_LOCATION, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: LocationButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_LocationButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_LocationButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keyLocation2") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - LocationButton({ icon: LocationIconStyle.FULL_FILLED, text: LocationDescription.SELECT_LOCATION, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: LocationButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_LocationButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_LocationButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.VERTICAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keyLocation3") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - LocationButton({ icon: LocationIconStyle.FULL_FILLED, text: LocationDescription.SHARE_LOCATION, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: LocationButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_LocationButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_LocationButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keyLocation4") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - LocationButton({ icon: LocationIconStyle.FULL_FILLED, text: LocationDescription.SEND_LOCATION, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: LocationButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_LocationButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_LocationButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keyLocation5") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - LocationButton({ icon: LocationIconStyle.FULL_FILLED, text: LocationDescription.LOCATING, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: LocationButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_LocationButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_LocationButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keyLocation6") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - LocationButton({ icon: LocationIconStyle.FULL_FILLED, text: LocationDescription.LOCATION, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: LocationButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_LocationButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_LocationButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keyLocation7") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - LocationButton({ icon: LocationIconStyle.FULL_FILLED, text: LocationDescription.SEND_CURRENT_LOCATION, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: LocationButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_LocationButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_LocationButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keyLocation8") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - LocationButton({ icon: LocationIconStyle.FULL_FILLED, text: LocationDescription.RELOCATION, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: LocationButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_LocationButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_LocationButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keyLocation9") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - LocationButton({ icon: LocationIconStyle.FULL_FILLED, text: LocationDescription.PUNCH_IN, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: LocationButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_LocationButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_LocationButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keyLocation10") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - LocationButton({ icon: LocationIconStyle.FULL_FILLED, text: LocationDescription.CURRENT_POSITION, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: LocationButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_LocationButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_LocationButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keyLocation11") - }.width('100%').height(this.heightValue).margin(this.marginValue) - } - } -} diff --git a/test/security_component/entry/src/main/ets/MainAbility/pages/pasteButton.ets b/test/security_component/entry/src/main/ets/MainAbility/pages/pasteButton.ets deleted file mode 100644 index dc8e31964fa0bed3ddcd01cb2c02067865836471..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/MainAbility/pages/pasteButton.ets +++ /dev/null @@ -1,241 +0,0 @@ -/** - * Copyright (c) 2023 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 events_emitter from '@ohos.events.emitter' - -@Entry -@Component -struct pasteButton { - @State bgType: ButtonType = ButtonType.Normal - @State iconSize: number = 16 - @State direct: SecurityComponentLayoutDirection = 0 - @State positionX: number = 0 - @State positionY: number = 0 - @State anchorX: number = 0 - @State anchorY: number = 0 - @State offsetX: number = 0 - @State offsetY: number = 0 - @State fontSize: number = 16 - @State fontStyle: FontStyle = FontStyle.Normal - @State fontWeight: FontWeight = FontWeight.Medium - @State fontFamily: string = 'HarmonyOS Sans' - @State fontColor: number = 0xffffffff - @State iconColor: number = 0xffffffff - @State bgColor: number = 0xff007dff - @State borderSty: BorderStyle = BorderStyle.Dashed - @State borderWid: number = 0 - @State borderCol: number = 0xffffffff - @State borderRad: number = 0 - @State left: number = 24 - @State right: number = 24 - @State top: number = 8 - @State bottom: number = 8 - @State middle: number = 4 - @State clipSet: boolean = false - @State columnWidth: string = '100%' - @State columnHeight: string = '100%' - private stateChangeCallBack = (eventData) => { - if (eventData != null) { - console.debug("====>page_pasteButton page state change called:" + JSON.stringify(eventData)); - if (eventData.data.bgType != null) { - this.bgType = eventData.data.bgType; - } - if (eventData.data.iconSize != null) { - this.iconSize = eventData.data.iconSize; - } - if (eventData.data.direct != null) { - this.direct = eventData.data.direct; - } - if (eventData.data.positionX != null) { - this.positionX = eventData.data.positionX; - } - if (eventData.data.positionY != null) { - this.positionY = eventData.data.positionY; - } - if (eventData.data.anchorX != null) { - this.anchorX = eventData.data.anchorX; - } - if (eventData.data.anchorY != null) { - this.anchorY = eventData.data.anchorY; - } - if (eventData.data.offsetX != null) { - this.offsetX = eventData.data.offsetX; - } - if (eventData.data.offsetY != null) { - this.offsetY = eventData.data.offsetY; - } - if (eventData.data.fontSize != null) { - this.fontSize = eventData.data.fontSize; - } - if (eventData.data.fontStyle != null) { - this.fontStyle = eventData.data.fontStyle; - } - if (eventData.data.fontWeight != null) { - this.fontWeight = eventData.data.fontWeight; - } - if (eventData.data.fontFamily != null) { - this.fontFamily = eventData.data.fontFamily; - } - if (eventData.data.fontColor != null) { - this.fontColor = eventData.data.fontColor; - } - if (eventData.data.iconColor != null) { - this.iconColor = eventData.data.iconColor; - } - if (eventData.data.bgColor != null) { - this.bgColor = eventData.data.bgColor; - } - if (eventData.data.borderSty != null) { - this.borderSty = eventData.data.borderSty; - } - if (eventData.data.borderWid != null) { - this.borderWid = eventData.data.borderWid; - } - if (eventData.data.borderCol != null) { - this.borderCol = eventData.data.borderCol; - } - if (eventData.data.borderRad != null) { - this.borderRad = eventData.data.borderRad; - } - if (eventData.data.left != null) { - this.left = eventData.data.left; - } - if (eventData.data.right != null) { - this.right = eventData.data.right; - } - if (eventData.data.top != null) { - this.top = eventData.data.top; - } - if (eventData.data.bottom != null) { - this.bottom = eventData.data.bottom; - } - if (eventData.data.middle != null) { - this.middle = eventData.data.middle; - } - if (eventData.data.clipSet != null) { - this.clipSet = eventData.data.clipSet; - } - if (eventData.data.columnWidth != null) { - this.columnWidth = eventData.data.columnWidth; - } - if (eventData.data.columnHeight != null) { - this.columnHeight = eventData.data.columnHeight; - } - } - } - - onPageShow() { - console.debug('====>page_pasteButton page show called'); - var stateChangeEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(stateChangeEvent, this.stateChangeCallBack); - } - - onPageHide() { - console.debug('====>page_pasteButton page hide called'); - events_emitter.off(1); - } - - build() { - Row() { - Column() { - PasteButton({ icon: PasteIconStyle.LINES, text: PasteDescription.PASTE, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: PasteButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_pasteButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_pasteButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(this.direct) - .position({ x: this.positionX, y: this.positionY }) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: this.offsetY }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor(this.fontColor) - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keyPaste") - Button() { - Text('--------------------') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 200, - bottom:60 - }).backgroundColor('#00000000') - PasteButton({ icon: PasteIconStyle.LINES, text: PasteDescription.PASTE, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: PasteButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_pasteButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_pasteButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(this.direct) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: this.offsetY }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor(this.fontColor) - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keyPaste1") - }.width(this.columnWidth).height(this.columnHeight).clip(this.clipSet) - }.height('100%') - } -} diff --git a/test/security_component/entry/src/main/ets/MainAbility/pages/saveButton.ets b/test/security_component/entry/src/main/ets/MainAbility/pages/saveButton.ets deleted file mode 100644 index 4660b6736b69d717f109cabc683e5d8c4b3ccad8..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/MainAbility/pages/saveButton.ets +++ /dev/null @@ -1,241 +0,0 @@ -/** - * Copyright (c) 2023 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 events_emitter from '@ohos.events.emitter' - -@Entry -@Component -struct saveButton { - @State bgType: ButtonType = ButtonType.Normal - @State iconSize: number = 16 - @State direct: SecurityComponentLayoutDirection = 0 - @State positionX: number = 0 - @State positionY: number = 0 - @State anchorX: number = 0 - @State anchorY: number = 0 - @State offsetX: number = 0 - @State offsetY: number = 0 - @State fontSize: number = 16 - @State fontStyle: FontStyle = FontStyle.Normal - @State fontWeight: FontWeight = FontWeight.Medium - @State fontFamily: string = 'HarmonyOS Sans' - @State fontColor: number = 0xffffffff - @State iconColor: number = 0xffffffff - @State bgColor: number = 0xff007dff - @State borderSty: BorderStyle = BorderStyle.Dashed - @State borderWid: number = 0 - @State borderCol: number = 0xffffffff - @State borderRad: number = 0 - @State left: number = 24 - @State right: number = 24 - @State top: number = 8 - @State bottom: number = 8 - @State middle: number = 4 - @State clipSet: boolean = false - @State columnWidth: string = '100%' - @State columnHeight: string = '100%' - private stateChangeCallBack = (eventData) => { - if (eventData != null) { - console.debug("====>page_saveButton page state change called:" + JSON.stringify(eventData)); - if (eventData.data.bgType != null) { - this.bgType = eventData.data.bgType; - } - if (eventData.data.iconSize != null) { - this.iconSize = eventData.data.iconSize; - } - if (eventData.data.direct != null) { - this.direct = eventData.data.direct; - } - if (eventData.data.positionX != null) { - this.positionX = eventData.data.positionX; - } - if (eventData.data.positionY != null) { - this.positionY = eventData.data.positionY; - } - if (eventData.data.anchorX != null) { - this.anchorX = eventData.data.anchorX; - } - if (eventData.data.anchorY != null) { - this.anchorY = eventData.data.anchorY; - } - if (eventData.data.offsetX != null) { - this.offsetX = eventData.data.offsetX; - } - if (eventData.data.offsetY != null) { - this.offsetY = eventData.data.offsetY; - } - if (eventData.data.fontSize != null) { - this.fontSize = eventData.data.fontSize; - } - if (eventData.data.fontStyle != null) { - this.fontStyle = eventData.data.fontStyle; - } - if (eventData.data.fontWeight != null) { - this.fontWeight = eventData.data.fontWeight; - } - if (eventData.data.fontFamily != null) { - this.fontFamily = eventData.data.fontFamily; - } - if (eventData.data.fontColor != null) { - this.fontColor = eventData.data.fontColor; - } - if (eventData.data.iconColor != null) { - this.iconColor = eventData.data.iconColor; - } - if (eventData.data.bgColor != null) { - this.bgColor = eventData.data.bgColor; - } - if (eventData.data.borderSty != null) { - this.borderSty = eventData.data.borderSty; - } - if (eventData.data.borderWid != null) { - this.borderWid = eventData.data.borderWid; - } - if (eventData.data.borderCol != null) { - this.borderCol = eventData.data.borderCol; - } - if (eventData.data.borderRad != null) { - this.borderRad = eventData.data.borderRad; - } - if (eventData.data.left != null) { - this.left = eventData.data.left; - } - if (eventData.data.right != null) { - this.right = eventData.data.right; - } - if (eventData.data.top != null) { - this.top = eventData.data.top; - } - if (eventData.data.bottom != null) { - this.bottom = eventData.data.bottom; - } - if (eventData.data.middle != null) { - this.middle = eventData.data.middle; - } - if (eventData.data.clipSet != null) { - this.clipSet = eventData.data.clipSet; - } - if (eventData.data.columnWidth != null) { - this.columnWidth = eventData.data.columnWidth; - } - if (eventData.data.columnHeight != null) { - this.columnHeight = eventData.data.columnHeight; - } - } - } - - onPageShow() { - console.debug('====>page_saveButton page show called'); - var stateChangeEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(stateChangeEvent, this.stateChangeCallBack); - } - - onPageHide() { - console.debug('====>page_saveButton page hide called'); - events_emitter.off(1); - } - - build() { - Row() { - Column() { - SaveButton({ icon: SaveIconStyle.FULL_FILLED, text: SaveDescription.DOWNLOAD, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: SaveButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_saveButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_saveButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(this.direct) - .position({ x: this.positionX, y: this.positionY }) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: this.offsetY }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor(this.fontColor) - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keySave") - Button() { - Text('--------------------') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 200, - bottom:60 - }).backgroundColor('#00000000') - SaveButton({ icon: SaveIconStyle.FULL_FILLED, text: SaveDescription.DOWNLOAD, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: SaveButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_saveButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_saveButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(this.direct) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: this.offsetY }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor(this.fontColor) - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keySave1") - }.width(this.columnWidth).height(this.columnHeight).clip(this.clipSet) - }.height('100%') - } -} diff --git a/test/security_component/entry/src/main/ets/MainAbility/pages/saveButton_1.ets b/test/security_component/entry/src/main/ets/MainAbility/pages/saveButton_1.ets deleted file mode 100644 index 7414dbdebf521aee87eb1321a700c3faaa8ca22e..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/MainAbility/pages/saveButton_1.ets +++ /dev/null @@ -1,320 +0,0 @@ -/** - * Copyright (c) 2023 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 events_emitter from '@ohos.events.emitter' - -@Entry -@Component -struct saveButton_1 { - @State icon: SaveIconStyle = 0 - @State textType: SaveDescription = 0 - @State bgType: ButtonType = ButtonType.Normal - @State iconSize: number = 16 - @State positionX: number = 0 - @State positionY: number = 0 - @State anchorX: number = 0 - @State anchorY: number = 0 - @State offsetX: number = 0 - @State offsetY: number = 0 - @State fontSize: number = 16 - @State fontStyle: FontStyle = FontStyle.Normal - @State fontWeight: FontWeight = FontWeight.Medium - @State fontFamily: string = 'HarmonyOS Sans' - @State fontColor: number = 0xffffffff - @State iconColor: number = 0xffffffff - @State bgColor: number = 0x7dff - @State borderSty: BorderStyle = BorderStyle.Dashed - @State borderWid: number = 0 - @State borderCol: number = 0xffffffff - @State borderRad: number = 0 - @State left: number = 24 - @State right: number = 24 - @State top: number = 8 - @State bottom: number = 8 - @State middle: number = 4 - @State heightValue: number = 4 - marginValue = {top:30, bottom:30, left:10, right:10} - - build() { - Column() { - Row() { - SaveButton({ icon: SaveIconStyle.LINES, text: SaveDescription.DOWNLOAD_FILE, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: SaveButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_SaveButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_SaveButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keySave2") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - SaveButton({ icon: SaveIconStyle.FULL_FILLED, text: SaveDescription.SAVE, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: SaveButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_SaveButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_SaveButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.VERTICAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keySave3") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - SaveButton({ icon: SaveIconStyle.FULL_FILLED, text: SaveDescription.SAVE_IMAGE, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: SaveButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_SaveButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_SaveButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keySave4") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - SaveButton({ icon: SaveIconStyle.FULL_FILLED, text: SaveDescription.SAVE_FILE, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: SaveButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_SaveButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_SaveButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keySave5") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - SaveButton({ icon: SaveIconStyle.FULL_FILLED, text: SaveDescription.DOWNLOAD_AND_SHARE, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: SaveButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_SaveButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_SaveButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keySave6") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - SaveButton({ icon: SaveIconStyle.FULL_FILLED, text: SaveDescription.RECEIVE, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: SaveButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_SaveButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_SaveButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keySave7") - }.width('100%').height(this.heightValue).margin(this.marginValue) - Row() { - SaveButton({ icon: SaveIconStyle.FULL_FILLED, text: SaveDescription.CONTINUE_TO_RECEIVE, buttonType: this.bgType }) - .onClick((event: ClickEvent, result: SaveButtonOnClickResult) => { - try { - var clickData = { - data: { - "clickResult": result, - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>page_SaveButton onclick result:" + JSON.stringify(result)) - events_emitter.emit(clickEvent, clickData) - } catch (err) { - console.debug("====>page_SaveButton emit action state err: " + JSON.stringify(err.message)) - } - }) - .iconSize(this.iconSize) - .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL) - .markAnchor({ x: this.anchorX, y: this.anchorY }) - .offset({ x: this.offsetX, y: 0 }) - .fontSize(this.fontSize) - .fontStyle(this.fontStyle) - .fontWeight(this.fontWeight) - .fontFamily(this.fontFamily) - .fontColor('0xFFFFF000') - .iconColor(this.iconColor) - .backgroundColor(this.bgColor) - .borderStyle(this.borderSty) - .borderWidth(this.borderWid) - .borderColor(this.borderCol) - .borderRadius(this.borderRad) - .padding({ left: this.left, right: this.right, top: this.top, bottom: this.bottom }) - .textIconSpace(this.middle) - .key("keySave8") - }.width('100%').height(this.heightValue).margin(this.marginValue) - } - } -} diff --git a/test/security_component/entry/src/main/ets/TestAbility/TestAbility.ts b/test/security_component/entry/src/main/ets/TestAbility/TestAbility.ts deleted file mode 100644 index 368bbfc95338f58f24c4854f8ce6157fcc4af5f9..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/TestAbility/TestAbility.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 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 TestAbility extends Ability { - onCreate(want, launchParam) { - console.log('TestAbility onCreate') - } - - onDestroy() { - console.log('TestAbility onDestroy') - } - - onWindowStageCreate(windowStage) { - console.log('TestAbility onWindowStageCreate') - windowStage.loadContent("TestAbility/pages/index", (err, data) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) - }); - - globalThis.abilityContext = this.context; - } - - onWindowStageDestroy() { - console.log('TestAbility onWindowStageDestroy') - } - - onForeground() { - console.log('TestAbility onForeground') - } - - onBackground() { - console.log('TestAbility onBackground') - } -}; \ No newline at end of file diff --git a/test/security_component/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/test/security_component/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts deleted file mode 100644 index bf0d2c2ec3dde78d766e2a564468bfeef97d31ea..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts +++ /dev/null @@ -1,79 +0,0 @@ -// @ts-nocheck -/** - * Copyright (c) 2023 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.app.ability.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.example.securitycomponent.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/test/security_component/entry/src/main/ets/test/LocationComponentTest.test.ets b/test/security_component/entry/src/main/ets/test/LocationComponentTest.test.ets deleted file mode 100644 index b1b39baa11151f430d9a2252f6264cc79f6f87fb..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/test/LocationComponentTest.test.ets +++ /dev/null @@ -1,1927 +0,0 @@ -/** - * Copyright (c) 2023 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 router from '@ohos.router'; -import events_emitter from '@ohos.events.emitter'; -import { Driver, ON } from '@ohos.UiTest' -import Utils from './Utils'; - -export default function locationComponentTest() { - describe('locationComponentTest', function () { - beforeAll(async function (done) { - let options = { - url: 'MainAbility/pages/locationButton', - } - try { - router.clear(); - let pages = router.getState(); - console.debug("====>locationComponentTest get state success " + JSON.stringify(pages)); - if (!("locationButton" == pages.name)) { - console.debug("====>locationComponentTest get state success " + JSON.stringify(pages.name)); - let result = await router.pushUrl(options); - await Utils.sleep(2000); - console.debug("====>locationComponentTest push page success " + JSON.stringify(result)); - } - } catch (err) { - console.error("====>locationComponentTest push page error: " + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.debug("====>locationComponentTest after each called"); - }); - - it('Test_Security_Button_Location_0100', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_0100] START===='); - let strJson = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJson); - expect(obj.$attrs.icon).assertEqual(0); - expect(obj.$attrs.text).assertEqual(0); - expect(obj.$attrs.buttonType).assertEqual(0); - expect(obj.$attrs.iconSize).assertEqual('16.00vp'); - expect(obj.$attrs.layoutDirection).assertEqual(0); - expect(obj.$attrs.position.x).assertEqual('0.00vp'); - expect(obj.$attrs.position.y).assertEqual('0.00vp'); - expect(obj.$attrs.markAnchor.x).assertEqual('0.00vp'); - expect(obj.$attrs.markAnchor.y).assertEqual('0.00vp'); - expect(obj.$attrs.offset.x).assertEqual('0.00vp'); - expect(obj.$attrs.offset.y).assertEqual('0.00vp'); - expect(obj.$attrs.fontSize).assertEqual('16.00fp'); - expect(obj.$attrs.fontStyle).assertEqual(0); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Medium'); - expect(obj.$attrs.fontFamily).assertEqual('HarmonyOS Sans'); - expect(obj.$attrs.fontColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.iconColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.backgroundColor).assertEqual('#FF007DFF'); - expect(obj.$attrs.borderStyle).assertEqual(1); - expect(obj.$attrs.borderWidth).assertEqual('0.00vp'); - expect(obj.$attrs.borderColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.borderRadius).assertEqual('0.00vp'); - expect(obj.$attrs.padding.left).assertEqual('24.00vp'); - expect(obj.$attrs.padding.right).assertEqual('24.00vp'); - expect(obj.$attrs.padding.top).assertEqual('8.00vp'); - expect(obj.$attrs.padding.bottom).assertEqual('8.00vp'); - expect(obj.$attrs.textIconSpace).assertEqual('4.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = async (clickData) => { - console.debug("====>[Test_Security_Button_Location_0100] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_0100] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_0100] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - await Utils.sleep(500); - let driver = Driver.create(); - let textComponent = await driver.findComponent(ON.type('Button')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_0100] textComponent is:" + JSON.stringify(textComponent)); - await textComponent.click(); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_0100] END===="); - done() - } else { - console.debug("====>[Test_Security_Button_Location_0100] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_0100] END===="); - done() - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0100] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_0100] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0100] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_0200', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_0200] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": SecurityComponentLayoutDirection.VERTICAL, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_0200] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0200] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.layoutDirection).assertEqual(SecurityComponentLayoutDirection.VERTICAL); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_0200] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_0200] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_0200] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_0200] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_0200] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_0200] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0200] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_0200] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0200] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_0300', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_0300] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 150, - "positionY": 20, - "anchorX": 20, - "anchorY": 20, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_0300] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0300] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.position.x).assertEqual('150.00vp'); - expect(obj.$attrs.position.y).assertEqual('20.00vp'); - expect(obj.$attrs.markAnchor.x).assertEqual('20.00vp'); - expect(obj.$attrs.markAnchor.y).assertEqual('20.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_0300] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_0300] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_0300] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_0300] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_0300] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_0300] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0300] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_0300] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0300] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_0400', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_0400] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 1, - "positionX": 0, - "positionY": 0, - "anchorX": 20, - "anchorY": 20, - "offsetX": 100, - "offsetY": 100, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_0400] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0400] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation1'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.offset.x).assertEqual('100.00vp'); - expect(obj.$attrs.offset.y).assertEqual('100.00vp'); - expect(obj.$attrs.markAnchor.x).assertEqual('20.00vp'); - expect(obj.$attrs.markAnchor.y).assertEqual('20.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_0400] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_0400] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_0400] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_0400] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_0400] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_0400] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0400] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_0400] button is:" + JSON.stringify(button)); - await button[1].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0400] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_0500', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_0500] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Italic, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_0500] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0500] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontStyle).assertEqual(1); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_0500] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_0500] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_0500] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_0500] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_0500] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_0500] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0500] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_0500] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0500] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_0600', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_0600] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Lighter, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_0600] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0600] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Lighter'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_0600] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_0600] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_0600] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_0600] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_0600] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_0600] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0600] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_0600] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0600] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_0700', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_0700] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Normal, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_0700] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0700] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Normal'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_0700] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_0700] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_0700] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_0700] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_0700] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_0700] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0700] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_0700] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0700] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_0800', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_0800] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Regular, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_0800] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0800] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Regular'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_0800] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_0800] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_0800] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_0800] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_0800] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_0800] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0800] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_0800] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0800] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_0900', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_0900] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Bold, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_0900] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0900] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Bold'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_0900] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_0900] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_0900] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_0900] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_0900] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_0900] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0900] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_0900] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_0900] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_1000', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_1000] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Bolder, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_1000] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1000] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Bolder'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_1000] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_1000] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_1000] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_1000] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_1000] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_1000] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1000] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_1000] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1000] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_1100', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_1100] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dotted, - "borderWid": 5, - "borderCol": 0xffffffff, - "borderRad": 5, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_1100] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1100] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.borderStyle).assertEqual(2); - expect(obj.$attrs.borderWidth).assertEqual('5.00vp'); - expect(obj.$attrs.borderColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.borderRadius).assertEqual('5.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_1100] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_1100] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_1100] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_1100] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_1100] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_1100] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1100] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_1100] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1100] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_1200', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_1200] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 5, - "borderCol": 0xffffffff, - "borderRad": 5, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_1200] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1200] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.borderStyle).assertEqual(1); - expect(obj.$attrs.borderWidth).assertEqual('5.00vp'); - expect(obj.$attrs.borderColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.borderRadius).assertEqual('5.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_1200] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_1200] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_1200] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_1200] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_1200] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_1200] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1200] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_1200] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1200] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_1300', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_1300] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Solid, - "borderWid": 5, - "borderCol": 0xffffffff, - "borderRad": 5, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_1300] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1300] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.borderStyle).assertEqual(0); - expect(obj.$attrs.borderWidth).assertEqual('5.00vp'); - expect(obj.$attrs.borderColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.borderRadius).assertEqual('5.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_1300] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_1300] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_1300] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_1300] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_1300] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_1300] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1300] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_1300] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1300] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_1400', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_1400] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 200, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_1400] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1400] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation1'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.offset.x).assertEqual('200.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_1400] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_1400] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Location_1400] ERR CASE 成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Location_1400] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_1400] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_1400] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1400] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_1400] button is:" + JSON.stringify(button)); - await button[1].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1400] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_1500', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_1500] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": -200, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_1500] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1500] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation1'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.offset.x).assertEqual('-200.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_1500] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_1500] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Location_1500] ERR CASE 成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Location_1500] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_1500] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_1500] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1500] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_1500] button is:" + JSON.stringify(button)); - await button[1].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1500] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_1600', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_1600] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 150, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_1600] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1600] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.iconSize).assertEqual('150.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_1600] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_1600] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Location_1600] ERR CASE 成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Location_1600] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_1600] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_1600] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1600] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_1600] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1600] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_1700', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_1700] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0x10ff0000, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_1700] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1700] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.iconColor).assertEqual('#10FF0000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_1700] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_1700] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Location_1700] ERR CASE 成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Location_1700] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_1700] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_1700] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1700] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_1700] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1700] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_1800', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_1800] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 20, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xfffa0050, - "bgColor": 0xffff0000, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_1800] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1800] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.buttonType).assertEqual(0); - expect(obj.$attrs.iconSize).assertEqual('20.00vp'); - expect(obj.$attrs.iconColor).assertEqual('#FFFA0050'); - expect(obj.$attrs.backgroundColor).assertEqual('#FFFF0000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_1800] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_1800] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Location_1800] ERR CASE 成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Location_1800] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_1800] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_1800] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1800] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_1800] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1800] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_1900', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_1900] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 1, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 20, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_1900] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1900] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.iconSize).assertEqual('1.00vp'); - expect(obj.$attrs.fontSize).assertEqual('20.00fp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_1900] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_1900] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Location_1900] ERR CASE 成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Location_1900] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_1900] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_1900] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1900] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_1900] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_1900] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_2000', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_2000] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": Color.Transparent, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_2000] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2000] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.iconColor).assertEqual('#00000000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_2000] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_2000] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Location_2000] ERR CASE 成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Location_2000] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_2000] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_2000] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2000] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_2000] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2000] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_2100', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_2100] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": Color.Transparent, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_2100] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2100] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontColor).assertEqual('#00000000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_2100] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_2100] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Location_2100] ERR CASE 成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Location_2100] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_2100] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_2100] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2100] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_2100] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2100] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_2200', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_2200] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 20, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": Color.Transparent, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Location_2200] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2200] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.backgroundColor).assertEqual('#00000000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_2200] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_2200] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Location_2200] ERR CASE 成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Location_2200] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_2200] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_2200] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2200] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_2200] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2200] clickSecComponent err : " + JSON.stringify(err)); - } - }); - }) -} \ No newline at end of file diff --git a/test/security_component/entry/src/main/ets/test/LocationComponentTest_1.test.ets b/test/security_component/entry/src/main/ets/test/LocationComponentTest_1.test.ets deleted file mode 100644 index dad8ed8b0da2928e5df703c4345e2dac7d1086fe..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/test/LocationComponentTest_1.test.ets +++ /dev/null @@ -1,490 +0,0 @@ -/** - * Copyright (c) 2023 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 router from '@ohos.router'; -import events_emitter from '@ohos.events.emitter'; -import { Driver, ON } from '@ohos.UiTest' -import Utils from './Utils'; - -export default function locationComponentTest_1() { - describe('locationComponentTest_1', function () { - beforeAll(async function (done) { - let options = { - url: 'MainAbility/pages/locationButton_1', - } - try { - router.clear(); - let pages = router.getState(); - console.debug("====>locationComponentTest_1 get state success " + JSON.stringify(pages)); - if (!("locationButton_1" == pages.name)) { - console.debug("====>locationComponentTest_1 get state success " + JSON.stringify(pages.name)); - let result = await router.pushUrl(options); - await Utils.sleep(2000); - console.debug("====>locationComponentTest_1 push page success " + JSON.stringify(result)); - } - } catch (err) { - console.error("====>locationComponentTest_1 push page error: " + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.debug("====>locationComponentTest_1 after each called"); - }); - - it('Test_Security_Button_Location_2300', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_2300] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation2'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.icon:" + obj.$attrs.icon); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.icon).assertEqual(1); - expect(obj.$attrs.text).assertEqual(1); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_2300] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_2300] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_2300] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_2300] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_2300] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_2300] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2300] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_2300] button is:" + JSON.stringify(button)); - await button[0].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2300] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_2400', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_2400] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation3'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(2); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_2400] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_2400] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_2400] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_2400] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_2400] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_2400] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2400] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_2400] button is:" + JSON.stringify(button)); - await button[1].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2400] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_2500', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_2500] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation4'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(3); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_2500] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_2500] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_2500] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_2500] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_2500] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_2500] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2500] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_2500] button is:" + JSON.stringify(button)); - await button[2].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2500] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_2600', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_2600] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation5'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(4); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_2600] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_2600] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_2600] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_2600] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_2600] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_2600] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2600] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_2600] button is:" + JSON.stringify(button)); - await button[3].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2600] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_2700', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_2700] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation6'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(5); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_2700] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_2700] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_2700] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_2700] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_2700] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_2700] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2700] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_2700] button is:" + JSON.stringify(button)); - await button[4].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2700] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_2800', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_2800] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation7'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(6); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_2800] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_2800] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_2800] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_2800] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_2800] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_2800] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2800] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_2800] button is:" + JSON.stringify(button)); - await button[5].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2800] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_2900', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_2900] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation8'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(7); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_2900] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_2900] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_2900] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_2900] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_2900] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_2900] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2900] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_2900] button is:" + JSON.stringify(button)); - await button[6].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_2900] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_3000', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_3000] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation9'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(8); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_3000] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_3000] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_3000] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_3000] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_3000] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_3000] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_3000] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_3000] button is:" + JSON.stringify(button)); - await button[7].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_3000] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_3100', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_3100] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation10'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(9); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_3100] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_3100] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_3100] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_3100] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_3100] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_3100] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_3100] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_3100] button is:" + JSON.stringify(button)); - await button[8].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_3100] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Location_3200', 0, async function (done) { - console.debug('====>[Test_Security_Button_Location_3200] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyLocation11'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(10); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Location_3200] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Location_3200] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Location_3200] 设置权限成功"); - expect(clickData.data.clickResult == LocationButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Location_3200] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Location_3200] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Location_3200] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_3200] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('LocationButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Location_3200] button is:" + JSON.stringify(button)); - await button[9].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Location_3200] clickSecComponent err : " + JSON.stringify(err)); - } - }); - }) -} \ No newline at end of file diff --git a/test/security_component/entry/src/main/ets/test/PasteComponentTest.test.ets b/test/security_component/entry/src/main/ets/test/PasteComponentTest.test.ets deleted file mode 100644 index fbf134d308213e46692d5ade3b39e248bca65076..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/test/PasteComponentTest.test.ets +++ /dev/null @@ -1,1923 +0,0 @@ -/** - * Copyright (c) 2023 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 router from '@ohos.router'; -import events_emitter from '@ohos.events.emitter'; -import { Driver, ON } from '@ohos.UiTest' -import Utils from './Utils'; - -export default function pasteComponentTest() { - describe('pasteComponentTest', function () { - beforeAll(async function (done) { - let options = { - url: 'MainAbility/pages/pasteButton', - } - try { - router.clear(); - let pages = router.getState(); - console.debug("====>pasteComponentTest get state success " + JSON.stringify(pages)); - if (!("pasteButton" == pages.name)) { - console.debug("====>pasteComponentTest get state success " + JSON.stringify(pages.name)); - let result = await router.pushUrl(options); - await Utils.sleep(2000); - console.debug("====>pasteComponentTest push page success " + JSON.stringify(result)); - } - } catch (err) { - console.error("====>pasteComponentTest push page error: " + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.debug("====>pasteComponentTest after each called"); - }); - - it('Test_Security_Button_Paste_0100', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_0100] START'); - let strJson = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJson); - expect(obj.$attrs.icon).assertEqual(0); - expect(obj.$attrs.text).assertEqual(0); - expect(obj.$attrs.buttonType).assertEqual(0); - expect(obj.$attrs.iconSize).assertEqual('16.00vp'); - expect(obj.$attrs.layoutDirection).assertEqual(0); - expect(obj.$attrs.position.x).assertEqual('0.00vp'); - expect(obj.$attrs.position.y).assertEqual('0.00vp'); - expect(obj.$attrs.markAnchor.x).assertEqual('0.00vp'); - expect(obj.$attrs.markAnchor.y).assertEqual('0.00vp'); - expect(obj.$attrs.offset.x).assertEqual('0.00vp'); - expect(obj.$attrs.offset.y).assertEqual('0.00vp'); - expect(obj.$attrs.fontSize).assertEqual('16.00fp'); - expect(obj.$attrs.fontStyle).assertEqual(0); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Medium'); - expect(obj.$attrs.fontFamily).assertEqual('HarmonyOS Sans'); - expect(obj.$attrs.fontColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.iconColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.backgroundColor).assertEqual('#FF007DFF'); - expect(obj.$attrs.borderStyle).assertEqual(1); - expect(obj.$attrs.borderWidth).assertEqual('0.00vp'); - expect(obj.$attrs.borderColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.borderRadius).assertEqual('0.00vp'); - expect(obj.$attrs.padding.left).assertEqual('24.00vp'); - expect(obj.$attrs.padding.right).assertEqual('24.00vp'); - expect(obj.$attrs.padding.top).assertEqual('8.00vp'); - expect(obj.$attrs.padding.bottom).assertEqual('8.00vp'); - expect(obj.$attrs.textIconSpace).assertEqual('4.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = async (clickData) => { - console.debug("====>[Test_Security_Button_Paste_0100] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_0100] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Paste_0100] 设置权限成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS).assertTrue(); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_0100] END===="); - done() - } else { - console.debug("====>[Test_Security_Button_Paste_0100] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_0100] END===="); - done() - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0100] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_0100] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0100] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - - it('Test_Security_Button_Paste_0200', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_0200] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": SecurityComponentLayoutDirection.VERTICAL, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_0200] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0200] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.layoutDirection).assertEqual(SecurityComponentLayoutDirection.VERTICAL); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_0200] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_0200] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Paste_0200] 设置权限成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_0200] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_0200] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_0200] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0200] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_0200] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0200] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_0300', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_0300] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 150, - "positionY": 20, - "anchorX": 20, - "anchorY": 20, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_0300] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0300] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.position.x).assertEqual('150.00vp'); - expect(obj.$attrs.position.y).assertEqual('20.00vp'); - expect(obj.$attrs.markAnchor.x).assertEqual('20.00vp'); - expect(obj.$attrs.markAnchor.y).assertEqual('20.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_0300] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_0300] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Paste_0300] 设置权限成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_0300] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_0300] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_0300] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0300] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_0300] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0300] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - - it('Test_Security_Button_Paste_0400', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_0400] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 1, - "positionX": 0, - "positionY": 0, - "anchorX": 20, - "anchorY": 20, - "offsetX": 100, - "offsetY": 100, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_0400] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0400] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste1'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.offset.x).assertEqual('100.00vp'); - expect(obj.$attrs.offset.y).assertEqual('100.00vp'); - expect(obj.$attrs.markAnchor.x).assertEqual('20.00vp'); - expect(obj.$attrs.markAnchor.y).assertEqual('20.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_0400] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_0400] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Paste_0400] 设置权限成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_0400] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_0400] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_0400] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0400] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_0400] button is:" + JSON.stringify(button)); - await button[1].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0400] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_0500', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_0500] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Italic, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_0500] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0500] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontStyle).assertEqual(1); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_0500] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_0500] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Paste_0500] 设置权限成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_0500] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_0500] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_0500] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0500] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_0500] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0500] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_0600', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_0600] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Lighter, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_0600] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0600] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Lighter'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_0600] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_0600] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Paste_0600] 设置权限成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_0600] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_0600] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_0600] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0600] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_0600] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0600] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_0700', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_0700] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Normal, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_0700] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0700] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Normal'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_0700] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_0700] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Paste_0700] 设置权限成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_0700] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_0700] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_0700] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0700] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_0700] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0700] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_0800', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_0800] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Regular, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_0800] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0800] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Regular'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_0800] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_0800] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Paste_0800] 设置权限成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_0800] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_0800] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_0800] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0800] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_0800] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0800] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_0900', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_0900] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Bold, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_0900] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0900] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Bold'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_0900] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_0900] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Paste_0900] 设置权限成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_0900] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_0900] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_0900] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0900] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_0900] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_0900] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_1000', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_1000] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Bolder, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_1000] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1000] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Bolder'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_1000] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_1000] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Paste_1000] 设置权限成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_1000] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_1000] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_1000] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1000] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_1000] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1000] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_1100', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_1100] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dotted, - "borderWid": 5, - "borderCol": 0xffffffff, - "borderRad": 5, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_1100] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1100] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.borderStyle).assertEqual(2); - expect(obj.$attrs.borderWidth).assertEqual('5.00vp'); - expect(obj.$attrs.borderColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.borderRadius).assertEqual('5.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_1100] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_1100] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Paste_1100] 设置权限成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_1100] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_1100] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_1100] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1100] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_1100] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1100] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_1200', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_1200] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 5, - "borderCol": 0xffffffff, - "borderRad": 5, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_1200] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1200] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.borderStyle).assertEqual(1); - expect(obj.$attrs.borderWidth).assertEqual('5.00vp'); - expect(obj.$attrs.borderColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.borderRadius).assertEqual('5.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_1200] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_1200] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Paste_1200] 设置权限成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_1200] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_1200] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_1200] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1200] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_1200] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1200] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_1300', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_1300] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Solid, - "borderWid": 5, - "borderCol": 0xffffffff, - "borderRad": 5, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_1300] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1300] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.borderStyle).assertEqual(0); - expect(obj.$attrs.borderWidth).assertEqual('5.00vp'); - expect(obj.$attrs.borderColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.borderRadius).assertEqual('5.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_1300] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_1300] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Paste_1300] 设置权限成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_1300] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_1300] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_1300] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1300] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_1300] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1300] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_1400', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_1400] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 200, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_1400] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1400] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste1'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.offset.x).assertEqual('200.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_1400] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_1400] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Paste_1400] ERR CASE 成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_1400] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_1400] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_1400] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1400] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_1400] button is:" + JSON.stringify(button)); - await button[1].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1400] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_1500', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_1500] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": -200, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_1500] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1500] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste1'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.offset.x).assertEqual('-200.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_1500] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_1500] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Paste_1500] ERR CASE 成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_1500] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_1500] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_1500] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1500] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_1500] button is:" + JSON.stringify(button)); - await button[1].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1500] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_1600', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_1600] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 150, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_1600] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1600] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.iconSize).assertEqual('150.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_1600] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_1600] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Paste_1600] ERR CASE 成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_1600] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_1600] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_1600] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1600] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_1600] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1600] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_1700', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_1700] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0x10ff0000, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_1700] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1700] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.iconColor).assertEqual('#10FF0000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_1700] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_1700] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Paste_1700] ERR CASE 成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_1700] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_1700] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_1700] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1700] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_1700] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1700] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_1800', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_1800] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 20, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xfffa0050, - "bgColor": 0xffff0000, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_1800] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1800] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.buttonType).assertEqual(0); - expect(obj.$attrs.iconSize).assertEqual('20.00vp'); - expect(obj.$attrs.iconColor).assertEqual('#FFFA0050'); - expect(obj.$attrs.backgroundColor).assertEqual('#FFFF0000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_1800] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_1800] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Paste_1800] ERR CASE 成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_1800] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_1800] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_1800] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1800] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_1800] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1800] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_1900', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_1900] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 1, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 20, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_1900] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1900] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.iconSize).assertEqual('1.00vp'); - expect(obj.$attrs.fontSize).assertEqual('20.00fp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_1900] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_1900] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Paste_1900] ERR CASE 成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_1900] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_1900] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_1900] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1900] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_1900] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_1900] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_2000', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_2000] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor":Color.Transparent, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_2000] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_2000] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.iconColor).assertEqual('#00000000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_2000] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_2000] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Paste_2000] ERR CASE 成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_2000] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_2000] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_2000] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_2000] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_2000] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_2000] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_2100', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_2100] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": Color.Transparent, - "iconColor":0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_2100] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_2100] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontColor).assertEqual('#00000000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_2100] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_2100] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Paste_2100] ERR CASE 成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_2100] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_2100] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_2100] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_2100] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_2100] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_2100] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Paste_2200', 0, async function (done) { - console.debug('====>[Test_Security_Button_Paste_2200] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 20, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor":0xffffffff, - "bgColor": Color.Transparent, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Paste_2200] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_2200] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keyPaste'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.backgroundColor).assertEqual('#00000000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Paste_2200] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Paste_2200] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Paste_2200] ERR CASE 成功"); - expect(clickData.data.clickResult == PasteButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Paste_2200] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Paste_2200] ERR CASE 失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Paste_2200] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_2200] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('PasteButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Paste_2200] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Paste_2200] clickSecComponent err : " + JSON.stringify(err)); - } - }); - }) -} \ No newline at end of file diff --git a/test/security_component/entry/src/main/ets/test/SaveComponentTest.test.ets b/test/security_component/entry/src/main/ets/test/SaveComponentTest.test.ets deleted file mode 100644 index 112b6bbacfb32d7fa30214e4065fc21d7a8b0828..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/test/SaveComponentTest.test.ets +++ /dev/null @@ -1,1926 +0,0 @@ -/** - * Copyright (c) 2023 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 router from '@ohos.router'; -import events_emitter from '@ohos.events.emitter'; -import { Driver, ON } from '@ohos.UiTest' -import Utils from './Utils'; - -export default function saveComponentTest() { - describe('saveComponentTest', function () { - beforeAll(async function (done) { - let options = { - url: 'MainAbility/pages/saveButton', - } - try { - router.clear(); - let pages = router.getState(); - console.debug("====>saveComponentTest get state success " + JSON.stringify(pages)); - if (!("saveButton" == pages.name)) { - console.debug("====>saveComponentTest get state success " + JSON.stringify(pages.name)); - let result = await router.pushUrl(options); - await Utils.sleep(2000); - console.debug("====>saveComponentTest push page success " + JSON.stringify(result)); - } - } catch (err) { - console.error("====>saveComponentTest push page error: " + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.debug("====>saveComponentTest after each called"); - }); - - it('Test_Security_Button_Save_0100', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_0100] START===='); - let strJson = getInspectorByKey('keySave'); - let obj = JSON.parse(strJson); - expect(obj.$attrs.icon).assertEqual(0); - expect(obj.$attrs.text).assertEqual(0); - expect(obj.$attrs.buttonType).assertEqual(0); - expect(obj.$attrs.iconSize).assertEqual('16.00vp'); - expect(obj.$attrs.layoutDirection).assertEqual(0); - expect(obj.$attrs.position.x).assertEqual('0.00vp'); - expect(obj.$attrs.position.y).assertEqual('0.00vp'); - expect(obj.$attrs.markAnchor.x).assertEqual('0.00vp'); - expect(obj.$attrs.markAnchor.y).assertEqual('0.00vp'); - expect(obj.$attrs.offset.x).assertEqual('0.00vp'); - expect(obj.$attrs.offset.y).assertEqual('0.00vp'); - expect(obj.$attrs.fontSize).assertEqual('16.00fp'); - expect(obj.$attrs.fontStyle).assertEqual(0); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Medium'); - expect(obj.$attrs.fontFamily).assertEqual('HarmonyOS Sans'); - expect(obj.$attrs.fontColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.iconColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.backgroundColor).assertEqual('#FF007DFF'); - expect(obj.$attrs.borderStyle).assertEqual(1); - expect(obj.$attrs.borderWidth).assertEqual('0.00vp'); - expect(obj.$attrs.borderColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.borderRadius).assertEqual('0.00vp'); - expect(obj.$attrs.padding.left).assertEqual('24.00vp'); - expect(obj.$attrs.padding.right).assertEqual('24.00vp'); - expect(obj.$attrs.padding.top).assertEqual('8.00vp'); - expect(obj.$attrs.padding.bottom).assertEqual('8.00vp'); - expect(obj.$attrs.textIconSpace).assertEqual('4.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = async (clickData) => { - console.debug("====>[Test_Security_Button_Save_0100] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_0100] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_0100] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - await Utils.sleep(500); - let driver = Driver.create(); - let textComponent = await driver.findComponent(ON.type('Button')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_0100] textComponent is:" + JSON.stringify(textComponent)); - await textComponent.click(); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_0100] END===="); - done() - } else { - console.debug("====>[Test_Security_Button_Save_0100] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_0100] END===="); - done() - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0100] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_0100] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0100] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_0200', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_0200] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": SecurityComponentLayoutDirection.VERTICAL, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_0200] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0200] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.layoutDirection).assertEqual(SecurityComponentLayoutDirection.VERTICAL); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_0200] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_0200] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_0200] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_0200] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_0200] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_0200] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0200] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_0200] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0200] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_0300', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_0300] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 150, - "positionY": 20, - "anchorX": 20, - "anchorY": 20, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_0300] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0300] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.position.x).assertEqual('150.00vp'); - expect(obj.$attrs.position.y).assertEqual('20.00vp'); - expect(obj.$attrs.markAnchor.x).assertEqual('20.00vp'); - expect(obj.$attrs.markAnchor.y).assertEqual('20.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_0300] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_0300] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_0300] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_0300] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_0300] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_0300] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0300] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_0300] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0300] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_0400', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_0400] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 1, - "positionX": 0, - "positionY": 0, - "anchorX": 20, - "anchorY": 20, - "offsetX": 100, - "offsetY": 100, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_0400] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0400] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave1'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.offset.x).assertEqual('100.00vp'); - expect(obj.$attrs.offset.y).assertEqual('100.00vp'); - expect(obj.$attrs.markAnchor.x).assertEqual('20.00vp'); - expect(obj.$attrs.markAnchor.y).assertEqual('20.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_0400] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_0400] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_0400] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_0400] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_0400] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_0400] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0400] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_0400] button is:" + JSON.stringify(button)); - await button[1].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0400] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_0500', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_0500] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Italic, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_0500] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0500] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontStyle).assertEqual(1); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_0500] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_0500] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_0500] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_0500] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_0500] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_0500] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0500] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_0500] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0500] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_0600', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_0600] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Lighter, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_0600] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0600] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Lighter'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_0600] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_0600] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_0600] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_0600] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_0600] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_0600] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0600] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_0600] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0600] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_0700', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_0700] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Normal, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_0700] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0700] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Normal'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_0700] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_0700] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_0700] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_0700] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_0700] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_0700] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0700] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_0700] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0700] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_0800', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_0800] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Regular, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_0800] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0800] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Regular'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_0800] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_0800] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_0800] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_0800] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_0800] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_0800] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0800] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_0800] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0800] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_0900', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_0900] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Bold, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_0900] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0900] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Bold'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_0900] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_0900] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_0900] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_0900] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_0900] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_0900] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0900] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_0900] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_0900] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_1000', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_1000] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Bolder, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_1000] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1000] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Bolder'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_1000] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_1000] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_1000] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_1000] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_1000] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_1000] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1000] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_1000] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1000] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_1100', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_1100] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dotted, - "borderWid": 5, - "borderCol": 0xffffffff, - "borderRad": 5, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_1100] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1100] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.borderStyle).assertEqual(2); - expect(obj.$attrs.borderWidth).assertEqual('5.00vp'); - expect(obj.$attrs.borderColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.borderRadius).assertEqual('5.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_1100] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_1100] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_1100] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_1100] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_1100] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_1100] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1100] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_1100] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1100] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_1200', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_1200] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 5, - "borderCol": 0xffffffff, - "borderRad": 5, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_1200] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1200] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.borderStyle).assertEqual(1); - expect(obj.$attrs.borderWidth).assertEqual('5.00vp'); - expect(obj.$attrs.borderColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.borderRadius).assertEqual('5.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_1200] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_1200] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_1200] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_1200] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_1200] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_1200] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1200] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_1200] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1200] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_1300', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_1300] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Solid, - "borderWid": 5, - "borderCol": 0xffffffff, - "borderRad": 5, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_1300] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1300] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.borderStyle).assertEqual(0); - expect(obj.$attrs.borderWidth).assertEqual('5.00vp'); - expect(obj.$attrs.borderColor).assertEqual('#FFFFFFFF'); - expect(obj.$attrs.borderRadius).assertEqual('5.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_1300] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_1300] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_1300] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_1300] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_1300] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_1300] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1300] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_1300] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1300] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_1400', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_1400] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 200, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_1400] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1400] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave1'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.offset.x).assertEqual('200.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_1400] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_1400] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Save_1400] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Save_1400] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_1400] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_1400] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1400] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_1400] button is:" + JSON.stringify(button)); - await button[1].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1400] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_1500', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_1500] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": -200, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_1500] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1500] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave1'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.offset.x).assertEqual('-200.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_1500] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_1500] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Save_1500] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Save_1500] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_1500] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_1500] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1500] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_1500] button is:" + JSON.stringify(button)); - await button[1].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1500] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_1600', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_1600] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 150, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_1600] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1600] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.iconSize).assertEqual('150.00vp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_1600] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_1600] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Save_1600] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Save_1600] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_1600] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_1600] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1600] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_1600] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1600] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_1700', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_1700] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0x10ff0000, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_1700] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1700] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.iconColor).assertEqual('#10FF0000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_1700] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_1700] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Save_1700] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Save_1700] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_1700] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_1700] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1700] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_1700] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1700] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_1800', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_1800] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 20, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xfffa0050, - "bgColor": 0xffff0000, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_1800] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1800] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.iconSize).assertEqual('20.00vp'); - expect(obj.$attrs.iconColor).assertEqual('#FFFA0050'); - expect(obj.$attrs.backgroundColor).assertEqual('#FFFF0000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_1800] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_1800] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Save_1800] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Save_1800] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_1800] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_1800] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1800] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_1800] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1800] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_1900', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_1900] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 1, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 20, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_1900] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1900] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.iconSize).assertEqual('1.00vp'); - expect(obj.$attrs.fontSize).assertEqual('20.00fp'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_1900] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_1900] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Save_1900] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Save_1900] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_1900] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_1900] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1900] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_1900] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_1900] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_2000', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_2000] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": Color.Transparent, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_2000] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2000] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.iconColor).assertEqual('#00000000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_2000] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_2000] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Save_2000] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Save_2000] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_2000] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_2000] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2000] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_2000] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2000] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_2100', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_2100] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 16, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": Color.Transparent, - "iconColor": 0xffffffff, - "bgColor": 0xff007dff, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_2100] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2100] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.fontColor).assertEqual('#00000000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_2100] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_2100] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Save_2100] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Save_2100] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_2100] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_2100] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2100] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_2100] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2100] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_2200', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_2200] START===='); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "icon": 0, - "textType": 0, - "bgType": ButtonType.Normal, - "iconSize": 16, - "direct": 0, - "positionX": 0, - "positionY": 0, - "anchorX": 0, - "anchorY": 0, - "offsetX": 0, - "offsetY": 0, - "fontSize": 20, - "fontStyle": FontStyle.Normal, - "fontWeight": FontWeight.Medium, - "fontFamily": 'HarmonyOS Sans', - "fontColor": 0xffffffff, - "iconColor": 0xffffffff, - "bgColor": Color.Transparent, - "borderSty": BorderStyle.Dashed, - "borderWid": 0, - "borderCol": 0xffffffff, - "borderRad": 0, - "left": 24, - "right": 24, - "top": 8, - "bottom": 8, - "middle": 4 - } - } - var innerEvent = { - eventId: 1, - priority: events_emitter.EventPriority.LOW - } - console.debug("====>[Test_Security_Button_Save_2200] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2200] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave'); - let obj = JSON.parse(strJsonNew); - expect(obj.$attrs.backgroundColor).assertEqual('#00000000'); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_2200] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_2200] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED) { - console.debug("====>[Test_Security_Button_Save_2200] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.TEMPORARY_AUTHORIZATION_FAILED).assertTrue(); - console.debug("====>[Test_Security_Button_Save_2200] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_2200] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_2200] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2200] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponent(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_2200] button is:" + JSON.stringify(button)); - await button.click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2200] clickSecComponent err : " + JSON.stringify(err)); - } - }); - }) -} \ No newline at end of file diff --git a/test/security_component/entry/src/main/ets/test/SaveComponentTest_1.test.ets b/test/security_component/entry/src/main/ets/test/SaveComponentTest_1.test.ets deleted file mode 100644 index 6ac33ad30eb4b4f1984f1dbb689d9d2bc19afd20..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/test/SaveComponentTest_1.test.ets +++ /dev/null @@ -1,358 +0,0 @@ -/** - * Copyright (c) 2023 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 router from '@ohos.router'; -import events_emitter from '@ohos.events.emitter'; -import { Driver, ON } from '@ohos.UiTest' -import Utils from './Utils'; - -export default function saveComponentTest_1() { - describe('saveComponentTest_1', function () { - beforeAll(async function (done) { - let options = { - url: 'MainAbility/pages/saveButton_1', - } - try { - router.clear(); - let pages = router.getState(); - console.debug("====>saveComponentTest_1 get state success " + JSON.stringify(pages)); - if (!("saveButton_1" == pages.name)) { - console.debug("====>saveComponentTest_1 get state success " + JSON.stringify(pages.name)); - let result = await router.pushUrl(options); - await Utils.sleep(2000); - console.debug("====>saveComponentTest_1 push page success " + JSON.stringify(result)); - } - } catch (err) { - console.error("====>saveComponentTest_1 push page error: " + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.debug("====>saveComponentTest_1 after each called"); - }); - - it('Test_Security_Button_Save_2300', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_2300] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave2'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.icon:" + obj.$attrs.icon); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.icon).assertEqual(1); - expect(obj.$attrs.text).assertEqual(1); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_2300] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_2300] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_2300] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_2300] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_2300] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_2300] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2300] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_2300] button is:" + JSON.stringify(button)); - await button[0].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2300] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_2400', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_2400] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave3'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(2); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_2400] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_2400] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_2400] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_2400] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_2400] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_2400] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2400] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_2400] button is:" + JSON.stringify(button)); - await button[1].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2400] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_2500', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_2500] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave4'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(3); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_2500] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_2500] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_2500] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_2500] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_2500] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_2500] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2500] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_2500] button is:" + JSON.stringify(button)); - await button[2].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2500] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_2600', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_2600] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave5'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(4); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_2600] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_2600] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_2600] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_2600] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_2600] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_2600] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2600] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_2600] button is:" + JSON.stringify(button)); - await button[3].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2600] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_2700', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_2700] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave6'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(5); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_2700] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_2700] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_2700] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_2700] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_2700] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_2700] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2700] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_2700] button is:" + JSON.stringify(button)); - await button[4].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2700] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_2800', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_2800] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave7'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(6); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_2800] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_2800] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_2800] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_2800] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_2800] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_2800] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2800] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_2800] button is:" + JSON.stringify(button)); - await button[5].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2800] clickSecComponent err : " + JSON.stringify(err)); - } - }); - - it('Test_Security_Button_Save_2900', 0, async function (done) { - console.debug('====>[Test_Security_Button_Save_2900] START===='); - await Utils.sleep(1000); - let strJsonNew = getInspectorByKey('keySave8'); - let obj = JSON.parse(strJsonNew); - console.debug("====>component obj.$attrs.text:" + obj.$attrs.text); - expect(obj.$attrs.text).assertEqual(7); - await Utils.sleep(1000); - try { - let clickCallback = (clickData) => { - console.debug("====>[Test_Security_Button_Save_2900] get clickEvent result is: " + JSON.stringify(clickEvent)); - console.debug("====>[Test_Security_Button_Save_2900] get clickData.data.clickResult is: " + JSON.stringify(clickData.data.clickResult)); - if (clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS) { - console.debug("====>[Test_Security_Button_Save_2900] 设置权限成功"); - expect(clickData.data.clickResult == SaveButtonOnClickResult.SUCCESS).assertTrue(); - console.debug("====>[Test_Security_Button_Save_2900] END===="); - done(); - } else { - console.debug("====>[Test_Security_Button_Save_2900] 设置权限失败"); - expect().assertFail() - console.debug("====>[Test_Security_Button_Save_2900] END===="); - done(); - } - } - var clickEvent = { - eventId: 2, - priority: events_emitter.EventPriority.LOW - } - events_emitter.once(clickEvent, clickCallback); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2900] once clickEvent err : " + JSON.stringify(err)); - } - try { - let driver = Driver.create(); - let button = await driver.findComponents(ON.type('SaveButton')); - await Utils.sleep(500); - console.debug("====>[Test_Security_Button_Save_2900] button is:" + JSON.stringify(button)); - await button[6].click(); - await Utils.sleep(1000); - } catch (err) { - console.debug("====>[Test_Security_Button_Save_2900] clickSecComponent err : " + JSON.stringify(err)); - } - }); - }) -} \ No newline at end of file diff --git a/test/security_component/entry/src/main/ets/test/Utils.ets b/test/security_component/entry/src/main/ets/test/Utils.ets deleted file mode 100644 index bb1f4a49ebf2db8543071ec5999d44fff08a94d1..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/ets/test/Utils.ets +++ /dev/null @@ -1,118 +0,0 @@ -// @ts-nocheck -/** - * Copyright (c) 2023 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) { - var xStep; - var yStep; - var swipeSteps; - var 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) - var 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 (var i = 1;i <= swipeSteps; i++) { - var 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) - } - var 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/test/security_component/entry/src/main/module.json b/test/security_component/entry/src/main/module.json deleted file mode 100644 index 0db2097afeb7deb0c5107a0b327ba7ce20522e48..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/module.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "module": { - "name": "phone", - "type": "entry", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:phone_entry_dsc", - "mainElement": "MainAbility", - "deviceTypes": [ - "tablet", - "default", - "phone", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "uiSyntax": "ets", - "pages": "$profile:main_pages", - "metadata": [ - { - "name": "ArkTSPartialUpdate", - "value": "true" - } - ], - "abilities": [ - { - "name": "com.example.securitycomponent.MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:phone_entry_main", - "icon": "$media:icon", - "label": "$string:entry_label", - "visible": true, - "orientation": "portrait", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} \ No newline at end of file diff --git a/test/security_component/entry/src/main/resources/base/element/color.json b/test/security_component/entry/src/main/resources/base/element/color.json deleted file mode 100644 index 07a14d2b8dcf50dae012854d8310c489dfd7391c..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "color": [ - { - "name": "color_hello", - "value": "#ffff0000" - }, - { - "name": "color_world", - "value": "#ff0000ff" - } - ] -} \ No newline at end of file diff --git a/test/security_component/entry/src/main/resources/base/element/float.json b/test/security_component/entry/src/main/resources/base/element/float.json deleted file mode 100644 index 26a0491a2b293d8296d4de4d55c8d682527b6c6b..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/resources/base/element/float.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "float":[ - { - "name":"font_hello", - "value":"28.0fp" - }, - { - "name":"font_world", - "value":"20.0fp" - } - ] -} \ No newline at end of file diff --git a/test/security_component/entry/src/main/resources/base/element/string.json b/test/security_component/entry/src/main/resources/base/element/string.json deleted file mode 100644 index f9f9529435996599eaf1069ead7cb6f832f34968..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "entry_MainAbility" - }, - { - "name": "description_mainability", - "value": "ETS_Empty Ability" - }, - { - "name": "TestAbility_desc", - "value": "description" - }, - { - "name": "TestAbility_label", - "value": "label" - }, - { - "name":"string_hello", - "value":"Hello" - }, - { - "name":"string_world", - "value":"World" - }, - { - "name":"message_arrive", - "value":"We will arrive at %s." - }, - { - "name": "phone_entry_dsc", - "value": "i am an entry for phone" - }, - { - "name": "phone_entry_main", - "value": "the phone entry ability" - }, - { - "name": "entry_label", - "value": "ActsContextTest" - }, - { - "name": "form_description", - "value": "my form" - }, - { - "name": "serviceability_description", - "value": "my whether" - }, - { - "name": "description_application", - "value": "demo for test" - }, - { - "name": "app_name", - "value": "Demo" - } - ] -} \ No newline at end of file diff --git a/test/security_component/entry/src/main/resources/base/media/icon.png b/test/security_component/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/test/security_component/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/test/security_component/entry/src/main/resources/base/profile/main_pages.json b/test/security_component/entry/src/main/resources/base/profile/main_pages.json deleted file mode 100644 index edbffe608c130bd5f11cccb7c10a74f0b472d154..0000000000000000000000000000000000000000 --- a/test/security_component/entry/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "src": [ - "MainAbility/pages/index/index", - "MainAbility/pages/pasteButton", - "MainAbility/pages/locationButton", - "MainAbility/pages/locationButton_1", - "MainAbility/pages/saveButton", - "MainAbility/pages/saveButton_1" - ] -} \ No newline at end of file diff --git a/test/security_component/signature/openharmony_sx.p7b b/test/security_component/signature/openharmony_sx.p7b deleted file mode 100644 index 91a332fc135b8a7ecb91d161d7d11d672584c448..0000000000000000000000000000000000000000 Binary files a/test/security_component/signature/openharmony_sx.p7b and /dev/null differ