1 /*
2  * Copyright (C) 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 "system_ability_definition.h"
18 #include "if_system_ability_manager.h"
19 #include "iservice_registry.h"
20 #include "ipc_skeleton.h"
21 #include "rpc_test.h"
22 
23 namespace OHOS {
24 using namespace testing::ext;
25 using namespace OHOS;
26 
27 class RpcServerTest : public testing::Test {
28 public:
29     static void SetUpTestCase(void);
30     static void TearDownTestCase(void);
31 };
32 
SetUpTestCase()33 void RpcServerTest::SetUpTestCase() {}
34 
TearDownTestCase()35 void RpcServerTest::TearDownTestCase()
36 {
37     IPCSkeleton::JoinWorkThread();
38 }
39 
40 HWTEST_F(RpcServerTest, function_test_001, TestSize.Level1)
41 {
42     auto saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
43     ASSERT_TRUE(saMgr != nullptr);
44 
45     ISystemAbilityManager::SAExtraProp saExtra;
46     saExtra.isDistributed = true;
47     int result = saMgr->AddSystemAbility(RPC_TEST_SERVICE, new RpcFooStub(), saExtra);
48     ASSERT_EQ(result, 0);
49 }
50 
51 HWTEST_F(RpcServerTest, function_test_002, TestSize.Level1)
52 {
53     auto saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
54     ASSERT_TRUE(saMgr != nullptr);
55 
56     int result = saMgr->AddSystemAbility(RPC_TEST_SERVICE2, new RpcFooStub());
57     ASSERT_EQ(result, 0);
58 }
59 }