open pipeline context unittest case

Signed-off-by: liyujie <liyujie43@huawei.com>
Change-Id: I85db1ff271e5164bb3d23fea7b6157aa10a2a320
This commit is contained in:
liyujie 2023-03-20 21:26:02 +08:00
parent fefd957dce
commit ca105b53d1
37 changed files with 633 additions and 426 deletions

View File

@ -85,4 +85,4 @@ void DumpLog::ShowDumpHelp(std::vector<std::string>& info)
info.emplace_back(" -frontend |show path and components count of current page");
}
} // namespace OHOS::Ace
} // namespace OHOS::Ace

View File

@ -87,10 +87,16 @@ const std::string& AceApplicationInfo::GetPackageName() const
{
return packageName_;
}
const std::string& AceApplicationInfo::GetProcessName() const
{
return processName_;
}
#endif
AceApplicationInfo& AceApplicationInfo::GetInstance()
{
return MockAceApplicationInfo::GetInstance();
}
} // namespace OHOS::Ace
} // namespace OHOS::Ace

View File

@ -35,6 +35,7 @@ ohos_unittest("ClipboardTest") {
deps = [
"$ace_root/adapter/ohos/osal:ace_osal_ohos",
"$ace_root/frameworks/base:ace_base_ohos",
"//third_party/googletest:gmock_main",
]
}

View File

@ -36,6 +36,7 @@ ohos_unittest("EnvironmentTest") {
deps = [
"$ace_root/adapter/ohos/osal:ace_osal_ohos",
"$ace_root/frameworks/base:ace_base_ohos",
"//third_party/googletest:gmock_main",
]
}

View File

@ -35,6 +35,7 @@ ohos_unittest("ImeTest") {
deps = [
"$ace_flutter_engine_root/skia:ace_skia_ohos",
"$ace_root/build:ace_ohos_unittest_base",
"//third_party/googletest:gmock_main",
]
external_deps = [ "ability_base:base" ]

View File

@ -36,6 +36,7 @@ ohos_unittest("PluginManagerTest") {
"$ability_runtime_path/frameworks/native/ability/native:abilitykit_native",
"$ace_flutter_engine_root/skia:ace_skia_ohos",
"$ace_root/build:ace_ohos_unittest_base",
"//third_party/googletest:gmock_main",
]
external_deps = [

View File

@ -37,6 +37,7 @@ ohos_unittest("RegisterTest") {
deps = [
"$ace_root/adapter/ohos/osal:ace_osal_ohos",
"$ace_root/frameworks/base:ace_base_ohos",
"//third_party/googletest:gmock_main",
"//third_party/libuv:uv",
]
}

View File

@ -36,6 +36,7 @@ ohos_unittest("ShareDataTest") {
deps = [
"$ace_root/adapter/ohos/osal:ace_osal_ohos",
"$ace_root/frameworks/base:ace_base_ohos",
"//third_party/googletest:gmock_main",
]
part_name = ace_engine_part

View File

@ -36,6 +36,7 @@ ohos_unittest("StorageTest") {
deps = [
"$ace_root/adapter/ohos/osal:ace_osal_ohos",
"$ace_root/frameworks/base:ace_base_ohos",
"//third_party/googletest:gmock_main",
]
}

View File

@ -36,7 +36,6 @@ ohos_unittest("VibratorTest") {
"$ace_root/adapter/ohos/osal:ace_osal_ohos",
"$ace_root/frameworks/base:ace_base_ohos",
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
]
}

View File

@ -22,7 +22,6 @@
#include "core/common/container_scope.h"
namespace OHOS::Ace {
Window::Window(std::unique_ptr<PlatformWindow> platformWindow) : platformWindow_(std::move(platformWindow))
{
CHECK_NULL_VOID(platformWindow_);
@ -83,6 +82,4 @@ void Window::SetVsyncCallback(AceVsyncCallback&& callback)
.containerId_ = Container::CurrentId(),
});
}
} // namespace OHOS::Ace

View File

@ -22,6 +22,7 @@
#include "core/components_ng/test/mock/rosen/testing_canvas.h"
#include "core/components_ng/test/mock/rosen/testing_color.h"
#include "core/components_ng/test/mock/rosen/testing_filter.h"
#include "core/components_ng/test/mock/rosen/testing_font_collection.h"
#include "core/components_ng/test/mock/rosen/testing_mask_filter.h"
#include "core/components_ng/test/mock/rosen/testing_path.h"
#include "core/components_ng/test/mock/rosen/testing_path_effect.h"
@ -32,6 +33,8 @@
#include "core/components_ng/test/mock/rosen/testing_shadowflags.h"
#include "core/components_ng/test/mock/rosen/testing_text_style.h"
#include "core/components_ng/test/mock/rosen/testing_typography.h"
#include "core/components_ng/test/mock/rosen/testing_typography_create.h"
#include "core/components_ng/test/mock/rosen/testing_typography_style.h"
namespace OHOS::Ace {
using RSCanvas = Testing::TestingCanvas;
@ -67,8 +70,10 @@ using RSTextStyle = Testing::TestingTextStyle;
using RSColorQuad = uint32_t;
using RSScalar = float;
using RSPathFillType = Testing::TestingPathFillType;
using RSParagraph = Testing::TestingTypography;
using RSTypographyProperties = Testing::TestingTypographyProperties;
using RSParagraphStyle = Testing::TestingTypographyStyle;
using RSParagraphBuilder = Testing::TestingTypographyCreate;
using RSFontCollection = Testing::TestingFontCollection;
} // namespace OHOS::Ace
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_DRAWING_MOCK_H

View File

@ -24,4 +24,9 @@ RefPtr<NG::ImageObject> ImageCache::GetCacheImgObjNG(const std::string& key)
}
void ImageCache::CacheImgObjNG(const std::string& key, const RefPtr<NG::ImageObject>& imgObj) {}
RefPtr<ImageCache> ImageCache::Create()
{
return nullptr;
}
} // namespace OHOS::Ace

View File

@ -0,0 +1,44 @@
/*
* 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.
*/
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_FONT_COLLECTION_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_FONT_COLLECTION_H
#include <memory>
#include <string>
#include "core/components_ng/test/mock/rosen/testing_text_style.h"
#include "core/components_ng/test/mock/rosen/testing_typography.h"
namespace OHOS::Ace::Testing {
class TestingFontCollection {
public:
TestingFontCollection() = default;
virtual ~TestingFontCollection() = default;
static std::shared_ptr<TestingFontCollection> GetInstance(bool createWithICU = true)
{
if (instance) {
return instance;
}
instance = std::make_shared<TestingFontCollection>();
return instance;
}
private:
static std::shared_ptr<TestingFontCollection> instance;
};
} // namespace OHOS::Ace::Testing
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_FONT_COLLECTION_H

View File

