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 "if_system_ability_manager.h"
18#include "iservice_registry.h"
19#include "itest_transaction_service.h"
20#include "parameter.h"
21#include "system_ability_definition.h"
22#include "test_log.h"
23
24#define private public
25#include "system_ability_manager.h"
26
27namespace OHOS {
28namespace SAMGR {
29namespace {
30constexpr int32_t LOOP_SIZE = 1000;
31}
32
33class SystemAbilityManagerTest : public testing::Test {
34public:
35    static void SetUpTestCase();
36    static void TearDownTestCase();
37    void SetUp();
38    void TearDown();
39};
40
41void SystemAbilityManagerTest::SetUpTestCase()
42{
43    DTEST_LOG << "SystemAbilityManagerTest SetUpTestCase" << std::endl;
44}
45
46void SystemAbilityManagerTest::TearDownTestCase()
47{
48    DTEST_LOG << "SystemAbilityManagerTest TearDownTestCase" << std::endl;
49}
50
51void SystemAbilityManagerTest::SetUp()
52{
53    DTEST_LOG << "SystemAbilityManagerTest SetUp" << std::endl;
54}
55
56void SystemAbilityManagerTest::TearDown()
57{
58    DTEST_LOG << "SystemAbilityManagerTest TearDown" << std::endl;
59}
60
61/**
62 * @tc.name: param check samgr ready event
63 * @tc.desc: param check samgr ready event
64 * @tc.type: FUNC
65 */
66HWTEST_F(SystemAbilityManagerTest, SamgrReady001, TestSize.Level1)
67{
68    DTEST_LOG << " SamgrReady001 start " << std::endl;
69    /**
70     * @tc.steps: step1. param check samgr ready event
71     * @tc.expected: step1. param check samgr ready event
72     */
73    auto ret = WaitParameter("bootevent.samgr.ready", "true", 1);
74    ASSERT_EQ(ret, 0);
75}
76
77/**
78 * @tc.name: CheckSystemAbilityTest001
79 * @tc.desc: check system ability with deviceid
80 * @tc.type: FUNC
81 */
82HWTEST_F(SystemAbilityManagerTest, CheckSystemAbilityTest001, TestSize.Level1)
83{
84    DTEST_LOG << " CheckSystemAbilityTest001 start " << std::endl;
85    /**
86     * @tc.steps: step1. get samgr instance
87     * @tc.expected: step1. samgr instance not nullptr
88     */
89    sptr<ISystemAbilityManager> sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
90    ASSERT_TRUE(sm != nullptr);
91    /**
92     * @tc.steps: step2. get system ability with deviceid
93     * @tc.expected: step2. get system ability with deviceid
94     */
95    std::string mockDeviceid = "12345678";
96    sptr<IRemoteObject> ability = sm->CheckSystemAbility(DISTRIBUTED_SCHED_TEST_TT_ID, mockDeviceid);
97    ASSERT_TRUE(ability == nullptr);
98}
99
100/**
101 * @tc.name: CheckSystemAbilityTest002
102 * @tc.desc: check system ability with deviceid
103 * @tc.type: FUNC
104 */
105HWTEST_F(SystemAbilityManagerTest, CheckSystemAbilityTest002, TestSize.Level1)
106{
107    DTEST_LOG << " CheckSystemAbilityTest002 start " << std::endl;
108    /**
109     * @tc.steps: step1. get samgr instance
110     * @tc.expected: step1. samgr instance not nullptr
111     */
112    sptr<ISystemAbilityManager> sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
113    ASSERT_TRUE(sm != nullptr);
114    /**
115     * @tc.steps: step2. get system ability with deviceid
116     * @tc.expected: step2. get system ability with deviceid
117     */
118    std::string mockDeviceid = "012345679000111";
119    int32_t mockSaid = 0;
120    sptr<IRemoteObject> ability = sm->CheckSystemAbility(mockSaid, mockDeviceid);
121    ASSERT_TRUE(ability == nullptr);
122}
123
124/**
125 * @tc.name: CheckSystemAbilityTest003
126 * @tc.desc: check system ability with deviceid
127 * @tc.type: FUNC
128 */
129HWTEST_F(SystemAbilityManagerTest, CheckSystemAbilityTest003, TestSize.Level1)
130{
131    DTEST_LOG << " CheckSystemAbilityTest003 start " << std::endl;
132    /**
133     * @tc.steps: step1. get samgr instance
134     * @tc.expected: step1. samgr instance not nullptr
135     */
136    sptr<ISystemAbilityManager> sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
137    /**
138     * @tc.steps: step2. get system ability with deviceid
139     * @tc.expected: step2. get system ability with deviceid
140     */
141    ASSERT_TRUE(sm != nullptr);
142    int32_t mockSaid = -1;
143    sptr<IRemoteObject> ability = sm->CheckSystemAbility(mockSaid, "");
144    ASSERT_TRUE(ability == nullptr);
145}
146
147/**
148 * @tc.name: CheckSystemAbilityTest004
149 * @tc.desc: check system ability with deviceid
150 * @tc.type: FUNC
151 */
152HWTEST_F(SystemAbilityManagerTest, CheckSystemAbilityTest004, TestSize.Level3)
153{
154    DTEST_LOG << " CheckSystemAbilityTest004 start " << std::endl;
155    /**
156     * @tc.steps: step1. get samgr instance
157     * @tc.expected: step1. samgr instance not nullptr
158     */
159    sptr<ISystemAbilityManager> sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
160    ASSERT_TRUE(sm != nullptr);
161    /**
162     * @tc.steps: step2. get system ability with deviceid
163     * @tc.expected: step2. get system ability with deviceid
164     */
165    for (int32_t i = 0; i < LOOP_SIZE; ++i) {
166        sptr<IRemoteObject> ability = sm->CheckSystemAbility(DISTRIBUTED_SCHED_TEST_TT_ID, "");
167        ASSERT_TRUE(ability == nullptr);
168    }
169}
170
171/**
172 * @tc.name: CheckSystemAbilityTest005
173 * @tc.desc: check system ability with deviceid
174 * @tc.type: FUNC
175 */
176HWTEST_F(SystemAbilityManagerTest, CheckSystemAbilityTest005, TestSize.Level1)
177{
178    DTEST_LOG << " CheckSystemAbilityTest005 start " << std::endl;
179    /**
180     * @tc.steps: step1. get samgr instance
181     * @tc.expected: step1. samgr instance not nullptr
182     */
183    sptr<ISystemAbilityManager> sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
184    ASSERT_TRUE(sm != nullptr);
185    /**
186     * @tc.steps: step2. get system ability with mock said
187     * @tc.expected: step2. not get sa
188     */
189    int32_t mockSaid = -1;
190    bool isExist = true;
191    sptr<IRemoteObject> ability = sm->CheckSystemAbility(mockSaid, isExist);
192    ASSERT_TRUE(ability == nullptr);
193}
194
195/**
196 * @tc.name: CheckSystemAbilityTest006
197 * @tc.desc: check system ability with deviceid
198 * @tc.type: FUNC
199 */
200HWTEST_F(SystemAbilityManagerTest, CheckSystemAbilityTest006, TestSize.Level1)
201{
202    DTEST_LOG << " CheckSystemAbilityTest006 start " << std::endl;
203    /**
204     * @tc.steps: step1. get samgr instance
205     * @tc.expected: step1. samgr instance not nullptr
206     */
207    sptr<ISystemAbilityManager> sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
208    ASSERT_TRUE(sm != nullptr);
209    /**
210     * @tc.steps: step2. get system ability with mock said
211     * @tc.expected: step2. not get sa
212     */
213    int32_t mockSaid = -1;
214    bool isExist = false;
215    sptr<IRemoteObject> ability = sm->CheckSystemAbility(mockSaid, isExist);
216    ASSERT_TRUE(ability == nullptr);
217}
218
219/**
220 * @tc.name: CheckSystemAbilityTest007
221 * @tc.desc: check system ability with deviceid
222 * @tc.type: FUNC
223 */
224HWTEST_F(SystemAbilityManagerTest, CheckSystemAbilityTest007, TestSize.Level1)
225{
226    DTEST_LOG << " CheckSystemAbilityTest007 start " << std::endl;
227    /**
228     * @tc.steps: step1. get samgr instance
229     * @tc.expected: step1. samgr instance not nullptr
230     */
231    sptr<ISystemAbilityManager> sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
232    ASSERT_TRUE(sm != nullptr);
233    /**
234     * @tc.steps: step2. get system ability with mock said
235     * @tc.expected: step2. not get sa
236     */
237    bool isExist = false;
238    sptr<IRemoteObject> ability = sm->CheckSystemAbility(DISTRIBUTED_SCHED_TEST_TT_ID, isExist);
239    ASSERT_TRUE(ability == nullptr);
240}
241
242/**
243 * @tc.name: CheckSystemAbilityTest008
244 * @tc.desc: check system ability with deviceid
245 * @tc.type: FUNC
246 */
247HWTEST_F(SystemAbilityManagerTest, CheckSystemAbilityTest008, TestSize.Level1)
248{
249    DTEST_LOG << " CheckSystemAbilityTest008 start " << std::endl;
250    /**
251     * @tc.steps: step1. get samgr instance
252     * @tc.expected: step1. samgr instance not nullptr
253     */
254    sptr<ISystemAbilityManager> sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
255    ASSERT_TRUE(sm != nullptr);
256    /**
257     * @tc.steps: step2. get system ability with mock said
258     * @tc.expected: step2. not get sa
259     */
260    bool isExist = true;
261    sptr<IRemoteObject> ability = sm->CheckSystemAbility(DISTRIBUTED_SCHED_TEST_TT_ID, isExist);
262    ASSERT_TRUE(ability == nullptr);
263}
264
265/**
266 * @tc.name: AddSystemProcess001
267 * @tc.desc: check add process remoteobject
268 */
269HWTEST_F(SystemAbilityManagerTest, AddSystemProcess001, TestSize.Level1)
270{
271    DTEST_LOG << " AddSystemProcess001 start " << std::endl;
272    /**
273     * @tc.steps: step1. get samgr instance
274     * @tc.expected: step1. samgr instance not nullptr
275     */
276    sptr<ISystemAbilityManager> sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
277    ASSERT_TRUE(sm != nullptr);
278    /**
279     * @tc.steps: step2. add system process remote obejct
280     * @tc.expected: step2. add system process remote obejct
281     */
282    int32_t ret = sm->AddSystemProcess("", nullptr);
283    ASSERT_TRUE(ret != ERR_OK);
284}
285
286/**
287 * @tc.name: AddSystemProcess002
288 * @tc.desc: check add process remoteobject
289 * @tc.type: FUNC
290 */
291HWTEST_F(SystemAbilityManagerTest, AddSystemProcess002, TestSize.Level1)
292{
293    DTEST_LOG << " AddSystemProcess002 start " << std::endl;
294    /**
295     * @tc.steps: step1. get samgr instance
296     * @tc.expected: step1. samgr instance not nullptr
297     */
298    sptr<ISystemAbilityManager> sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
299    ASSERT_TRUE(sm != nullptr);
300    /**
301     * @tc.steps: step2. add system process remote obejct
302     * @tc.expected: step2. add system process remote obejct
303     */
304    int32_t ret = sm->AddSystemProcess("test_process", nullptr);
305    ASSERT_TRUE(ret != ERR_OK);
306}
307
308/**
309 * @tc.name: AddSystemProcess003
310 * @tc.desc: check add process remoteobject
311 * @tc.type: FUNC
312 */
313HWTEST_F(SystemAbilityManagerTest, AddSystemProcess003, TestSize.Level1)
314{
315    DTEST_LOG << " AddSystemProcess003 start " << std::endl;
316    /**
317     * @tc.steps: step1. get samgr instance
318     * @tc.expected: step1. samgr instance not nullptr
319     */
320    sptr<ISystemAbilityManager> sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
321    ASSERT_TRUE(sm != nullptr);
322    /**
323     * @tc.steps: step2. add system process remote obejct
324     * @tc.expected: step2. add system process remote obejct
325     */
326    int32_t ret = sm->AddSystemProcess("test_process", nullptr);
327    ASSERT_TRUE(ret != ERR_OK);
328}
329
330/**
331 * @tc.name: AddSystemProcess004
332 * @tc.desc: check add system process remoteobject
333 * @tc.type: FUNC
334 */
335HWTEST_F(SystemAbilityManagerTest, AddSystemProcess004, TestSize.Level1)
336{
337    DTEST_LOG << " AddSystemProcess004 start " << std::endl;
338    /**
339     * @tc.steps: step1. get samgr instance
340     * @tc.expected: step1. samgr instance not nullptr
341     */
342    sptr<ISystemAbilityManager> sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
343    ASSERT_TRUE(sm != nullptr);
344    /**
345     * @tc.steps: step2. add system process remote obejct
346     * @tc.expected: step2. add system process remote obejct
347     */
348    for (int32_t i = 0; i < LOOP_SIZE; ++i) {
349        sptr<IRemoteObject> ability = sm->AddSystemProcess("", nullptr);
350        ASSERT_TRUE(ret != ERR_OK);
351    }
352}
353
354/**
355 * @tc.name: RemoveSystemProcess001
356 * @tc.desc: check remove system process remoteobject
357 * @tc.type: FUNC
358 */
359HWTEST_F(SystemAbilityManagerTest, RemoveSystemProcess001, TestSize.Level1)
360{
361    DTEST_LOG << " RemoveSystemProcess001 start " << std::endl;
362    /**
363     * @tc.steps: step1. get samgr instance
364     * @tc.expected: step1. samgr instance not nullptr
365     */
366    sptr<SystemAbilityManager> saMgr = SystemAbilityManager::GetInstance();
367    ASSERT_TRUE(sm != nullptr);
368    /**
369     * @tc.steps: step2. remove system process remote obejct
370     * @tc.expected: step2. remove system process remote obejct
371     */
372    int32_t ret = saMgr->RemoveSystemProcess(nullptr);
373    ASSERT_TRUE(ret != ERR_OK);
374}
375
376/**
377 * @tc.name: RemoveSystemProcess002
378 * @tc.desc: check remove system process remoteobject
379 * @tc.type: FUNC
380 */
381HWTEST_F(SystemAbilityManagerTest, RemoveSystemProcess002, TestSize.Level1)
382{
383    DTEST_LOG << " RemoveSystemProcess001 star2 " << std::endl;
384    /**
385     * @tc.steps: step1. get samgr instance
386     * @tc.expected: step1. samgr instance not nullptr
387     */
388    sptr<SystemAbilityManager> saMgr = SystemAbilityManager::GetInstance();
389    ASSERT_TRUE(sm != nullptr);
390    /**
391     * @tc.steps: step2. remove system process remote obejct
392     * @tc.expected: step2. remove system process remote obejct
393     */
394    for (int32_t i = 0; i < LOOP_SIZE; ++i) {
395        int32_t ret = saMgr->RemoveSystemProcess(nullptr);
396        ASSERT_TRUE(ret != ERR_OK);
397    }
398}
399
400/**
401 * @tc.name: GetSystemAbilityFromRemote001
402 * @tc.desc: check get system ability from remote function
403 * @tc.type: FUNC
404 */
405HWTEST_F(SystemAbilityManagerTest, GetSystemAbilityFromRemote001, TestSize.Level1)
406{
407    DTEST_LOG << " GetSystemAbilityFromRemote001 start " << std::endl;
408    /**
409     * @tc.steps: step1. get samgr instance
410     * @tc.expected: step1. samgr instance not nullptr
411     */
412    sptr<SystemAbilityManager> saMgr = SystemAbilityManager::GetInstance();
413    ASSERT_TRUE(sm != nullptr);
414    /**
415     * @tc.steps: step2. GetSystemAbilityFromRemote with invalid said
416     * @tc.expected: step2. not found sa
417     */
418    sptr<IRemoteObject> object = saMgr->GetSystemAbilityFromRemote(-1);
419    ASSERT_TRUE(object == nullptr);
420}
421
422/**
423 * @tc.name: GetSystemAbilityFromRemote002
424 * @tc.desc: check get system ability from remote function
425 * @tc.type: FUNC
426 */
427HWTEST_F(SystemAbilityManagerTest, GetSystemAbilityFromRemote002, TestSize.Level1)
428{
429    DTEST_LOG << " GetSystemAbilityFromRemote002 start " << std::endl;
430    /**
431     * @tc.steps: step1. get samgr instance
432     * @tc.expected: step1. samgr instance not nullptr
433     */
434    sptr<SystemAbilityManager> saMgr = SystemAbilityManager::GetInstance();
435    ASSERT_TRUE(sm != nullptr);
436    /**
437     * @tc.steps: step2. GetSystemAbilityFromRemote with invalid said
438     * @tc.expected: step2. not found sa
439     */
440    sptr<IRemoteObject> object = saMgr->GetSystemAbilityFromRemote(0);
441    ASSERT_TRUE(object == nullptr);
442}
443
444/**
445 * @tc.name: GetSystemAbilityFromRemote003
446 * @tc.desc: check get system ability from remote function
447 * @tc.type: FUNC
448 */
449HWTEST_F(SystemAbilityManagerTest, GetSystemAbilityFromRemote003, TestSize.Level1)
450{
451    DTEST_LOG << " GetSystemAbilityFromRemote003 start " << std::endl;
452    /**
453     * @tc.steps: step1. get samgr instance
454     * @tc.expected: step1. samgr instance not nullptr
455     */
456    sptr<SystemAbilityManager> saMgr = SystemAbilityManager::GetInstance();
457    ASSERT_TRUE(sm != nullptr);
458    /**
459     * @tc.steps: step2. GetSystemAbilityFromRemote with not-exist said
460     * @tc.expected: step2. not found sa
461     */
462    sptr<IRemoteObject> object = saMgr->GetSystemAbilityFromRemote(DISTRIBUTED_SCHED_TEST_TT_ID);
463    ASSERT_TRUE(object == nullptr);
464}
465
466/**
467 * @tc.name: GetSystemAbilityFromRemote004
468 * @tc.desc: check get system ability from remote function
469 * @tc.type: FUNC
470 */
471HWTEST_F(SystemAbilityManagerTest, GetSystemAbilityFromRemote004, TestSize.Level1)
472{
473    DTEST_LOG << " GetSystemAbilityFromRemote004 start " << std::endl;
474    /**
475     * @tc.steps: step1. get samgr instance
476     * @tc.expected: step1. samgr instance not nullptr
477     */
478    sptr<SystemAbilityManager> saMgr = SystemAbilityManager::GetInstance();
479    ASSERT_TRUE(sm != nullptr);
480    /**
481     * @tc.steps: step2. mock add system ability with not distributed
482     * @tc.expected: step2. add successfully
483     */
484    ISystemAbilityManager::SAExtraProp saExtraProp(false, ISystemAbilityManager::DUMP_FLAG_PRIORITY_DEFAULT,
485        u"", u"");
486    int32_t ret = sm->AddSystemAbility(DISTRIBUTED_SCHED_TEST_TT_ID, new TestTransactionService(), saExtraProp);
487    ASSERT_TRUE(ret == ERR_OK);
488    /**
489     * @tc.steps: step3.  GetSystemAbilityFromRemote with mock said
490     * @tc.expected: step3. not found sa
491     */
492    sptr<IRemoteObject> object = saMgr->GetSystemAbilityFromRemote(DISTRIBUTED_SCHED_TEST_TT_ID);
493    ASSERT_TRUE(object == nullptr);
494    /**
495     * @tc.steps: step4. Remove mock sa
496     * @tc.expected: step4. Remove mock sa
497     */
498    saMgr->RemoveSystemAbility(DISTRIBUTED_SCHED_TEST_TT_ID);
499}
500
501/**
502 * @tc.name: GetSystemAbilityFromRemote005
503 * @tc.desc: check get system ability from remote function
504 * @tc.type: FUNC
505 */
506HWTEST_F(SystemAbilityManagerTest, GetSystemAbilityFromRemote005, TestSize.Level1)
507{
508    DTEST_LOG << " GetSystemAbilityFromRemote005 start " << std::endl;
509    /**
510     * @tc.steps: step1. get samgr instance
511     * @tc.expected: step1. samgr instance not nullptr
512     */
513    sptr<SystemAbilityManager> saMgr = SystemAbilityManager::GetInstance();
514    ASSERT_TRUE(sm != nullptr);
515    /**
516     * @tc.steps: step2. mock add system ability with not distributed
517     * @tc.expected: step2. add successfully
518     */
519    ISystemAbilityManager::SAExtraProp saExtraProp(true, ISystemAbilityManager::DUMP_FLAG_PRIORITY_DEFAULT,
520        u"", u"");
521    int32_t ret = sm->AddSystemAbility(DISTRIBUTED_SCHED_TEST_TT_ID, new TestTransactionService(), saExtraProp);
522    ASSERT_TRUE(ret == ERR_OK);
523    /**
524     * @tc.steps: step3.  GetSystemAbilityFromRemote with mock said
525     * @tc.expected: step3. not found sa
526     */
527    sptr<IRemoteObject> object = saMgr->GetSystemAbilityFromRemote(DISTRIBUTED_SCHED_TEST_TT_ID);
528    ASSERT_TRUE(object != nullptr);
529    /**
530     * @tc.steps: step4. Remove mock sa
531     * @tc.expected: step4. Remove mock sa
532     */
533    saMgr->RemoveSystemAbility(DISTRIBUTED_SCHED_TEST_TT_ID);
534}
535
536/**
537 * @tc.name: GetSystemAbilityFromRemote006
538 * @tc.desc: check get system ability from remote function
539 * @tc.type: FUNC
540 */
541HWTEST_F(SystemAbilityManagerTest, GetSystemAbilityFromRemote006, TestSize.Level3)
542{
543    DTEST_LOG << " GetSystemAbilityFromRemote006 start " << std::endl;
544    /**
545     * @tc.steps: step1. get samgr instance
546     * @tc.expected: step1. samgr instance not nullptr
547     */
548    sptr<SystemAbilityManager> saMgr = SystemAbilityManager::GetInstance();
549    ASSERT_TRUE(sm != nullptr);
550    /**
551     * @tc.steps: step2. GetSystemAbilityFromRemote with invalid said
552     * @tc.expected: step2. not found sa
553     */
554    for (int32_t i = 0; i < LOOP_SIZE; ++i) {
555        int32_t ret = saMgr->GetSystemAbilityFromRemote(0);
556        ASSERT_TRUE(object == nullptr);
557    }
558}
559
560/**
561 * @tc.name: ProcessOnDemandEvent001
562 * @tc.desc: test ProcessOnDemandEvent with empty saControlList
563 * @tc.type: FUNC
564 */
565HWTEST_F(SystemAbilityManagerTest, ProcessOnDemandEvent001, TestSize.Level3)
566{
567    DTEST_LOG << " ProcessOnDemandEvent001 start " << std::endl;
568    sptr<SystemAbilityManager> saMgr = SystemAbilityManager::GetInstance();
569    ASSERT_TRUE(sm != nullptr);
570    std::list<SaControlInfo> saControlList;
571    OnDemandEvent event;
572    saMgr->ProcessOnDemandEvent(event, saControlList);
573    DTEST_LOG << " ProcessOnDemandEvent001 end " << std::endl;
574}
575
576/**
577 * @tc.name: ProcessOnDemandEvent002
578 * @tc.desc: test ProcessOnDemandEvent with  saControlList
579 * @tc.type: FUNC
580 */
581HWTEST_F(SystemAbilityManagerTest, ProcessOnDemandEvent002, TestSize.Level3)
582{
583    DTEST_LOG << " ProcessOnDemandEvent002 start " << std::endl;
584    sptr<SystemAbilityManager> saMgr = SystemAbilityManager::GetInstance();
585    ASSERT_TRUE(sm != nullptr);
586    std::list<SaControlInfo> saControlList;
587    OnDemandEvent event;
588    SaControlInfo saControlInfo1 = {START_ON_DEMAND, DISTRIBUTED_SCHED_SA_ID};
589    SaControlInfo saControlInfo2 = {START_ON_DEMAND, DISTRIBUTED_SCHED_ADAPTER_SA_ID};
590    SaControlInfo saControlInfo3 = {STOP_ON_DEMAND, DISTRIBUTED_SCHED_ADAPTER_SA_ID};
591    SaControlInfo saControlInfo4 = {STOP_ON_DEMAND + 1, DISTRIBUTED_SCHED_ADAPTER_SA_ID};
592    SaProfile saInfo1 = {u"distributedsched", DISTRIBUTED_SCHED_SA_ID};
593    SaProfile saInfo2 = {u"distributedadapter", DISTRIBUTED_SCHED_ADAPTER_SA_ID};
594    saMgr->saProfileMap_[DISTRIBUTED_SCHED_SA_ID] = saInfo1;
595    saMgr->saProfileMap_[DISTRIBUTED_SCHED_ADAPTER_SA_ID] = saInfo2;
596    saControlList.emplace_back(saControlInfo1);
597    saControlList.emplace_back(saControlInfo2);
598    saControlList.emplace_back(saControlInfo3);
599    saControlList.emplace_back(saControlInfo4);
600    saMgr->ProcessOnDemandEvent(event, saControlList);
601    DTEST_LOG << " ProcessOnDemandEvent002 end " << std::endl;
602}
603}
604}