!11821 新增tdd用例

Merge pull request !11821 from kangchongtao/0331
This commit is contained in:
openharmony_ci 2023-04-01 06:51:37 +00:00 committed by Gitee
commit 31cc936036
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 92 additions and 3 deletions

View File

@ -138,6 +138,7 @@ ohos_unittest("swiper_pattern_test_ng") {
"$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp",
"swiper_accessibility_property_test_ng.cpp",
"swiper_indicator_pattern_test_ng.cpp",
"swiper_pattern_test_ng.cpp",
]
deps = [

View File

@ -0,0 +1,91 @@
/*
* 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 "gtest/gtest.h"
#define private public
#define protected public
#include "core/components_ng/base/view_stack_processor.h"
#include "core/components_ng/pattern/swiper/swiper_pattern.h"
#include "core/animation/animator.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS::Ace::NG {
namespace {
} // namespace
class SwiperPatternTestNg : public testing::Test {
public:
static void SetUpTestCase() {};
static void TearDownTestCase() {};
};
/**
* @tc.name: SwiperEvent001
* @tc.desc: HandleTouchDown
* @tc.type: FUNC
*/
HWTEST_F(SwiperPatternTestNg, SwiperEvent001, TestSize.Level1)
{
auto* stack = ViewStackProcessor::GetInstance();
auto swiperNode = FrameNode::GetOrCreateFrameNode(
"Swiper", 0, []() { return AceType::MakeRefPtr<SwiperPattern>(); });
stack->Push(swiperNode);
TouchLocationInfo touchLocationInfo("down", 0);
touchLocationInfo.SetTouchType(TouchType::DOWN);
std::list<TouchLocationInfo> infoList;
infoList.emplace_back(touchLocationInfo);
TouchEventInfo touchEventInfo("down");
touchEventInfo.touches_ = infoList;
auto pattern = swiperNode->GetPattern<SwiperPattern>();
pattern->HandleTouchEvent(touchEventInfo);
EXPECT_FALSE(pattern->indicatorDoingAnimation_);
const char* name = "HandleTouchDown";
pattern->controller_ = AceType::MakeRefPtr<Animator>(name);
pattern->controller_->status_ = Animator::Status::RUNNING;
pattern->springController_ = AceType::MakeRefPtr<Animator>(name);
pattern->springController_->status_ = Animator::Status::RUNNING;
pattern->HandleTouchEvent(touchEventInfo);
EXPECT_FALSE(pattern->indicatorDoingAnimation_);
touchLocationInfo.SetTouchType(TouchType::UP);
pattern->HandleTouchEvent(touchEventInfo);
pattern->controller_ = nullptr;
pattern->springController_ = nullptr;
touchLocationInfo.SetTouchType(TouchType::CANCEL);
pattern->HandleTouchEvent(touchEventInfo);
EXPECT_FALSE(pattern->indicatorDoingAnimation_);
}
/**
* @tc.name: SwiperEvent002
* @tc.desc: HandleTouchDown
* @tc.type: FUNC
*/
HWTEST_F(SwiperPatternTestNg, SwiperEvent002, TestSize.Level1)
{
auto* stack = ViewStackProcessor::GetInstance();
auto swiperNode = FrameNode::GetOrCreateFrameNode(
"Swiper", 0, []() { return AceType::MakeRefPtr<SwiperPattern>(); });
stack->Push(swiperNode);
auto pattern = swiperNode->GetPattern<SwiperPattern>();
auto eventHub = AceType::MakeRefPtr<EventHub>();
auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
pattern->InitPanEvent(gestureEventHub);
EXPECT_EQ(pattern->direction_, Axis::HORIZONTAL);
}
} // namespace OHOS::Ace::NG

View File

@ -80,9 +80,6 @@ ohos_fuzztest("ImageLoaderFuzzTest") {
"$ace_root/frameworks/core/common/test/mock/mock_watch_dog.cpp",
"$ace_root/frameworks/core/event/back_end_event_manager.cpp",
#"theme_constants_test.cpp",
"$ace_root/frameworks/core/components/test/unittest/theme/theme_mock.cpp",
# mock
#"$ace_root/frameworks/base/test/mock/mock_system_properties.cpp",