@ -16,14 +16,12 @@
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_H
#include <vector>
#include "core/components_ng/test/mock/rosen/testing_typography_properties.h"
namespace OHOS::Ace::Testing {
enum class WordBreakType {
WordBreakTypeNormal = 0,
WordBreakTypeBreakAll,
WordBreakTypeBreakWord
};
enum class WordBreakType { WordBreakTypeNormal = 0, WordBreakTypeBreakAll, WordBreakTypeBreakWord };
enum class TextAlign {
LEFT = 0,
@ -37,17 +35,27 @@ enum class TextAlign {
class TestingTypography {
public:
TestingTypography() = default;
~TestingTypography() = default;
virtual ~TestingTypography() = default;
double GetMaxWidth();
double GetHeight();
double GetLongestLine();
double GetMinIntrinsicWidth();
double GetMaxIntrinsicWidth();
double GetAlphabeticBaseline();
double GetIdeographicBaseline();
bool DidExceedMaxLines();
void Layout(double width);
virtual double GetHeight()
{
return 1.0;
}
virtual void Layout(double width) {}
virtual std::vector<TestingTypographyProperties::TextBox> GetRectsForRange(size_t /* start */, size_t /* end */,
TestingTypographyProperties::RectHeightStyle /* height */,
TestingTypographyProperties::RectWidthStyle /* width */)
{
return {};
}
virtual TestingTypographyProperties::PositionAndAffinity GetGlyphPositionAtCoordinateWithCluster(double x, double y)
{
TestingTypographyProperties::PositionAndAffinity res(1, TestingTypographyProperties::Affinity::UPSTREAM);
return res;
}
};
} // namespace OHOS::Ace::Testing
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_H

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_CREATE_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_CREATE_H
#include <memory>
#include <vector>
#include "core/components_ng/test/mock/rosen/testing_font_collection.h"
#include "core/components_ng/test/mock/rosen/testing_typography.h"
#include "core/components_ng/test/mock/rosen/testing_typography_properties.h"
#include "core/components_ng/test/mock/rosen/testing_typography_style.h"
namespace OHOS::Ace::Testing {
class TestingTypographyCreate {
public:
TestingTypographyCreate() = default;
virtual ~TestingTypographyCreate() = default;
static std::unique_ptr<TestingTypographyCreate> CreateRosenBuilder(
const TestingTypographyStyle& style, std::shared_ptr<TestingFontCollection> font_collection)
{
return std::make_unique<TestingTypographyCreate>();
}
virtual void PushStyle(const TestingTextStyle& style) {}
virtual void Pop() {}
virtual void AddText(const std::u16string& text) {}
virtual std::unique_ptr<TestingTypography> Build()
{
return std::make_unique<TestingTypography>();
}
};
} // namespace OHOS::Ace::Testing
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_CREATE_H

View File

@ -16,6 +16,10 @@
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_PROPERTIES_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_PROPERTIES_H
#include <cstddef>
#include "core/components_ng/test/mock/rosen/testing_rect.h"
namespace OHOS::Ace::Testing {
enum class TextDirection {
RTL,
@ -45,6 +49,7 @@ public:
struct TextBox {
TextDirection direction_;
TestingRect rect_;
};
struct PositionAndAffinity {
@ -58,7 +63,7 @@ public:
T start_, end_;
Range() : start_(), end_() {}
Range(T a, T b) : start_(a), end_(b) {}
bool operator == (const Range<T>& rhs) const
bool operator==(const Range<T>& rhs) const
{
return start_ == rhs.start_ && end_ == rhs.end_;
}

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_STYLE_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_STYLE_H
#include <string>
#include <vector>
#include "core/components_ng/test/mock/rosen/testing_typography.h"
#include "core/components_ng/test/mock/rosen/testing_typography_properties.h"
namespace OHOS::Ace::Testing {
class TestingTypographyStyle {
public:
static const std::u16string ELLIPSIS;
TextDirection textDirection_;
std::string locale_;
WordBreakType wordBreakType_ = WordBreakType::WordBreakTypeBreakWord;
double fontSize_ = 14;
std::u16string ellipsis_;
TextAlign textAlign_ = TextAlign::START;
size_t maxLines_ = std::numeric_limits<size_t>::max();
};
} // namespace OHOS::Ace::Testing
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_STYLE_H

View File

@ -15,33 +15,24 @@
#include "core/pipeline_ng/pipeline_context.h"
#include "base/memory/ace_type.h"
#include "core/components_ng/base/ui_node.h"
#include "core/components_ng/pattern/image/image_layout_property.h"
#include "core/components_ng/pattern/navigation/navigation_group_node.h"
#include "core/components_ng/pattern/navigation/title_bar_node.h"
#include "core/components_ng/pattern/navrouter/navdestination_group_node.h"
#include "core/event/ace_events.h"
#include "core/event/touch_event.h"
#ifdef ENABLE_ROSEN_BACKEND
#include "render_service_client/core/transaction/rs_transaction.h"
#include "render_service_client/core/ui/rs_ui_director.h"
#include "core/components_ng/render/adapter/rosen_window.h"
#endif
#include <algorithm>
#include <cinttypes>
#include <cstdint>
#include <memory>
#ifdef ENABLE_ROSEN_BACKEND
#include "render_service_client/core/transaction/rs_transaction.h"
#include "render_service_client/core/ui/rs_ui_director.h"
#include "core/components_ng/render/adapter/rosen_window.h"
#endif
#include "base/geometry/ng/offset_t.h"
#include "base/log/ace_trace.h"
#include "base/log/ace_tracker.h"
#include "base/log/dump_log.h"
#include "base/log/event_report.h"
#include "base/log/frame_report.h"
#include "base/memory/ace_type.h"
#include "base/memory/referenced.h"
#include "base/ressched/ressched_report.h"
#include "base/thread/task_executor.h"
@ -56,16 +47,23 @@
#include "core/common/window.h"
#include "core/components/common/layout/screen_system_manager.h"
#include "core/components_ng/base/frame_node.h"
#include "core/components_ng/base/ui_node.h"
#include "core/components_ng/pattern/app_bar/app_bar_view.h"
#include "core/components_ng/pattern/container_modal/container_modal_pattern.h"
#include "core/components_ng/pattern/container_modal/container_modal_view.h"
#include "core/components_ng/pattern/custom/custom_node_base.h"
#include "core/components_ng/pattern/image/image_layout_property.h"
#include "core/components_ng/pattern/navigation/navigation_group_node.h"
#include "core/components_ng/pattern/navigation/title_bar_node.h"
#include "core/components_ng/pattern/navrouter/navdestination_group_node.h"
#include "core/components_ng/pattern/overlay/overlay_manager.h"
#include "core/components_ng/pattern/root/root_pattern.h"
#include "core/components_ng/pattern/stage/stage_pattern.h"
#include "core/components_ng/pattern/text_field/text_field_manager.h"
#include "core/components_ng/property/calc_length.h"
#include "core/components_v2/inspector/inspector_constants.h"
#include "core/event/ace_events.h"
#include "core/event/touch_event.h"
#include "core/pipeline/base/element_register.h"
#include "core/pipeline/pipeline_context.h"
#include "core/pipeline_ng/ui_task_scheduler.h"

View File

@ -0,0 +1,28 @@
/*
* 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 "core/common/window.h"
namespace OHOS::Ace {
Window::Window(std::unique_ptr<PlatformWindow> platformWindow) : platformWindow_(std::move(platformWindow)) {}
void Window::OnVsync(uint64_t nanoTimestamp, uint32_t frameCount) {}
void Window::RequestFrame() {}
void Window::SetRootRenderNode(const RefPtr<RenderNode>& root) {}
void Window::SetVsyncCallback(AceVsyncCallback&& callback) {}
} // namespace OHOS::Ace

View File

@ -16,20 +16,33 @@
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_PIPELINE_NG_TEST_MOCK_MOCK_WINDOW_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_PIPELINE_NG_TEST_MOCK_MOCK_WINDOW_H
#include "gmock/gmock-function-mocker.h"
#include "gmock/gmock.h"
#include "core/common/window.h"
#include "core/components/test/unittest/image/image_test_utils.h"
namespace OHOS::Ace::NG {
class MockWindow : public Window {
#include "core/common/window.h"
namespace OHOS::Ace {
class ACE_EXPORT MockWindow : public Window {
public:
MockWindow() = default;
MOCK_METHOD(void, RequestFrame, (), (override));
MOCK_METHOD(void, Destroy, (), (override));
MOCK_METHOD(void, SetRootRenderNode, (const RefPtr<RenderNode>& root), (override));
MOCK_METHOD(void, RecordFrameTime, (uint64_t timeStamp, const std::string& name), (override));
MOCK_METHOD(bool, FlushCustomAnimation, (uint64_t timeStamp), (override));
~MockWindow() override = default;
MOCK_METHOD0(RequestFrame, void());
MOCK_METHOD0(Destroy, void());
MOCK_METHOD0(Init, void());
MOCK_METHOD0(OnShow, void());
MOCK_METHOD0(OnHide, void());
MOCK_METHOD0(FlushTasks, void());
MOCK_CONST_METHOD0(GetRefreshRate, float());
MOCK_CONST_METHOD0(GetCurrentWindowRect, Rect());
MOCK_CONST_METHOD0(GetRSUIDirector, std::shared_ptr<Rosen::RSUIDirector>());
MOCK_METHOD1(SetDrawTextAsBitmap, void(bool useBitmap));
MOCK_METHOD1(SetRootFrameNode, void(const RefPtr<NG::FrameNode>& root));
MOCK_METHOD1(SetInstanceId, void(int32_t instanceId));
MOCK_METHOD1(SetTaskExecutor, void(const RefPtr<TaskExecutor>& taskExecutor));
MOCK_METHOD1(SetVsyncCallback, void(AceVsyncCallback&& callback));
MOCK_METHOD1(SetRootRenderNode, void(const RefPtr<RenderNode>& root));
MOCK_METHOD1(FlushCustomAnimation, bool(uint64_t timeStamp));
MOCK_METHOD2(RecordFrameTime, void(uint64_t timeStamp, const std::string& name));
};
} // namespace OHOS::Ace::NG
} // namespace OHOS::Ace
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_PIPELINE_NG_TEST_MOCK_MOCK_WINDOW_H

View File

@ -60,6 +60,7 @@ ohos_fuzztest("UtilEngineFuzzTest") {
#"$ace_root/adapter/ohos/osal:ace_osal_ohos",
"//foundation/window/window_manager/utils:libwmutil",
"//foundation/window/window_manager/wm:libwm",
"//third_party/googletest:gmock_main",
"//third_party/icu/icu4c:shared_icui18n",
"//third_party/icu/icu4c:shared_icuuc",
]

View File

@ -0,0 +1,60 @@
/*
* 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 "base/log/event_report.h"
namespace OHOS::Ace {
void EventReport::SendEvent(const EventInfo& eventInfo) {}
void EventReport::SendJsCardRenderTimeEvent(
const std::string& sessionID, const std::string& timeType, uint64_t timeDelay)
{}
void EventReport::SendAppStartException(AppStartExcepType type) {}
void EventReport::SendPageRouterException(PageRouterExcepType type, const std::string& pageUrl) {}
void EventReport::SendComponentException(ComponentExcepType type) {}
void EventReport::SendAPIChannelException(APIChannelExcepType type) {}
void EventReport::SendRenderException(RenderExcepType type) {}
void EventReport::SendJsException(JsExcepType type) {}
void EventReport::SendAnimationException(AnimationExcepType type) {}
void EventReport::SendEventException(EventExcepType type) {}
void EventReport::SendInternalException(InternalExcepType type) {}
void EventReport::SendAccessibilityException(AccessibilityExcepType type) {}
void EventReport::SendFormException(FormExcepType type) {}
void EventReport::JsEventReport(int32_t eventType, const std::string& jsonStr) {}
void EventReport::JsErrReport(const std::string& packageName, const std::string& reason, const std::string& summary) {}
void EventReport::ANRRawReport(RawEventType type, int32_t uid, const std::string& packageName,
const std::string& processName, const std::string& msg)
{}
void EventReport::ANRShowDialog(
int32_t uid, const std::string& packageName, const std::string& processName, const std::string& msg)
{}
void EventReport::SendEventInner(const EventInfo& eventInfo) {}
} // namespace OHOS::Ace

View File

@ -13,6 +13,8 @@
* limitations under the License.
*/
#include "test/mock/core/common/mock_container.h"
#include "core/common/container.h"
namespace OHOS::Ace {
@ -20,9 +22,11 @@ namespace {
int32_t g_id = 0;
} // namespace
RefPtr<MockContainer> MockContainer::container_;
int32_t Container::CurrentId()
{
return 0;
return g_id;
}
RefPtr<Container> Container::GetActive()
@ -35,4 +39,29 @@ void Container::UpdateCurrent(int32_t id)
{
g_id = id;
}
RefPtr<Container> Container::Current()
{
return MockContainer::Current();
}
bool Container::Dump(const std::vector<std::string>& /* params */, std::vector<std::string>& /* info */)
{
return true;
}
void MockContainer::SetUp()
{
container_ = AceType::MakeRefPtr<MockContainer>();
}
void MockContainer::TearDown()
{
container_ = nullptr;
}
RefPtr<MockContainer> MockContainer::Current()
{
return container_;
}
} // namespace OHOS::Ace

View File

@ -13,8 +13,8 @@
* limitations under the License.
*/
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_TEST_MOCK_MOCK_CONTAINER_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_TEST_MOCK_MOCK_CONTAINER_H
#ifndef FOUNDATION_ACE_TEST_MOCK_CORE_COMMON_MOCK_CONTAINER_H
#define FOUNDATION_ACE_TEST_MOCK_CORE_COMMON_MOCK_CONTAINER_H
#include "gmock/gmock.h"
@ -26,10 +26,16 @@ class MockContainer final : public Container {
public:
explicit MockContainer(RefPtr<PipelineBase> pipelineContext = nullptr) : pipelineContext_(pipelineContext) {}
RefPtr<PipelineBase> GetPipelineContext() const override
{
return pipelineContext_;
}
static void SetUp();
static void TearDown();
static RefPtr<MockContainer> Current();
MOCK_METHOD(void, Initialize, (), (override));
MOCK_METHOD(void, Destroy, (), (override));
MOCK_METHOD(int32_t, GetInstanceId, (), (const, override));
@ -46,8 +52,10 @@ public:
MOCK_METHOD(uint32_t, GetWindowId, (), (const, override));
MOCK_METHOD(void*, GetView, (), (const, override));
static RefPtr<MockContainer> container_;
private:
RefPtr<PipelineBase> pipelineContext_;
};
} // namespace OHOS::Ace
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_TEST_MOCK_MOCK_CONTAINER_H
#endif // FOUNDATION_ACE_TEST_MOCK_CORE_COMMON_MOCK_CONTAINER_H

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "test/mock/core/common/mock_font_manager.h"
#include "core/common/font_manager.h"
namespace OHOS::Ace {
RefPtr<FontManager> FontManager::Create()
{
return AceType::MakeRefPtr<MockFontManager>();
}
} // namespace OHOS::Ace

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_ACE_TEST_MOCK_CORE_COMMON_MOCK_FONT_MANAGER_H
#define FOUNDATION_ACE_TEST_MOCK_CORE_COMMON_MOCK_FONT_MANAGER_H
#include "gmock/gmock.h"
#include "core/common/font_manager.h"
namespace OHOS::Ace {
class MockFontManager : public FontManager {
DECLARE_ACE_TYPE(MockFontManager, FontManager);
public:
MOCK_METHOD0(VaryFontCollectionWithFontWeightScale, void());
MOCK_METHOD0(LoadSystemFont, void());
};
} // namespace OHOS::Ace
#endif // FOUNDATION_ACE_TEST_MOCK_CORE_COMMON_MOCK_FONT_MANAGER_H

View File

@ -13,13 +13,16 @@
* limitations under the License.
*/
#include "core/components/common/layout/constants.h"
#include "core/components_ng/pattern/container_modal/container_modal_pattern.h"
namespace OHOS::Ace::NG {
void ContainerModalPattern::ShowTitle(bool isShow, bool hasDeco)
void ContainerModalPattern::ShowTitle(bool /* isShow */, bool hasDeco)
{
hasDeco_ = hasDeco;
windowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
moveX_ = 1.0;
moveY_ = 1.0;
}
void ContainerModalPattern::InitContainerEvent() {}
@ -35,7 +38,8 @@ void ContainerModalPattern::ChangeTitle(const RefPtr<FrameNode>& titleNode, bool
void ContainerModalPattern::ChangeFloatingTitle(const RefPtr<FrameNode>& floatingNode, bool isFocus) {}
void ContainerModalPattern::ChangeTitleButtonIcon(
const RefPtr<FrameNode>& buttonNode, InternalResource::ResourceId icon, bool isFocus) {}
const RefPtr<FrameNode>& buttonNode, InternalResource::ResourceId icon, bool isFocus)
{}
bool ContainerModalPattern::CanShowFloatingTitle()
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* 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
@ -14,8 +14,8 @@
*/
#include "base/memory/referenced.h"
#include "core/components_ng/pattern/container_modal/container_modal_view.h"
#include "core/components_ng/pattern/container_modal/container_modal_pattern.h"
#include "core/components_ng/pattern/container_modal/container_modal_view.h"
namespace OHOS::Ace::NG {
RefPtr<FrameNode> ContainerModalView::Create(RefPtr<FrameNode>& content)

View File

@ -0,0 +1,23 @@
/*
* Copyright (c) 2022-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 "core/components_ng/render/font_collection.h"
namespace OHOS::Ace::NG {
RefPtr<FontCollection> FontCollection::Current()
{
return nullptr;
}
} // namespace OHOS::Ace::NG

View File

@ -13,22 +13,13 @@
* limitations under the License.
*/
#include "core/components_ng/pattern/app_bar/app_bar_view.h"
#include "test/mock/core/render/mock_paragraph.h"
#include "core/components_ng/render/paragraph.h"
namespace OHOS::Ace::NG {
RefPtr<FrameNode> AppBarView::Create(RefPtr<FrameNode>& content)
RefPtr<Paragraph> Paragraph::Create(const ParagraphStyle& paraStyle, const RefPtr<FontCollection>& fontCollection)
{
return nullptr;
}
RefPtr<FrameNode> AppBarView::BuildBarTitle()
{
return nullptr;
}
RefPtr<FrameNode> AppBarView::BuildIconButton(
InternalResource::ResourceId icon, GestureEventFunc&& clickCallback, bool isBackButton)
{
return nullptr;
return AceType::MakeRefPtr<MockParagraph>();
}
} // namespace OHOS::Ace::NG

View File

@ -0,0 +1,54 @@
/*
* 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.
*/
#ifndef FOUNDATION_ACE_TEST_MOCK_CORE_RENDER_MOCK_PARAGRAPH_H
#define FOUNDATION_ACE_TEST_MOCK_CORE_RENDER_MOCK_PARAGRAPH_H
#include "gmock/gmock.h"
#include "core/components_ng/render/paragraph.h"
namespace OHOS::Ace::NG {
class MockParagraph : public Paragraph {
DECLARE_ACE_TYPE(MockParagraph, Paragraph);
public:
MockParagraph() = default;
~MockParagraph() override = default;
MOCK_METHOD0(IsValid, bool());
MOCK_METHOD0(PopStyle, void());
MOCK_METHOD0(Build, void());
MOCK_METHOD0(Reset, void());
MOCK_METHOD0(GetHeight, float());
MOCK_METHOD0(GetTextWidth, float());
MOCK_METHOD0(GetLineCount, size_t());
MOCK_METHOD0(GetMaxIntrinsicWidth, float());
MOCK_METHOD0(DidExceedMaxLines, bool());
MOCK_METHOD0(GetLongestLine, float());
MOCK_METHOD0(GetMaxWidth, float());
MOCK_METHOD0(GetAlphabeticBaseline, float());
MOCK_METHOD1(PushStyle, void(const TextStyle& style));
MOCK_METHOD1(AddText, void(const std::u16string& text));
MOCK_METHOD1(Layout, void(float width));
MOCK_METHOD1(GetHandlePositionForClick, int32_t(const Offset& offset));
MOCK_METHOD2(ComputeOffsetForCaretDownstream, bool(int32_t extent, CaretMetrics& result));
MOCK_METHOD2(ComputeOffsetForCaretUpstream, bool(int32_t extent, CaretMetrics& result));
MOCK_METHOD3(GetRectsForRange, void(int32_t start, int32_t end, std::vector<Rect>& selectedRects));
MOCK_METHOD3(Paint, void(const RSCanvas& canvas, float x, float y));
MOCK_METHOD3(Paint, void(SkCanvas* skCanvas, float x, float y));
};
} // namespace OHOS::Ace::NG
#endif // FOUNDATION_ACE_TEST_MOCK_CORE_RENDER_MOCK_PARAGRAPH_H

View File

@ -16,5 +16,8 @@ import("//foundation/arkui/ace_engine/ace_config.gni")
group("core_unittest") {
testonly = true
deps = [ "pattern:core_pattern_unittest" ]
deps = [
"pattern:core_pattern_unittest",
"pipeline:pipeline_context_test_ng",
]
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Copyright (c) 2022-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
@ -15,29 +15,27 @@ import("//build/test.gni")
import("//foundation/arkui/ace_engine/test/unittest/ace_unittest.gni")
ohos_unittest("pipeline_context_test_ng") {
module_out_path = base_test_outout_path
module_out_path = "$basic_test_output_path/pipeline"
sources = [
# animation
"$ace_root/frameworks/core/animation/animatable_data.cpp",
"$ace_root/frameworks/core/animation/animatable_properties.cpp",
"$ace_root/frameworks/core/animation/anticipate_curve.cpp",
"$ace_root/frameworks/core/animation/cubic_curve.cpp",
"$ace_root/frameworks/core/animation/curves.cpp",
"$ace_root/frameworks/core/animation/friction_motion.cpp",
"$ace_root/frameworks/core/animation/property_animation.cpp",
"$ace_root/frameworks/core/animation/scheduler.cpp",
"$ace_root/frameworks/core/animation/scroll_motion.cpp",
"$ace_root/frameworks/core/animation/spring_model.cpp",
"$ace_root/frameworks/core/animation/spring_motion.cpp",
"$ace_root/frameworks/core/components_ng/animation/geometry_transition.cpp",
# accessibility
"$ace_root/frameworks/core/accessibility/accessibility_node.cpp",
# animation
"$ace_root/frameworks/core/animation/animatable_data.cpp",
"$ace_root/frameworks/core/animation/animatable_properties.cpp",
"$ace_root/frameworks/core/animation/scheduler.cpp",
"$ace_root/frameworks/core/animation/spring_model.cpp",
"$ace_root/frameworks/core/animation/spring_motion.cpp",
#base
"$ace_root/adapter/ohos/osal/log_wrapper.cpp",
# base
"$ace_root/adapter/ohos/osal/ressched_report.cpp",
"$ace_root/frameworks/base/geometry/animatable_dimension.cpp",
"$ace_root/frameworks/base/geometry/animatable_matrix4.cpp",
@ -49,161 +47,45 @@ ohos_unittest("pipeline_context_test_ng") {
"$ace_root/frameworks/base/geometry/transform_util.cpp",
"$ace_root/frameworks/base/json/json_util.cpp",
"$ace_root/frameworks/base/log/ace_tracker.cpp",
"$ace_root/frameworks/base/log/dump_log.cpp",
"$ace_root/frameworks/base/memory/memory_monitor.cpp",
"$ace_root/frameworks/base/ressched/ressched_report.cpp",
"$ace_root/frameworks/base/thread/background_task_executor.cpp",
"$ace_root/frameworks/base/utils/base_id.cpp",
"$ace_root/frameworks/base/utils/string_expression.cpp",
"$ace_root/frameworks/base/utils/string_utils.cpp",
"$ace_root/frameworks/base/utils/time_util.cpp",
# common
"$ace_root/frameworks/core/common/ace_application_info.cpp",
"$ace_root/frameworks/core/common/ace_engine.cpp",
"$ace_root/frameworks/core/common/clipboard/clipboard_proxy.cpp",
"$ace_root/frameworks/core/common/container.cpp",
"$ace_root/frameworks/core/common/container_scope.cpp",
"$ace_root/frameworks/core/common/flutter/flutter_task_executor.cpp",
"$ace_root/frameworks/core/common/focus_animation_manager.cpp",
"$ace_root/frameworks/core/common/font_manager.cpp",
"$ace_root/frameworks/core/common/text_field_manager.cpp",
"$ace_root/frameworks/core/common/thread_checker.cpp",
"$ace_root/frameworks/core/common/vibrator/vibrator_proxy.cpp",
"$ace_root/frameworks/core/common/window.cpp",
# components
"$ace_root/frameworks/core/components/box/box_component.cpp",
"$ace_root/frameworks/core/components/display/display_component.cpp",
"$ace_root/frameworks/core/components/overlay/overlay_component.cpp",
"$ace_root/frameworks/core/components/page/page_component.cpp",
"$ace_root/frameworks/core/components/root/root_component.cpp",
"$ace_root/frameworks/core/components/transform/transform_component.cpp",
"$ace_root/frameworks/core/components/tween/tween_component.cpp",
"$ace_root/frameworks/core/pipeline/base/component.cpp",
"$ace_root/frameworks/core/pipeline/base/composed_component.cpp",
# elements
"$ace_root/frameworks/core/components/box/box_element.cpp",
"$ace_root/frameworks/core/components/bubble/bubble_element.cpp",
"$ace_root/frameworks/core/components/display/display_element.cpp",
"$ace_root/frameworks/core/components/flex/flex_element.cpp",
"$ace_root/frameworks/core/components/page/page_element.cpp",
"$ace_root/frameworks/core/components/page_transition/page_transition_component.cpp",
"$ace_root/frameworks/core/components/page_transition/page_transition_element.cpp",
"$ace_root/frameworks/core/components/root/root_element.cpp",
"$ace_root/frameworks/core/components/stack/stack_element.cpp",
"$ace_root/frameworks/core/components/stage/stage_element.cpp",
"$ace_root/frameworks/core/components/transition/transition_element.cpp",
"$ace_root/frameworks/core/components/tween/tween_element.cpp",
"$ace_root/frameworks/core/pipeline/base/component_group_element.cpp",
"$ace_root/frameworks/core/pipeline/base/composed_element.cpp",
"$ace_root/frameworks/core/pipeline/base/element.cpp",
"$ace_root/frameworks/core/pipeline/base/render_element.cpp",
"$ace_root/frameworks/core/pipeline/base/sole_child_element.cpp",
# others
"$ace_root/frameworks/core/components/theme/app_theme.cpp",
"$ace_root/frameworks/core/components/theme/theme_attributes.cpp",
"$ace_root/frameworks/core/components/theme/theme_constants.cpp",
"$ace_root/frameworks/core/components/theme/theme_manager_impl.cpp",
"$ace_root/frameworks/core/components/theme/theme_utils.cpp",
"$ace_root/frameworks/core/components/common/properties/alignment.cpp",
"$ace_root/frameworks/core/components/common/properties/border.cpp",
"$ace_root/frameworks/core/components/common/properties/border_edge.cpp",
"$ace_root/frameworks/core/components/common/properties/border_image.cpp",
"$ace_root/frameworks/core/components/common/properties/color.cpp",
"$ace_root/frameworks/core/components/common/properties/shadow_config.cpp",
"$ace_root/frameworks/core/components/common/properties/text_style.cpp",
"$ace_root/frameworks/core/event/back_end_event_manager.cpp",
"$ace_root/frameworks/core/event/multimodal/multimodal_manager.cpp",
"$ace_root/frameworks/core/event/multimodal/multimodal_scene.cpp",
"$root_out_dir/arkui/framework/core/components/theme/theme_constants_default.cpp",
# focus
"$ace_root/frameworks/core/focus/focus_node.cpp",
# gestures
"$ace_root/frameworks/core/gestures/click_recognizer.cpp",
"$ace_root/frameworks/core/gestures/drag_recognizer.cpp",
"$ace_root/frameworks/core/gestures/exclusive_recognizer.cpp",
"$ace_root/frameworks/core/gestures/gesture_recognizer.cpp",
"$ace_root/frameworks/core/gestures/gesture_referee.cpp",
"$ace_root/frameworks/core/gestures/long_press_recognizer.cpp",
"$ace_root/frameworks/core/gestures/multi_fingers_recognizer.cpp",
"$ace_root/frameworks/core/gestures/pan_recognizer.cpp",
"$ace_root/frameworks/core/gestures/parallel_recognizer.cpp",
"$ace_root/frameworks/core/gestures/raw_recognizer.cpp",
"$ace_root/frameworks/core/gestures/sequenced_recognizer.cpp",
"$ace_root/frameworks/core/gestures/swipe_recognizer.cpp",
"$ace_root/frameworks/core/gestures/timeout_recognizer.cpp",
"$ace_root/frameworks/core/gestures/velocity_tracker.cpp",
# image
"$ace_root/frameworks/core/image/flutter_image_cache.cpp",
"$ace_root/frameworks/core/image/image_cache.cpp",
"$ace_root/frameworks/core/image/image_source_info.cpp",
# layout
"$ace_root/frameworks/core/components/common/layout/grid_column_info.cpp",
"$ace_root/frameworks/core/components/common/layout/grid_container_info.cpp",
"$ace_root/frameworks/core/components/common/layout/grid_system_manager.cpp",
"$ace_root/frameworks/core/components/common/layout/screen_system_manager.cpp",
# properties
"$ace_root/frameworks/core/components/common/painter/flutter_svg_painter.cpp",
"$ace_root/frameworks/core/components/common/properties/alignment.cpp",
"$ace_root/frameworks/core/components/common/properties/border.cpp",
"$ace_root/frameworks/core/components/common/properties/border_edge.cpp",
"$ace_root/frameworks/core/components/common/properties/color.cpp",
"$ace_root/frameworks/core/components/common/properties/decoration.cpp",
"$ace_root/frameworks/core/components/common/properties/edge.cpp",
"$ace_root/frameworks/core/components/common/properties/motion_path_evaluator.cpp",
"$ace_root/frameworks/core/components/common/properties/page_transition_option.cpp",
"$ace_root/frameworks/core/components/common/properties/scroll_bar.cpp",
"$ace_root/frameworks/core/components/common/properties/shadow.cpp",
"$ace_root/frameworks/core/components/common/properties/text_style.cpp",
# rendering
"$ace_root/frameworks/core/components/box/render_box.cpp",
"$ace_root/frameworks/core/components/box/render_box_base.cpp",
"$ace_root/frameworks/core/components/bubble/render_bubble.cpp",
"$ace_root/frameworks/core/components/display/render_display.cpp",
"$ace_root/frameworks/core/components/focus_animation/render_focus_animation.cpp",
"$ace_root/frameworks/core/components/proxy/render_proxy.cpp",
"$ace_root/frameworks/core/components/refresh/render_refresh.cpp",
"$ace_root/frameworks/core/components/root/render_root.cpp",
"$ace_root/frameworks/core/components/scroll/render_multi_child_scroll.cpp",
"$ace_root/frameworks/core/components/scroll/render_scroll.cpp",
"$ace_root/frameworks/core/components/scroll/render_single_child_scroll.cpp",
"$ace_root/frameworks/core/components/scroll/scroll_bar_controller.cpp",
"$ace_root/frameworks/core/components/stack/render_stack.cpp",
"$ace_root/frameworks/core/components/stage/render_stage.cpp",
"$ace_root/frameworks/core/components/test/unittest/mock/mock_flutter_font_manager.cpp",
"$ace_root/frameworks/core/components/test/unittest/mock/mock_render_node_factory.cpp",
"$ace_root/frameworks/core/components/touch_listener/render_touch_listener.cpp",
"$ace_root/frameworks/core/components/transform/render_transform.cpp",
"$ace_root/frameworks/core/components_v2/inspector/inspector_constants.cpp",
"$ace_root/frameworks/core/components_v2/list/render_list.cpp",
"$ace_root/frameworks/core/pipeline/base/render_node.cpp",
#mock
"$ace_root/frameworks/base/test/mock/mock_drag_window_old.cpp",
"$ace_root/frameworks/base/test/mock/mock_frame_report.cpp",
"$ace_root/frameworks/base/test/mock/mock_system_properties.cpp",
"$ace_root/frameworks/base/test/mock/mock_trace_id_impl.cpp",
"$ace_root/frameworks/core/animation/test/mock/mock_animator.cpp",
"$ace_root/frameworks/core/common/test/mock/mock_ace_application_info.cpp",
"$ace_root/frameworks/core/common/test/mock/mock_layout_inspector.cpp",
"$ace_root/frameworks/core/common/test/mock/mock_text_editing_value.cpp",
"$ace_root/frameworks/core/common/test/mock/mock_watch_dog.cpp",
"$ace_root/frameworks/core/components/test/mock/mock_resource_adapter.cpp",
"$ace_root/frameworks/core/components/test/mock/mock_text_overlay_component.cpp",
"$ace_root/frameworks/core/components/test/mock/mock_text_overlay_manager.cpp",
"$ace_root/frameworks/core/components/test/unittest/mock/ace_trace_mock.cpp",
"$ace_root/frameworks/core/components/test/unittest/mock/event_report_mock.cpp",
"$ace_root/frameworks/core/components/test/unittest/mock/mock_container_modal_compoment.cpp",
"$ace_root/frameworks/core/components/test/unittest/mock/mock_container_modal_element.cpp",
"$ace_root/frameworks/core/components/test/unittest/mock/mock_drag_drop_event.cpp",
"$ace_root/frameworks/core/components/test/unittest/mock/mock_icon_theme.cpp",
"$ace_root/frameworks/core/components/test/unittest/mock/mock_render_text_field.cpp",
"$ace_root/frameworks/core/components/test/unittest/mock/mock_semi_modal_element.cpp",
"$ace_root/frameworks/core/components_v2/test/mock/mock_inspector_composed_element.cpp",
"$ace_root/frameworks/core/image/test/mock/mock_image_loader.cpp",
"$ace_root/frameworks/core/pipeline/base/element_register.cpp",
# base
"$ace_root/frameworks/core/components_ng/base/frame_node.cpp",
"$ace_root/frameworks/core/components_ng/base/geometry_node.cpp",
@ -235,15 +117,58 @@ ohos_unittest("pipeline_context_test_ng") {
"$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp",
# pattern
"$ace_root/frameworks/core/components_ng/manager/select_overlay/select_overlay_manager.cpp",
"$ace_root/frameworks/core/components_ng/manager/select_overlay/select_overlay_proxy.cpp",
"$ace_root/frameworks/core/components_ng/pattern/app_bar/app_bar_view.cpp",
"$ace_root/frameworks/core/components_ng/pattern/button/button_layout_algorithm.cpp",
"$ace_root/frameworks/core/components_ng/pattern/button/button_pattern.cpp",
"$ace_root/frameworks/core/components_ng/pattern/button/toggle_button_pattern.cpp",
"$ace_root/frameworks/core/components_ng/pattern/custom/custom_measure_layout_node.cpp",
"$ace_root/frameworks/core/components_ng/pattern/custom/custom_node.cpp",
"$ace_root/frameworks/core/components_ng/pattern/custom/custom_node_base.cpp",
"$ace_root/frameworks/core/components_ng/pattern/custom/custom_node_layout_algorithm.cpp",
"$ace_root/frameworks/core/components_ng/pattern/custom/custom_node_pattern.cpp",
"$ace_root/frameworks/core/components_ng/pattern/flex/flex_layout_algorithm.cpp",
"$ace_root/frameworks/core/components_ng/pattern/grid_container/grid_container_layout_property.cpp",
"$ace_root/frameworks/core/components_ng/pattern/grid_container/grid_container_model_ng.cpp",
"$ace_root/frameworks/core/components_ng/pattern/image/image_layout_algorithm.cpp",
"$ace_root/frameworks/core/components_ng/pattern/image/image_paint_method.cpp",
"$ace_root/frameworks/core/components_ng/pattern/image/image_pattern.cpp",
"$ace_root/frameworks/core/components_ng/pattern/menu/menu_accessibility_property.cpp",
"$ace_root/frameworks/core/components_ng/pattern/menu/menu_item/menu_item_pattern.cpp",
"$ace_root/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp",
"$ace_root/frameworks/core/components_ng/pattern/menu/menu_paint_method.cpp",
"$ace_root/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp",
"$ace_root/frameworks/core/components_ng/pattern/menu/menu_view.cpp",
"$ace_root/frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.cpp",
"$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_layout_algorithm.cpp",
"$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.cpp",
"$ace_root/frameworks/core/components_ng/pattern/option/option_accessibility_property.cpp",
"$ace_root/frameworks/core/components_ng/pattern/option/option_layout_algorithm.cpp",
"$ace_root/frameworks/core/components_ng/pattern/option/option_paint_method.cpp",
"$ace_root/frameworks/core/components_ng/pattern/option/option_pattern.cpp",
"$ace_root/frameworks/core/components_ng/pattern/option/option_view.cpp",
"$ace_root/frameworks/core/components_ng/pattern/search/search_event_hub.cpp",
"$ace_root/frameworks/core/components_ng/pattern/search/search_pattern.cpp",
"$ace_root/frameworks/core/components_ng/pattern/select_overlay/select_overlay_layout_algorithm.cpp",
"$ace_root/frameworks/core/components_ng/pattern/select_overlay/select_overlay_node.cpp",
"$ace_root/frameworks/core/components_ng/pattern/select_overlay/select_overlay_paint_method.cpp",
"$ace_root/frameworks/core/components_ng/pattern/select_overlay/select_overlay_pattern.cpp",
"$ace_root/frameworks/core/components_ng/pattern/select_overlay/select_overlay_property.cpp",
"$ace_root/frameworks/core/components_ng/pattern/stack/stack_layout_algorithm.cpp",
"$ace_root/frameworks/core/components_ng/pattern/stage/page_pattern.cpp",
"$ace_root/frameworks/core/components_ng/pattern/stage/stage_manager.cpp",
"$ace_root/frameworks/core/components_ng/pattern/text/span_node.cpp",
"$ace_root/frameworks/core/components_ng/pattern/text/text_accessibility_property.cpp",
"$ace_root/frameworks/core/components_ng/pattern/text/text_content_modifier.cpp",
"$ace_root/frameworks/core/components_ng/pattern/text/text_layout_algorithm.cpp",
"$ace_root/frameworks/core/components_ng/pattern/text/text_layout_property.cpp",
"$ace_root/frameworks/core/components_ng/pattern/text/text_overlay_modifier.cpp",
"$ace_root/frameworks/core/components_ng/pattern/text/text_paint_method.cpp",
"$ace_root/frameworks/core/components_ng/pattern/text/text_pattern.cpp",
"$ace_root/frameworks/core/components_ng/pattern/text/text_styles.cpp",
"$ace_root/frameworks/core/components_ng/pattern/text_field/text_field_manager.cpp",
"$ace_root/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp",
# property
"$ace_root/frameworks/core/components_ng/property/calc_length.cpp",
@ -258,11 +183,6 @@ ohos_unittest("pipeline_context_test_ng") {
"$ace_root/frameworks/core/components_ng/gestures/long_press_gesture.cpp",
"$ace_root/frameworks/core/components_ng/gestures/pan_gesture.cpp",
"$ace_root/frameworks/core/components_ng/gestures/pinch_gesture.cpp",
"$ace_root/frameworks/core/components_ng/gestures/rotation_gesture.cpp",
"$ace_root/frameworks/core/components_ng/gestures/swipe_gesture.cpp",
"$ace_root/frameworks/core/components_ng/gestures/tap_gesture.cpp",
# recognizers
"$ace_root/frameworks/core/components_ng/gestures/recognizers/click_recognizer.cpp",
"$ace_root/frameworks/core/components_ng/gestures/recognizers/exclusive_recognizer.cpp",
"$ace_root/frameworks/core/components_ng/gestures/recognizers/gesture_recognizer.cpp",
@ -275,23 +195,45 @@ ohos_unittest("pipeline_context_test_ng") {
"$ace_root/frameworks/core/components_ng/gestures/recognizers/rotation_recognizer.cpp",
"$ace_root/frameworks/core/components_ng/gestures/recognizers/sequenced_recognizer.cpp",
"$ace_root/frameworks/core/components_ng/gestures/recognizers/swipe_recognizer.cpp",
"$ace_root/frameworks/core/components_ng/gestures/rotation_gesture.cpp",
"$ace_root/frameworks/core/components_ng/gestures/swipe_gesture.cpp",
"$ace_root/frameworks/core/components_ng/gestures/tap_gesture.cpp",
# render
"$ace_root/frameworks/core/components_ng/render/paint_wrapper.cpp",
"$ace_root/frameworks/core/components_ng/render/render_context.cpp",
# public mock
"$ace_root/frameworks/core/components_ng/test/mock/animation/mock_geometry_transition.cpp",
"$ace_root/frameworks/base/test/mock/mock_drag_window_old.cpp",
"$ace_root/frameworks/base/test/mock/mock_frame_report.cpp",
"$ace_root/frameworks/base/test/mock/mock_subwindow_manager.cpp",
"$ace_root/frameworks/base/test/mock/mock_system_properties.cpp",
"$ace_root/frameworks/base/test/mock/mock_trace_id_impl.cpp",
"$ace_root/frameworks/core/animation/test/mock/mock_animator.cpp",
"$ace_root/frameworks/core/common/test/mock/mock_ace_application_info.cpp",
"$ace_root/frameworks/core/common/test/mock/mock_layout_inspector.cpp",
"$ace_root/frameworks/core/common/test/mock/mock_text_editing_value.cpp",
"$ace_root/frameworks/core/common/test/mock/mock_watch_dog.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/base/mock_localization.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_cache.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_loading_context.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_painter.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_source_info.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/manager/drag_drop/mock_drag_drop_proxy.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/render/mock_animation_utils.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/render/mock_modifier_adapter.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/render/mock_render_context_creator.cpp",
"$ace_root/frameworks/core/components_ng/test/mock/render/mock_render_property.cpp",
# mock file
"$ace_root/test/unittest/core/pipeline/mock_app_bar_view.cpp",
"$ace_root/test/unittest/core/pipeline/mock_container_modal_pattern.cpp",
"$ace_root/test/unittest/core/pipeline/mock_container_modal_view.cpp",
"$ace_root/frameworks/core/components_ng/test/pattern/text/mock/mock_text_layout_adapter.cpp",
"$ace_root/frameworks/core/pipeline_ng/test/mock/mock_element_register.cpp",
"$ace_root/frameworks/core/pipeline_ng/test/mock/mock_window.cpp",
"$ace_root/test/mock/base/mock_event_report.cpp",
"$ace_root/test/mock/core/common/mock_container.cpp",
"$ace_root/test/mock/core/common/mock_font_manager.cpp",
"$ace_root/test/mock/core/pattern/container_modal/mock_container_modal_pattern.cpp",
"$ace_root/test/mock/core/pattern/container_modal/mock_container_modal_view.cpp",
"$ace_root/test/mock/core/render/mock_font_collection.cpp",
"$ace_root/test/mock/core/render/mock_paragraph.cpp",
"$ace_root/test/unittest/core/pipeline/mock_drag_drop_manager.cpp",
"$ace_root/test/unittest/core/pipeline/mock_event_manager.cpp",
"$ace_root/test/unittest/core/pipeline/mock_full_screen_manager.cpp",
@ -302,66 +244,20 @@ ohos_unittest("pipeline_context_test_ng") {
"$ace_root/frameworks/core/pipeline/pipeline_base.cpp",
"$ace_root/frameworks/core/pipeline_ng/pipeline_context.cpp",
"$ace_root/frameworks/core/pipeline_ng/ui_task_scheduler.cpp",
# self
"$ace_root/test/unittest/core/pipeline/pipeline_context_test_ng.cpp",
"$ace_root/test/unittest/core/pipeline/ui_task_scheduler_test.cpp",
]
if (is_wearable_product) {
sources += [ "$root_out_dir/arkui/framework/core/components/theme/theme_constants_watch.cpp" ]
} else {
sources += [ "$root_out_dir/arkui/framework/core/components/theme/theme_constants_tv.cpp" ]
}
include_dirs = [
"//foundation/graphic/graphic_2d/interfaces/inner_api/common",
"//foundation/graphic/graphic_2d/interfaces/inner_api/composer",
"//foundation/graphic/graphic_2d/interfaces/inner_api/surface",
"//foundation/graphic/graphic_2d/rosen/modules",
"//foundation/graphic/graphic_2d/rosen/modules/2d_engine",
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/include",
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/src",
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/src/drawing/engine_adapter",
"//foundation/graphic/graphic_2d/rosen/modules/composer/vsync/include",
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client/core",
"//foundation/graphic/graphic_2d/rosen/modules/render_service_base/include",
"//foundation/multimedia/image_framework/interfaces/innerkits/include",
"//foundation/window/window_manager/interfaces/innerkits",
"//drivers/peripheral/display/interfaces/include",
"//commonlibrary/c_utils/base/include",
"$ace_root",
"$ace_root/frameworks",
]
defines = [
"ENABLE_ROSEN_BACKEND",
"OHOS_PLATFORM",
]
deps = [
"$ace_flutter_engine_root:third_party_flutter_engine_ohos",
"$ace_flutter_engine_root/icu:ace_libicu_ohos",
"$ace_flutter_engine_root/skia:ace_skia_ohos",
"$ace_root/frameworks/base/resource:ace_resource",
"$ace_root/frameworks/base:ace_memory_monitor_ohos",
"$ace_root/frameworks/core/components/theme:ace_core_components_theme_ohos",
"$ace_root/frameworks/core/components/theme:build_theme_code",
"$ace_root/test/unittest:ace_unittest_log",
"$ace_root/test/unittest:ace_unittest_trace",
"$cjson_root:cjson",
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
]
if (frame_trace_support) {
include_dirs += [ "//foundation/resourceschedule/frame_aware_sched/interfaces/innerkits/frameintf" ]
deps += [ "//foundation/resourceschedule/frame_aware_sched/interfaces/innerkits/frameintf:frame_trace_intf" ]
sources += [ "$ace_root/adapter/ohos/osal/frame_trace_adapter_impl.cpp" ]
} else {
sources +=
[ "$ace_root/adapter/ohos/osal/frame_trace_adapter_fake_impl.cpp" ]
}
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
cflags_cc = [ "-w" ]
configs = [ "$ace_root:ace_config" ]
configs = [ "$ace_root/test/unittest:ace_unittest_config" ]
}

View File

@ -13,8 +13,9 @@
* limitations under the License.
*/
#include "test/unittest/core/pipeline/common_constants.h"
#include "core/common/event_manager.h"
#include "core/pipeline_ng/test/unittest/common_constants.h"
namespace OHOS::Ace {
void EventManager::TouchTest(const TouchEvent& touchPoint, const RefPtr<RenderNode>& renderNode,
@ -140,6 +141,8 @@ bool EventManager::DispatchRotationEvent(
return true;
}
void EventManager::DispatchKeyboardShortcut(const KeyEvent& event) {}
void EventManager::ClearResults() {}
EventManager::EventManager() {}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,18 +15,20 @@
#include <cstdint>
#include "gtest/gtest.h"
#include "test/mock/core/common/mock_container.h"
#include "core/components/common/layout/constants.h"
// Add the following two macro definitions to test the private and protected method.
#define private public
#define protected public
#include "common_constants.h"
#include "mock_schedule_task.h"
#include "test/mock/core/common/mock_container.h"
#include "base/memory/ace_type.h"
#include "base/memory/referenced.h"
#include "core/common/ace_engine.h"
#include "core/common/event_manager.h"
#include "core/components/common/layout/constants.h"
#include "core/components_ng/base/frame_node.h"
#include "core/components_ng/event/event_hub.h"
#include "core/components_ng/event/focus_hub.h"
@ -40,8 +42,6 @@
#include "core/pipeline_ng/test/mock/mock_frontend.h"
#include "core/pipeline_ng/test/mock/mock_task_executor.h"
#include "core/pipeline_ng/test/mock/mock_window.h"
#include "core/pipeline_ng/test/unittest/common_constants.h"
#include "core/pipeline_ng/test/unittest/mock_schedule_task.h"
using namespace testing;
using namespace testing::ext;
@ -52,7 +52,6 @@ constexpr int32_t DEFAULT_INSTANCE_ID = 0;
constexpr int32_t DEFAULT_INT0 = 0;
constexpr int32_t DEFAULT_INT1 = 1;
constexpr int32_t DEFAULT_INT3 = 3;
constexpr int32_t DEFAULT_INT4 = 4;
constexpr int32_t DEFAULT_INT10 = 10;
constexpr uint32_t DEFAULT_SIZE1 = 1;
constexpr uint32_t DEFAULT_SIZE2 = 2;
@ -72,9 +71,7 @@ public:
static void ResetEventFlag(int32_t testFlag);
static bool GetEventFlag(int32_t testFlag);
static void SetUpTestSuite();
static void TearDownTestSuite() {}
void SetUp() override {}
void TearDown() override {}
static void TearDownTestSuite();
private:
static ElementIdType frameNodeId_;
@ -110,12 +107,28 @@ void PipelineContextTestNg::SetUpTestSuite()
// AddUINode is called in the function.
customNode_ = CustomNode::CreateCustomNode(customNodeId_, TEST_TAG);
ElementRegister::GetInstance()->AddUINode(frameNode_);
ContainerScope scope(DEFAULT_INSTANCE_ID);
auto window = std::make_shared<MockWindow>();
EXPECT_CALL(*window, RequestFrame()).Times(AnyNumber());
EXPECT_CALL(*window, FlushTasks()).Times(AnyNumber());
EXPECT_CALL(*window, OnHide()).Times(AnyNumber());
EXPECT_CALL(*window, RecordFrameTime(_, _)).Times(AnyNumber());
EXPECT_CALL(*window, OnShow()).Times(AnyNumber());
EXPECT_CALL(*window, FlushCustomAnimation(NANO_TIME_STAMP))
.Times(AtLeast(1))
.WillOnce(testing::Return(true))
.WillRepeatedly(testing::Return(false));
EXPECT_CALL(*window, SetRootFrameNode(_)).Times(AnyNumber());
context_ = AceType::MakeRefPtr<PipelineContext>(
std::make_unique<MockWindow>(), AceType::MakeRefPtr<MockTaskExecutor>(), nullptr, nullptr, DEFAULT_INSTANCE_ID);
window, AceType::MakeRefPtr<MockTaskExecutor>(), nullptr, nullptr, DEFAULT_INSTANCE_ID);
context_->SetEventManager(AceType::MakeRefPtr<EventManager>());
RefPtr<Container> container = AceType::MakeRefPtr<MockContainer>(context_);
AceEngine::Get().AddContainer(DEFAULT_INSTANCE_ID, container);
MockContainer::SetUp();
MockContainer::Current()->pipelineContext_ = context_;
}
void PipelineContextTestNg::TearDownTestSuite()
{
context_->window_.reset();
MockContainer::TearDown();
}
/**
@ -154,14 +167,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg002, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
auto mockWindow = std::make_unique<MockWindow>();
Mock::AllowLeak(mockWindow.get());
EXPECT_CALL(*mockWindow, FlushCustomAnimation(NANO_TIME_STAMP))
.Times(AtLeast(1))
.WillOnce(testing::Return(true))
.WillRepeatedly(testing::Return(false));
context_->window_ = std::move(mockWindow);
context_->SetupRootElement();
/**
@ -214,7 +219,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg003, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
context_->SetupRootElement();
/**
@ -289,7 +293,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg005, TestSize.Level1)
* @tc.steps1: initialize parameters.
* @tc.expected: All pointer is non-null.
*/
ContainerScope scope(DEFAULT_INSTANCE_ID);
ASSERT_NE(context_, nullptr);
context_->SetupRootElement();
@ -336,7 +339,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg007, TestSize.Level1)
* @tc.steps1: initialize parameters.
* @tc.expected: All pointer is non-null.
*/
ContainerScope scope(DEFAULT_INSTANCE_ID);
ASSERT_NE(context_, nullptr);
/**
* @tc.steps2: Call the function SetupRootElement with isJsCard_ = true.
@ -368,7 +370,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg008, TestSize.Level1)
* @tc.steps1: initialize parameters.
* @tc.expected: All pointer is non-null.
*/
ContainerScope scope(DEFAULT_INSTANCE_ID);
ASSERT_NE(context_, nullptr);
/**
@ -399,7 +400,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg009, TestSize.Level1)
* @tc.steps1: initialize parameters.
* @tc.expected: All pointer is non-null.
*/
ContainerScope scope(DEFAULT_INSTANCE_ID);
ASSERT_NE(context_, nullptr);
context_->rootWidth_ = DEFAULT_INT10;
context_->rootHeight_ = DEFAULT_INT10;
@ -517,7 +517,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg012, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
context_->SetupRootElement();
context_->onWindowFocusChangedCallbacks_.clear();
context_->AddWindowFocusChangedCallback(ElementRegister::UndefinedElementId);
@ -659,7 +658,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg016, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
context_->SetupRootElement();
context_->onWindowStateChangedCallbacks_.clear();
context_->AddWindowStateChangedCallback(ElementRegister::UndefinedElementId);
@ -695,7 +693,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg017, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
context_->SetupRootElement();
auto manager = context_->GetDragDropManager();
@ -739,7 +736,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg018, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
context_->windowModal_ = WindowModal::CONTAINER_MODAL;
context_->SetupRootElement();
ASSERT_NE(context_->rootNode_, nullptr);
@ -779,7 +775,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg019, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
context_->windowModal_ = WindowModal::CONTAINER_MODAL;
context_->SetupRootElement();
ASSERT_NE(context_->rootNode_, nullptr);
@ -819,7 +814,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg020, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
context_->windowModal_ = WindowModal::CONTAINER_MODAL;
context_->SetupRootElement();
ASSERT_NE(context_->rootNode_, nullptr);
@ -906,7 +900,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg022, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
context_->SetupRootElement();
auto eventManager = AceType::MakeRefPtr<EventManager>();
context_->SetEventManager(eventManager);
@ -971,7 +964,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg023, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
context_->SetupRootElement();
MouseEvent event;
@ -1066,7 +1058,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg024, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
context_->SetupRootElement();
TouchEvent event;
context_->touchEvents_.clear();
@ -1102,7 +1093,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg025, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
context_->SetupRootElement();
/**
@ -1163,7 +1153,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg026, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
context_->SetupRootElement();
/**
@ -1224,7 +1213,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg027, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
context_->SetupRootElement();
auto frontend = AceType::MakeRefPtr<MockFrontend>();
auto& windowConfig = frontend->GetWindowConfig();
@ -1276,7 +1264,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg028, TestSize.Level1)
* @tc.expected: All pointer is non-null.
*/
ASSERT_NE(context_, nullptr);
ContainerScope scope(DEFAULT_INSTANCE_ID);
context_->SetupRootElement();
auto frontend = AceType::MakeRefPtr<MockFrontend>();
auto& windowConfig = frontend->GetWindowConfig();
@ -1290,6 +1277,6 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg028, TestSize.Level1)
*/
context_->designWidthScale_ = DEFAULT_DOUBLE1;
context_->OnVirtualKeyboardHeightChange(DEFAULT_DOUBLE1);
EXPECT_DOUBLE_EQ(context_->designWidthScale_, DEFAULT_INT0);
EXPECT_DOUBLE_EQ(context_->designWidthScale_, DEFAULT_DOUBLE1);
}
} // namespace OHOS::Ace::NG

View File

@ -1,113 +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 <cstdint>
#include "gtest/gtest.h"
// Add the following two macro definitions to test the private and protected method.
#define private public
#define protected public
#include "core/components_ng/base/frame_node.h"
#include "core/pipeline_ng/ui_task_scheduler.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS::Ace::NG {
class UITaskSchedulerTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
};
void UITaskSchedulerTest::SetUpTestCase()
{
GTEST_LOG_(INFO) << "UITaskSchedulerTest SetUpTestCase";
}
void UITaskSchedulerTest::TearDownTestCase()
{
GTEST_LOG_(INFO) << "UITaskSchedulerTest TearDownTestCase";
}
void UITaskSchedulerTest::SetUp()
{
GTEST_LOG_(INFO) << "UITaskSchedulerTest SetUp";
}
void UITaskSchedulerTest::TearDown()
{
GTEST_LOG_(INFO) << "UITaskSchedulerTest TearDown";
}
/**
* @tc.name: UITaskSchedulerTest001
* @tc.desc: Test the function AddDirtyRenderNode.
* @tc.type: FUNC
*/
HWTEST_F(UITaskSchedulerTest, UITaskSchedulerTest001, TestSize.Level1)
{
/**
* @tc.steps1: initialize parameters.
*/
UITaskScheduler uiTaskScheduler;
const std::string testTag("testTag");
constexpr int32_t testNodeId = 1;
auto frameNode = FrameNode::GetOrCreateFrameNode(testTag, testNodeId, nullptr);
ASSERT_NE(frameNode, nullptr);
int32_t pageId = frameNode->GetPageId();
/**
* @tc.steps2: Call the function AddDirtyRenderNode.
* @tc.expected: The new FrameNode object is added to the map dirtyRenderNodes_ and its size is changed to 1.
*/
EXPECT_EQ(uiTaskScheduler.dirtyRenderNodes_.find(pageId), uiTaskScheduler.dirtyRenderNodes_.end());
uiTaskScheduler.AddDirtyRenderNode(frameNode);
EXPECT_NE(uiTaskScheduler.dirtyRenderNodes_.find(pageId), uiTaskScheduler.dirtyRenderNodes_.end());
EXPECT_EQ(uiTaskScheduler.dirtyRenderNodes_[pageId].size(), 1);
/**
* @tc.steps3: Call the function AddDirtyRenderNode again.
* @tc.expected: The new FrameNode object is not added to the map dirtyRenderNodes_ and its size is not changed.
*/
uiTaskScheduler.AddDirtyRenderNode(frameNode);
EXPECT_EQ(uiTaskScheduler.dirtyRenderNodes_[pageId].size(), 1);
}
/**
* @tc.name: UITaskSchedulerTest002
* @tc.desc: Test the function FlushPredictTask.
* @tc.type: FUNC
*/
HWTEST_F(UITaskSchedulerTest, UITaskSchedulerTest002, TestSize.Level1)
{
/**
* @tc.steps1: initialize parameters.
*/
UITaskScheduler uiTaskScheduler;
constexpr int64_t deadlineVal = 10;
int64_t flagTask = 0;
uiTaskScheduler.AddPredictTask(nullptr);
uiTaskScheduler.AddPredictTask([&flagTask] (int64_t deadline) { flagTask = deadline; });
/**
* @tc.steps2: Call the function FlushPredictTask.
* @tc.expected: The flagTask is set to deadlineVal.
*/
uiTaskScheduler.FlushPredictTask(deadlineVal);
EXPECT_EQ(flagTask, deadlineVal);
}
} // namespace OHOS::Ace::NG