1 /*
2  * Copyright (c) 2024 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 #include <gtest/gtest.h>
16 
17 #define private public
18 #define protected public
19 #include "iremote_stub.h"
20 #include "mock_render_state_observer_stub.h"
21 #include "parcel.h"
22 #undef protected
23 #undef private
24 
25 using namespace testing;
26 using namespace testing::ext;
27 
28 namespace OHOS {
29 namespace AppExecFwk {
30 class RenderStateObserverStubTest : public testing::Test {
31 public:
32     static void SetUpTestCase(void);
33     static void TearDownTestCase(void);
34     void SetUp();
35     void TearDown();
36     sptr<RenderStateObserverStub> observerStub_ {nullptr};
37 };
38 
SetUpTestCase(void)39 void RenderStateObserverStubTest::SetUpTestCase(void)
40 {}
41 
TearDownTestCase(void)42 void RenderStateObserverStubTest::TearDownTestCase(void)
43 {}
44 
SetUp()45 void RenderStateObserverStubTest::SetUp()
46 {}
47 
TearDown()48 void RenderStateObserverStubTest::TearDown()
49 {}
50 
51 /**
52  * @tc.number: OnRenderStateChangedInner_0100
53  * @tc.desc: Test when params is not nullptr.
54  * @tc.type: FUNC
55  */
56 HWTEST_F(RenderStateObserverStubTest, OnRenderStateChangedInner_0100, TestSize.Level1)
57 {
58     auto stub = new (std::nothrow) MockRenderStateObserverStub();
59     EXPECT_TRUE(stub);
60     EXPECT_CALL(*stub, OnRenderStateChanged(_)).Times(1);
61     MessageParcel data;
62     RenderStateData renderStateData;
63     data.WriteParcelable(&renderStateData);
64     MessageParcel reply;
65     auto result = stub->OnRenderStateChangedInner(data, reply);
66     EXPECT_EQ(NO_ERROR, result);
67 }
68 
69 } // namespace AppExecFwk
70 } // namespace OHOS