1e0dac50fSopenharmony_ci/*
2e0dac50fSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
3e0dac50fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e0dac50fSopenharmony_ci * you may not use this file except in compliance with the License.
5e0dac50fSopenharmony_ci * You may obtain a copy of the License at
6e0dac50fSopenharmony_ci *
7e0dac50fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e0dac50fSopenharmony_ci *
9e0dac50fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e0dac50fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e0dac50fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e0dac50fSopenharmony_ci * See the License for the specific language governing permissions and
13e0dac50fSopenharmony_ci * limitations under the License.
14e0dac50fSopenharmony_ci */
15e0dac50fSopenharmony_ci
16e0dac50fSopenharmony_ci#include <gtest/gtest.h>
17e0dac50fSopenharmony_ci#include <transaction/rs_transaction.h>
18e0dac50fSopenharmony_ci#include "display_manager.h"
19e0dac50fSopenharmony_ci#include "input_window_monitor.h"
20e0dac50fSopenharmony_ci#include "iremote_object_mocker.h"
21e0dac50fSopenharmony_ci#include "minimize_app.h"
22e0dac50fSopenharmony_ci#include "mock_RSIWindowAnimationController.h"
23e0dac50fSopenharmony_ci#include "remote_animation.h"
24e0dac50fSopenharmony_ci#include "starting_window.h"
25e0dac50fSopenharmony_ci#include "window_helper.h"
26e0dac50fSopenharmony_ciusing namespace testing;
27e0dac50fSopenharmony_ciusing namespace testing::ext;
28e0dac50fSopenharmony_ci
29e0dac50fSopenharmony_cinamespace OHOS {
30e0dac50fSopenharmony_cinamespace Rosen {
31e0dac50fSopenharmony_cinamespace {
32e0dac50fSopenharmony_ciconstexpr uint32_t SLEEP_TIME_IN_US = 10000;
33e0dac50fSopenharmony_ci}
34e0dac50fSopenharmony_ci
35e0dac50fSopenharmony_ciclass RemoteAnimationTest : public testing::Test {
36e0dac50fSopenharmony_cipublic:
37e0dac50fSopenharmony_ci    static void SetUpTestCase();
38e0dac50fSopenharmony_ci    static void TearDownTestCase();
39e0dac50fSopenharmony_ci    void SetUp() override;
40e0dac50fSopenharmony_ci    void TearDown() override;
41e0dac50fSopenharmony_ci    void InitRemoteAnimation();
42e0dac50fSopenharmony_ci    void CreateWindowNodeContainer();
43e0dac50fSopenharmony_ciprivate:
44e0dac50fSopenharmony_ci    RSSurfaceNode::SharedPtr CreateRSSurfaceNode(uint32_t windowId);
45e0dac50fSopenharmony_ci    sptr<WindowProperty> CreateWindowProperty(uint32_t windowId);
46e0dac50fSopenharmony_ci    Rect GetSurfaceBoundsRect(sptr<WindowNode> node);
47e0dac50fSopenharmony_ci    sptr<RSIWindowAnimationController> animationController_;
48e0dac50fSopenharmony_ci    sptr<WindowRoot> windowRoot_;
49e0dac50fSopenharmony_ci    sptr<WindowController> windowController_;
50e0dac50fSopenharmony_ci    std::shared_ptr<AppExecFwk::EventHandler> wmsTaskHandler_;
51e0dac50fSopenharmony_ci    sptr<WindowTransitionInfo> transitionInfo_ = nullptr;
52e0dac50fSopenharmony_ci    sptr<WindowNode> node_ = nullptr;
53e0dac50fSopenharmony_ci};
54e0dac50fSopenharmony_ci
55e0dac50fSopenharmony_civoid RemoteAnimationTest::SetUpTestCase()
56e0dac50fSopenharmony_ci{
57e0dac50fSopenharmony_ci}
58e0dac50fSopenharmony_ci
59e0dac50fSopenharmony_civoid RemoteAnimationTest::TearDownTestCase()
60e0dac50fSopenharmony_ci{
61e0dac50fSopenharmony_ci}
62e0dac50fSopenharmony_ci
63e0dac50fSopenharmony_civoid RemoteAnimationTest::SetUp()
64e0dac50fSopenharmony_ci{
65e0dac50fSopenharmony_ci    InitRemoteAnimation();
66e0dac50fSopenharmony_ci    CreateWindowNodeContainer();
67e0dac50fSopenharmony_ci    transitionInfo_ = new WindowTransitionInfo();
68e0dac50fSopenharmony_ci    sptr<IRemoteObject> token = new IRemoteObjectMocker();
69e0dac50fSopenharmony_ci    transitionInfo_->SetAbilityToken(token);
70e0dac50fSopenharmony_ci    transitionInfo_->displayId_ = 0;
71e0dac50fSopenharmony_ci    transitionInfo_->supportWindowModes_ = {
72e0dac50fSopenharmony_ci        AppExecFwk::SupportWindowMode::FULLSCREEN,
73e0dac50fSopenharmony_ci        AppExecFwk::SupportWindowMode::SPLIT,
74e0dac50fSopenharmony_ci        AppExecFwk::SupportWindowMode::FLOATING
75e0dac50fSopenharmony_ci    };
76e0dac50fSopenharmony_ci    windowController_->StartingWindow(transitionInfo_, nullptr, 0xFFFFFFFF, true);
77e0dac50fSopenharmony_ci    node_ = windowRoot_->FindWindowNodeWithToken(transitionInfo_->GetAbilityToken());
78e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, node_);
79e0dac50fSopenharmony_ci}
80e0dac50fSopenharmony_ci
81e0dac50fSopenharmony_civoid RemoteAnimationTest::TearDown()
82e0dac50fSopenharmony_ci{
83e0dac50fSopenharmony_ci    if (node_ != nullptr) {
84e0dac50fSopenharmony_ci        windowController_->DestroyWindow(node_->GetWindowId(), false);
85e0dac50fSopenharmony_ci        node_ = nullptr;
86e0dac50fSopenharmony_ci    }
87e0dac50fSopenharmony_ci    animationController_ = nullptr;
88e0dac50fSopenharmony_ci    wmsTaskHandler_ = nullptr;
89e0dac50fSopenharmony_ci    windowRoot_ = nullptr;
90e0dac50fSopenharmony_ci    windowController_ = nullptr;
91e0dac50fSopenharmony_ci    transitionInfo_ = nullptr;
92e0dac50fSopenharmony_ci}
93e0dac50fSopenharmony_ci
94e0dac50fSopenharmony_civoid RemoteAnimationTest::InitRemoteAnimation()
95e0dac50fSopenharmony_ci{
96e0dac50fSopenharmony_ci    animationController_ = new RSIWindowAnimationControllerMocker();
97e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, RemoteAnimation::SetWindowAnimationController(animationController_));
98e0dac50fSopenharmony_ci    RemoteAnimation::isRemoteAnimationEnable_ = true;
99e0dac50fSopenharmony_ci    RemoteAnimation::animationFirst_ = true;
100e0dac50fSopenharmony_ci    windowRoot_ = new WindowRoot([](Event event, const sptr<IRemoteObject>& remoteObject) {});
101e0dac50fSopenharmony_ci    sptr<InputWindowMonitor> inputMonitor = new InputWindowMonitor(windowRoot_);
102e0dac50fSopenharmony_ci    windowController_ = new WindowController(windowRoot_, inputMonitor);
103e0dac50fSopenharmony_ci    RemoteAnimation::SetWindowControllerAndRoot(windowController_, windowRoot_);
104e0dac50fSopenharmony_ci    auto runner = AppExecFwk::EventRunner::Create("RemoteAnimationTest");
105e0dac50fSopenharmony_ci    wmsTaskHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
106e0dac50fSopenharmony_ci    RemoteAnimation::SetMainTaskHandler(wmsTaskHandler_);
107e0dac50fSopenharmony_ci}
108e0dac50fSopenharmony_ci
109e0dac50fSopenharmony_civoid RemoteAnimationTest::CreateWindowNodeContainer()
110e0dac50fSopenharmony_ci{
111e0dac50fSopenharmony_ci    auto display = DisplayManager::GetInstance().GetDefaultDisplay();
112e0dac50fSopenharmony_ci    ASSERT_TRUE((display != nullptr));
113e0dac50fSopenharmony_ci    sptr<DisplayInfo> displayInfo = display->GetDisplayInfo();
114e0dac50fSopenharmony_ci    ASSERT_TRUE((displayInfo != nullptr));
115e0dac50fSopenharmony_ci    windowRoot_->CreateWindowNodeContainer(0, displayInfo);
116e0dac50fSopenharmony_ci}
117e0dac50fSopenharmony_ci
118e0dac50fSopenharmony_cisptr<WindowProperty> RemoteAnimationTest::CreateWindowProperty(uint32_t windowId)
119e0dac50fSopenharmony_ci{
120e0dac50fSopenharmony_ci    sptr<WindowProperty> property = new WindowProperty();
121e0dac50fSopenharmony_ci    property->SetWindowId(windowId);
122e0dac50fSopenharmony_ci    return property;
123e0dac50fSopenharmony_ci}
124e0dac50fSopenharmony_ci
125e0dac50fSopenharmony_ciRect RemoteAnimationTest::GetSurfaceBoundsRect(sptr<WindowNode> node)
126e0dac50fSopenharmony_ci{
127e0dac50fSopenharmony_ci    if (!node->leashWinSurfaceNode_) {
128e0dac50fSopenharmony_ci        return {0, 0, 0, 0};
129e0dac50fSopenharmony_ci    }
130e0dac50fSopenharmony_ci    auto& stagingProperties = node->leashWinSurfaceNode_->GetStagingProperties();
131e0dac50fSopenharmony_ci    auto bounds = stagingProperties.GetBounds();
132e0dac50fSopenharmony_ci    Rect rect = {bounds[0], bounds[1], bounds[2], bounds[3]}; // 1, 2, 3 is index
133e0dac50fSopenharmony_ci    return rect;
134e0dac50fSopenharmony_ci}
135e0dac50fSopenharmony_ci
136e0dac50fSopenharmony_ciRSSurfaceNode::SharedPtr RemoteAnimationTest::CreateRSSurfaceNode(uint32_t windowId)
137e0dac50fSopenharmony_ci{
138e0dac50fSopenharmony_ci    struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
139e0dac50fSopenharmony_ci    rsSurfaceNodeConfig.SurfaceNodeName = "AppSurfaceNode" + std::to_string(windowId);
140e0dac50fSopenharmony_ci    auto surfaceNode = RSSurfaceNode::Create(rsSurfaceNodeConfig);
141e0dac50fSopenharmony_ci    return surfaceNode;
142e0dac50fSopenharmony_ci}
143e0dac50fSopenharmony_ci
144e0dac50fSopenharmony_cinamespace {
145e0dac50fSopenharmony_ci/**
146e0dac50fSopenharmony_ci * @tc.name: IsRemoteAnimationEnabledAndFirst01
147e0dac50fSopenharmony_ci * @tc.desc: IsRemoteAnimationEnabledAndFirst return false since animationFirst false
148e0dac50fSopenharmony_ci * @tc.type: FUNC
149e0dac50fSopenharmony_ci */
150e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, IsRemoteAnimationEnabledAndFirst01, Function | SmallTest | Level2)
151e0dac50fSopenharmony_ci{
152e0dac50fSopenharmony_ci    RemoteAnimation::SetAnimationFirst(false);
153e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::animationFirst_);
154e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::IsRemoteAnimationEnabledAndFirst(0));
155e0dac50fSopenharmony_ci}
156e0dac50fSopenharmony_ci
157e0dac50fSopenharmony_ci/**
158e0dac50fSopenharmony_ci * @tc.name: IsRemoteAnimationEnabledAndFirst02
159e0dac50fSopenharmony_ci * @tc.desc: IsRemoteAnimationEnabledAndFirst return true since animationFirst true
160e0dac50fSopenharmony_ci * @tc.type: FUNC
161e0dac50fSopenharmony_ci */
162e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, IsRemoteAnimationEnabledAndFirst02, Function | SmallTest | Level2)
163e0dac50fSopenharmony_ci{
164e0dac50fSopenharmony_ci    EXPECT_EQ(true, RemoteAnimation::animationFirst_);
165e0dac50fSopenharmony_ci    EXPECT_EQ(true, RemoteAnimation::IsRemoteAnimationEnabledAndFirst(0));
166e0dac50fSopenharmony_ci}
167e0dac50fSopenharmony_ci
168e0dac50fSopenharmony_ci/**
169e0dac50fSopenharmony_ci * @tc.name: IsRemoteAnimationEnabledAndFirst03
170e0dac50fSopenharmony_ci * @tc.desc: IsRemoteAnimationEnabledAndFirst return false since CheckRemoteAnimationEnabled false
171e0dac50fSopenharmony_ci * @tc.type: FUNC
172e0dac50fSopenharmony_ci */
173e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, IsRemoteAnimationEnabledAndFirst03, Function | SmallTest | Level2)
174e0dac50fSopenharmony_ci{
175e0dac50fSopenharmony_ci    RemoteAnimation::windowRoot_ = nullptr;
176e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::CheckRemoteAnimationEnabled(0));
177e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::IsRemoteAnimationEnabledAndFirst(0));
178e0dac50fSopenharmony_ci    RemoteAnimation::windowRoot_ = windowRoot_;
179e0dac50fSopenharmony_ci    auto container = RemoteAnimation::windowRoot_->GetOrCreateWindowNodeContainer(0);
180e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, container);
181e0dac50fSopenharmony_ci    container->isScreenLocked_ = true;
182e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::IsRemoteAnimationEnabledAndFirst(0));
183e0dac50fSopenharmony_ci}
184e0dac50fSopenharmony_ci
185e0dac50fSopenharmony_ci/**
186e0dac50fSopenharmony_ci * @tc.name: IsRemoteAnimationEnabledAndFirst04
187e0dac50fSopenharmony_ci * @tc.desc: return false since CheckRemoteAnimationEnabled false, set animationController nullptr
188e0dac50fSopenharmony_ci * @tc.type: FUNC
189e0dac50fSopenharmony_ci */
190e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, IsRemoteAnimationEnabledAndFirst04, Function | SmallTest | Level2)
191e0dac50fSopenharmony_ci{
192e0dac50fSopenharmony_ci    sptr<RSIWindowAnimationController> controller = nullptr;
193e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NULLPTR, RemoteAnimation::SetWindowAnimationController(controller));
194e0dac50fSopenharmony_ci    RemoteAnimation::windowAnimationController_ = nullptr;
195e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::IsRemoteAnimationEnabledAndFirst(0));
196e0dac50fSopenharmony_ci    controller = new RSIWindowAnimationControllerMocker();
197e0dac50fSopenharmony_ci    RemoteAnimation::isRemoteAnimationEnable_ = false;
198e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NO_REMOTE_ANIMATION, RemoteAnimation::SetWindowAnimationController(controller));
199e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::CheckRemoteAnimationEnabled(0));
200e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::IsRemoteAnimationEnabledAndFirst(0));
201e0dac50fSopenharmony_ci    RemoteAnimation::isRemoteAnimationEnable_ = true;
202e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, RemoteAnimation::SetWindowAnimationController(controller));
203e0dac50fSopenharmony_ci    EXPECT_EQ(true, RemoteAnimation::IsRemoteAnimationEnabledAndFirst(0));
204e0dac50fSopenharmony_ci    RemoteAnimation::SetAnimationFirst(false);
205e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::animationFirst_);
206e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::IsRemoteAnimationEnabledAndFirst(0));
207e0dac50fSopenharmony_ci}
208e0dac50fSopenharmony_ci
209e0dac50fSopenharmony_ci/**
210e0dac50fSopenharmony_ci * @tc.name: CheckTransition01
211e0dac50fSopenharmony_ci * @tc.desc: CheckTransition return false
212e0dac50fSopenharmony_ci * @tc.type: FUNC
213e0dac50fSopenharmony_ci */
214e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, CheckTransition01, Function | SmallTest | Level2)
215e0dac50fSopenharmony_ci{
216e0dac50fSopenharmony_ci    const sptr<WindowNode> node = nullptr;
217e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::CheckTransition(transitionInfo_, node, transitionInfo_, node));
218e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = StartingWindow::CreateWindowNode(transitionInfo_, 0);
219e0dac50fSopenharmony_ci    ASSERT_NE(nullptr, srcNode);
220e0dac50fSopenharmony_ci    srcNode->leashWinSurfaceNode_ = nullptr; // leash and app surface node is nullptr
221e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::CheckTransition(transitionInfo_, srcNode, transitionInfo_, srcNode));
222e0dac50fSopenharmony_ci    srcNode->surfaceNode_ = CreateRSSurfaceNode(0); // leash is null, but surfaceNode is not
223e0dac50fSopenharmony_ci    EXPECT_EQ(true, RemoteAnimation::CheckTransition(transitionInfo_, srcNode, transitionInfo_, srcNode));
224e0dac50fSopenharmony_ci    srcNode = StartingWindow::CreateWindowNode(transitionInfo_, 0); // leash and app surfaceNode both not nullptr
225e0dac50fSopenharmony_ci    ASSERT_NE(nullptr, srcNode);
226e0dac50fSopenharmony_ci    sptr<WindowNode> dstNode = StartingWindow::CreateWindowNode(transitionInfo_, 1);
227e0dac50fSopenharmony_ci    ASSERT_NE(nullptr, dstNode);
228e0dac50fSopenharmony_ci    EXPECT_EQ(true, RemoteAnimation::CheckTransition(transitionInfo_, node, transitionInfo_, dstNode));
229e0dac50fSopenharmony_ci    EXPECT_EQ(true, RemoteAnimation::CheckTransition(transitionInfo_, srcNode, transitionInfo_, node));
230e0dac50fSopenharmony_ci    dstNode->leashWinSurfaceNode_ = nullptr;
231e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::CheckTransition(transitionInfo_, srcNode, transitionInfo_, dstNode));
232e0dac50fSopenharmony_ci    dstNode->surfaceNode_ = CreateRSSurfaceNode(1); // leash is null, but surfaceNode is not
233e0dac50fSopenharmony_ci    EXPECT_EQ(true, RemoteAnimation::CheckTransition(transitionInfo_, srcNode, transitionInfo_, dstNode));
234e0dac50fSopenharmony_ci}
235e0dac50fSopenharmony_ci
236e0dac50fSopenharmony_ci/**
237e0dac50fSopenharmony_ci * @tc.name: CheckTransition02
238e0dac50fSopenharmony_ci * @tc.desc: CheckTransition return false since windowMode not support
239e0dac50fSopenharmony_ci * @tc.type: FUNC
240e0dac50fSopenharmony_ci */
241e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, CheckTransition02, Function | SmallTest | Level2)
242e0dac50fSopenharmony_ci{
243e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = StartingWindow::CreateWindowNode(transitionInfo_, 0);
244e0dac50fSopenharmony_ci    ASSERT_NE(nullptr, srcNode);
245e0dac50fSopenharmony_ci    sptr<WindowNode> dstNode = StartingWindow::CreateWindowNode(transitionInfo_, 1);
246e0dac50fSopenharmony_ci    ASSERT_NE(nullptr, dstNode);
247e0dac50fSopenharmony_ci    dstNode->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
248e0dac50fSopenharmony_ci    dstNode->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING);
249e0dac50fSopenharmony_ci    ASSERT_EQ(false, WindowHelper::CheckSupportWindowMode(dstNode->GetWindowMode(),
250e0dac50fSopenharmony_ci        dstNode->GetModeSupportInfo(), transitionInfo_));
251e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::CheckTransition(transitionInfo_, srcNode, transitionInfo_, dstNode));
252e0dac50fSopenharmony_ci}
253e0dac50fSopenharmony_ci
254e0dac50fSopenharmony_ci/**
255e0dac50fSopenharmony_ci * @tc.name: CheckTransition03
256e0dac50fSopenharmony_ci * @tc.desc: CheckTransition return true
257e0dac50fSopenharmony_ci * @tc.type: FUNC
258e0dac50fSopenharmony_ci */
259e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, CheckTransition03, Function | SmallTest | Level2)
260e0dac50fSopenharmony_ci{
261e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = StartingWindow::CreateWindowNode(transitionInfo_, 0);
262e0dac50fSopenharmony_ci    ASSERT_NE(nullptr, srcNode);
263e0dac50fSopenharmony_ci    sptr<WindowNode> dstNode = StartingWindow::CreateWindowNode(transitionInfo_, 1);
264e0dac50fSopenharmony_ci    ASSERT_NE(nullptr, dstNode);
265e0dac50fSopenharmony_ci    EXPECT_EQ(true, RemoteAnimation::CheckTransition(transitionInfo_, srcNode, nullptr, dstNode));
266e0dac50fSopenharmony_ci    EXPECT_EQ(true, RemoteAnimation::CheckTransition(transitionInfo_, srcNode, transitionInfo_, dstNode));
267e0dac50fSopenharmony_ci}
268e0dac50fSopenharmony_ci
269e0dac50fSopenharmony_ci/**
270e0dac50fSopenharmony_ci * @tc.name: OnRemoteDieAndCallbackTimeOutProcess01
271e0dac50fSopenharmony_ci * @tc.desc: OnRemoteDie and setAnimationController nullptr
272e0dac50fSopenharmony_ci * @tc.type: FUNC
273e0dac50fSopenharmony_ci */
274e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, OnRemoteDieAndCallbackTimeOutProcess01, Function | SmallTest | Level2)
275e0dac50fSopenharmony_ci{
276e0dac50fSopenharmony_ci    auto testController = RemoteAnimation::windowAnimationController_;
277e0dac50fSopenharmony_ci    ASSERT_EQ(true, RemoteAnimation::windowAnimationController_->AsObject() == animationController_->AsObject());
278e0dac50fSopenharmony_ci    RemoteAnimation::OnRemoteDie(animationController_->AsObject()); // controller is not nullptr
279e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::CheckAnimationController());
280e0dac50fSopenharmony_ci    RemoteAnimation::OnRemoteDie(testController->AsObject()); // controller is nullptr
281e0dac50fSopenharmony_ci    RemoteAnimation::SetAnimationFirst(false);
282e0dac50fSopenharmony_ci    RemoteAnimation::OnRemoteDie(testController->AsObject()); // controller is nullptr
283e0dac50fSopenharmony_ci}
284e0dac50fSopenharmony_ci
285e0dac50fSopenharmony_ci/**
286e0dac50fSopenharmony_ci * @tc.name: OnRemoteDieAndCallbackTimeOutProcess02
287e0dac50fSopenharmony_ci * @tc.desc: OnRemoteDie and not set animation controller
288e0dac50fSopenharmony_ci * @tc.type: FUNC
289e0dac50fSopenharmony_ci */
290e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, OnRemoteDieAndCallbackTimeOutProcess02, Function | SmallTest | Level2)
291e0dac50fSopenharmony_ci{
292e0dac50fSopenharmony_ci    sptr<IRemoteObject> remoteObject = nullptr;
293e0dac50fSopenharmony_ci    RemoteAnimation::windowRoot_ = nullptr;
294e0dac50fSopenharmony_ci    RemoteAnimation::OnRemoteDie(remoteObject); // controller is not nullptr
295e0dac50fSopenharmony_ci    EXPECT_EQ(true, RemoteAnimation::CheckAnimationController());
296e0dac50fSopenharmony_ci}
297e0dac50fSopenharmony_ci
298e0dac50fSopenharmony_ci/**
299e0dac50fSopenharmony_ci * @tc.name: OnRemoteDieAndCallbackTimeOutProcess03
300e0dac50fSopenharmony_ci * @tc.desc: OnRemoteDie and timeout process success
301e0dac50fSopenharmony_ci * @tc.type: FUNC
302e0dac50fSopenharmony_ci */
303e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, OnRemoteDieAndCallbackTimeOutProcess03, Function | SmallTest | Level2)
304e0dac50fSopenharmony_ci{
305e0dac50fSopenharmony_ci    auto root = RemoteAnimation::windowRoot_;
306e0dac50fSopenharmony_ci    node_->stateMachine_.TransitionTo(WindowNodeState::SHOW_ANIMATION_PLAYING);
307e0dac50fSopenharmony_ci    auto testController = RemoteAnimation::windowAnimationController_;
308e0dac50fSopenharmony_ci    RemoteAnimation::OnRemoteDie(testController->AsObject()); // controller is not nullptr
309e0dac50fSopenharmony_ci    EXPECT_EQ(false, RemoteAnimation::CheckAnimationController());
310e0dac50fSopenharmony_ci    EXPECT_EQ(true, node_->stateMachine_.currState_ == WindowNodeState::SHOW_ANIMATION_DONE);
311e0dac50fSopenharmony_ci}
312e0dac50fSopenharmony_ci
313e0dac50fSopenharmony_ci/**
314e0dac50fSopenharmony_ci * @tc.name: CreateWindowAnimationTarget01
315e0dac50fSopenharmony_ci * @tc.desc: CreateWindowAnimationTarget with null node/different windowType
316e0dac50fSopenharmony_ci * @tc.type: FUNC
317e0dac50fSopenharmony_ci */
318e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, CreateWindowAnimationTarget01, Function | SmallTest | Level2)
319e0dac50fSopenharmony_ci{
320e0dac50fSopenharmony_ci    sptr<WindowNode> node = nullptr;
321e0dac50fSopenharmony_ci    EXPECT_EQ(nullptr, RemoteAnimation::CreateWindowAnimationTarget(transitionInfo_, node));
322e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = new WindowNode(CreateWindowProperty(1)); // 1 is windowId
323e0dac50fSopenharmony_ci    EXPECT_EQ(nullptr, RemoteAnimation::CreateWindowAnimationTarget(transitionInfo_, srcNode)); // no surfaceNode
324e0dac50fSopenharmony_ci    srcNode->GetWindowProperty()->SetWindowType(WindowType::WINDOW_TYPE_DESKTOP);
325e0dac50fSopenharmony_ci    EXPECT_EQ(nullptr, RemoteAnimation::CreateWindowAnimationTarget(transitionInfo_, srcNode)); // no surfaceNode
326e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, RemoteAnimation::CreateWindowAnimationTarget(transitionInfo_, node_));
327e0dac50fSopenharmony_ci    node_->startingWinSurfaceNode_ = nullptr;
328e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, RemoteAnimation::CreateWindowAnimationTarget(transitionInfo_, node_)); // start win null
329e0dac50fSopenharmony_ci}
330e0dac50fSopenharmony_ci
331e0dac50fSopenharmony_ci/**
332e0dac50fSopenharmony_ci * @tc.name: CreateShowAnimationFinishedCallback01
333e0dac50fSopenharmony_ci * @tc.desc: CreateShowAnimationFinishedCallback with animationFirst false
334e0dac50fSopenharmony_ci * @tc.type: FUNC
335e0dac50fSopenharmony_ci */
336e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, CreateShowAnimationFinishedCallback01, Function | SmallTest | Level2)
337e0dac50fSopenharmony_ci{
338e0dac50fSopenharmony_ci    RemoteAnimation::SetAnimationFirst(false);
339e0dac50fSopenharmony_ci    auto finishCallback = RemoteAnimation::CreateShowAnimationFinishedCallback(node_, node_, true);
340e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
341e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // not animation playing
342e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
343e0dac50fSopenharmony_ci
344e0dac50fSopenharmony_ci    node_->stateMachine_.TransitionTo(WindowNodeState::SHOW_ANIMATION_PLAYING);
345e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateShowAnimationFinishedCallback(node_, node_, true);
346e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
347e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // leashSurfaceNode is not nullptr
348e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
349e0dac50fSopenharmony_ci
350e0dac50fSopenharmony_ci    sptr<WindowNode> dstNode = nullptr;
351e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateShowAnimationFinishedCallback(node_, dstNode, true);
352e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
353e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // dstNode is nullptr
354e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
355e0dac50fSopenharmony_ci
356e0dac50fSopenharmony_ci    dstNode = new WindowNode(CreateWindowProperty(1)); // leashSurfaceNode is nullptr
357e0dac50fSopenharmony_ci    dstNode->stateMachine_.TransitionTo(WindowNodeState::HIDE_ANIMATION_PLAYING);
358e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateShowAnimationFinishedCallback(node_, dstNode, true);
359e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
360e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished();
361e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
362e0dac50fSopenharmony_ci}
363e0dac50fSopenharmony_ci
364e0dac50fSopenharmony_ci/**
365e0dac50fSopenharmony_ci * @tc.name: CreateShowAnimationFinishedCallback02
366e0dac50fSopenharmony_ci * @tc.desc: CreateShowAnimationFinishedCallback with animationFirst true
367e0dac50fSopenharmony_ci * @tc.type: FUNC
368e0dac50fSopenharmony_ci */
369e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, CreateShowAnimationFinishedCallback02, Function | SmallTest | Level2)
370e0dac50fSopenharmony_ci{
371e0dac50fSopenharmony_ci    sptr<WindowNode> dstNode = nullptr;
372e0dac50fSopenharmony_ci    auto finishCallback = RemoteAnimation::CreateShowAnimationFinishedCallback(node_, dstNode, true);
373e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
374e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // dstNode is nullptr
375e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
376e0dac50fSopenharmony_ci
377e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = nullptr;
378e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateShowAnimationFinishedCallback(srcNode, node_, true);
379e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
380e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // process srcNode state task with nullptr, node task count < 0
381e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
382e0dac50fSopenharmony_ci
383e0dac50fSopenharmony_ci    srcNode = nullptr;
384e0dac50fSopenharmony_ci    node_->stateMachine_.ResetAnimationTaskCount(2); // 2 is animationCount
385e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateShowAnimationFinishedCallback(srcNode, node_, false);
386e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
387e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // process srcNode state task with nullptr, node task count > 0
388e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
389e0dac50fSopenharmony_ci}
390e0dac50fSopenharmony_ci
391e0dac50fSopenharmony_ci/**
392e0dac50fSopenharmony_ci * @tc.name: CreateHideAnimationFinishedCallback01
393e0dac50fSopenharmony_ci * @tc.desc: CreateHideAnimationFinishedCallback with animationFirst false
394e0dac50fSopenharmony_ci * @tc.type: FUNC
395e0dac50fSopenharmony_ci */
396e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, CreateHideAnimationFinishedCallback01, Function | SmallTest | Level2)
397e0dac50fSopenharmony_ci{
398e0dac50fSopenharmony_ci    RemoteAnimation::SetAnimationFirst(false);
399e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = nullptr;
400e0dac50fSopenharmony_ci    auto finishCallback = RemoteAnimation::CreateHideAnimationFinishedCallback(srcNode, TransitionEvent::MINIMIZE);
401e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
402e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // srcNode is nullptr
403e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
404e0dac50fSopenharmony_ci
405e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateHideAnimationFinishedCallback(node_, TransitionEvent::MINIMIZE);
406e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
407e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // not hide animation playing
408e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
409e0dac50fSopenharmony_ci    EXPECT_NE(WindowNodeState::HIDE_ANIMATION_DONE, node_->stateMachine_.currState_);
410e0dac50fSopenharmony_ci
411e0dac50fSopenharmony_ci    node_->stateMachine_.TransitionTo(WindowNodeState::HIDE_ANIMATION_PLAYING);
412e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateHideAnimationFinishedCallback(node_, TransitionEvent::CLOSE);
413e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
414e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // hide animation playing and with close
415e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
416e0dac50fSopenharmony_ci    EXPECT_EQ(WindowNodeState::HIDE_ANIMATION_DONE, node_->stateMachine_.currState_);
417e0dac50fSopenharmony_ci
418e0dac50fSopenharmony_ci    node_->stateMachine_.TransitionTo(WindowNodeState::HIDE_ANIMATION_PLAYING);
419e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateHideAnimationFinishedCallback(node_, TransitionEvent::MINIMIZE);
420e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
421e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // hide animation playing and with MINIMIZE
422e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
423e0dac50fSopenharmony_ci    EXPECT_EQ(WindowNodeState::HIDE_ANIMATION_DONE, node_->stateMachine_.currState_);
424e0dac50fSopenharmony_ci
425e0dac50fSopenharmony_ci    node_->stateMachine_.TransitionTo(WindowNodeState::STARTING_CREATED);
426e0dac50fSopenharmony_ci    node_->abilityToken_ = nullptr;
427e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateHideAnimationFinishedCallback(node_, TransitionEvent::MINIMIZE);
428e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
429e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // abilityToken is nullptr
430e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
431e0dac50fSopenharmony_ci    EXPECT_EQ(WindowNodeState::STARTING_CREATED, node_->stateMachine_.currState_);
432e0dac50fSopenharmony_ci}
433e0dac50fSopenharmony_ci
434e0dac50fSopenharmony_ci/**
435e0dac50fSopenharmony_ci * @tc.name: CreateHideAnimationFinishedCallback02
436e0dac50fSopenharmony_ci * @tc.desc: CreateHideAnimationFinishedCallback with animationFirst true
437e0dac50fSopenharmony_ci * @tc.type: FUNC
438e0dac50fSopenharmony_ci */
439e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, CreateHideAnimationFinishedCallback02, Function | SmallTest | Level2)
440e0dac50fSopenharmony_ci{
441e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = nullptr;
442e0dac50fSopenharmony_ci    auto finishCallback = RemoteAnimation::CreateHideAnimationFinishedCallback(srcNode, TransitionEvent::CLOSE);
443e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
444e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // srcNode is nullptr
445e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
446e0dac50fSopenharmony_ci
447e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateHideAnimationFinishedCallback(node_, TransitionEvent::MINIMIZE);
448e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
449e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // with minimize
450e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
451e0dac50fSopenharmony_ci
452e0dac50fSopenharmony_ci    node_->firstFrameAvailable_ = true;
453e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateHideAnimationFinishedCallback(node_, TransitionEvent::CLOSE);
454e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
455e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // create hide callback with firstFrameAvailable_ true
456e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
457e0dac50fSopenharmony_ci
458e0dac50fSopenharmony_ci    node_->firstFrameAvailable_ = false;
459e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateHideAnimationFinishedCallback(node_, TransitionEvent::CLOSE);
460e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
461e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // create hide callback with surfaceNode null
462e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
463e0dac50fSopenharmony_ci
464e0dac50fSopenharmony_ci    node_->firstFrameAvailable_ = false;
465e0dac50fSopenharmony_ci    node_->surfaceNode_ = CreateRSSurfaceNode(1);
466e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateHideAnimationFinishedCallback(node_, TransitionEvent::CLOSE);
467e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
468e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // create hide callback with surfaceNode not null
469e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
470e0dac50fSopenharmony_ci
471e0dac50fSopenharmony_ci    node_->leashWinSurfaceNode_ = CreateRSSurfaceNode(1);
472e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateHideAnimationFinishedCallback(node_, TransitionEvent::CLOSE);
473e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
474e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished(); // create hide callback with leashWinSurfaceNode_ null
475e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
476e0dac50fSopenharmony_ci}
477e0dac50fSopenharmony_ci
478e0dac50fSopenharmony_ci/**
479e0dac50fSopenharmony_ci * @tc.name: ProcessNodeStateTask01
480e0dac50fSopenharmony_ci * @tc.desc: ProcessNodeStateTask with different node state
481e0dac50fSopenharmony_ci * @tc.type: FUNC
482e0dac50fSopenharmony_ci */
483e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, ProcessNodeStateTask01, Function | SmallTest | Level2)
484e0dac50fSopenharmony_ci{
485e0dac50fSopenharmony_ci    // ExecuteFinalStateTask with task is nullptr
486e0dac50fSopenharmony_ci    node_->stateMachine_.ResetAnimationTaskCount(1);
487e0dac50fSopenharmony_ci    RemoteAnimation::ProcessNodeStateTask(node_);
488e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
489e0dac50fSopenharmony_ci    EXPECT_EQ(WindowNodeState::STARTING_CREATED, node_->stateMachine_.currState_);
490e0dac50fSopenharmony_ci
491e0dac50fSopenharmony_ci    node_->stateMachine_.ResetAnimationTaskCount(1);
492e0dac50fSopenharmony_ci    node_->stateMachine_.TransitionTo(WindowNodeState::HIDE_ANIMATION_PLAYING);
493e0dac50fSopenharmony_ci    RemoteAnimation::ProcessNodeStateTask(node_); // hide animation playing
494e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
495e0dac50fSopenharmony_ci    EXPECT_EQ(WindowNodeState::HIDE_ANIMATION_DONE, node_->stateMachine_.currState_);
496e0dac50fSopenharmony_ci
497e0dac50fSopenharmony_ci    RemoteAnimation::windowRoot_ = nullptr;
498e0dac50fSopenharmony_ci    node_->stateMachine_.ResetAnimationTaskCount(1);
499e0dac50fSopenharmony_ci    RemoteAnimation::ProcessNodeStateTask(node_); // hide animation playing and windowRoot is nullptr
500e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
501e0dac50fSopenharmony_ci    EXPECT_EQ(WindowNodeState::HIDE_ANIMATION_DONE, node_->stateMachine_.currState_);
502e0dac50fSopenharmony_ci
503e0dac50fSopenharmony_ci    RemoteAnimation::windowRoot_ = windowRoot_;
504e0dac50fSopenharmony_ci    node_->stateMachine_.TransitionTo(WindowNodeState::SHOW_ANIMATION_PLAYING);
505e0dac50fSopenharmony_ci    node_->stateMachine_.ResetAnimationTaskCount(1);
506e0dac50fSopenharmony_ci    RemoteAnimation::ProcessNodeStateTask(node_); // show animation playing
507e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
508e0dac50fSopenharmony_ci    EXPECT_EQ(WindowNodeState::SHOW_ANIMATION_DONE, node_->stateMachine_.currState_);
509e0dac50fSopenharmony_ci
510e0dac50fSopenharmony_ci    bool taskExecute = false;
511e0dac50fSopenharmony_ci    node_->stateMachine_.SetDestroyTask([&taskExecute] {taskExecute = true;});
512e0dac50fSopenharmony_ci    node_->stateMachine_.ResetAnimationTaskCount(1);
513e0dac50fSopenharmony_ci    RemoteAnimation::ProcessNodeStateTask(node_); // execute destroy task
514e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
515e0dac50fSopenharmony_ci    EXPECT_EQ(true, taskExecute);
516e0dac50fSopenharmony_ci
517e0dac50fSopenharmony_ci    RemoteAnimation::windowRoot_ = nullptr;
518e0dac50fSopenharmony_ci    node_->stateMachine_.ResetAnimationTaskCount(1);
519e0dac50fSopenharmony_ci    RemoteAnimation::ProcessNodeStateTask(node_); // show animation playing and windowRoot is nullptr
520e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
521e0dac50fSopenharmony_ci    EXPECT_EQ(WindowNodeState::SHOW_ANIMATION_DONE, node_->stateMachine_.currState_);
522e0dac50fSopenharmony_ci
523e0dac50fSopenharmony_ci    wmsTaskHandler_ = nullptr;
524e0dac50fSopenharmony_ci    RemoteAnimation::wmsTaskHandler_ = wmsTaskHandler_;
525e0dac50fSopenharmony_ci    node_->stateMachine_.ResetAnimationTaskCount(1);
526e0dac50fSopenharmony_ci    node_->stateMachine_.SetDestroyTask([&taskExecute] {taskExecute = false;});
527e0dac50fSopenharmony_ci    RemoteAnimation::ExecuteFinalStateTask(node_); // handler is nullptr
528e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
529e0dac50fSopenharmony_ci    EXPECT_EQ(true, taskExecute);
530e0dac50fSopenharmony_ci}
531e0dac50fSopenharmony_ci
532e0dac50fSopenharmony_ci/**
533e0dac50fSopenharmony_ci * @tc.name: PostProcessShowCallback01
534e0dac50fSopenharmony_ci * @tc.desc: PostProcessShowCallback with different leashWinSurfaceNode
535e0dac50fSopenharmony_ci * @tc.type: FUNC
536e0dac50fSopenharmony_ci */
537e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, PostProcessShowCallback01, Function | SmallTest | Level2)
538e0dac50fSopenharmony_ci{
539e0dac50fSopenharmony_ci    sptr<WindowNode> dstNode = nullptr;
540e0dac50fSopenharmony_ci    RemoteAnimation::PostProcessShowCallback(dstNode);
541e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
542e0dac50fSopenharmony_ci
543e0dac50fSopenharmony_ci    Rect expectRect = {0, 0, 100, 100}; // 100 is test data
544e0dac50fSopenharmony_ci    node_->SetWindowRect(expectRect);
545e0dac50fSopenharmony_ci    RemoteAnimation::PostProcessShowCallback(node_);
546e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
547e0dac50fSopenharmony_ci    Rect actualRect = GetSurfaceBoundsRect(node_);
548e0dac50fSopenharmony_ci    EXPECT_EQ(expectRect, actualRect);
549e0dac50fSopenharmony_ci    node_->leashWinSurfaceNode_ = nullptr;
550e0dac50fSopenharmony_ci    RemoteAnimation::PostProcessShowCallback(node_);
551e0dac50fSopenharmony_ci}
552e0dac50fSopenharmony_ci
553e0dac50fSopenharmony_ci/**
554e0dac50fSopenharmony_ci * @tc.name: GetTransitionEvent01
555e0dac50fSopenharmony_ci * @tc.desc: GetTransitionEvent with reason not ability_transition
556e0dac50fSopenharmony_ci * @tc.type: FUNC
557e0dac50fSopenharmony_ci */
558e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, GetTransitionEvent01, Function | SmallTest | Level2)
559e0dac50fSopenharmony_ci{
560e0dac50fSopenharmony_ci    transitionInfo_->SetTransitionReason(TransitionReason::MINIMIZE);
561e0dac50fSopenharmony_ci    auto event = RemoteAnimation::GetTransitionEvent(transitionInfo_, transitionInfo_, node_, node_);
562e0dac50fSopenharmony_ci    EXPECT_EQ(TransitionEvent::MINIMIZE, event);
563e0dac50fSopenharmony_ci
564e0dac50fSopenharmony_ci    transitionInfo_->SetTransitionReason(TransitionReason::BACK_TRANSITION);
565e0dac50fSopenharmony_ci    event = RemoteAnimation::GetTransitionEvent(transitionInfo_, transitionInfo_, node_, node_);
566e0dac50fSopenharmony_ci    EXPECT_EQ(TransitionEvent::BACK_TRANSITION, event);
567e0dac50fSopenharmony_ci
568e0dac50fSopenharmony_ci    transitionInfo_->SetTransitionReason(TransitionReason::CLOSE);
569e0dac50fSopenharmony_ci    event = RemoteAnimation::GetTransitionEvent(transitionInfo_, transitionInfo_, node_, node_);
570e0dac50fSopenharmony_ci    EXPECT_EQ(TransitionEvent::CLOSE, event);
571e0dac50fSopenharmony_ci
572e0dac50fSopenharmony_ci    node_->stateMachine_.TransitionTo(WindowNodeState::HIDE_ANIMATION_PLAYING);
573e0dac50fSopenharmony_ci    transitionInfo_->SetTransitionReason(TransitionReason::CLOSE);
574e0dac50fSopenharmony_ci    event = RemoteAnimation::GetTransitionEvent(transitionInfo_, transitionInfo_, node_, node_);
575e0dac50fSopenharmony_ci    EXPECT_EQ(TransitionEvent::UNKNOWN, event);
576e0dac50fSopenharmony_ci}
577e0dac50fSopenharmony_ci
578e0dac50fSopenharmony_ci/**
579e0dac50fSopenharmony_ci * @tc.name: GetTransitionEvent02
580e0dac50fSopenharmony_ci * @tc.desc: GetTransitionEvent with reason ability_transition
581e0dac50fSopenharmony_ci * @tc.type: FUNC
582e0dac50fSopenharmony_ci */
583e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, GetTransitionEvent02, Function | SmallTest | Level2)
584e0dac50fSopenharmony_ci{
585e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = nullptr;
586e0dac50fSopenharmony_ci    transitionInfo_->SetTransitionReason(TransitionReason::ABILITY_TRANSITION);
587e0dac50fSopenharmony_ci    auto event = RemoteAnimation::GetTransitionEvent(transitionInfo_, transitionInfo_, srcNode, node_);
588e0dac50fSopenharmony_ci    EXPECT_EQ(TransitionEvent::APP_TRANSITION, event);
589e0dac50fSopenharmony_ci
590e0dac50fSopenharmony_ci    sptr<WindowNode> dstNode = nullptr;
591e0dac50fSopenharmony_ci    event = RemoteAnimation::GetTransitionEvent(transitionInfo_, transitionInfo_, node_, dstNode);
592e0dac50fSopenharmony_ci    EXPECT_EQ(TransitionEvent::UNKNOWN, event);
593e0dac50fSopenharmony_ci
594e0dac50fSopenharmony_ci    node_->stateMachine_.TransitionTo(WindowNodeState::SHOW_ANIMATION_PLAYING);
595e0dac50fSopenharmony_ci    event = RemoteAnimation::GetTransitionEvent(transitionInfo_, transitionInfo_, node_, node_);
596e0dac50fSopenharmony_ci    EXPECT_EQ(TransitionEvent::UNKNOWN, event);
597e0dac50fSopenharmony_ci
598e0dac50fSopenharmony_ci    transitionInfo_->SetWindowType(WindowType::WINDOW_TYPE_DESKTOP);
599e0dac50fSopenharmony_ci    event = RemoteAnimation::GetTransitionEvent(transitionInfo_, transitionInfo_, node_, node_);
600e0dac50fSopenharmony_ci    EXPECT_EQ(TransitionEvent::HOME, event);
601e0dac50fSopenharmony_ci
602e0dac50fSopenharmony_ci    transitionInfo_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
603e0dac50fSopenharmony_ci    event = RemoteAnimation::GetTransitionEvent(transitionInfo_, transitionInfo_, node_, node_);
604e0dac50fSopenharmony_ci    EXPECT_EQ(TransitionEvent::UNKNOWN, event);
605e0dac50fSopenharmony_ci
606e0dac50fSopenharmony_ci    transitionInfo_->SetAbilityToken(nullptr);
607e0dac50fSopenharmony_ci    event = RemoteAnimation::GetTransitionEvent(transitionInfo_, transitionInfo_, node_, dstNode);
608e0dac50fSopenharmony_ci    EXPECT_EQ(TransitionEvent::UNKNOWN, event);
609e0dac50fSopenharmony_ci}
610e0dac50fSopenharmony_ci
611e0dac50fSopenharmony_ci/**
612e0dac50fSopenharmony_ci * @tc.name: GetExpectRect01
613e0dac50fSopenharmony_ci * @tc.desc: GetExpectRect
614e0dac50fSopenharmony_ci * @tc.type: FUNC
615e0dac50fSopenharmony_ci */
616e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, GetExpectRect01, Function | SmallTest | Level2)
617e0dac50fSopenharmony_ci{
618e0dac50fSopenharmony_ci    auto target = RemoteAnimation::CreateWindowAnimationTarget(transitionInfo_, node_);
619e0dac50fSopenharmony_ci    RemoteAnimation::GetExpectRect(node_, target);
620e0dac50fSopenharmony_ci    Rect actualRect = GetSurfaceBoundsRect(node_);
621e0dac50fSopenharmony_ci    EXPECT_EQ(node_->GetWindowRect(), actualRect); // avoidRect is empty thus return
622e0dac50fSopenharmony_ci
623e0dac50fSopenharmony_ci    sptr<WindowNode> statusBar = new WindowNode(CreateWindowProperty(0));
624e0dac50fSopenharmony_ci    ASSERT_NE(nullptr, statusBar);
625e0dac50fSopenharmony_ci    statusBar->GetWindowProperty()->SetWindowType(WindowType::WINDOW_TYPE_STATUS_BAR);
626e0dac50fSopenharmony_ci    statusBar->SetWindowRect({0, 0, 100, 100});
627e0dac50fSopenharmony_ci    windowRoot_->windowNodeMap_[0] = statusBar;
628e0dac50fSopenharmony_ci
629e0dac50fSopenharmony_ci    Rect avoidRect = windowRoot_->GetDisplayRectWithoutSystemBarAreas(node_);
630e0dac50fSopenharmony_ci    EXPECT_FALSE(WindowHelper::IsEmptyRect(avoidRect));
631e0dac50fSopenharmony_ci
632e0dac50fSopenharmony_ci    RemoteAnimation::GetExpectRect(node_, target);
633e0dac50fSopenharmony_ci    actualRect = GetSurfaceBoundsRect(node_);
634e0dac50fSopenharmony_ci    EXPECT_EQ(avoidRect, actualRect); // get expect rect
635e0dac50fSopenharmony_ci
636e0dac50fSopenharmony_ci    node_->leashWinSurfaceNode_ = nullptr;
637e0dac50fSopenharmony_ci    RemoteAnimation::GetExpectRect(node_, target);
638e0dac50fSopenharmony_ci
639e0dac50fSopenharmony_ci    node_->GetWindowProperty()->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
640e0dac50fSopenharmony_ci    RemoteAnimation::GetExpectRect(node_, target);
641e0dac50fSopenharmony_ci    EXPECT_FALSE(WindowHelper::IsMainFullScreenWindow(node_->GetWindowType(), node_->GetWindowMode()));
642e0dac50fSopenharmony_ci
643e0dac50fSopenharmony_ci    RemoteAnimation::windowRoot_ = nullptr;
644e0dac50fSopenharmony_ci    RemoteAnimation::GetExpectRect(node_, target);
645e0dac50fSopenharmony_ci
646e0dac50fSopenharmony_ci    node_->GetWindowProperty()->SetWindowFlags(0);
647e0dac50fSopenharmony_ci    RemoteAnimation::GetExpectRect(node_, target);
648e0dac50fSopenharmony_ci    bool needAvoid = (node_->GetWindowFlags() & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID));
649e0dac50fSopenharmony_ci    EXPECT_EQ(false, needAvoid);
650e0dac50fSopenharmony_ci}
651e0dac50fSopenharmony_ci
652e0dac50fSopenharmony_ci/**
653e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationTransition01
654e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationTransition failed
655e0dac50fSopenharmony_ci * @tc.type: FUNC
656e0dac50fSopenharmony_ci */
657e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationTransition01, Function | SmallTest | Level2)
658e0dac50fSopenharmony_ci{
659e0dac50fSopenharmony_ci    sptr<WindowNode> dstNode = nullptr;
660e0dac50fSopenharmony_ci    WMError ret = RemoteAnimation::NotifyAnimationTransition(transitionInfo_, transitionInfo_, node_, dstNode);
661e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NULLPTR, ret); //
662e0dac50fSopenharmony_ci    dstNode = new WindowNode(CreateWindowProperty(1)); // leashSurfaceNode is nullptr
663e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationTransition(transitionInfo_, transitionInfo_, node_, dstNode);
664e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NO_MEM, ret); // no surfaceNode thus target is nullptr
665e0dac50fSopenharmony_ci}
666e0dac50fSopenharmony_ci
667e0dac50fSopenharmony_ci/**
668e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationTransition02
669e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationTransition with OnAppTransition
670e0dac50fSopenharmony_ci * @tc.type: FUNC
671e0dac50fSopenharmony_ci */
672e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationTransition02, Function | SmallTest | Level2)
673e0dac50fSopenharmony_ci{
674e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = new WindowNode(CreateWindowProperty(2)); // 2 is windowId
675e0dac50fSopenharmony_ci    MinimizeApp::AddNeedMinimizeApp(srcNode, MinimizeReason::OTHER_WINDOW);
676e0dac50fSopenharmony_ci
677e0dac50fSopenharmony_ci    WMError ret = RemoteAnimation::NotifyAnimationTransition(transitionInfo_, transitionInfo_, srcNode, node_);
678e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret); //
679e0dac50fSopenharmony_ci    EXPECT_EQ(0, MinimizeApp::GetNeedMinimizeAppNodesWithReason(MinimizeReason::OTHER_WINDOW).size());
680e0dac50fSopenharmony_ci
681e0dac50fSopenharmony_ci    RemoteAnimation::SetAnimationFirst(false);
682e0dac50fSopenharmony_ci    MinimizeApp::AddNeedMinimizeApp(srcNode, MinimizeReason::OTHER_WINDOW);
683e0dac50fSopenharmony_ci
684e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationTransition(transitionInfo_, transitionInfo_, srcNode, node_);
685e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret); //
686e0dac50fSopenharmony_ci    EXPECT_EQ(1, MinimizeApp::GetNeedMinimizeAppNodesWithReason(MinimizeReason::OTHER_WINDOW).size());
687e0dac50fSopenharmony_ci
688e0dac50fSopenharmony_ci    RemoteAnimation::windowController_ = nullptr;
689e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationTransition(transitionInfo_, transitionInfo_, srcNode, node_);
690e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret);
691e0dac50fSopenharmony_ci}
692e0dac50fSopenharmony_ci
693e0dac50fSopenharmony_ci/**
694e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationTransition03
695e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationTransition with NotifyAnimationStartApp
696e0dac50fSopenharmony_ci * @tc.type: FUNC
697e0dac50fSopenharmony_ci */
698e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationTransition03, Function | SmallTest | Level2)
699e0dac50fSopenharmony_ci{
700e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = new WindowNode(CreateWindowProperty(2)); // 2 is windowId
701e0dac50fSopenharmony_ci    srcNode->GetWindowProperty()->SetWindowType(WindowType::WINDOW_TYPE_DESKTOP);
702e0dac50fSopenharmony_ci    node_->surfaceNode_ = CreateRSSurfaceNode(2);
703e0dac50fSopenharmony_ci    WMError ret = RemoteAnimation::NotifyAnimationTransition(transitionInfo_, transitionInfo_, srcNode, node_);
704e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret); // srcNode is nullptr, from launcher
705e0dac50fSopenharmony_ci
706e0dac50fSopenharmony_ci    srcNode->GetWindowProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
707e0dac50fSopenharmony_ci    transitionInfo_->SetIsRecent(true);
708e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationTransition(transitionInfo_, transitionInfo_, srcNode, node_);
709e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret); // srcNode is nullptr, from recent
710e0dac50fSopenharmony_ci
711e0dac50fSopenharmony_ci    srcNode = nullptr;
712e0dac50fSopenharmony_ci    transitionInfo_->SetIsRecent(false);
713e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationTransition(transitionInfo_, transitionInfo_, srcNode, node_);
714e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret); // srcNode is null && need minimize false, from other
715e0dac50fSopenharmony_ci
716e0dac50fSopenharmony_ci    MinimizeApp::AddNeedMinimizeApp(srcNode, MinimizeReason::OTHER_WINDOW);
717e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationTransition(transitionInfo_, transitionInfo_, srcNode, node_);
718e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret); // srcNode is nullptr, but need minimize true, from other
719e0dac50fSopenharmony_ci
720e0dac50fSopenharmony_ci    RemoteAnimation::SetAnimationFirst(false);
721e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationTransition(transitionInfo_, transitionInfo_, srcNode, node_);
722e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret); // srcNode is nullptr, but need minimize true, from other
723e0dac50fSopenharmony_ci}
724e0dac50fSopenharmony_ci
725e0dac50fSopenharmony_ci/**
726e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationMinimize01
727e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationMinimize
728e0dac50fSopenharmony_ci * @tc.type: FUNC
729e0dac50fSopenharmony_ci */
730e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationMinimize01, Function | SmallTest | Level2)
731e0dac50fSopenharmony_ci{
732e0dac50fSopenharmony_ci    WMError ret = RemoteAnimation::NotifyAnimationMinimize(transitionInfo_, node_);
733e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret);
734e0dac50fSopenharmony_ci
735e0dac50fSopenharmony_ci    RemoteAnimation::windowController_ = nullptr;
736e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationMinimize(transitionInfo_, node_);
737e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret);
738e0dac50fSopenharmony_ci
739e0dac50fSopenharmony_ci    node_->leashWinSurfaceNode_ = nullptr;
740e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationMinimize(transitionInfo_, node_);
741e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NO_MEM, ret); // srcTarget is nullptr
742e0dac50fSopenharmony_ci}
743e0dac50fSopenharmony_ci
744e0dac50fSopenharmony_ci/**
745e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationClose01
746e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationClose
747e0dac50fSopenharmony_ci * @tc.type: FUNC
748e0dac50fSopenharmony_ci */
749e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationClose01, Function | SmallTest | Level2)
750e0dac50fSopenharmony_ci{
751e0dac50fSopenharmony_ci    WMError ret = RemoteAnimation::NotifyAnimationClose(transitionInfo_, node_, TransitionEvent::CLOSE);
752e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret);
753e0dac50fSopenharmony_ci
754e0dac50fSopenharmony_ci    RemoteAnimation::windowController_ = nullptr;
755e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationClose(transitionInfo_, node_, TransitionEvent::CLOSE);
756e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret);
757e0dac50fSopenharmony_ci
758e0dac50fSopenharmony_ci    node_->leashWinSurfaceNode_ = nullptr;
759e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationClose(transitionInfo_, node_, TransitionEvent::CLOSE);
760e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NO_MEM, ret); // srcTarget is nullptr
761e0dac50fSopenharmony_ci}
762e0dac50fSopenharmony_ci
763e0dac50fSopenharmony_ci/**
764e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationBackTransition01
765e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationBackTransition failed
766e0dac50fSopenharmony_ci * @tc.type: FUNC
767e0dac50fSopenharmony_ci */
768e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationBackTransition01, Function | SmallTest | Level2)
769e0dac50fSopenharmony_ci{
770e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = new WindowNode(CreateWindowProperty(2)); // 2 is windowId
771e0dac50fSopenharmony_ci    TransitionEvent event = TransitionEvent::BACK_TRANSITION;
772e0dac50fSopenharmony_ci    srcNode->leashWinSurfaceNode_ = nullptr;
773e0dac50fSopenharmony_ci    WMError ret = RemoteAnimation::NotifyAnimationBackTransition(transitionInfo_, transitionInfo_, srcNode, node_,
774e0dac50fSopenharmony_ci        event);
775e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NO_MEM, ret); // only src Target is null
776e0dac50fSopenharmony_ci
777e0dac50fSopenharmony_ci    sptr<WindowNode> dstNode = new WindowNode(CreateWindowProperty(3)); // 3 is windowId
778e0dac50fSopenharmony_ci    dstNode->leashWinSurfaceNode_ = nullptr;
779e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationBackTransition(transitionInfo_, transitionInfo_, node_, dstNode, event);
780e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NO_MEM, ret); // only dstTarget is null
781e0dac50fSopenharmony_ci
782e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationBackTransition(transitionInfo_, transitionInfo_, srcNode, dstNode, event);
783e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NO_MEM, ret); // both srcTarget and dstTarget art null
784e0dac50fSopenharmony_ci
785e0dac50fSopenharmony_ci    srcNode = nullptr;
786e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationBackTransition(transitionInfo_, transitionInfo_, srcNode, node_, event);
787e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NULLPTR, ret); // only srcNode is null
788e0dac50fSopenharmony_ci
789e0dac50fSopenharmony_ci    dstNode = nullptr;
790e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationBackTransition(transitionInfo_, transitionInfo_, node_, dstNode, event);
791e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NULLPTR, ret); // only dstNode is null
792e0dac50fSopenharmony_ci
793e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationBackTransition(transitionInfo_, transitionInfo_, srcNode, dstNode, event);
794e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NULLPTR, ret); // both srcNode and dstNode are null
795e0dac50fSopenharmony_ci
796e0dac50fSopenharmony_ci    RemoteAnimation::SetAnimationFirst(false);
797e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationBackTransition(transitionInfo_, transitionInfo_, node_, node_, event);
798e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NO_REMOTE_ANIMATION, ret);
799e0dac50fSopenharmony_ci}
800e0dac50fSopenharmony_ci
801e0dac50fSopenharmony_ci/**
802e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationBackTransition02
803e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationBackTransition success
804e0dac50fSopenharmony_ci * @tc.type: FUNC
805e0dac50fSopenharmony_ci */
806e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationBackTransition02, Function | SmallTest | Level2)
807e0dac50fSopenharmony_ci{
808e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = new WindowNode(CreateWindowProperty(2)); // 2 is windowId
809e0dac50fSopenharmony_ci    TransitionEvent event = TransitionEvent::BACK_TRANSITION;
810e0dac50fSopenharmony_ci    srcNode->leashWinSurfaceNode_ = CreateRSSurfaceNode(2); // 2 is windowId
811e0dac50fSopenharmony_ci    WMError ret = RemoteAnimation::NotifyAnimationBackTransition(transitionInfo_, transitionInfo_, srcNode, node_,
812e0dac50fSopenharmony_ci        event);
813e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret);
814e0dac50fSopenharmony_ci    RSIWindowAnimationControllerMocker* testController = reinterpret_cast<RSIWindowAnimationControllerMocker*>(
815e0dac50fSopenharmony_ci        animationController_.GetRefPtr());
816e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, testController->finishedCallback_);
817e0dac50fSopenharmony_ci    testController->finishedCallback_->OnAnimationFinished();
818e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
819e0dac50fSopenharmony_ci
820e0dac50fSopenharmony_ci    RemoteAnimation::windowController_ = nullptr;
821e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationBackTransition(transitionInfo_, transitionInfo_, srcNode, node_, event);
822e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret);
823e0dac50fSopenharmony_ci    testController = reinterpret_cast<RSIWindowAnimationControllerMocker*>(
824e0dac50fSopenharmony_ci        animationController_.GetRefPtr());
825e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, testController->finishedCallback_);
826e0dac50fSopenharmony_ci    testController->finishedCallback_->OnAnimationFinished();
827e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
828e0dac50fSopenharmony_ci}
829e0dac50fSopenharmony_ci
830e0dac50fSopenharmony_ci/**
831e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationByHome01
832e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationByHome with animationFirst false and create animationTarget failed
833e0dac50fSopenharmony_ci * @tc.type: FUNC
834e0dac50fSopenharmony_ci */
835e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationByHome01, Function | SmallTest | Level2)
836e0dac50fSopenharmony_ci{
837e0dac50fSopenharmony_ci    RemoteAnimation::SetAnimationFirst(false);
838e0dac50fSopenharmony_ci    WMError ret = RemoteAnimation::NotifyAnimationByHome();
839e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret); // no node need home
840e0dac50fSopenharmony_ci
841e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = new WindowNode(CreateWindowProperty(2)); // 2 is windowId
842e0dac50fSopenharmony_ci    MinimizeApp::AddNeedMinimizeApp(srcNode, MinimizeReason::MINIMIZE_ALL);
843e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationByHome();
844e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret); // create animationTarget failed with no surface, and no callback
845e0dac50fSopenharmony_ci
846e0dac50fSopenharmony_ci    srcNode->leashWinSurfaceNode_ = CreateRSSurfaceNode(2); // 2 is windowId
847e0dac50fSopenharmony_ci    srcNode->GetWindowProperty()->SetWindowType(WindowType::WINDOW_TYPE_DESKTOP);
848e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationByHome();
849e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret); // create animationTarget failed, and no callback
850e0dac50fSopenharmony_ci    RSIWindowAnimationControllerMocker* testController = reinterpret_cast<RSIWindowAnimationControllerMocker*>(
851e0dac50fSopenharmony_ci        animationController_.GetRefPtr());
852e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, testController->finishedCallback_);
853e0dac50fSopenharmony_ci    testController->finishedCallback_->OnAnimationFinished();
854e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
855e0dac50fSopenharmony_ci    EXPECT_NE(WindowNodeState::HIDE_ANIMATION_DONE, srcNode->stateMachine_.currState_);
856e0dac50fSopenharmony_ci
857e0dac50fSopenharmony_ci    srcNode->stateMachine_.TransitionTo(WindowNodeState::HIDE_ANIMATION_PLAYING);
858e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationByHome();
859e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret); // create animationTarget failed, and no callback
860e0dac50fSopenharmony_ci
861e0dac50fSopenharmony_ci    srcNode->GetWindowProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
862e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationByHome();
863e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret); // create animationTarget failed, and no callback
864e0dac50fSopenharmony_ci}
865e0dac50fSopenharmony_ci
866e0dac50fSopenharmony_ci/*
867e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationByHome02
868e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationByHome with animationFirst false and create animationTarget success
869e0dac50fSopenharmony_ci * @tc.type: FUNC
870e0dac50fSopenharmony_ci */
871e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationByHome02, Function | SmallTest | Level2)
872e0dac50fSopenharmony_ci{
873e0dac50fSopenharmony_ci    RemoteAnimation::SetAnimationFirst(false);
874e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = new WindowNode(CreateWindowProperty(2)); // 2 is windowId
875e0dac50fSopenharmony_ci    srcNode->leashWinSurfaceNode_ = CreateRSSurfaceNode(2); // 2 is windowId
876e0dac50fSopenharmony_ci    MinimizeApp::AddNeedMinimizeApp(srcNode, MinimizeReason::MINIMIZE_ALL);
877e0dac50fSopenharmony_ci    WMError ret = RemoteAnimation::NotifyAnimationByHome();
878e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret);
879e0dac50fSopenharmony_ci
880e0dac50fSopenharmony_ci    RSIWindowAnimationControllerMocker* testController = reinterpret_cast<RSIWindowAnimationControllerMocker*>(
881e0dac50fSopenharmony_ci        animationController_.GetRefPtr());
882e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, testController->finishedCallback_);
883e0dac50fSopenharmony_ci    testController->finishedCallback_->OnAnimationFinished();
884e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
885e0dac50fSopenharmony_ci    EXPECT_EQ(WindowNodeState::HIDE_ANIMATION_DONE, srcNode->stateMachine_.currState_);
886e0dac50fSopenharmony_ci}
887e0dac50fSopenharmony_ci
888e0dac50fSopenharmony_ci/*
889e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationByHome03
890e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationByHome with animationFirst true and create animationTarget success
891e0dac50fSopenharmony_ci * @tc.type: FUNC
892e0dac50fSopenharmony_ci */
893e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationByHome03, Function | SmallTest | Level2)
894e0dac50fSopenharmony_ci{
895e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = new WindowNode(CreateWindowProperty(2)); // 2 is windowId
896e0dac50fSopenharmony_ci    srcNode->leashWinSurfaceNode_ = CreateRSSurfaceNode(2); // 2 is windowId
897e0dac50fSopenharmony_ci    MinimizeApp::AddNeedMinimizeApp(srcNode, MinimizeReason::MINIMIZE_ALL);
898e0dac50fSopenharmony_ci    EXPECT_EQ(1, MinimizeApp::GetNeedMinimizeAppNodesWithReason(MinimizeReason::MINIMIZE_ALL).size());
899e0dac50fSopenharmony_ci    WMError ret = RemoteAnimation::NotifyAnimationByHome();
900e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret);
901e0dac50fSopenharmony_ci    EXPECT_EQ(0, MinimizeApp::GetNeedMinimizeAppNodesWithReason(MinimizeReason::MINIMIZE_ALL).size());
902e0dac50fSopenharmony_ci
903e0dac50fSopenharmony_ci    RSIWindowAnimationControllerMocker* testController = reinterpret_cast<RSIWindowAnimationControllerMocker*>(
904e0dac50fSopenharmony_ci        animationController_.GetRefPtr());
905e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, testController->finishedCallback_);
906e0dac50fSopenharmony_ci    testController->finishedCallback_->OnAnimationFinished();
907e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
908e0dac50fSopenharmony_ci    EXPECT_EQ(WindowNodeState::HIDE_ANIMATION_DONE, srcNode->stateMachine_.currState_);
909e0dac50fSopenharmony_ci}
910e0dac50fSopenharmony_ci
911e0dac50fSopenharmony_ci/*
912e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationTargetsUpdate01
913e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationTargetsUpdate failed
914e0dac50fSopenharmony_ci * @tc.type: FUNC
915e0dac50fSopenharmony_ci */
916e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationTargetsUpdate01, Function | SmallTest | Level2)
917e0dac50fSopenharmony_ci{
918e0dac50fSopenharmony_ci    std::vector<uint32_t> fullScreenWinIds;
919e0dac50fSopenharmony_ci    std::vector<uint32_t> floatWinIds;
920e0dac50fSopenharmony_ci    RemoteAnimation::NotifyAnimationTargetsUpdate(fullScreenWinIds, floatWinIds); // fullScreenAnimationTarget is empty
921e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
922e0dac50fSopenharmony_ci    RSIWindowAnimationControllerMocker* testController = reinterpret_cast<RSIWindowAnimationControllerMocker*>(
923e0dac50fSopenharmony_ci        animationController_.GetRefPtr());
924e0dac50fSopenharmony_ci    EXPECT_EQ(nullptr, testController->animationTarget_);
925e0dac50fSopenharmony_ci    EXPECT_EQ(0, testController->floatingWindowTargets_.size());
926e0dac50fSopenharmony_ci
927e0dac50fSopenharmony_ci    RemoteAnimation::windowRoot_ = nullptr;
928e0dac50fSopenharmony_ci    RemoteAnimation::NotifyAnimationTargetsUpdate(fullScreenWinIds, floatWinIds);
929e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
930e0dac50fSopenharmony_ci    testController = reinterpret_cast<RSIWindowAnimationControllerMocker*>(
931e0dac50fSopenharmony_ci        animationController_.GetRefPtr());
932e0dac50fSopenharmony_ci    EXPECT_EQ(nullptr, testController->animationTarget_);
933e0dac50fSopenharmony_ci    EXPECT_EQ(0, testController->floatingWindowTargets_.size());
934e0dac50fSopenharmony_ci
935e0dac50fSopenharmony_ci    RemoteAnimation::windowAnimationController_ = nullptr;
936e0dac50fSopenharmony_ci    RemoteAnimation::NotifyAnimationTargetsUpdate(fullScreenWinIds, floatWinIds);
937e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
938e0dac50fSopenharmony_ci    testController = reinterpret_cast<RSIWindowAnimationControllerMocker*>(
939e0dac50fSopenharmony_ci        animationController_.GetRefPtr());
940e0dac50fSopenharmony_ci    EXPECT_EQ(nullptr, testController->animationTarget_);
941e0dac50fSopenharmony_ci    EXPECT_EQ(0, testController->floatingWindowTargets_.size());
942e0dac50fSopenharmony_ci
943e0dac50fSopenharmony_ci    wmsTaskHandler_ = nullptr;
944e0dac50fSopenharmony_ci    RemoteAnimation::wmsTaskHandler_ = wmsTaskHandler_;
945e0dac50fSopenharmony_ci    RemoteAnimation::NotifyAnimationTargetsUpdate(fullScreenWinIds, floatWinIds);
946e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
947e0dac50fSopenharmony_ci    testController = reinterpret_cast<RSIWindowAnimationControllerMocker*>(
948e0dac50fSopenharmony_ci        animationController_.GetRefPtr());
949e0dac50fSopenharmony_ci    EXPECT_EQ(nullptr, testController->animationTarget_);
950e0dac50fSopenharmony_ci    EXPECT_EQ(0, testController->floatingWindowTargets_.size());
951e0dac50fSopenharmony_ci}
952e0dac50fSopenharmony_ci
953e0dac50fSopenharmony_ci/*
954e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationTargetsUpdate02
955e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationTargetsUpdate success
956e0dac50fSopenharmony_ci * @tc.type: FUNC
957e0dac50fSopenharmony_ci */
958e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationTargetsUpdate02, Function | SmallTest | Level2)
959e0dac50fSopenharmony_ci{
960e0dac50fSopenharmony_ci    std::vector<uint32_t> fullScreenWinIds;
961e0dac50fSopenharmony_ci    std::vector<uint32_t> floatWinIds;
962e0dac50fSopenharmony_ci    fullScreenWinIds.push_back(2); // 2 is windowId
963e0dac50fSopenharmony_ci    floatWinIds.push_back(2); // 2 is windowId
964e0dac50fSopenharmony_ci    RemoteAnimation::NotifyAnimationTargetsUpdate(fullScreenWinIds, floatWinIds); // CreateWindowAnimationTarget nullptr
965e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
966e0dac50fSopenharmony_ci    RSIWindowAnimationControllerMocker* testController = reinterpret_cast<RSIWindowAnimationControllerMocker*>(
967e0dac50fSopenharmony_ci        animationController_.GetRefPtr());
968e0dac50fSopenharmony_ci    EXPECT_EQ(nullptr, testController->animationTarget_);
969e0dac50fSopenharmony_ci    EXPECT_EQ(0, testController->floatingWindowTargets_.size());
970e0dac50fSopenharmony_ci
971e0dac50fSopenharmony_ci    fullScreenWinIds.push_back(node_->GetWindowId()); // 1, 2 in vector
972e0dac50fSopenharmony_ci    floatWinIds.push_back(node_->GetWindowId()); // CreateWindowAnimationTarget success
973e0dac50fSopenharmony_ci    RemoteAnimation::NotifyAnimationTargetsUpdate(fullScreenWinIds, floatWinIds);
974e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
975e0dac50fSopenharmony_ci    testController = reinterpret_cast<RSIWindowAnimationControllerMocker*>(
976e0dac50fSopenharmony_ci        animationController_.GetRefPtr());
977e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, testController->animationTarget_);
978e0dac50fSopenharmony_ci    EXPECT_EQ(1, testController->floatingWindowTargets_.size());
979e0dac50fSopenharmony_ci}
980e0dac50fSopenharmony_ci
981e0dac50fSopenharmony_ci/*
982e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationScreenUnlock01
983e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationScreenUnlock success
984e0dac50fSopenharmony_ci * @tc.type: FUNC
985e0dac50fSopenharmony_ci */
986e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationScreenUnlock01, Function | SmallTest | Level2)
987e0dac50fSopenharmony_ci{
988e0dac50fSopenharmony_ci    std::function<void(void)> callback = nullptr;
989e0dac50fSopenharmony_ci    WMError ret = RemoteAnimation::NotifyAnimationScreenUnlock(callback, nullptr);
990e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NO_MEM, ret);
991e0dac50fSopenharmony_ci
992e0dac50fSopenharmony_ci    callback = []() {};
993e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationScreenUnlock(callback, node_);
994e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret);
995e0dac50fSopenharmony_ci
996e0dac50fSopenharmony_ci    RemoteAnimation::windowAnimationController_ = nullptr;
997e0dac50fSopenharmony_ci    ret = RemoteAnimation::NotifyAnimationScreenUnlock(callback, node_);
998e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NO_REMOTE_ANIMATION, ret);
999e0dac50fSopenharmony_ci}
1000e0dac50fSopenharmony_ci
1001e0dac50fSopenharmony_ci/*
1002e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationUpdateWallpaper01
1003e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationUpdateWallpaper success
1004e0dac50fSopenharmony_ci * @tc.type: FUNC
1005e0dac50fSopenharmony_ci */
1006e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationUpdateWallpaper01, Function | SmallTest | Level2)
1007e0dac50fSopenharmony_ci{
1008e0dac50fSopenharmony_ci    RemoteAnimation::NotifyAnimationUpdateWallpaper(node_);
1009e0dac50fSopenharmony_ci    RSIWindowAnimationControllerMocker* testController = reinterpret_cast<RSIWindowAnimationControllerMocker*>(
1010e0dac50fSopenharmony_ci        animationController_.GetRefPtr());
1011e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, testController->animationTarget_);
1012e0dac50fSopenharmony_ci
1013e0dac50fSopenharmony_ci    testController->animationTarget_ = nullptr;
1014e0dac50fSopenharmony_ci    RemoteAnimation::windowAnimationController_ = nullptr;
1015e0dac50fSopenharmony_ci    RemoteAnimation::NotifyAnimationUpdateWallpaper(node_);
1016e0dac50fSopenharmony_ci    EXPECT_EQ(nullptr, testController->animationTarget_);
1017e0dac50fSopenharmony_ci}
1018e0dac50fSopenharmony_ci
1019e0dac50fSopenharmony_ci/*
1020e0dac50fSopenharmony_ci * @tc.name: CreateAnimationFinishedCallback01
1021e0dac50fSopenharmony_ci * @tc.desc: CreateAnimationFinishedCallback
1022e0dac50fSopenharmony_ci * @tc.type: FUNC
1023e0dac50fSopenharmony_ci */
1024e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, CreateAnimationFinishedCallback01, Function | SmallTest | Level2)
1025e0dac50fSopenharmony_ci{
1026e0dac50fSopenharmony_ci    std::function<void(void)> callback = nullptr;
1027e0dac50fSopenharmony_ci    EXPECT_EQ(nullptr, RemoteAnimation::CreateAnimationFinishedCallback(callback, node_));
1028e0dac50fSopenharmony_ci
1029e0dac50fSopenharmony_ci    bool testFlag = false;
1030e0dac50fSopenharmony_ci    callback = [&testFlag]() { testFlag = true; };
1031e0dac50fSopenharmony_ci    auto finishCallback = RemoteAnimation::CreateAnimationFinishedCallback(callback, node_);
1032e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
1033e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished();
1034e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
1035e0dac50fSopenharmony_ci    EXPECT_EQ(true, testFlag);
1036e0dac50fSopenharmony_ci
1037e0dac50fSopenharmony_ci    wmsTaskHandler_ = nullptr;
1038e0dac50fSopenharmony_ci    RemoteAnimation::wmsTaskHandler_ = wmsTaskHandler_;
1039e0dac50fSopenharmony_ci    callback = [&testFlag]() { testFlag = false; };
1040e0dac50fSopenharmony_ci    finishCallback = RemoteAnimation::CreateAnimationFinishedCallback(callback, node_);
1041e0dac50fSopenharmony_ci    EXPECT_NE(nullptr, finishCallback);
1042e0dac50fSopenharmony_ci    finishCallback->OnAnimationFinished();
1043e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
1044e0dac50fSopenharmony_ci    EXPECT_EQ(true, testFlag);
1045e0dac50fSopenharmony_ci}
1046e0dac50fSopenharmony_ci
1047e0dac50fSopenharmony_ci/*
1048e0dac50fSopenharmony_ci * @tc.name: GetWindowAnimationTargets01
1049e0dac50fSopenharmony_ci * @tc.desc: GetWindowAnimationTargets for null window root
1050e0dac50fSopenharmony_ci * @tc.type: FUNC
1051e0dac50fSopenharmony_ci */
1052e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, GetWindowAnimationTargets01, Function | SmallTest | Level2)
1053e0dac50fSopenharmony_ci{
1054e0dac50fSopenharmony_ci    RemoteAnimation::windowRoot_ = nullptr;
1055e0dac50fSopenharmony_ci    std::vector<uint32_t> missionIds;
1056e0dac50fSopenharmony_ci    std::vector<sptr<RSWindowAnimationTarget>> targets;
1057e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_ERROR_NO_MEM, RemoteAnimation::GetWindowAnimationTargets(missionIds, targets));
1058e0dac50fSopenharmony_ci}
1059e0dac50fSopenharmony_ci
1060e0dac50fSopenharmony_ci/*
1061e0dac50fSopenharmony_ci * @tc.name: GetWindowAnimationTargets02
1062e0dac50fSopenharmony_ci * @tc.desc: GetWindowAnimationTargets for not exit mission
1063e0dac50fSopenharmony_ci * @tc.type: FUNC
1064e0dac50fSopenharmony_ci */
1065e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, GetWindowAnimationTargets02, Function | SmallTest | Level2)
1066e0dac50fSopenharmony_ci{
1067e0dac50fSopenharmony_ci    std::vector<uint32_t> missionIds;
1068e0dac50fSopenharmony_ci    missionIds.push_back(1);
1069e0dac50fSopenharmony_ci    std::vector<sptr<RSWindowAnimationTarget>> targets;
1070e0dac50fSopenharmony_ci    WMError ret = RemoteAnimation::GetWindowAnimationTargets(missionIds, targets);
1071e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret);
1072e0dac50fSopenharmony_ci    EXPECT_EQ(true, targets.empty());
1073e0dac50fSopenharmony_ci}
1074e0dac50fSopenharmony_ci
1075e0dac50fSopenharmony_ci/*
1076e0dac50fSopenharmony_ci * @tc.name: GetWindowAnimationTargets03
1077e0dac50fSopenharmony_ci * @tc.desc: GetWindowAnimationTargets successful
1078e0dac50fSopenharmony_ci * @tc.type: FUNC
1079e0dac50fSopenharmony_ci */
1080e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, GetWindowAnimationTargets03, Function | SmallTest | Level2)
1081e0dac50fSopenharmony_ci{
1082e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = new WindowNode(CreateWindowProperty(1)); // 1 is windowId
1083e0dac50fSopenharmony_ci    srcNode->abilityInfo_.missionId_ = 1;
1084e0dac50fSopenharmony_ci    srcNode->surfaceNode_ = CreateRSSurfaceNode(0);
1085e0dac50fSopenharmony_ci    windowRoot_->windowNodeMap_[1] = srcNode;
1086e0dac50fSopenharmony_ci    std::vector<uint32_t> missionIds;
1087e0dac50fSopenharmony_ci    missionIds.push_back(1);
1088e0dac50fSopenharmony_ci    std::vector<sptr<RSWindowAnimationTarget>> targets;
1089e0dac50fSopenharmony_ci    WMError ret = RemoteAnimation::GetWindowAnimationTargets(missionIds, targets);
1090e0dac50fSopenharmony_ci    EXPECT_EQ(WMError::WM_OK, ret);
1091e0dac50fSopenharmony_ci    ASSERT_GE(targets.size(), 1);
1092e0dac50fSopenharmony_ci    ASSERT_NE(targets[0], nullptr);
1093e0dac50fSopenharmony_ci    EXPECT_EQ(true, targets[0]->missionId_ == 1);
1094e0dac50fSopenharmony_ci    usleep(SLEEP_TIME_IN_US);
1095e0dac50fSopenharmony_ci}
1096e0dac50fSopenharmony_ci
1097e0dac50fSopenharmony_ci/*
1098e0dac50fSopenharmony_ci * @tc.name: GetAndDrawSnapShot
1099e0dac50fSopenharmony_ci * @tc.desc: GetWindowAnimationTargets successful
1100e0dac50fSopenharmony_ci * @tc.type: FUNC
1101e0dac50fSopenharmony_ci */
1102e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, GetAndDrawSnapShot, Function | SmallTest | Level2)
1103e0dac50fSopenharmony_ci{
1104e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = new WindowNode();
1105e0dac50fSopenharmony_ci    std::shared_ptr<Media::PixelMap> pixelMap = std::make_shared<Media::PixelMap>();
1106e0dac50fSopenharmony_ci    bool snapSucc = SurfaceDraw::GetSurfaceSnapshot(srcNode->surfaceNode_, pixelMap, SNAPSHOT_TIMEOUT_MS, 1.0, 1.0);
1107e0dac50fSopenharmony_ci    ASSERT_FALSE(snapSucc);
1108e0dac50fSopenharmony_ci}
1109e0dac50fSopenharmony_ci
1110e0dac50fSopenharmony_ci/*
1111e0dac50fSopenharmony_ci * @tc.name: GetExpectRect
1112e0dac50fSopenharmony_ci * @tc.desc: GetWindowAnimationTargets successful
1113e0dac50fSopenharmony_ci * @tc.type: FUNC
1114e0dac50fSopenharmony_ci */
1115e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, GetExpectRect, Function | SmallTest | Level2)
1116e0dac50fSopenharmony_ci{
1117e0dac50fSopenharmony_ci    sptr<WindowNode> dstNode = new WindowNode();
1118e0dac50fSopenharmony_ci    std::vector<uint32_t> missionIds;
1119e0dac50fSopenharmony_ci    sptr<RSWindowAnimationTarget> dstTarget;
1120e0dac50fSopenharmony_ci    std::vector<sptr<RSWindowAnimationTarget>> targets;
1121e0dac50fSopenharmony_ci    auto avoidRect = windowRoot_->GetDisplayRectWithoutSystemBarAreas(dstNode);
1122e0dac50fSopenharmony_ci    auto result = WindowHelper::IsEmptyRect(avoidRect);
1123e0dac50fSopenharmony_ci    ASSERT_FALSE(result);
1124e0dac50fSopenharmony_ci    RemoteAnimation::GetExpectRect(dstNode, dstTarget);
1125e0dac50fSopenharmony_ci}
1126e0dac50fSopenharmony_ci
1127e0dac50fSopenharmony_ci/*
1128e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationAbilityDied
1129e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationAbilityDied for null window root
1130e0dac50fSopenharmony_ci * @tc.type: FUNC
1131e0dac50fSopenharmony_ci */
1132e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationAbilityDied, Function | SmallTest | Level2)
1133e0dac50fSopenharmony_ci{
1134e0dac50fSopenharmony_ci    sptr<WindowTransitionInfo> info = new WindowTransitionInfo();
1135e0dac50fSopenharmony_ci    RemoteAnimation::NotifyAnimationAbilityDied(info);
1136e0dac50fSopenharmony_ci    std::vector<sptr<RSWindowAnimationTarget>> targets;
1137e0dac50fSopenharmony_ci    EXPECT_EQ(true, targets.empty());
1138e0dac50fSopenharmony_ci}
1139e0dac50fSopenharmony_ci
1140e0dac50fSopenharmony_ci/*
1141e0dac50fSopenharmony_ci * @tc.name: NotifyAnimationMinimize
1142e0dac50fSopenharmony_ci * @tc.desc: NotifyAnimationMinimize
1143e0dac50fSopenharmony_ci * @tc.type: FUNC
1144e0dac50fSopenharmony_ci */
1145e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, NotifyAnimationMinimize, Function | SmallTest | Level2)
1146e0dac50fSopenharmony_ci{
1147e0dac50fSopenharmony_ci    sptr<WindowTransitionInfo> srcInfo = new WindowTransitionInfo();
1148e0dac50fSopenharmony_ci    sptr<WindowNode> srcNode = new WindowNode();
1149e0dac50fSopenharmony_ci    sptr<RSWindowAnimationFinishedCallback> finishedCallback = RemoteAnimation::CreateHideAnimationFinishedCallback(
1150e0dac50fSopenharmony_ci        srcNode, TransitionEvent::MINIMIZE);
1151e0dac50fSopenharmony_ci    finishedCallback = nullptr;
1152e0dac50fSopenharmony_ci    ASSERT_EQ(finishedCallback, nullptr);
1153e0dac50fSopenharmony_ci    auto result = RemoteAnimation::NotifyAnimationMinimize(srcInfo, srcNode);
1154e0dac50fSopenharmony_ci    ASSERT_EQ(result, WMError::WM_ERROR_NO_MEM);
1155e0dac50fSopenharmony_ci}
1156e0dac50fSopenharmony_ci
1157e0dac50fSopenharmony_ci/*
1158e0dac50fSopenharmony_ci * @tc.name: CreateAnimationFinishedCallback02
1159e0dac50fSopenharmony_ci * @tc.desc: CreateAnimationFinishedCallback
1160e0dac50fSopenharmony_ci * @tc.type: FUNC
1161e0dac50fSopenharmony_ci */
1162e0dac50fSopenharmony_ciHWTEST_F(RemoteAnimationTest, CreateAnimationFinishedCallback02, Function | SmallTest | Level2)
1163e0dac50fSopenharmony_ci{
1164e0dac50fSopenharmony_ci    std::function<void(void)> callback;
1165e0dac50fSopenharmony_ci    sptr<WindowNode> windowNode = new WindowNode();
1166e0dac50fSopenharmony_ci    std::string timeOutTaskName;
1167e0dac50fSopenharmony_ci    wptr<WindowNode> weakNode = windowNode;
1168e0dac50fSopenharmony_ci    auto timeoutFunc = [callback, timeOutTaskName, weakNode]()
1169e0dac50fSopenharmony_ci    {
1170e0dac50fSopenharmony_ci        callback();
1171e0dac50fSopenharmony_ci        auto node = weakNode.promote();
1172e0dac50fSopenharmony_ci    };
1173e0dac50fSopenharmony_ci    std::vector<sptr<RSWindowAnimationTarget>> targets;
1174e0dac50fSopenharmony_ci    EXPECT_EQ(true, targets.empty());
1175e0dac50fSopenharmony_ci}
1176e0dac50fSopenharmony_ci}
1177e0dac50fSopenharmony_ci}
1178e0dac50fSopenharmony_ci}
1179