• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #include <gtest/gtest.h>
17 #include "service_router_mgr_service.h"
18 
19 #include "hilog_tag_wrapper.h"
20 #include "hilog_wrapper.h"
21 
22 using namespace testing;
23 using namespace testing::ext;
24 using OHOS::DelayedSingleton;
25 
26 namespace OHOS {
27 namespace AbilityRuntime {
28 class ServiceRouterMgrServiceTest : public testing::Test {
29 public:
30     static void SetUpTestCase();
31     static void TearDownTestCase();
32     void SetUp() override;
33     void TearDown() override;
34 public:
35     static std::shared_ptr<ServiceRouterMgrService> serviceRouterMgrService_;
36 };
SetUpTestCase(void)37 void ServiceRouterMgrServiceTest::SetUpTestCase(void)
38 {}
39 
TearDownTestCase(void)40 void ServiceRouterMgrServiceTest::TearDownTestCase(void)
41 {
42     serviceRouterMgrService_->OnStop();
43 }
44 
SetUp()45 void ServiceRouterMgrServiceTest::SetUp()
46 {
47     serviceRouterMgrService_->OnStart();
48 }
49 
TearDown()50 void ServiceRouterMgrServiceTest::TearDown()
51 {}
52 
53 std::shared_ptr<ServiceRouterMgrService> ServiceRouterMgrServiceTest::serviceRouterMgrService_ =
54     DelayedSingleton<ServiceRouterMgrService>::GetInstance();
55 
56 /**
57  * @tc.name: test StartUIExtensionAbility_001
58  * @tc.desc: StartUIExtensionAbility
59  */
60 HWTEST_F(ServiceRouterMgrServiceTest, StartUIExtensionAbility_001, Function | SmallTest | Level0)
61 {
62     TAG_LOGI(AAFwkTag::TEST, "StartUIExtensionAbility_001 start");
63     sptr<SessionInfo> sessionInfo = nullptr;
64     int32_t userId = 1;
65     auto ret = serviceRouterMgrService_->StartUIExtensionAbility(sessionInfo, userId);
66     TAG_LOGI(AAFwkTag::TEST, "StartUIExtensionAbility_001 result %{public}d", ret);
67     TAG_LOGI(AAFwkTag::TEST, "StartUIExtensionAbility_001 end");
68 }
69 
70 /**
71  * @tc.name: test ConnectUIExtensionAbility_001
72  * @tc.desc: ConnectUIExtensionAbility
73  */
74 HWTEST_F(ServiceRouterMgrServiceTest, ConnectUIExtensionAbility_001, Function | SmallTest | Level0)
75 {
76     TAG_LOGI(AAFwkTag::TEST, "ConnectUIExtensionAbility_001 start");
77     Want want;
78     sptr<IAbilityConnection> connect = nullptr;
79     sptr<SessionInfo> sessionInfo = nullptr;
80     int32_t userId = 1;
81     auto ret = serviceRouterMgrService_->ConnectUIExtensionAbility(want, connect, sessionInfo, userId);
82     TAG_LOGI(AAFwkTag::TEST, "ConnectUIExtensionAbility_001 result %{public}d", ret);
83     TAG_LOGI(AAFwkTag::TEST, "ConnectUIExtensionAbility_001 end");
84 }
85 
86 /**
87  * @tc.name: test QueryPurposeInfos_001
88  * @tc.desc: QueryPurposeInfos
89  */
90 HWTEST_F(ServiceRouterMgrServiceTest, QueryPurposeInfos_001, Function | SmallTest | Level0)
91 {
92     TAG_LOGI(AAFwkTag::TEST, "QueryPurposeInfos_001 start");
93     Want want;
94     std::vector<PurposeInfo> purposeInfos;
95     auto ret = serviceRouterMgrService_->QueryPurposeInfos(want, "", purposeInfos);
96     TAG_LOGI(AAFwkTag::TEST, "QueryPurposeInfos_001 result %{public}d", ret);
97     TAG_LOGI(AAFwkTag::TEST, "QueryPurposeInfos_001 end");
98 }
99 
100 /**
101  * @tc.name: test QueryBusinessAbilityInfos_001
102  * @tc.desc: QueryBusinessAbilityInfos
103  */
104 HWTEST_F(ServiceRouterMgrServiceTest, QueryBusinessAbilityInfos_001, Function | SmallTest | Level0)
105 {
106     TAG_LOGI(AAFwkTag::TEST, "QueryBusinessAbilityInfos_001 start");
107     BusinessAbilityFilter filter;
108     filter.businessType = BusinessType::UNSPECIFIED;
109     std::vector<BusinessAbilityInfo> abilityInfos;
110     auto ret = serviceRouterMgrService_->QueryBusinessAbilityInfos(filter, abilityInfos);
111     TAG_LOGI(AAFwkTag::TEST, "QueryBusinessAbilityInfos_001 result %{public}d", ret);
112     TAG_LOGI(AAFwkTag::TEST, "QueryBusinessAbilityInfos_001 end");
113 }
114 }
115 }
116 
117