mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-10-07 16:33:54 +00:00
!14541 删除window extension并把相关逻辑加入到ui extension
Merge pull request !14541 from liyujie/master
This commit is contained in:
commit
70df86eefc
@ -21,10 +21,11 @@
|
||||
|
||||
#include "ability.h"
|
||||
#include "ability_loader.h"
|
||||
#include "want.h"
|
||||
#include "window.h"
|
||||
|
||||
#include "core/common/window_animation_config.h"
|
||||
#include "core/event/touch_event.h"
|
||||
#include "want.h"
|
||||
#include "wm/window.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
class AceAbility;
|
||||
@ -60,6 +61,7 @@ public:
|
||||
|
||||
// override Rosen::IAvoidAreaChangedListener virtual callback function
|
||||
void OnAvoidAreaChanged(const OHOS::Rosen::AvoidArea avoidArea, OHOS::Rosen::AvoidAreaType type) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<AceAbility> callbackOwner_;
|
||||
};
|
||||
|
@ -21,8 +21,16 @@ build_component_ng("ui_extension_pattern_ng") {
|
||||
"ui_extension_pattern.cpp",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"input:libmmi-client",
|
||||
"window_manager:scene_session",
|
||||
]
|
||||
if (is_ohos_standard_system) {
|
||||
deps = [ "$graphic_standard_path/rosen/modules/render_service_client:librender_service_client" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_runtime:abilitykit_native",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
"window_manager:libwm",
|
||||
"window_manager:scene_session",
|
||||
"window_manager:scene_session_manager",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,78 @@
|
||||
|
||||
#include "core/components_ng/pattern/ui_extension/ui_extension_pattern.h"
|
||||
|
||||
#include "session/host/include/extension_session.h"
|
||||
#include "session_manager/include/extension_session_manager.h"
|
||||
#include "ui/rs_surface_node.h"
|
||||
|
||||
#include "adapter/ohos/entrance/ace_container.h"
|
||||
#include "core/components_ng/pattern/ui_extension/ui_extension_layout_algorithm.h"
|
||||
#include "core/pipeline_ng/pipeline_context.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
UIExtensionPattern::UIExtensionPattern(const std::string& bundleName, const std::string& abilityName)
|
||||
{
|
||||
auto container = AceType::DynamicCast<Platform::AceContainer>(Container::Current());
|
||||
CHECK_NULL_VOID(container);
|
||||
auto callerToken = container->GetToken();
|
||||
|
||||
Rosen::ExtensionSessionManager::GetInstance().Init();
|
||||
Rosen::SessionInfo extensionSessionInfo = {
|
||||
.bundleName_ = bundleName,
|
||||
.abilityName_ = abilityName,
|
||||
.callerToken_ = callerToken,
|
||||
};
|
||||
session_ = Rosen::ExtensionSessionManager::GetInstance().RequestExtensionSession(extensionSessionInfo);
|
||||
RegisterLifecycleListener();
|
||||
RequestExtensionSessionActivation();
|
||||
}
|
||||
|
||||
UIExtensionPattern::~UIExtensionPattern()
|
||||
{
|
||||
UnregisterLifecycleListener();
|
||||
RequestExtensionSessionDestruction();
|
||||
}
|
||||
|
||||
void UIExtensionPattern::OnConnect()
|
||||
{
|
||||
WindowPattern::OnConnect();
|
||||
CHECK_NULL_VOID(session_);
|
||||
auto surfaceNode = session_->GetSurfaceNode();
|
||||
CHECK_NULL_VOID(surfaceNode);
|
||||
surfaceNode->CreateNodeInRenderThread();
|
||||
}
|
||||
|
||||
void UIExtensionPattern::OnWindowShow()
|
||||
{
|
||||
RequestExtensionSessionActivation();
|
||||
}
|
||||
|
||||
void UIExtensionPattern::OnWindowHide()
|
||||
{
|
||||
RequestExtensionSessionBackground();
|
||||
}
|
||||
|
||||
void UIExtensionPattern::RequestExtensionSessionActivation()
|
||||
{
|
||||
CHECK_NULL_VOID(session_);
|
||||
sptr<Rosen::ExtensionSession> extensionSession(static_cast<Rosen::ExtensionSession*>(session_.GetRefPtr()));
|
||||
Rosen::ExtensionSessionManager::GetInstance().RequestExtensionSessionActivation(extensionSession);
|
||||
}
|
||||
|
||||
void UIExtensionPattern::RequestExtensionSessionBackground()
|
||||
{
|
||||
CHECK_NULL_VOID(session_);
|
||||
sptr<Rosen::ExtensionSession> extensionSession(static_cast<Rosen::ExtensionSession*>(session_.GetRefPtr()));
|
||||
Rosen::ExtensionSessionManager::GetInstance().RequestExtensionSessionBackground(extensionSession);
|
||||
}
|
||||
|
||||
void UIExtensionPattern::RequestExtensionSessionDestruction()
|
||||
{
|
||||
CHECK_NULL_VOID(session_);
|
||||
sptr<Rosen::ExtensionSession> extensionSession(static_cast<Rosen::ExtensionSession*>(session_.GetRefPtr()));
|
||||
Rosen::ExtensionSessionManager::GetInstance().RequestExtensionSessionDestruction(extensionSession);
|
||||
}
|
||||
|
||||
RefPtr<LayoutAlgorithm> UIExtensionPattern::CreateLayoutAlgorithm()
|
||||
{
|
||||
return MakeRefPtr<UIExtensionLayoutAlgorithm>();
|
||||
|
@ -16,19 +16,29 @@
|
||||
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_UI_EXTENSION_UI_EXTENSION_PATTERN_H
|
||||
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_UI_EXTENSION_UI_EXTENSION_PATTERN_H
|
||||
|
||||
#include "core/components_ng/pattern/ui_extension/ui_extension_layout_algorithm.h"
|
||||
#include "core/components_ng/pattern/window_scene/scene/window_extension.h"
|
||||
#include "core/components_ng/pattern/window_scene/scene/window_pattern.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
class UIExtensionPattern : public WindowExtension {
|
||||
DECLARE_ACE_TYPE(UIExtensionPattern, WindowExtension);
|
||||
class UIExtensionPattern : public WindowPattern {
|
||||
DECLARE_ACE_TYPE(UIExtensionPattern, WindowPattern);
|
||||
|
||||
public:
|
||||
UIExtensionPattern(const std::string& bundleName, const std::string& abilityName)
|
||||
: WindowExtension(bundleName, abilityName)
|
||||
{}
|
||||
UIExtensionPattern(const std::string& bundleName, const std::string& abilityName);
|
||||
~UIExtensionPattern() override;
|
||||
|
||||
~UIExtensionPattern() override = default;
|
||||
void OnWindowShow() override;
|
||||
void OnWindowHide() override;
|
||||
|
||||
bool HasStartingPage() override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void OnConnect() override;
|
||||
|
||||
void RequestExtensionSessionActivation();
|
||||
void RequestExtensionSessionBackground();
|
||||
void RequestExtensionSessionDestruction();
|
||||
|
||||
RefPtr<LayoutAlgorithm> CreateLayoutAlgorithm() override;
|
||||
|
||||
|
@ -30,7 +30,6 @@ build_component_ng("window_scene") {
|
||||
sources = [
|
||||
"root/root_scene_model.cpp",
|
||||
"scene/system_window_scene.cpp",
|
||||
"scene/window_extension.cpp",
|
||||
"scene/window_node.cpp",
|
||||
"scene/window_pattern.cpp",
|
||||
"scene/window_scene.cpp",
|
||||
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "core/components_ng/pattern/window_scene/scene/window_extension.h"
|
||||
|
||||
#include "session/host/include/extension_session.h"
|
||||
#include "session_manager/include/extension_session_manager.h"
|
||||
#include "ui/rs_surface_node.h"
|
||||
|
||||
#include "adapter/ohos/entrance/ace_container.h"
|
||||
#include "core/pipeline_ng/pipeline_context.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
WindowExtension::WindowExtension(const std::string& bundleName, const std::string& abilityName)
|
||||
{
|
||||
auto container = AceType::DynamicCast<Platform::AceContainer>(Container::Current());
|
||||
CHECK_NULL_VOID(container);
|
||||
auto callerToken = container->GetToken();
|
||||
|
||||
Rosen::ExtensionSessionManager::GetInstance().Init();
|
||||
Rosen::SessionInfo extensionSessionInfo = {
|
||||
.bundleName_ = bundleName,
|
||||
.abilityName_ = abilityName,
|
||||
.callerToken_ = callerToken,
|
||||
};
|
||||
session_ = Rosen::ExtensionSessionManager::GetInstance().RequestExtensionSession(extensionSessionInfo);
|
||||
RegisterLifecycleListener();
|
||||
RequestExtensionSessionActivation();
|
||||
}
|
||||
|
||||
WindowExtension::~WindowExtension()
|
||||
{
|
||||
UnregisterLifecycleListener();
|
||||
RequestExtensionSessionDestruction();
|
||||
}
|
||||
|
||||
void WindowExtension::OnConnect()
|
||||
{
|
||||
WindowPattern::OnConnect();
|
||||
|
||||
CHECK_NULL_VOID(session_);
|
||||
auto surfaceNode = session_->GetSurfaceNode();
|
||||
CHECK_NULL_VOID(surfaceNode);
|
||||
surfaceNode->CreateNodeInRenderThread();
|
||||
}
|
||||
|
||||
void WindowExtension::OnWindowShow()
|
||||
{
|
||||
RequestExtensionSessionActivation();
|
||||
}
|
||||
|
||||
void WindowExtension::OnWindowHide()
|
||||
{
|
||||
RequestExtensionSessionBackground();
|
||||
}
|
||||
|
||||
void WindowExtension::RequestExtensionSessionActivation()
|
||||
{
|
||||
CHECK_NULL_VOID(session_);
|
||||
sptr<Rosen::ExtensionSession> extensionSession(static_cast<Rosen::ExtensionSession*>(session_.GetRefPtr()));
|
||||
Rosen::ExtensionSessionManager::GetInstance().RequestExtensionSessionActivation(extensionSession);
|
||||
}
|
||||
|
||||
void WindowExtension::RequestExtensionSessionBackground()
|
||||
{
|
||||
CHECK_NULL_VOID(session_);
|
||||
sptr<Rosen::ExtensionSession> extensionSession(static_cast<Rosen::ExtensionSession*>(session_.GetRefPtr()));
|
||||
Rosen::ExtensionSessionManager::GetInstance().RequestExtensionSessionBackground(extensionSession);
|
||||
}
|
||||
|
||||
void WindowExtension::RequestExtensionSessionDestruction()
|
||||
{
|
||||
CHECK_NULL_VOID(session_);
|
||||
sptr<Rosen::ExtensionSession> extensionSession(static_cast<Rosen::ExtensionSession*>(session_.GetRefPtr()));
|
||||
Rosen::ExtensionSessionManager::GetInstance().RequestExtensionSessionDestruction(extensionSession);
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WINDOW_EXTENSION_H
|
||||
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WINDOW_EXTENSION_H
|
||||
|
||||
#include "core/components_ng/pattern/window_scene/scene/window_pattern.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
class WindowExtension : public WindowPattern {
|
||||
DECLARE_ACE_TYPE(WindowExtension, WindowPattern);
|
||||
|
||||
public:
|
||||
WindowExtension(const std::string& bundleName, const std::string& abilityName);
|
||||
~WindowExtension() override;
|
||||
|
||||
void OnWindowShow() override;
|
||||
void OnWindowHide() override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Whether this extension has starting page.
|
||||
* If true, starting page will show first until the first frame of surface node is drawn.
|
||||
* Otherwise, no content will be shown until the first frame of surface node is drawn.
|
||||
*/
|
||||
bool HasStartingPage() override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void OnConnect() override;
|
||||
|
||||
void RequestExtensionSessionActivation();
|
||||
void RequestExtensionSessionBackground();
|
||||
void RequestExtensionSessionDestruction();
|
||||
|
||||
private:
|
||||
ACE_DISALLOW_COPY_AND_MOVE(WindowExtension);
|
||||
};
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WINDOW_EXTENSION_H
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "core/components_ng/pattern/window_scene/scene/window_extension.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
WindowExtension::WindowExtension(const std::string& /* bundleName */, const std::string& /* abilityName */) {}
|
||||
|
||||
WindowExtension::~WindowExtension() = default;
|
||||
|
||||
void WindowExtension::OnWindowShow() {}
|
||||
|
||||
void WindowExtension::OnWindowHide() {}
|
||||
|
||||
void WindowExtension::OnConnect() {}
|
||||
|
||||
void WindowExtension::RequestExtensionSessionActivation() {}
|
||||
|
||||
void WindowExtension::RequestExtensionSessionBackground() {}
|
||||
|
||||
void WindowExtension::RequestExtensionSessionDestruction() {}
|
||||
} // namespace OHOS::Ace::NG
|
@ -143,7 +143,8 @@ template("ace_unittest") {
|
||||
"$ace_root/test/unittest:ace_components_syntax",
|
||||
]
|
||||
|
||||
configs = ace_unittest_config
|
||||
configs = []
|
||||
configs += ace_unittest_config
|
||||
|
||||
if (defined(invoker.configs)) {
|
||||
configs += invoker.configs
|
||||
@ -162,7 +163,8 @@ template("ace_unittest") {
|
||||
deps = ace_unittest_deps
|
||||
deps += [ "$ace_root/test/unittest:ace_base" ]
|
||||
|
||||
configs = ace_unittest_config
|
||||
configs = []
|
||||
configs += ace_unittest_config
|
||||
|
||||
if (defined(invoker.configs)) {
|
||||
configs += invoker.configs
|
||||
|
@ -21,13 +21,18 @@ ace_unittest("ui_extension_test_ng") {
|
||||
"$ace_root/frameworks/core/components_ng/pattern/ui_extension/ui_extension_model_ng.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/pattern/ui_extension/ui_extension_node.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/pattern/ui_extension/ui_extension_pattern.cpp",
|
||||
"$ace_root/test/mock/adapter/mock_ace_container.cpp",
|
||||
"$ace_root/test/mock/adapter/mock_mmi_event_convertor.cpp",
|
||||
"$ace_root/test/mock/core/pattern/window_scene/mock_window_extension.cpp",
|
||||
"$ace_root/test/mock/core/pattern/window_scene/mock_window_pattern.cpp",
|
||||
"$ace_root/test/unittest/core/pattern/ui_extension/ui_extension_test_ng.cpp",
|
||||
]
|
||||
external_deps = [
|
||||
"ability_runtime:abilitykit_native",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
"window_manager:libdm",
|
||||
"window_manager:libwm",
|
||||
"window_manager:scene_session",
|
||||
"window_manager:scene_session_manager",
|
||||
]
|
||||
}
|
||||
|
@ -124,7 +124,6 @@ ohos_unittest("window_scene_test") {
|
||||
# self
|
||||
"$ace_root/frameworks/core/components_ng/pattern/window_scene/root/root_scene_model.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/pattern/window_scene/scene/system_window_scene.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/pattern/window_scene/scene/window_extension.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/pattern/window_scene/scene/window_node.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/pattern/window_scene/scene/window_scene.cpp",
|
||||
|
@ -21,18 +21,17 @@
|
||||
#include "key_event.h"
|
||||
#include "pointer_event.h"
|
||||
#include "session_manager/include/scene_session_manager.h"
|
||||
#include "test/mock/core/common/mock_container.h"
|
||||
#include "ui/rs_surface_node.h"
|
||||
|
||||
#include "core/components_ng/base/view_stack_processor.h"
|
||||
#include "core/components_ng/pattern/window_scene/scene/system_window_scene.h"
|
||||
#include "core/components_ng/pattern/window_scene/scene/window_extension.h"
|
||||
#include "core/components_ng/pattern/window_scene/scene/window_node.h"
|
||||
#include "core/components_ng/pattern/window_scene/scene/window_pattern.h"
|
||||
#include "core/components_ng/pattern/window_scene/scene/window_scene.h"
|
||||
#include "core/components_ng/pattern/window_scene/scene/window_scene_model.h"
|
||||
#include "core/event/touch_event.h"
|
||||
#include "core/pipeline_ng/test/mock/mock_pipeline_base.h"
|
||||
#include "test/mock/core/common/mock_container.h"
|
||||
|
||||
#undef private
|
||||
#undef protected
|
||||
@ -44,7 +43,6 @@ namespace OHOS::Ace::NG {
|
||||
namespace {
|
||||
const std::string BUNDLE_NAME = "com.example.helloworld";
|
||||
const std::string ABILITY_NAME = "MainAbility";
|
||||
const int32_t NODE_ID = 1000;
|
||||
} // namespace
|
||||
|
||||
class WindowPatternTest : public testing::Test {
|
||||
@ -67,8 +65,7 @@ HWTEST_F(WindowPatternTest, WindowPatternTest001, TestSize.Level1)
|
||||
uint64_t persistentId = 0;
|
||||
model.Create(persistentId);
|
||||
|
||||
auto windowSceneNode =
|
||||
AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
auto windowSceneNode = AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
EXPECT_EQ(windowSceneNode, nullptr);
|
||||
}
|
||||
|
||||
@ -84,16 +81,12 @@ HWTEST_F(WindowPatternTest, WindowPatternTest002, TestSize.Level1)
|
||||
*/
|
||||
auto model = WindowSceneModel();
|
||||
|
||||
Rosen::SessionInfo sessionInfo = {
|
||||
.bundleName_ = BUNDLE_NAME,
|
||||
.abilityName_ = ABILITY_NAME
|
||||
};
|
||||
Rosen::SessionInfo sessionInfo = { .bundleName_ = BUNDLE_NAME, .abilityName_ = ABILITY_NAME };
|
||||
auto session = Rosen::SceneSessionManager::GetInstance().RequestSceneSession(sessionInfo);
|
||||
uint64_t persistentId = session->GetPersistentId();
|
||||
model.Create(persistentId);
|
||||
|
||||
auto frameNode =
|
||||
AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
auto frameNode = AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
EXPECT_NE(frameNode, nullptr);
|
||||
}
|
||||
|
||||
@ -116,21 +109,15 @@ HWTEST_F(WindowPatternTest, WindowPatternTest003, TestSize.Level1)
|
||||
EXPECT_NE(context, nullptr);
|
||||
auto model = WindowSceneModel();
|
||||
|
||||
Rosen::SessionInfo sessionInfo = {
|
||||
.bundleName_ = BUNDLE_NAME,
|
||||
.abilityName_ = ABILITY_NAME
|
||||
};
|
||||
Rosen::SessionInfo sessionInfo = { .bundleName_ = BUNDLE_NAME, .abilityName_ = ABILITY_NAME };
|
||||
auto session = Rosen::SceneSessionManager::GetInstance().RequestSceneSession(sessionInfo);
|
||||
uint64_t persistentId = session->GetPersistentId();
|
||||
model.Create(persistentId);
|
||||
|
||||
auto frameNode =
|
||||
AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
auto frameNode = AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
|
||||
Rosen::RSSurfaceNodeConfig config = {
|
||||
.SurfaceNodeName = "SurfaceNode"
|
||||
};
|
||||
Rosen::RSSurfaceNodeConfig config = { .SurfaceNodeName = "SurfaceNode" };
|
||||
session->surfaceNode_ = Rosen::RSSurfaceNode::Create(config);
|
||||
EXPECT_NE(session->surfaceNode_, nullptr);
|
||||
|
||||
@ -160,10 +147,7 @@ HWTEST_F(WindowPatternTest, WindowPatternTest004, TestSize.Level1)
|
||||
EXPECT_NE(context, nullptr);
|
||||
auto model = WindowSceneModel();
|
||||
|
||||
Rosen::SessionInfo sessionInfo = {
|
||||
.bundleName_ = BUNDLE_NAME,
|
||||
.abilityName_ = ABILITY_NAME
|
||||
};
|
||||
Rosen::SessionInfo sessionInfo = { .bundleName_ = BUNDLE_NAME, .abilityName_ = ABILITY_NAME };
|
||||
auto session = Rosen::SceneSessionManager::GetInstance().RequestSceneSession(sessionInfo);
|
||||
uint64_t persistentId = session->GetPersistentId();
|
||||
|
||||
@ -172,8 +156,7 @@ HWTEST_F(WindowPatternTest, WindowPatternTest004, TestSize.Level1)
|
||||
*/
|
||||
session->state_ = Rosen::SessionState::STATE_DISCONNECT;
|
||||
model.Create(persistentId);
|
||||
auto frameNode =
|
||||
AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
auto frameNode = AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
|
||||
/**
|
||||
@ -181,22 +164,18 @@ HWTEST_F(WindowPatternTest, WindowPatternTest004, TestSize.Level1)
|
||||
*/
|
||||
session->state_ = Rosen::SessionState::STATE_ACTIVE;
|
||||
model.Create(persistentId);
|
||||
frameNode =
|
||||
AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
frameNode = AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. Set session state to STATE_BACKGROUND.
|
||||
*/
|
||||
Rosen::RSSurfaceNodeConfig config = {
|
||||
.SurfaceNodeName = "SurfaceNode"
|
||||
};
|
||||
Rosen::RSSurfaceNodeConfig config = { .SurfaceNodeName = "SurfaceNode" };
|
||||
session->surfaceNode_ = Rosen::RSSurfaceNode::Create(config);
|
||||
EXPECT_NE(session->surfaceNode_, nullptr);
|
||||
session->state_ = Rosen::SessionState::STATE_BACKGROUND;
|
||||
model.Create(persistentId);
|
||||
frameNode =
|
||||
AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
frameNode = AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
}
|
||||
|
||||
@ -219,21 +198,15 @@ HWTEST_F(WindowPatternTest, WindowPatternTest005, TestSize.Level1)
|
||||
EXPECT_NE(context, nullptr);
|
||||
auto model = WindowSceneModel();
|
||||
|
||||
Rosen::SessionInfo sessionInfo = {
|
||||
.bundleName_ = BUNDLE_NAME,
|
||||
.abilityName_ = ABILITY_NAME
|
||||
};
|
||||
Rosen::SessionInfo sessionInfo = { .bundleName_ = BUNDLE_NAME, .abilityName_ = ABILITY_NAME };
|
||||
auto session = Rosen::SceneSessionManager::GetInstance().RequestSceneSession(sessionInfo);
|
||||
uint64_t persistentId = session->GetPersistentId();
|
||||
model.Create(persistentId);
|
||||
|
||||
auto frameNode =
|
||||
AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
auto frameNode = AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
|
||||
Rosen::RSSurfaceNodeConfig config = {
|
||||
.SurfaceNodeName = "SurfaceNode"
|
||||
};
|
||||
Rosen::RSSurfaceNodeConfig config = { .SurfaceNodeName = "SurfaceNode" };
|
||||
session->surfaceNode_ = Rosen::RSSurfaceNode::Create(config);
|
||||
EXPECT_NE(session->surfaceNode_, nullptr);
|
||||
|
||||
@ -262,16 +235,12 @@ HWTEST_F(WindowPatternTest, WindowPatternTest006, TestSize.Level1)
|
||||
EXPECT_NE(context, nullptr);
|
||||
auto model = WindowSceneModel();
|
||||
|
||||
Rosen::SessionInfo sessionInfo = {
|
||||
.bundleName_ = BUNDLE_NAME,
|
||||
.abilityName_ = ABILITY_NAME
|
||||
};
|
||||
Rosen::SessionInfo sessionInfo = { .bundleName_ = BUNDLE_NAME, .abilityName_ = ABILITY_NAME };
|
||||
auto session = Rosen::SceneSessionManager::GetInstance().RequestSceneSession(sessionInfo);
|
||||
uint64_t persistentId = session->GetPersistentId();
|
||||
model.Create(persistentId);
|
||||
|
||||
auto frameNode =
|
||||
AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
auto frameNode = AceType::DynamicCast<WindowNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
auto pattern = frameNode->GetPattern<WindowScene>();
|
||||
ASSERT_NE(pattern, nullptr);
|
||||
@ -291,91 +260,6 @@ HWTEST_F(WindowPatternTest, WindowPatternTest006, TestSize.Level1)
|
||||
pattern->DispatchKeyEvent(keyEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowPatternTest007
|
||||
* @tc.desc: WindowPattern test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowPatternTest, WindowPatternTest007, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Create WindowExtension.
|
||||
*/
|
||||
MockPipelineBase::SetUp();
|
||||
MockContainer::SetUp();
|
||||
MockContainer::container_->pipelineContext_ = MockPipelineBase::pipeline_;
|
||||
auto container = Container::Current();
|
||||
EXPECT_NE(container, nullptr);
|
||||
auto context = container->GetPipelineContext();
|
||||
EXPECT_NE(context, nullptr);
|
||||
|
||||
auto pattern = AceType::MakeRefPtr<WindowExtension>(BUNDLE_NAME, ABILITY_NAME);
|
||||
ASSERT_NE(pattern, nullptr);
|
||||
|
||||
pattern->OnConnect();
|
||||
pattern->OnWindowShow();
|
||||
pattern->OnWindowHide();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowPatternTest008
|
||||
* @tc.desc: WindowPattern test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowPatternTest, WindowPatternTest008, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Create WindowExtension.
|
||||
*/
|
||||
MockPipelineBase::SetUp();
|
||||
MockContainer::SetUp();
|
||||
MockContainer::container_->pipelineContext_ = MockPipelineBase::pipeline_;
|
||||
auto container = Container::Current();
|
||||
EXPECT_NE(container, nullptr);
|
||||
auto context = container->GetPipelineContext();
|
||||
EXPECT_NE(context, nullptr);
|
||||
|
||||
auto pattern = AceType::MakeRefPtr<WindowExtension>(BUNDLE_NAME, ABILITY_NAME);
|
||||
ASSERT_NE(pattern, nullptr);
|
||||
|
||||
pattern->OnAttachToFrameNode();
|
||||
pattern->InitContent();
|
||||
pattern->CreateSnapshotNode();
|
||||
pattern->CreateStartingNode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowPatternTest009
|
||||
* @tc.desc: WindowPattern test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowPatternTest, WindowPatternTest009, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Get or create WindowExtension.
|
||||
* @tc.expect: Get or create WindowExtension success.
|
||||
*/
|
||||
auto frameNode1 = WindowNode::GetOrCreateWindowNode("WindowNode", NODE_ID,
|
||||
[]() { return AceType::MakeRefPtr<WindowExtension>(BUNDLE_NAME, ABILITY_NAME); });
|
||||
EXPECT_NE(frameNode1, nullptr);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. Get or create WindowExtension.
|
||||
* @tc.expect: frameNode1 equal frameNode2.
|
||||
*/
|
||||
auto frameNode2 = WindowNode::GetOrCreateWindowNode("WindowNode", NODE_ID,
|
||||
[]() { return AceType::MakeRefPtr<WindowExtension>(BUNDLE_NAME, ABILITY_NAME); });
|
||||
EXPECT_EQ(frameNode1, frameNode2);
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. Get or create WindowExtension.
|
||||
* @tc.expect: frameNode2 does not equal frameNode3.
|
||||
*/
|
||||
auto frameNode3 = WindowNode::GetOrCreateWindowNode("WindowNode2", NODE_ID,
|
||||
[]() { return AceType::MakeRefPtr<WindowExtension>(BUNDLE_NAME, ABILITY_NAME); });
|
||||
EXPECT_NE(frameNode2, frameNode3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowPatternTest010
|
||||
* @tc.desc: WindowPattern test
|
||||
@ -388,17 +272,12 @@ HWTEST_F(WindowPatternTest, WindowPatternTest010, TestSize.Level1)
|
||||
*/
|
||||
auto model = WindowSceneModel();
|
||||
|
||||
Rosen::SessionInfo sessionInfo = {
|
||||
.bundleName_ = BUNDLE_NAME,
|
||||
.abilityName_ = ABILITY_NAME,
|
||||
.isSystem_ = true
|
||||
};
|
||||
Rosen::SessionInfo sessionInfo = { .bundleName_ = BUNDLE_NAME, .abilityName_ = ABILITY_NAME, .isSystem_ = true };
|
||||
auto session = Rosen::SceneSessionManager::GetInstance().RequestSceneSession(sessionInfo);
|
||||
uint64_t persistentId = session->GetPersistentId();
|
||||
model.Create(persistentId);
|
||||
|
||||
auto frameNode =
|
||||
AceType::DynamicCast<FrameNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
auto frameNode = AceType::DynamicCast<FrameNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
|
||||
EXPECT_NE(frameNode, nullptr);
|
||||
|
||||
auto pattern = frameNode->GetPattern<SystemWindowScene>();
|
||||
|
Loading…
Reference in New Issue
Block a user