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 #include "local_abilitys_test.h"
16
17 #include "local_abilitys.h"
18 #include "mock_iro_sendrequest.h"
19 #include "test_log.h"
20
21 using namespace std;
22 using namespace testing;
23 using namespace testing::ext;
24 using namespace OHOS;
25
26 namespace OHOS {
27 namespace {
28 constexpr uint32_t SAID = 1499;
29 }
SetUpTestCase()30 void LocalAbilitysTest::SetUpTestCase()
31 {
32 DTEST_LOG << "SetUpTestCase" << std::endl;
33 }
34
TearDownTestCase()35 void LocalAbilitysTest::TearDownTestCase()
36 {
37 DTEST_LOG << "TearDownTestCase" << std::endl;
38 }
39
SetUp()40 void LocalAbilitysTest::SetUp()
41 {
42 DTEST_LOG << "SetUp" << std::endl;
43 }
44
TearDown()45 void LocalAbilitysTest::TearDown()
46 {
47 DTEST_LOG << "TearDown" << std::endl;
48 }
49
50 /**
51 * @tc.name: AddAbility001
52 * @tc.desc: AddAbility and check ability
53 * @tc.type: FUNC
54 * @tc.require: I6EOBI
55 */
56 HWTEST_F(LocalAbilitysTest, AddAbility001, TestSize.Level1)
57 {
58 sptr<IRemoteObject> testAbility(new MockIroSendrequesteStub());
59 LocalAbilitys::GetInstance().AddAbility(SAID, testAbility);
60 auto proxy = LocalAbilitys::GetInstance().GetAbility(SAID);
61 EXPECT_TRUE(proxy != nullptr);
62 }
63
64 /**
65 * @tc.name: RemoveAbility001
66 * @tc.desc: RemoveAbility and check ability
67 * @tc.type: FUNC
68 * @tc.require: I6EOBI
69 */
70 HWTEST_F(LocalAbilitysTest, RemoveAbility001, TestSize.Level1)
71 {
72 sptr<IRemoteObject> testAbility(new MockIroSendrequesteStub());
73 LocalAbilitys::GetInstance().AddAbility(SAID, testAbility);
74 LocalAbilitys::GetInstance().RemoveAbility(SAID);
75 auto proxy = LocalAbilitys::GetInstance().GetAbility(SAID);
76 EXPECT_TRUE(proxy == nullptr);
77 }
78 }