• 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 <gtest/gtest.h>
17 
18 #define protected public
19 #include "disable_camera_plugin.h"
20 #undef protected
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 DisableCameraPluginTest : public testing::Test {
30 protected:
31     static void SetUpTestSuite(void);
32 
33     static void TearDownTestSuite(void);
34 };
35 
SetUpTestSuite(void)36 void DisableCameraPluginTest::SetUpTestSuite(void)
37 {
38     Utils::SetEdmInitialEnv();
39 }
40 
TearDownTestSuite(void)41 void DisableCameraPluginTest::TearDownTestSuite(void)
42 {
43     Utils::ResetTokenTypeAndUid();
44     ASSERT_TRUE(Utils::IsOriginalUTEnv());
45     std::cout << "now ut process is orignal ut env : " << Utils::IsOriginalUTEnv() << std::endl;
46 }
47 
48 /**
49  * @tc.name: TestDisableCameraPluginTestGet
50  * @tc.desc: Test DisableCameraPluginTest::OnGetPolicy function.
51  * @tc.type: FUNC
52  */
53 HWTEST_F(DisableCameraPluginTest, TestDisableCameraPluginTestGet, TestSize.Level1)
54 {
55     MessageParcel data;
56     MessageParcel reply;
57     std::string policyData = "true";
58     DisableCameraPlugin plugin;
59     ErrCode ret = plugin.OnGetPolicy(policyData, data, reply, 100);
60     ASSERT_TRUE(ret == ERR_OK);
61     ASSERT_TRUE(reply.ReadInt32() == ERR_OK);
62     ASSERT_FALSE(reply.ReadBool());
63 }
64 
65 } // namespace TEST
66 } // namespace EDM
67 } // namespace OHOS