• 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 <memory>
17 
18 #include "accesstoken_kit.h"
19 #include "gtest/gtest.h"
20 #include "ipc_skeleton.h"
21 
22 #include "cooperate_params.h"
23 #include "cooperate_server.h"
24 #include "default_params.h"
25 #include "fi_log.h"
26 #include "nativetoken_kit.h"
27 #include "test_context.h"
28 #include "token_setproc.h"
29 
30 #undef LOG_TAG
31 #define LOG_TAG "CooperateServerTest"
32 
33 namespace OHOS {
34 namespace Msdp {
35 namespace DeviceStatus {
36 using namespace testing::ext;
37 namespace {
38 uint64_t g_tokenID { 0 };
39 const std::string SYSTEM_BASIC { "system_basic" };
40 const char* g_basics[] = { "ohos.permission.COOPERATE_MANAGER" };
41 } // namespace
42 
43 class CooperateServerTest : public testing::Test {
44 public:
45     CooperateServerTest();
46     ~CooperateServerTest() = default;
47 
48     void SetUp();
49     void TearDown();
50     static void SetUpTestCase();
51     static void TearDownTestCase();
52     static void SetPermission(const std::string &level, const char** perms, size_t permAmount);
53     static void RemovePermission();
54 
55 private:
56     Intention intention_ { Intention::COOPERATE };
57     std::shared_ptr<TestContext> context_ { nullptr };
58     std::shared_ptr<CooperateServer> cooperateServer_ { nullptr };
59 };
60 
CooperateServerTest()61 CooperateServerTest::CooperateServerTest()
62 {
63     context_ = std::make_shared<TestContext>();
64     cooperateServer_ = std::make_shared<CooperateServer>(context_.get());
65 }
66 
SetUp()67 void CooperateServerTest::SetUp()
68 {}
69 
TearDown()70 void CooperateServerTest::TearDown()
71 {}
72 
SetUpTestCase()73 void CooperateServerTest::SetUpTestCase()
74 {
75     SetPermission(SYSTEM_BASIC, g_basics, sizeof(g_basics) / sizeof(g_basics[0]));
76 }
77 
TearDownTestCase()78 void CooperateServerTest::TearDownTestCase()
79 {
80     RemovePermission();
81 }
82 
SetPermission(const std::string & level,const char ** perms,size_t permAmount)83 void CooperateServerTest::SetPermission(const std::string &level, const char** perms, size_t permAmount)
84 {
85     CALL_DEBUG_ENTER;
86     if (perms == nullptr || permAmount == 0) {
87         FI_HILOGE("The perms is empty");
88         return;
89     }
90 
91     NativeTokenInfoParams infoInstance = {
92         .dcapsNum = 0,
93         .permsNum = permAmount,
94         .aclsNum = 0,
95         .dcaps = nullptr,
96         .perms = perms,
97         .acls = nullptr,
98         .processName = "CooperateServerTest",
99         .aplStr = level.c_str(),
100     };
101     g_tokenID = GetAccessTokenId(&infoInstance);
102     SetSelfTokenID(g_tokenID);
103     OHOS::Security::AccessToken::AccessTokenKit::AccessTokenKit::ReloadNativeTokenInfo();
104 }
105 
RemovePermission()106 void CooperateServerTest::RemovePermission()
107 {
108     CALL_DEBUG_ENTER;
109     int32_t ret = OHOS::Security::AccessToken::AccessTokenKit::DeleteToken(g_tokenID);
110     if (ret != RET_OK) {
111         FI_HILOGE("Failed to remove permission");
112         return;
113     }
114 }
115 
116 /**
117  * @tc.name: EnableTest1
118  * @tc.desc: Test func named enable
119  * @tc.type: FUNC
120  * @tc.require:
121  */
122 HWTEST_F(CooperateServerTest, EnableTest1, TestSize.Level0)
123 {
124     CALL_TEST_DEBUG;
125     CallingContext context {
126         .intention = intention_,
127         .tokenId = IPCSkeleton::GetCallingTokenID(),
128         .uid = IPCSkeleton::GetCallingUid(),
129         .pid = IPCSkeleton::GetCallingPid(),
130     };
131     MessageParcel datas;
132     MessageParcel reply;
133     ASSERT_NO_FATAL_FAILURE(cooperateServer_->Enable(context, datas, reply));
134 }
135 
136 /**
137  * @tc.name: DisableTest1
138  * @tc.desc: Test func named disable
139  * @tc.type: FUNC
140  * @tc.require:
141  */
142 HWTEST_F(CooperateServerTest, DisableTest1, TestSize.Level0)
143 {
144     CALL_TEST_DEBUG;
145     CallingContext context {
146         .intention = intention_,
147         .tokenId = IPCSkeleton::GetCallingTokenID(),
148         .uid = IPCSkeleton::GetCallingUid(),
149         .pid = IPCSkeleton::GetCallingPid(),
150     };
151     MessageParcel datas;
152     MessageParcel reply;
153     ASSERT_NO_FATAL_FAILURE(cooperateServer_->Disable(context, datas, reply));
154 }
155 
156 /**
157  * @tc.name: StartTest1
158  * @tc.desc: Test func named start
159  * @tc.type: FUNC
160  * @tc.require:
161  */
162 HWTEST_F(CooperateServerTest, StartTest1, TestSize.Level0)
163 {
164     CALL_TEST_DEBUG;
165     CallingContext context {
166         .intention = intention_,
167         .tokenId = IPCSkeleton::GetCallingTokenID(),
168         .uid = IPCSkeleton::GetCallingUid(),
169         .pid = IPCSkeleton::GetCallingPid(),
170     };
171     MessageParcel datas;
172     MessageParcel reply;
173     ASSERT_NO_FATAL_FAILURE(cooperateServer_->Start(context, datas, reply));
174 }
175 
176 /**
177  * @tc.name: StopTest1
178  * @tc.desc: Test func named stop
179  * @tc.type: FUNC
180  * @tc.require:
181  */
182 HWTEST_F(CooperateServerTest, StopTest1, TestSize.Level0)
183 {
184     CALL_TEST_DEBUG;
185     CallingContext context {
186         .intention = intention_,
187         .tokenId = IPCSkeleton::GetCallingTokenID(),
188         .uid = IPCSkeleton::GetCallingUid(),
189         .pid = IPCSkeleton::GetCallingPid(),
190     };
191     MessageParcel datas;
192     MessageParcel reply;
193     ASSERT_NO_FATAL_FAILURE(cooperateServer_->Stop(context, datas, reply));
194 }
195 
196 /**
197  * @tc.name: EnableTest2
198  * @tc.desc: Test func named enable
199  * @tc.type: FUNC
200  * @tc.require:
201  */
202 HWTEST_F(CooperateServerTest, EnableTest2, TestSize.Level0)
203 {
204     CALL_TEST_DEBUG;
205     CallingContext context {
206         .intention = intention_,
207         .tokenId = IPCSkeleton::GetCallingTokenID(),
208         .uid = IPCSkeleton::GetCallingUid(),
209         .pid = IPCSkeleton::GetCallingPid(),
210     };
211     MessageParcel data;
212     MessageParcel reply;
213     DefaultParam  param { 1 };
214     ASSERT_TRUE(param.Marshalling(data));
215     ASSERT_NO_FATAL_FAILURE(cooperateServer_->Enable(context, data, reply));
216     context_->GetPluginManager().UnloadCooperate();
217 }
218 
219 /**
220  * @tc.name: AddWatchTest1
221  * @tc.desc: Test func named add watch
222  * @tc.type: FUNC
223  * @tc.require:
224  */
225 HWTEST_F(CooperateServerTest, AddWatchTest1, TestSize.Level0)
226 {
227     CALL_TEST_DEBUG;
228     CallingContext context {
229         .intention = intention_,
230         .tokenId = IPCSkeleton::GetCallingTokenID(),
231         .uid = IPCSkeleton::GetCallingUid(),
232         .pid = IPCSkeleton::GetCallingPid(),
233     };
234     MessageParcel data;
235     MessageParcel reply;
236     DefaultParam  param { 1 };
237     ASSERT_TRUE(param.Marshalling(data));
238     ASSERT_NO_FATAL_FAILURE(cooperateServer_->AddWatch(context, CooperateRequestID::REGISTER_LISTENER, data, reply));
239     context_->GetPluginManager().UnloadCooperate();
240 }
241 
242 /**
243  * @tc.name: DisableTest2
244  * @tc.desc: Test func named disable
245  * @tc.type: FUNC
246  * @tc.require:
247  */
248 HWTEST_F(CooperateServerTest, DisableTest2, TestSize.Level0)
249 {
250     CALL_TEST_DEBUG;
251     CallingContext context {
252         .intention = intention_,
253         .tokenId = IPCSkeleton::GetCallingTokenID(),
254         .uid = IPCSkeleton::GetCallingUid(),
255         .pid = IPCSkeleton::GetCallingPid(),
256     };
257     DefaultParam  param { 1 };
258     MessageParcel datas;
259     MessageParcel reply;
260     param.Marshalling(datas);
261     ASSERT_TRUE(param.Marshalling(datas));
262     ASSERT_NO_FATAL_FAILURE(cooperateServer_->Disable(context, datas, reply));
263     context_->GetPluginManager().UnloadCooperate();
264 }
265 
266 /**
267  * @tc.name: AddWatchTest2
268  * @tc.desc: Test func named add watch
269  * @tc.type: FUNC
270  * @tc.require:
271  */
272 HWTEST_F(CooperateServerTest, AddWatchTest2, TestSize.Level0)
273 {
274     CALL_TEST_DEBUG;
275     CallingContext context {
276         .intention = intention_,
277         .tokenId = IPCSkeleton::GetCallingTokenID(),
278         .uid = IPCSkeleton::GetCallingUid(),
279         .pid = IPCSkeleton::GetCallingPid(),
280     };
281     MessageParcel data;
282     MessageParcel reply;
283     ASSERT_NO_FATAL_FAILURE(cooperateServer_->AddWatch(
284         context, CooperateRequestID::UNKNOWN_COOPERATE_ACTION, data, reply));
285     context_->GetPluginManager().UnloadCooperate();
286 }
287 
288 /**
289  * @tc.name: AddWatchTest3
290  * @tc.desc: Test func named add watch
291  * @tc.type: FUNC
292  * @tc.require:
293  */
294 HWTEST_F(CooperateServerTest, AddWatchTest3, TestSize.Level0)
295 {
296     CALL_TEST_DEBUG;
297     CallingContext context {
298         .intention = intention_,
299         .tokenId = IPCSkeleton::GetCallingTokenID(),
300         .uid = IPCSkeleton::GetCallingUid(),
301         .pid = IPCSkeleton::GetCallingPid(),
302     };
303     MessageParcel data;
304     MessageParcel reply;
305     ASSERT_NO_FATAL_FAILURE(cooperateServer_->AddWatch(
306         context, CooperateRequestID::REGISTER_HOTAREA_LISTENER, data, reply));
307     context_->GetPluginManager().UnloadCooperate();
308 }
309 
310 /**
311  * @tc.name: AddWatchTest4
312  * @tc.desc: Test func named add watch
313  * @tc.type: FUNC
314  * @tc.require:
315  */
316 HWTEST_F(CooperateServerTest, AddWatchTest4, TestSize.Level0)
317 {
318     CALL_TEST_DEBUG;
319     CallingContext context {
320         .intention = intention_,
321         .tokenId = IPCSkeleton::GetCallingTokenID(),
322         .uid = IPCSkeleton::GetCallingUid(),
323         .pid = IPCSkeleton::GetCallingPid(),
324     };
325     MessageParcel data;
326     MessageParcel reply;
327     RegisterEventListenerParam  param { "networkId" };
328     param.Marshalling(data);
329     ASSERT_TRUE(param.Marshalling(data));
330     ASSERT_NO_FATAL_FAILURE(cooperateServer_->AddWatch(
331         context, CooperateRequestID::REGISTER_EVENT_LISTENER, data, reply));
332     context_->GetPluginManager().UnloadCooperate();
333 }
334 
335 /**
336  * @tc.name: AddWatchTest5
337  * @tc.desc: Test func named add watch
338  * @tc.type: FUNC
339  * @tc.require:
340  */
341 HWTEST_F(CooperateServerTest, AddWatchTest5, TestSize.Level0)
342 {
343     CALL_TEST_DEBUG;
344     CallingContext context {
345         .intention = intention_,
346         .tokenId = IPCSkeleton::GetCallingTokenID(),
347         .uid = IPCSkeleton::GetCallingUid(),
348         .pid = IPCSkeleton::GetCallingPid(),
349     };
350     MessageParcel data;
351     MessageParcel reply;
352     ASSERT_NO_FATAL_FAILURE(cooperateServer_->AddWatch(
353         context, CooperateRequestID::REGISTER_EVENT_LISTENER, data, reply));
354     context_->GetPluginManager().UnloadCooperate();
355 }
356 
357 /**
358  * @tc.name: RemoveWatch1
359  * @tc.desc: Test func named remove watch
360  * @tc.type: FUNC
361  * @tc.require:
362  */
363 HWTEST_F(CooperateServerTest, RemoveWatch1, TestSize.Level0)
364 {
365     CALL_TEST_DEBUG;
366     CallingContext context {
367         .intention = intention_,
368         .tokenId = IPCSkeleton::GetCallingTokenID(),
369         .uid = IPCSkeleton::GetCallingUid(),
370         .pid = IPCSkeleton::GetCallingPid(),
371     };
372     MessageParcel data;
373     MessageParcel reply;
374     ASSERT_NO_FATAL_FAILURE(cooperateServer_->RemoveWatch(
375         context, CooperateRequestID::UNREGISTER_LISTENER, data, reply));
376     context_->GetPluginManager().UnloadCooperate();
377 }
378 
379 /**
380  * @tc.name: RemoveWatch2
381  * @tc.desc: Test func named remove watch
382  * @tc.type: FUNC
383  * @tc.require:
384  */
385 HWTEST_F(CooperateServerTest, RemoveWatch2, TestSize.Level0)
386 {
387     CALL_TEST_DEBUG;
388     CallingContext context {
389         .intention = intention_,
390         .tokenId = IPCSkeleton::GetCallingTokenID(),
391         .uid = IPCSkeleton::GetCallingUid(),
392         .pid = IPCSkeleton::GetCallingPid(),
393     };
394     MessageParcel data;
395     MessageParcel reply;
396     ASSERT_NO_FATAL_FAILURE(cooperateServer_->RemoveWatch(
397         context, CooperateRequestID::UNKNOWN_COOPERATE_ACTION, data, reply));
398     context_->GetPluginManager().UnloadCooperate();
399 }
400 
401 /**
402  * @tc.name: RemoveWatch3
403  * @tc.desc: Test func named remove watch
404  * @tc.type: FUNC
405  * @tc.require:
406  */
407 HWTEST_F(CooperateServerTest, RemoveWatch3, TestSize.Level0)
408 {
409     CALL_TEST_DEBUG;
410     CallingContext context {
411         .intention = intention_,
412         .tokenId = IPCSkeleton::GetCallingTokenID(),
413         .uid = IPCSkeleton::GetCallingUid(),
414         .pid = IPCSkeleton::GetCallingPid(),
415     };
416     MessageParcel data;
417     MessageParcel reply;
418     ASSERT_NO_FATAL_FAILURE(cooperateServer_->RemoveWatch(
419         context, CooperateRequestID::UNREGISTER_HOTAREA_LISTENER, data, reply));
420     context_->GetPluginManager().UnloadCooperate();
421 }
422 
423 /**
424  * @tc.name: RemoveWatch4
425  * @tc.desc: Test func named remove watch
426  * @tc.type: FUNC
427  * @tc.require:
428  */
429 HWTEST_F(CooperateServerTest, RemoveWatch4, TestSize.Level0)
430 {
431     CALL_TEST_DEBUG;
432     CallingContext context {
433         .intention = intention_,
434         .tokenId = IPCSkeleton::GetCallingTokenID(),
435         .uid = IPCSkeleton::GetCallingUid(),
436         .pid = IPCSkeleton::GetCallingPid(),
437     };
438     MessageParcel data;
439     MessageParcel reply;
440     ASSERT_NO_FATAL_FAILURE(cooperateServer_->RemoveWatch(
441         context, CooperateRequestID::UNREGISTER_EVENT_LISTENER, data, reply));
442     context_->GetPluginManager().UnloadCooperate();
443 }
444 
445 /**
446  * @tc.name: SetParam
447  * @tc.desc: Test func named set param
448  * @tc.type: FUNC
449  * @tc.require:
450  */
451 HWTEST_F(CooperateServerTest, SetParam, TestSize.Level0)
452 {
453     CALL_TEST_DEBUG;
454     CallingContext context {
455         .intention = intention_,
456         .tokenId = IPCSkeleton::GetCallingTokenID(),
457         .uid = IPCSkeleton::GetCallingUid(),
458         .pid = IPCSkeleton::GetCallingPid(),
459     };
460     MessageParcel data;
461     MessageParcel reply;
462     ASSERT_NO_FATAL_FAILURE(
463         cooperateServer_->SetParam(context, CooperateRequestID::SET_DAMPLING_COEFFICIENT, data, reply));
464 }
465 
466 /**
467  * @tc.name: SetParam1
468  * @tc.desc: Test func named set param
469  * @tc.type: FUNC
470  * @tc.require:
471  */
472 HWTEST_F(CooperateServerTest, SetParam1, TestSize.Level0)
473 {
474     CALL_TEST_DEBUG;
475     CallingContext context {
476         .intention = intention_,
477         .tokenId = IPCSkeleton::GetCallingTokenID(),
478         .uid = IPCSkeleton::GetCallingUid(),
479         .pid = IPCSkeleton::GetCallingPid(),
480     };
481     MessageParcel data;
482     MessageParcel reply;
483     ASSERT_NO_FATAL_FAILURE(cooperateServer_->SetParam(
484         context, CooperateRequestID::REGISTER_LISTENER, data, reply));
485 }
486 
487 /**
488  * @tc.name: SetParam2
489  * @tc.desc: Test func named set param
490  * @tc.type: FUNC
491  * @tc.require:
492  */
493 HWTEST_F(CooperateServerTest, SetParam2, TestSize.Level0)
494 {
495     CALL_TEST_DEBUG;
496     RemovePermission();
497     CallingContext context {
498         .intention = intention_,
499         .tokenId = IPCSkeleton::GetCallingTokenID(),
500         .uid = IPCSkeleton::GetCallingUid(),
501         .pid = IPCSkeleton::GetCallingPid(),
502     };
503     MessageParcel data;
504     MessageParcel reply;
505     ASSERT_NO_FATAL_FAILURE(cooperateServer_->SetParam(
506         context, CooperateRequestID::REGISTER_LISTENER, data, reply));
507 }
508 /**
509  * @tc.name: GetParam1
510  * @tc.desc: Test func named get param
511  * @tc.type: FUNC
512  * @tc.require:
513  */
514 HWTEST_F(CooperateServerTest, GetParam1, TestSize.Level0)
515 {
516     CALL_TEST_DEBUG;
517     CallingContext context {
518         .intention = intention_,
519         .tokenId = IPCSkeleton::GetCallingTokenID(),
520         .uid = IPCSkeleton::GetCallingUid(),
521         .pid = IPCSkeleton::GetCallingPid(),
522     };
523     MessageParcel data;
524     MessageParcel reply;
525     GetCooperateStateParam param {1, "networkId", true};
526     param.Marshalling(data);
527     ASSERT_TRUE(param.Marshalling(data));
528     ASSERT_NO_FATAL_FAILURE(cooperateServer_->GetParam(
529         context, CooperateRequestID::GET_COOPERATE_STATE, data, reply));
530     context_->GetPluginManager().UnloadCooperate();
531 }
532 
533 /**
534  * @tc.name: GetParam2
535  * @tc.desc: Test func named get param
536  * @tc.type: FUNC
537  * @tc.require:
538  */
539 HWTEST_F(CooperateServerTest, GetParam2, TestSize.Level0)
540 {
541     CALL_TEST_DEBUG;
542     CallingContext context {
543         .intention = intention_,
544         .tokenId = IPCSkeleton::GetCallingTokenID(),
545         .uid = IPCSkeleton::GetCallingUid(),
546         .pid = IPCSkeleton::GetCallingPid(),
547     };
548     MessageParcel data;
549     MessageParcel reply;
550     GetCooperateStateSyncParam param { "networkId" };
551     param.Marshalling(data);
552     ASSERT_TRUE(param.Marshalling(data));
553     ASSERT_NO_FATAL_FAILURE(cooperateServer_->GetParam(
554         context, CooperateRequestID::GET_COOPERATE_STATE_SYNC, data, reply));
555     context_->GetPluginManager().UnloadCooperate();
556 }
557 
558 /**
559  * @tc.name: GetParam3
560  * @tc.desc: Test func named get param
561  * @tc.type: FUNC
562  * @tc.require:
563  */
564 HWTEST_F(CooperateServerTest, GetParam3, TestSize.Level0)
565 {
566     CALL_TEST_DEBUG;
567     CallingContext context {
568         .intention = intention_,
569         .tokenId = IPCSkeleton::GetCallingTokenID(),
570         .uid = IPCSkeleton::GetCallingUid(),
571         .pid = IPCSkeleton::GetCallingPid(),
572     };
573     MessageParcel data;
574     MessageParcel reply;
575     ASSERT_NO_FATAL_FAILURE(cooperateServer_->GetParam(
576         context, CooperateRequestID::GET_COOPERATE_STATE_SYNC, data, reply));
577     context_->GetPluginManager().UnloadCooperate();
578 }
579 
580 /**
581  * @tc.name: StopTest2
582  * @tc.desc: Test func named stop
583  * @tc.type: FUNC
584  * @tc.require:
585  */
586 HWTEST_F(CooperateServerTest, StopTest2, TestSize.Level0)
587 {
588     CALL_TEST_DEBUG;
589     CallingContext context {
590         .intention = intention_,
591         .tokenId = IPCSkeleton::GetCallingTokenID(),
592         .uid = IPCSkeleton::GetCallingUid(),
593         .pid = IPCSkeleton::GetCallingPid(),
594     };
595     StopCooperateParam param {1, false, true};
596     MessageParcel data;
597     MessageParcel reply;
598     param.Marshalling(data);
599     ASSERT_TRUE(param.Marshalling(data));
600     ASSERT_NO_FATAL_FAILURE(cooperateServer_->Stop(context, data, reply));
601     context_->GetPluginManager().UnloadCooperate();
602 }
603 
604 /**
605  * @tc.name: ControlTest1
606  * @tc.desc: Test func named control
607  * @tc.type: FUNC
608  * @tc.require:
609  */
610 HWTEST_F(CooperateServerTest, ControlTest1, TestSize.Level0)
611 {
612     CALL_TEST_DEBUG;
613     CallingContext context {
614         .intention = intention_,
615         .tokenId = IPCSkeleton::GetCallingTokenID(),
616         .uid = IPCSkeleton::GetCallingUid(),
617         .pid = IPCSkeleton::GetCallingPid(),
618     };
619     MessageParcel data;
620     MessageParcel reply;
621     ASSERT_NO_FATAL_FAILURE(cooperateServer_->Control(
622         context, CooperateRequestID::UNKNOWN_COOPERATE_ACTION, data, reply));
623 }
624 
625 /**
626  * @tc.name: EnableTest3
627  * @tc.desc: Test func named enable
628  * @tc.type: FUNC
629  * @tc.require:
630  */
631 HWTEST_F(CooperateServerTest, EnableTest3, TestSize.Level0)
632 {
633     CALL_TEST_DEBUG;
634     RemovePermission();
635     CallingContext context {
636         .intention = intention_,
637         .tokenId = IPCSkeleton::GetCallingTokenID(),
638         .uid = IPCSkeleton::GetCallingUid(),
639         .pid = IPCSkeleton::GetCallingPid(),
640     };
641     MessageParcel datas;
642     MessageParcel reply;
643     cooperateServer_->Enable(context, datas, reply);
644     ASSERT_NO_FATAL_FAILURE(cooperateServer_->Enable(context, datas, reply));
645 }
646 
647 /**
648  * @tc.name: DisableTest3
649  * @tc.desc: Test func named Disable
650  * @tc.type: FUNC
651  * @tc.require:
652  */
653 HWTEST_F(CooperateServerTest, DisableTest3, TestSize.Level0)
654 {
655     CALL_TEST_DEBUG;
656     RemovePermission();
657     CallingContext context {
658         .intention = intention_,
659         .tokenId = IPCSkeleton::GetCallingTokenID(),
660         .uid = IPCSkeleton::GetCallingUid(),
661         .pid = IPCSkeleton::GetCallingPid(),
662     };
663     MessageParcel datas;
664     MessageParcel reply;
665     ASSERT_NO_FATAL_FAILURE(cooperateServer_->Disable(context, datas, reply));
666 }
667 
668 /**
669  * @tc.name: StartTest2
670  * @tc.desc: Test func named enable
671  * @tc.type: FUNC
672  * @tc.require:
673  */
674 HWTEST_F(CooperateServerTest, StartTest2, TestSize.Level0)
675 {
676     CALL_TEST_DEBUG;
677     RemovePermission();
678     CallingContext context {
679         .intention = intention_,
680         .tokenId = IPCSkeleton::GetCallingTokenID(),
681         .uid = IPCSkeleton::GetCallingUid(),
682         .pid = IPCSkeleton::GetCallingPid(),
683     };
684     MessageParcel datas;
685     MessageParcel reply;
686     ASSERT_NO_FATAL_FAILURE(cooperateServer_->Start(context, datas, reply));
687 }
688 
689 /**
690  * @tc.name: StopTest3
691  * @tc.desc: Test func named enable
692  * @tc.type: FUNC
693  * @tc.require:
694  */
695 HWTEST_F(CooperateServerTest, StopTest3, TestSize.Level0)
696 {
697     CALL_TEST_DEBUG;
698     RemovePermission();
699     CallingContext context {
700         .intention = intention_,
701         .tokenId = IPCSkeleton::GetCallingTokenID(),
702         .uid = IPCSkeleton::GetCallingUid(),
703         .pid = IPCSkeleton::GetCallingPid(),
704     };
705     MessageParcel datas;
706     MessageParcel reply;
707     ASSERT_NO_FATAL_FAILURE(cooperateServer_->Stop(context, datas, reply));
708 }
709 
710 /**
711  * @tc.name: AddWatchTest6
712  * @tc.desc: Test func named enable
713  * @tc.type: FUNC
714  * @tc.require:
715  */
716 HWTEST_F(CooperateServerTest, AddWatchTest6, TestSize.Level0)
717 {
718     CALL_TEST_DEBUG;
719     RemovePermission();
720     CallingContext context {
721         .intention = intention_,
722         .tokenId = IPCSkeleton::GetCallingTokenID(),
723         .uid = IPCSkeleton::GetCallingUid(),
724         .pid = IPCSkeleton::GetCallingPid(),
725     };
726     MessageParcel datas;
727     MessageParcel reply;
728     ASSERT_NO_FATAL_FAILURE(cooperateServer_->AddWatch(context, REGISTER_LISTENER, datas, reply));
729     context_->GetPluginManager().UnloadCooperate();
730 }
731 } // namespace DeviceStatus
732 } // namespace Msdp
733 } // namespace OHOS