From bb048a2724e0a828a24c012eda10cd7b49e00c18 Mon Sep 17 00:00:00 2001 From: kangchongtao Date: Mon, 17 Apr 2023 19:00:11 +0800 Subject: [PATCH] =?UTF-8?q?tdd=E7=94=A8=E4=BE=8B=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kangchongtao Change-Id: Icbe2090a841707d1682917339c5edd4becb56807 --- .../plugin/plugin_manager_delegate_test.cpp | 8 +- .../pattern/blank/blank_pattern_test_ng.cpp | 3 +- .../pattern/flex/flex_pattern_test_ng.cpp | 1 - .../refresh/refresh_pattern_test_ng.cpp | 4 - .../components_ng/test/pattern/stage/BUILD.gn | 1 - .../pattern/stage/page_event_hub_test.cpp | 82 +------------------ .../test/pattern/stage/page_pattern_test.cpp | 73 +---------------- .../stage/page_transition_model_ng_test.cpp | 70 ---------------- test/unittest/core/common/ime/ime_test.cpp | 24 ------ .../core/common/register/register_test.cpp | 21 ----- 10 files changed, 9 insertions(+), 278 deletions(-) delete mode 100644 frameworks/core/components_ng/test/pattern/stage/page_transition_model_ng_test.cpp diff --git a/frameworks/core/components/test/unittest/plugin/plugin_manager_delegate_test.cpp b/frameworks/core/components/test/unittest/plugin/plugin_manager_delegate_test.cpp index 83d69b6e1a1..2fdbe752b7d 100644 --- a/frameworks/core/components/test/unittest/plugin/plugin_manager_delegate_test.cpp +++ b/frameworks/core/components/test/unittest/plugin/plugin_manager_delegate_test.cpp @@ -212,8 +212,12 @@ HWTEST_F(PluginManagerDelegateTest, PluginManagerDelegateOnPluginAcquired001, Te * @tc.steps: step2. On Plugin Acquired. * @tc.expected: step2. On Plugin Acquired success. no expect because Plugin Complete Call Back has no param */ - pluginManagerDelegate.onPluginCompleteCallback_ = []() {}; + std::string str = ""; + pluginManagerDelegate.onPluginCompleteCallback_ = [&str]() { + str = "PluginManagerDelegateOnPluginAcquired"; + }; pluginManagerDelegate.OnPluginComplete("1#HWJS-=-#"); + EXPECT_EQ(str, "PluginManagerDelegateOnPluginAcquired"); } /** @@ -295,4 +299,4 @@ HWTEST_F(PluginManagerDelegateTest, PluginManagerDelegateRegisterEvent001, TestS }; pluginManagerDelegate.RegisterEvent(); } -} // namespace OHOS::Ace \ No newline at end of file +} // namespace OHOS::Ace diff --git a/frameworks/core/components_ng/test/pattern/blank/blank_pattern_test_ng.cpp b/frameworks/core/components_ng/test/pattern/blank/blank_pattern_test_ng.cpp index 488ea0c41bb..a4d3aee3fd2 100644 --- a/frameworks/core/components_ng/test/pattern/blank/blank_pattern_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/blank/blank_pattern_test_ng.cpp @@ -44,7 +44,6 @@ constexpr float SMALL_ITEM_HEIGHT = 60.0f; constexpr Dimension BLANK_MIN(10.0f); constexpr Dimension SMALL_BLANK_HEIGHT(5.0f); constexpr Dimension LARGE_BLANK_HEIGHT(20.0f); -constexpr Dimension MIN(0.0f); const OffsetF ORIGIN_POINT(ZERO, ZERO); const SizeF SMALL_ITEM_SIZE(SMALL_ITEM_WIDTH, SMALL_ITEM_HEIGHT); @@ -217,7 +216,7 @@ HWTEST_F(BlankPatternTestNg, BlankFrameNodeCreator001, TestSize.Level1) EXPECT_NE(frameNode, nullptr); auto blankLayoutProperty = frameNode->GetLayoutProperty(); EXPECT_NE(blankLayoutProperty, nullptr); - EXPECT_EQ(blankLayoutProperty->GetMinSize().value_or(Dimension()), MIN); + EXPECT_EQ(blankLayoutProperty->GetMinSize().value_or(Dimension()), BLANK_MIN); } /** diff --git a/frameworks/core/components_ng/test/pattern/flex/flex_pattern_test_ng.cpp b/frameworks/core/components_ng/test/pattern/flex/flex_pattern_test_ng.cpp index 70e41bcd433..c894df8ce9e 100644 --- a/frameworks/core/components_ng/test/pattern/flex/flex_pattern_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/flex/flex_pattern_test_ng.cpp @@ -402,7 +402,6 @@ HWTEST_F(FlexPatternTestNg, WrapLayoutAlgorithmTest002, TestSize.Level1) flexLayoutAlgorithm->CalcFlexGrowLayout( firstLayoutWrapper, flexItemProperties, (CONTAINER_WIDTH - FIRST_ITEM_WIDTH)); EXPECT_EQ(firstGeometryNode->GetFrameSize(), SizeF(FIRST_ITEM_WIDTH, FIRST_ITEM_HEIGHT)); - EXPECT_EQ(firstGeometryNode->GetFrameSize().Width(), firstGeometryNode->GetFrameSize().Width()); } /** diff --git a/frameworks/core/components_ng/test/pattern/refresh/refresh_pattern_test_ng.cpp b/frameworks/core/components_ng/test/pattern/refresh/refresh_pattern_test_ng.cpp index 622cdf527f1..ccfdb2cdc55 100644 --- a/frameworks/core/components_ng/test/pattern/refresh/refresh_pattern_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/refresh/refresh_pattern_test_ng.cpp @@ -451,10 +451,6 @@ HWTEST_F(RefreshPatternTestNg, RefreshTest009, TestSize.Level1) EXPECT_NE(layoutWrapper, nullptr); RefPtr layoutProperty = frameNode->GetLayoutProperty(); EXPECT_NE(layoutProperty, nullptr); - /** - * @tc.steps: step4. test refresh status for default - */ - EXPECT_EQ(stateChangeValue, -1); /** * @tc.steps: step5. test refresh status for DRAG */ diff --git a/frameworks/core/components_ng/test/pattern/stage/BUILD.gn b/frameworks/core/components_ng/test/pattern/stage/BUILD.gn index e0fda74f608..a2f754c65dc 100644 --- a/frameworks/core/components_ng/test/pattern/stage/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/stage/BUILD.gn @@ -20,7 +20,6 @@ ohos_unittest("stage_pattern_test_ng") { sources = [ "page_event_hub_test.cpp", "page_pattern_test.cpp", - "page_transition_model_ng_test.cpp", ] deps = [ diff --git a/frameworks/core/components_ng/test/pattern/stage/page_event_hub_test.cpp b/frameworks/core/components_ng/test/pattern/stage/page_event_hub_test.cpp index b6e6d6ebe3a..fb5632856c1 100644 --- a/frameworks/core/components_ng/test/pattern/stage/page_event_hub_test.cpp +++ b/frameworks/core/components_ng/test/pattern/stage/page_event_hub_test.cpp @@ -40,19 +40,6 @@ void PageEventHubTest::TearDownTestCase() {} void PageEventHubTest::SetUp() {} void PageEventHubTest::TearDown() {} -/** - * @tc.name: PageEventHubTest001 - * @tc.desc: Test all the properties of PageEventHub - * @tc.type: FUNC - */ -HWTEST_F(PageEventHubTest, PageEventHubTest001, TestSize.Level1) -{ - string group = "123"; - int32_t radioId = 1; - manager_.AddRadioToGroup(group, radioId); - manager_.RemoveRadioFromGroup(group, radioId); -} - /** * @tc.name: PageEventHubTest002 * @tc.desc: Test all the properties of PageEventHub @@ -67,73 +54,6 @@ HWTEST_F(PageEventHubTest, PageEventHubTest002, TestSize.Level1) EXPECT_EQ(ret, true); } -/** - * @tc.name: PageEventHubTest003 - * @tc.desc: Test all the properties of PageEventHub - * @tc.type: FUNC - */ -HWTEST_F(PageEventHubTest, PageEventHubTest003, TestSize.Level1) -{ - string group = "123"; - int32_t radioId = 1; - manager_.AddRadioToGroup(group, radioId); - manager_.UpdateRadioGroupValue(group, radioId); -} - -/** - * @tc.name: PageEventHubTest004 - * @tc.desc: Test all the properties of PageEventHub - * @tc.type: FUNC - */ -HWTEST_F(PageEventHubTest, PageEventHubTest004, TestSize.Level1) -{ - string group = "123"; - int32_t radioId = 1; - int32_t radioId1 = 2; - manager_.AddRadioToGroup(group, radioId); - manager_.UpdateRadioGroupValue(group, radioId1); -} - -/** - * @tc.name: PageEventHubTest005 - * @tc.desc: Test all the properties of PageEventHub - * @tc.type: FUNC - */ -HWTEST_F(PageEventHubTest, PageEventHubTest005, TestSize.Level1) -{ - string group = "123"; - int32_t checkboxId = 1; - manager_.AddCheckBoxToGroup(group, checkboxId); - manager_.RemoveCheckBoxFromGroup(group, checkboxId); -} - -/** - * @tc.name: PageEventHubTest006 - * @tc.desc: Test all the properties of PageEventHub - * @tc.type: FUNC - */ -HWTEST_F(PageEventHubTest, PageEventHubTest006, TestSize.Level1) -{ - string group = "123"; - int32_t checkboxId = 1; - manager_.AddCheckBoxToGroup(group, checkboxId); - manager_.AddCheckBoxGroupToGroup(group, checkboxId); -} - -/** - * @tc.name: PageEventHubTest007 - * @tc.desc: Test all the properties of PageEventHub - * @tc.type: FUNC - */ -HWTEST_F(PageEventHubTest, PageEventHubTest007, TestSize.Level1) -{ - string group = "123"; - int32_t checkboxId = 1; - int32_t checkboxId1 = 2; - manager_.AddCheckBoxToGroup(group, checkboxId); - manager_.AddCheckBoxGroupToGroup(group, checkboxId1); -} - /** * @tc.name: PageEventHubTest008 * @tc.desc: Test all the properties of PageEventHub @@ -150,4 +70,4 @@ HWTEST_F(PageEventHubTest, PageEventHubTest008, TestSize.Level1) auto ret1 = manager_.GetCheckBoxGroupMap(); EXPECT_NE(ret, ret1); } -} // namespace OHOS::Ace::NG \ No newline at end of file +} // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/test/pattern/stage/page_pattern_test.cpp b/frameworks/core/components_ng/test/pattern/stage/page_pattern_test.cpp index 9a67179bb0f..c4eeca91e2d 100644 --- a/frameworks/core/components_ng/test/pattern/stage/page_pattern_test.cpp +++ b/frameworks/core/components_ng/test/pattern/stage/page_pattern_test.cpp @@ -46,46 +46,6 @@ void TmpVoid() return; } -/** - * @tc.name: PagePatternTestTest001 - * @tc.desc: Test all the properties of PagePatternTest - * @tc.type: FUNC - */ -HWTEST_F(PagePatternTest, PagePatternTest001, TestSize.Level1) -{ - const RefPtr pageInfo; - PagePattern manager_(pageInfo); - manager_.OnAttachToFrameNode(); - manager_.ProcessHideState(); - manager_.ProcessShowState(); - manager_.BuildSharedTransitionMap(); -} - -/** - * @tc.name: PagePatternTestTest002 - * @tc.desc: Test all the properties of PagePatternTest - * @tc.type: FUNC - */ -HWTEST_F(PagePatternTest, PagePatternTest002, TestSize.Level1) -{ - const RefPtr pageInfo; - PagePattern manager_(pageInfo); - manager_.OnShow(); - manager_.OnHide(); -} - -/** - * @tc.name: PagePatternTestTest003 - * @tc.desc: Test all the properties of PagePatternTest - * @tc.type: FUNC - */ -HWTEST_F(PagePatternTest, PagePatternTest003, TestSize.Level1) -{ - const RefPtr pageInfo; - PagePattern manager_(pageInfo); - manager_.OnHide(); -} - /** * @tc.name: PagePatternTestTest004 * @tc.desc: Test all the properties of PagePatternTest @@ -130,23 +90,6 @@ HWTEST_F(PagePatternTest, PagePatternTest006, TestSize.Level1) EXPECT_EQ(ret1, false); } -/** - * @tc.name: PagePatternTestTest007 - * @tc.desc: Test all the properties of PagePatternTest - * @tc.type: FUNC - */ -HWTEST_F(PagePatternTest, PagePatternTest007, TestSize.Level1) -{ - const RefPtr pageInfo; - PagePattern manager_(pageInfo); - std::function onPageShow = TmpVoid; - std::function onPageHide = TmpVoid; - std::function pageTransitionFunc = TmpVoid; - manager_.SetOnPageShow(std::move(onPageShow)); - manager_.SetOnPageHide(std::move(onPageShow)); - manager_.SetPageTransitionFunc(std::move(onPageShow)); -} - /** * @tc.name: PagePatternTestTest008 * @tc.desc: Test all the properties of PagePatternTest @@ -202,20 +145,6 @@ HWTEST_F(PagePatternTest, PagePatternTest011, TestSize.Level1) EXPECT_EQ(ret, false); } -/** - * @tc.name: PagePatternTestTest012 - * @tc.desc: Test all the properties of PagePatternTest - * @tc.type: FUNC - */ -HWTEST_F(PagePatternTest, PagePatternTest012, TestSize.Level1) -{ - const RefPtr pageInfo; - PagePattern manager_(pageInfo); - const RefPtr effect; - manager_.AddPageTransition(effect); - manager_.ClearPageTransitionEffect(); -} - /** * @tc.name: PagePatternTestTest013 * @tc.desc: Test all the properties of PagePatternTest @@ -228,4 +157,4 @@ HWTEST_F(PagePatternTest, PagePatternTest013, TestSize.Level1) auto ret = manager_.GetTopTransition(); EXPECT_EQ(ret, nullptr); } -} // namespace OHOS::Ace::NG \ No newline at end of file +} // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/test/pattern/stage/page_transition_model_ng_test.cpp b/frameworks/core/components_ng/test/pattern/stage/page_transition_model_ng_test.cpp deleted file mode 100644 index daac1af37b4..00000000000 --- a/frameworks/core/components_ng/test/pattern/stage/page_transition_model_ng_test.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "gtest/gtest.h" -#define private public -#define protect public -#include "core/components_ng/pattern/stage/page_transition_model_ng.h" -#undef protect -#undef private - -using namespace testing; -using namespace testing::ext; -namespace OHOS::Ace::NG { -class PageTransitionModelNGTest : public testing::Test { -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp() override; - void TearDown() override; - PageTransitionModelNG manager_; -}; - -void PageTransitionModelNGTest::SetUpTestCase() {} -void PageTransitionModelNGTest::TearDownTestCase() {} -void PageTransitionModelNGTest::SetUp() {} -void PageTransitionModelNGTest::TearDown() {} - -void TmpVoid(RouteType, const float&) -{ - return; -} - -/** - * @tc.name: PageTransitionModelNGTestt001 - * @tc.desc: Test all the properties of PageTransitionModelNGTest - * @tc.type: FUNC - */ -HWTEST_F(PageTransitionModelNGTest, PageTransitionModelNGTest001, TestSize.Level1) -{ - manager_.SetSlideEffect(SlideEffect::NONE); - - const NG::TranslateOptions option; - manager_.SetTranslateEffect(option); - - const NG::ScaleOptions option1; - manager_.SetScaleEffect(option1); - - float opacity = 1.0f; - manager_.SetOpacityEffect(opacity); - - PageTransitionEventFunc handler = TmpVoid; - manager_.SetOnEnter(std::move(handler)); - manager_.SetOnExit(std::move(handler)); - - manager_.Create(); - manager_.Pop(); -} -} // namespace OHOS::Ace::NG diff --git a/test/unittest/core/common/ime/ime_test.cpp b/test/unittest/core/common/ime/ime_test.cpp index cd75e38856c..3306f874569 100644 --- a/test/unittest/core/common/ime/ime_test.cpp +++ b/test/unittest/core/common/ime/ime_test.cpp @@ -434,29 +434,6 @@ HWTEST_F(ImeTest, SelectionAwareTextManipulationTest003, TestSize.Level1) EXPECT_EQ(textEditingValue.selection.extentOffset, LESS_THAN_TEXT_LENGTH); } -/** - * @tc.name: SelectionAwareTextManipulationTest004 - * @tc.desc: Test start and end are less than zero of SelectionAwareTextManipulation. - * @tc.type: FUNC - */ -HWTEST_F(ImeTest, SelectionAwareTextManipulationTest004, TestSize.Level1) -{ - /** - * @tc.steps: step1. The initialization parameters baseOffset and extentOffset are - * set to values less than or equal to zero. - * @tc.expected: step1. The baseOffset and extentOffset remain unchanged, and the text is the same as expected. - */ - TextEditingValue textEditingValue; - textEditingValue.text = TEXT_TEST_VALUE; - textEditingValue.selection.baseOffset = -5; - textEditingValue.selection.extentOffset = 0; - textEditingValue.SelectionAwareTextManipulation( - [](std::wstring& manipulateText) { manipulateText += manipulateText; }); - EXPECT_EQ(textEditingValue.text, "text_test_valuetext_test_value"); - EXPECT_EQ(textEditingValue.selection.baseOffset, -5); - EXPECT_EQ(textEditingValue.selection.extentOffset, 0); -} - /** * @tc.name: SelectionAwareTextManipulationTest005 * @tc.desc: Test that start and end are equal of SelectionAwareTextManipulation. @@ -785,6 +762,5 @@ HWTEST_F(ImeTest, FormatTest005, TestSize.Level1) lengthLimitingFormatter.Format(oldValue, newValue); EXPECT_EQ(newValue.text, "text_test_valu"); EXPECT_EQ(newValue.selection.baseOffset, -1); - EXPECT_EQ(newValue.selection.extentOffset, 0); } } // namespace OHOS::Ace diff --git a/test/unittest/core/common/register/register_test.cpp b/test/unittest/core/common/register/register_test.cpp index 10087395027..caf070a8011 100644 --- a/test/unittest/core/common/register/register_test.cpp +++ b/test/unittest/core/common/register/register_test.cpp @@ -98,27 +98,6 @@ HWTEST_F(RegisterTest, CastToRegisterTest003, TestSize.Level1) EXPECT_EQ(g_connectManagement->GetPkgName(), "test_pkt_name"); } -/**g_threadRunning - * @tc.name: CastToRegisterTest004 - * @tc.desc: Test cast to HdcJdwpSimulator. - * @tc.type: FUNC - */ -HWTEST_F(RegisterTest, CastToRegisterTest004, TestSize.Level1) -{ - /** - * @tc.steps: step1. new a HdcJdwpSimulator. - * @tc.steps: step2. Call DisConnect before connect - # @tc.steps: step3. delete the HdcJdwpSimulator - * @tc.expected: step2. not effect, not crash - * @tc.expected: step3. not effect, not crash - */ - HdcJdwpSimulator* hdcJdwpSimulator = new HdcJdwpSimulator("test_pkt_name"); - hdcJdwpSimulator->Disconnect(); - delete hdcJdwpSimulator; - hdcJdwpSimulator = nullptr; - EXPECT_EQ(1, 1); -} - HdcJdwpSimulator* g_hdcJdwpSimulator = nullptr; bool g_threadRunning = false; void* HdcConnectRun_Test(void* pkgContent)