mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2025-03-07 11:44:41 +00:00
ui_event_test crash fix
Signed-off-by: kangchongtao <kangchongtao@huawei.com> Change-Id: Iefed91dd531c2ae91385b32d410602af2ab66ef7
This commit is contained in:
parent
72c40d1507
commit
d2b628b4e0
@ -20,4 +20,9 @@ bool AceForwardCompatibility::IsUseNG()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* AceForwardCompatibility::GetAceLibName()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -251,16 +251,31 @@ ohos_unittest("ui_event_test") {
|
||||
module_out_path = interface_test_output_path
|
||||
|
||||
sources = [
|
||||
"$ace_root/interfaces/inner_api/ace/ace_forward_compatibility.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/manager/frame_rate/frame_rate_manager.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/manager/safe_area/safe_area_manager.cpp",
|
||||
"$ace_root/interfaces/inner_api/ace/ui_event.cpp",
|
||||
"$ace_root/interfaces/inner_api/ace/ui_event_func.cpp",
|
||||
"ace_forward_compatibility_test.cpp",
|
||||
"ui_event_test.cpp",
|
||||
]
|
||||
|
||||
configs = [ "$ace_root/test/unittest:ace_unittest_config" ]
|
||||
include_dirs = [ "${ace_root}/interfaces/inner_api/ace" ]
|
||||
|
||||
deps = [
|
||||
"$ace_root/frameworks/core/components/theme:build_theme_code",
|
||||
"$ace_root/test/unittest:ace_base",
|
||||
"$ace_root/test/unittest:ace_components_base",
|
||||
"$ace_root/test/unittest:ace_components_event",
|
||||
"$ace_root/test/unittest:ace_components_gestures",
|
||||
"$ace_root/test/unittest:ace_components_layout",
|
||||
"$ace_root/test/unittest:ace_components_mock",
|
||||
"$ace_root/test/unittest:ace_components_pattern",
|
||||
"$ace_root/test/unittest:ace_components_property",
|
||||
"$ace_root/test/unittest:ace_components_render",
|
||||
"$ace_root/test/unittest:ace_components_syntax",
|
||||
"$ace_root/test/unittest:ace_core_animation",
|
||||
"$ace_root/test/unittest:ace_core_extra",
|
||||
"//third_party/googletest:gmock_main",
|
||||
]
|
||||
external_deps = [
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
|
@ -16,11 +16,15 @@
|
||||
#include "gtest/gtest.h"
|
||||
#define private public
|
||||
#define protected public
|
||||
|
||||
#include "ace_forward_compatibility.h"
|
||||
#include "interfaces/inner_api/ace/ui_event.h"
|
||||
#include "interfaces/inner_api/ace/ui_event_func.h"
|
||||
#include "interfaces/inner_api/ace/ui_event_observer.h"
|
||||
#include "test/mock/core/common/mock_container.h"
|
||||
#include "test/mock/core/common/mock_theme_manager.h"
|
||||
#include "test/mock/core/pipeline/mock_pipeline_context.h"
|
||||
|
||||
#include "core/components/popup/popup_theme.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
@ -28,8 +32,21 @@ using namespace testing::ext;
|
||||
namespace OHOS::Ace {
|
||||
class UiEventTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase() {}
|
||||
static void TearDownTestCase() {}
|
||||
static void SetUpTestSuite()
|
||||
{
|
||||
NG::MockPipelineContext::SetUp();
|
||||
MockContainer::SetUp();
|
||||
MockContainer::Current()->pipelineContext_ = PipelineBase::GetCurrentContext();
|
||||
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||
PipelineBase::GetCurrentContext()->SetThemeManager(themeManager);
|
||||
PipelineBase::GetCurrentContext()->SetEventManager(AceType::MakeRefPtr<EventManager>());
|
||||
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(AceType::MakeRefPtr<PopupTheme>()));
|
||||
}
|
||||
static void TearDownTestSuite()
|
||||
{
|
||||
MockContainer::Current()->pipelineContext_ = nullptr;
|
||||
NG::MockPipelineContext::TearDown();
|
||||
}
|
||||
void SetUp() {}
|
||||
void TearDown() {}
|
||||
};
|
||||
@ -54,7 +71,7 @@ HWTEST_F(UiEventTest, UiEventTest001, TestSize.Level1)
|
||||
UIEvent::GetNodeProperty(pageUrl, nodeProperties);
|
||||
|
||||
bool result = UIEventFunc::Get().IsAvailable();
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,6 +92,6 @@ HWTEST_F(UiEventTest, UiEventTest002, TestSize.Level1)
|
||||
*/
|
||||
UIEvent::GetSimplifiedInspectorTree(tree);
|
||||
bool result = UIEventFunc::Get().IsAvailable();
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
} // namespace OHOS::Ace
|
Loading…
x
Reference in New Issue
Block a user