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
18 #include "access_token.h"
19 #include "accesstoken_kit.h"
20 #ifdef ABILITY_RUNTIME_ENABLE
21 #include "ams_mgr_interface.h"
22 #include "app_manager_access_proxy.h"
23 #include "app_mgr_ipc_interface_code.h"
24
25 #include "ability_manager_ipc_interface_code.h"
26 #include "iapplication_state_observer.h"
27 #endif
28
29 #ifdef CAMERA_FRAMEWORK_ENABLE
30 #include "camera_service_ipc_interface_code.h"
31 #endif
32
33 #include "privacy_camera_service_ipc_interface_code.h"
34 #include "service_ipc_interface_code.h"
35
36 using namespace testing::ext;
37
38 namespace OHOS {
39 namespace Security {
40 namespace AccessToken {
41 class IpcCodeTest : public testing::Test {
42 public:
43 static void SetUpTestCase();
44 static void TearDownTestCase();
45 void SetUp();
46 void TearDown();
47 };
48
SetUpTestCase()49 void IpcCodeTest::SetUpTestCase()
50 {
51 }
52
TearDownTestCase()53 void IpcCodeTest::TearDownTestCase()
54 {
55 }
56
SetUp()57 void IpcCodeTest::SetUp()
58 {
59 }
60
TearDown()61 void IpcCodeTest::TearDown()
62 {
63 }
64
65 #ifdef ABILITY_RUNTIME_ENABLE
66 /*
67 * @tc.name: AppManagerCodeTest001
68 * @tc.desc: test appMgr ipc code
69 * @tc.type: FUNC
70 * @tc.require:
71 */
72 HWTEST_F(IpcCodeTest, AppManagerCodeTest001, TestSize.Level1)
73 {
74 ASSERT_EQ(static_cast<uint32_t>(AppExecFwk::AppMgrInterfaceCode::REGISTER_APPLICATION_STATE_OBSERVER),
75 static_cast<uint32_t>(AccessToken::IAppMgr::Message::REGISTER_APPLICATION_STATE_OBSERVER)); // 12
76 ASSERT_EQ(static_cast<uint32_t>(AppExecFwk::AppMgrInterfaceCode::UNREGISTER_APPLICATION_STATE_OBSERVER),
77 static_cast<uint32_t>(AccessToken::IAppMgr::Message::UNREGISTER_APPLICATION_STATE_OBSERVER)); // 13
78 ASSERT_EQ(static_cast<uint32_t>(AppExecFwk::AppMgrInterfaceCode::GET_FOREGROUND_APPLICATIONS),
79 static_cast<uint32_t>(AccessToken::IAppMgr::Message::GET_FOREGROUND_APPLICATIONS)); // 14
80 }
81
82 /*
83 * @tc.name: AmsManagerCodeTest001
84 * @tc.desc: test amsMgr ipc code
85 * @tc.type: FUNC
86 * @tc.require:
87 */
88 HWTEST_F(IpcCodeTest, AmsManagerCodeTest001, TestSize.Level1)
89 {
90 ASSERT_EQ(static_cast<uint32_t>(AppExecFwk::IAmsMgr::Message::FORCE_KILL_APPLICATION_BY_ACCESS_TOKEN_ID),
91 static_cast<uint32_t>(AccessToken::IAmsMgr::Message::FORCE_KILL_APPLICATION_BY_ACCESS_TOKEN_ID));
92 }
93
94 /*
95 * @tc.name: AmsManagerCodeTest001
96 * @tc.desc: test ability manager ipc code
97 * @tc.type: FUNC
98 * @tc.require:
99 */
100 HWTEST_F(IpcCodeTest, AbilityManagerCodeTest001, TestSize.Level1)
101 {
102 ASSERT_EQ(static_cast<uint32_t>(AAFwk::AbilityManagerInterfaceCode::START_ABILITY_ADD_CALLER),
103 static_cast<uint32_t>(AccessToken::AccessAbilityServiceInterfaceCode::START_ABILITY_ADD_CALLER));
104 }
105 #endif
106
107 #ifdef CAMERA_FRAMEWORK_ENABLE
108 /*
109 * @tc.name: CameraManagerCodeTest001
110 * @tc.desc: test camera framework ipc code
111 * @tc.type: FUNC
112 * @tc.require:
113 */
114 HWTEST_F(IpcCodeTest, CameraManagerCodeTest001, TestSize.Level1)
115 {
116 ASSERT_EQ(static_cast<uint32_t>(CameraStandard::CameraServiceInterfaceCode::CAMERA_SERVICE_IS_CAMERA_MUTED),
117 static_cast<uint32_t>(AccessToken::PrivacyCameraServiceInterfaceCode::CAMERA_SERVICE_IS_CAMERA_MUTED));
118 ASSERT_EQ(static_cast<uint32_t>(CameraStandard::CameraServiceInterfaceCode::CAMERA_SERVICE_MUTE_CAMERA_PERSIST),
119 static_cast<uint32_t>(AccessToken::PrivacyCameraServiceInterfaceCode::CAMERA_SERVICE_MUTE_CAMERA_PERSIST));
120 }
121 #endif
122
123 #ifdef AUDIO_FRAMEWORK_ENABLE
124 /*
125 * @tc.name: AudioManagerCodeTest001
126 * @tc.desc: test audio framework ipc code
127 * @tc.type: FUNC
128 * @tc.require:
129 */
130 HWTEST_F(IpcCodeTest, AudioManagerCodeTest001, TestSize.Level1)
131 {
132 }
133 #endif
134 } // namespace AccessToken
135 } // namespace Security
136 } // namespace OHOS
137