1 /*
2 * Copyright (c) 2023-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
16 #include "get_device_encryption_status_plugin.h"
17 #include <gtest/gtest.h>
18 #include "edm_data_ability_utils_mock.h"
19 #include "edm_ipc_interface_code.h"
20 #include "iplugin_manager.h"
21 #include "utils.h"
22
23 using namespace testing::ext;
24 using namespace testing;
25
26 namespace OHOS {
27 namespace EDM {
28 namespace TEST {
29 class GetDeviceEncryptionStatusPluginTest : public testing::Test {
30 protected:
31 static void SetUpTestSuite(void);
32
33 static void TearDownTestSuite(void);
34 };
35
SetUpTestSuite(void)36 void GetDeviceEncryptionStatusPluginTest::SetUpTestSuite(void)
37 {
38 Utils::SetEdmServiceEnable();
39 Utils::SetEdmInitialEnv();
40 }
41
TearDownTestSuite(void)42 void GetDeviceEncryptionStatusPluginTest::TearDownTestSuite(void)
43 {
44 Utils::SetEdmServiceDisable();
45 Utils::ResetTokenTypeAndUid();
46 ASSERT_TRUE(Utils::IsOriginalUTEnv());
47 std::cout << "now ut process is orignal ut env : " << Utils::IsOriginalUTEnv() << std::endl;
48 }
49
50 /**
51 * @tc.name: GetDeviceEncryptionStatusSuc
52 * @tc.desc: Test get device encryption status function.
53 * @tc.type: FUNC
54 */
55 HWTEST_F(GetDeviceEncryptionStatusPluginTest, GetDeviceEncryptionStatusSuc, TestSize.Level1)
56 {
57 std::shared_ptr<IPlugin> plugin = GetDeviceEncryptionStatusPlugin::GetPlugin();
58 std::string policyValue{"GetDeviceEncryptionStatus"};
59 MessageParcel data;
60 MessageParcel reply;
61 plugin->OnGetPolicy(policyValue, data, reply, DEFAULT_USER_ID);
62 ASSERT_TRUE(reply.ReadInt32() == ERR_OK);
63 ASSERT_TRUE(reply.ReadBool() == true);
64 }
65
66 } // namespace TEST
67 } // namespace EDM
68 } // namespace OHOS