• 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_stub.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace Rosen {
25 class RSWindowAnimationFinishedCallbackStubMock : public RSWindowAnimationFinishedCallbackStub {
26 public:
27     RSWindowAnimationFinishedCallbackStubMock() = default;
28     virtual ~RSWindowAnimationFinishedCallbackStubMock() = default;
29 
OnAnimationFinished()30     void OnAnimationFinished() override {};
31 };
32 
33 class RSWindowAnimationFinishedCallbackStubTest : public testing::Test {
34 public:
35     static void SetUpTestCase();
36     static void TearDownTestCase();
37     void SetUp() override;
38     void TearDown() override;
39 };
40 
SetUpTestCase()41 void RSWindowAnimationFinishedCallbackStubTest::SetUpTestCase() {}
TearDownTestCase()42 void RSWindowAnimationFinishedCallbackStubTest::TearDownTestCase() {}
SetUp()43 void RSWindowAnimationFinishedCallbackStubTest::SetUp() {}
TearDown()44 void RSWindowAnimationFinishedCallbackStubTest::TearDown() {}
45 
46 /**
47  * @tc.name: OnRemoteRequest001
48  * @tc.desc: Verify the OnRemoteRequest
49  * @tc.type:FUNC
50  */
51 HWTEST_F(RSWindowAnimationFinishedCallbackStubTest, OnRemoteRequest001, TestSize.Level1)
52 {
53     GTEST_LOG_(INFO) << "RSWindowAnimationFinishedCallbackStubTest OnRemoteRequest001 start";
54     MessageParcel data;
55     MessageParcel reply;
56     MessageOption option;
57 
58     auto finishedCallbackStub = std::make_shared<RSWindowAnimationFinishedCallbackStubMock>();
59     int res = finishedCallbackStub->OnRemoteRequest(
60         RSIWindowAnimationFinishedCallback::ON_ANIMATION_FINISHED, data, reply, option);
61     ASSERT_EQ(res, ERR_INVALID_STATE);
62     GTEST_LOG_(INFO) << "RSWindowAnimationFinishedCallbackStubTest OnRemoteRequest001 end";
63 }
64 
65 /**
66  * @tc.name: OnRemoteRequest002
67  * @tc.desc: Verify the OnRemoteRequest
68  * @tc.type:FUNC
69  */
70 HWTEST_F(RSWindowAnimationFinishedCallbackStubTest, OnRemoteRequest002, TestSize.Level1)
71 {
72     GTEST_LOG_(INFO) << "RSWindowAnimationFinishedCallbackStubTest OnRemoteRequest002 start";
73     MessageParcel data;
74     MessageParcel reply;
75     MessageOption option;
76     data.WriteInterfaceToken(RSIWindowAnimationFinishedCallback::GetDescriptor());
77 
78     auto finishedCallbackStub = std::make_shared<RSWindowAnimationFinishedCallbackStubMock>();
79     int res = finishedCallbackStub->OnRemoteRequest(-1, data, reply, option);
80     ASSERT_EQ(res, ERR_UNKNOWN_TRANSACTION);
81     GTEST_LOG_(INFO) << "RSWindowAnimationFinishedCallbackStubTest OnRemoteRequest002 end";
82 }
83 
84 /**
85  * @tc.name: OnRemoteRequest003
86  * @tc.desc: Verify the OnRemoteRequest
87  * @tc.type:FUNC
88  */
89 HWTEST_F(RSWindowAnimationFinishedCallbackStubTest, OnRemoteRequest003, TestSize.Level1)
90 {
91     GTEST_LOG_(INFO) << "RSWindowAnimationFinishedCallbackStubTest OnRemoteRequest003 start";
92     MessageParcel data;
93     MessageParcel reply;
94     MessageOption option;
95     data.WriteInterfaceToken(RSIWindowAnimationFinishedCallback::GetDescriptor());
96 
97     auto finishedCallbackStub = std::make_shared<RSWindowAnimationFinishedCallbackStubMock>();
98     int res = finishedCallbackStub->OnRemoteRequest(
99         RSIWindowAnimationFinishedCallback::ON_ANIMATION_FINISHED, data, reply, option);
100     ASSERT_EQ(res, ERR_NONE);
101     GTEST_LOG_(INFO) << "RSWindowAnimationFinishedCallbackStubTest OnRemoteRequest003 end";
102 }
103 } // namespace Rosen
104 } // namespace OHOS