1 /*
2 * Copyright (c) 2022-2022 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 #include "display_manager_agent_stub.h"
18 #include "display_manager_agent_default.h"
19
20
21 using namespace testing;
22 using namespace testing::ext;
23
24 namespace OHOS {
25 namespace Rosen {
26
27 class DisplayManagerAgentStubTest : public testing::Test {
28 public:
29 static void SetUpTestCase();
30 static void TearDownTestCase();
31 void SetUp() override;
32 void TearDown() override;
33 sptr<DisplayManagerAgentStub> stub_;
34 };
35
SetUpTestCase()36 void DisplayManagerAgentStubTest::SetUpTestCase()
37 {
38 }
39
TearDownTestCase()40 void DisplayManagerAgentStubTest::TearDownTestCase()
41 {
42 }
43
SetUp()44 void DisplayManagerAgentStubTest::SetUp()
45 {
46 stub_ = new DisplayManagerAgentDefault();
47 }
48
TearDown()49 void DisplayManagerAgentStubTest::TearDown()
50 {
51 }
52
53 namespace {
54 /**
55 * @tc.name: OnRemoteRequest01
56 * @tc.desc: TRANS_ID_ON_DISPLAY_CONNECT
57 * @tc.type: FUNC
58 */
59 HWTEST_F(DisplayManagerAgentStubTest, OnRemoteRequest01, Function | SmallTest | Level1)
60 {
61 MessageParcel data;
62 MessageParcel reply;
63 MessageOption option;
64
65 data.WriteInterfaceToken(DisplayManagerAgentStub::GetDescriptor());
66 sptr<DisplayInfo> displayInfo;
67 data.WriteParcelable(displayInfo.GetRefPtr());
68 uint32_t code = static_cast<uint32_t>(IDisplayManagerAgent::TRANS_ID_ON_DISPLAY_CONNECT);
69 int res = stub_->OnRemoteRequest(code, data, reply, option);
70 EXPECT_EQ(res, 0);
71 }
72
73 /**
74 * @tc.name: OnRemoteRequest02
75 * @tc.desc: TRANS_ID_ON_DISPLAY_DISCONNECT
76 * @tc.type: FUNC
77 */
78 HWTEST_F(DisplayManagerAgentStubTest, OnRemoteRequest02, Function | SmallTest | Level1)
79 {
80 MessageParcel data;
81 MessageParcel reply;
82 MessageOption option;
83
84 data.WriteInterfaceToken(DisplayManagerAgentStub::GetDescriptor());
85 DisplayId displayId = 0;
86 data.WriteUint64(displayId);
87 uint32_t code = static_cast<uint32_t>(IDisplayManagerAgent::TRANS_ID_ON_DISPLAY_DISCONNECT);
88 int res = stub_->OnRemoteRequest(code, data, reply, option);
89 EXPECT_EQ(res, 0);
90 }
91
92 }
93 } // namespace Rosen
94 } // namespace OHOS