• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "gtest/gtest.h"
17 
18 #include "rs_window_animation_finished_callback_proxy.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace Rosen {
25 class MockIRemoteObject : public IRemoteObject {
26 public:
MockIRemoteObject()27     MockIRemoteObject() : IRemoteObject {u"MockIRemoteObject"}
28     {
29     }
30 
~MockIRemoteObject()31     ~MockIRemoteObject()
32     {
33     }
34 
GetObjectRefCount()35     int32_t GetObjectRefCount()
36     {
37         return 0;
38     }
39 
SendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)40     int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
41     {
42         return sendRequestResult_;
43     }
44 
IsProxyObject() const45     bool IsProxyObject() const
46     {
47         return true;
48     }
49 
CheckObjectLegality() const50     bool CheckObjectLegality() const
51     {
52         return true;
53     }
54 
AddDeathRecipient(const sptr<DeathRecipient> & recipient)55     bool AddDeathRecipient(const sptr<DeathRecipient> &recipient)
56     {
57         return true;
58     }
59 
RemoveDeathRecipient(const sptr<DeathRecipient> & recipient)60     bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient)
61     {
62         return true;
63     }
64 
AsInterface()65     sptr<IRemoteBroker> AsInterface()
66     {
67         return nullptr;
68     }
69 
Dump(int fd,const std::vector<std::u16string> & args)70     int Dump(int fd, const std::vector<std::u16string> &args)
71     {
72         return 0;
73     }
74 
75     int sendRequestResult_ = 0;
76     int count_ = 0;
77 };
78 
79 class RSWindowAnimationFinishedCallbackProxyTest : public testing::Test {
80 public:
81     static void SetUpTestCase();
82     static void TearDownTestCase();
83     void SetUp() override;
84     void TearDown() override;
85 };
86 
SetUpTestCase()87 void RSWindowAnimationFinishedCallbackProxyTest::SetUpTestCase() {}
TearDownTestCase()88 void RSWindowAnimationFinishedCallbackProxyTest::TearDownTestCase() {}
SetUp()89 void RSWindowAnimationFinishedCallbackProxyTest::SetUp() {}
TearDown()90 void RSWindowAnimationFinishedCallbackProxyTest::TearDown() {}
91 
92 /**
93  * @tc.name: OnAnimationFinished001
94  * @tc.desc: Verify the OnAnimationFinished
95  * @tc.type:FUNC
96  */
97 HWTEST_F(RSWindowAnimationFinishedCallbackProxyTest, OnAnimationFinished001, TestSize.Level1)
98 {
99     GTEST_LOG_(INFO) << "RSWindowAnimationStubTest OnAnimationFinished001 start";
100     auto finishCallbackProxy = std::make_shared<RSWindowAnimationFinishedCallbackProxy>(nullptr);
101     ASSERT_TRUE(finishCallbackProxy != nullptr);
102     finishCallbackProxy->OnAnimationFinished();
103     GTEST_LOG_(INFO) << "RSWindowAnimationStubTest OnAnimationFinished001 end";
104 }
105 
106 /**
107  * @tc.name: OnAnimationFinished002
108  * @tc.desc: Verify the OnAnimationFinished
109  * @tc.type:FUNC
110  */
111 HWTEST_F(RSWindowAnimationFinishedCallbackProxyTest, OnAnimationFinished002, TestSize.Level1)
112 {
113     GTEST_LOG_(INFO) << "RSWindowAnimationStubTest OnAnimationFinished002 start";
114     sptr<MockIRemoteObject> remoteMocker = new MockIRemoteObject();
115     ASSERT_TRUE(remoteMocker != nullptr);
116     auto finishCallbackProxy = std::make_shared<RSWindowAnimationFinishedCallbackProxy>(remoteMocker);
117     ASSERT_TRUE(finishCallbackProxy != nullptr);
118     finishCallbackProxy->OnAnimationFinished();
119     GTEST_LOG_(INFO) << "RSWindowAnimationStubTest OnAnimationFinished002 end";
120 }
121 } // namespace Rosen
122 } // namespace OHOS