• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 
18 #include "iam_logger.h"
19 #include "iam_ptr.h"
20 
21 #include "screen_brightness_manager.h"
22 #include "service_ex_manager.h"
23 
24 using namespace testing;
25 using namespace testing::ext;
26 
27 #define LOG_TAG "FACE_AUTH_SA"
28 
29 namespace OHOS {
30 namespace UserIam {
31 namespace FaceAuth {
32 class FaceAuthScreenBrightnessTest : public testing::Test {
33 public:
34     static void SetUpTestCase();
35     static void TearDownTestCase();
36     void SetUp();
37     void TearDown();
38 };
39 
SetUpTestCase()40 void FaceAuthScreenBrightnessTest::SetUpTestCase()
41 {
42 }
43 
TearDownTestCase()44 void FaceAuthScreenBrightnessTest::TearDownTestCase()
45 {
46 }
47 
SetUp()48 void FaceAuthScreenBrightnessTest::SetUp()
49 {
50 }
51 
TearDown()52 void FaceAuthScreenBrightnessTest::TearDown()
53 {
54 }
55 
56 HWTEST_F(FaceAuthScreenBrightnessTest, FaceAuthScreenBrightnessTest_001, TestSize.Level0)
57 {
58     auto acquireRet = ServiceExManager::GetInstance().Acquire();
59     EXPECT_TRUE(acquireRet == UserAuth::SUCCESS);
60 
61     auto task = ServiceExManager::GetInstance().GetScreenBrightnessTask();
62     EXPECT_TRUE(task != nullptr);
63 
__anon9bfa13b90102() 64     task->RegisterDestructCallback([]() {
65         IAM_LOGI("task destruct");
66         ServiceExManager::GetInstance().Release();
67     });
68     task->Start();
69     IAM_LOGI("start brightness increase task");
70     task->Stop();
71     IAM_LOGI("end brightness increase task");
72     task = nullptr;
73 }
74 
75 HWTEST_F(FaceAuthScreenBrightnessTest, FaceAuthScreenBrightnessTest_002, TestSize.Level0)
76 {
77     auto manager = ScreenBrightnessManager::GetInstance();
78     EXPECT_TRUE(manager != nullptr);
79     auto executor = Common::MakeShared<FaceAuthAllInOneExecutorHdi>(nullptr);
80     EXPECT_TRUE(executor != nullptr);
81 
82     SaCommand beginCommand = { SaCommandId::BEGIN_SCREEN_BRIGHTNESS_INCREASE };
83     SaCommand endCommand = { SaCommandId::END_SCREEN_BRIGHTNESS_INCREASE };
84     auto result = manager->ProcessSaCommand(executor, beginCommand);
85     EXPECT_TRUE(result == UserAuth::SUCCESS);
86     IAM_LOGI("start brightness increase task");
87     result = manager->ProcessSaCommand(executor, endCommand);
88     EXPECT_TRUE(result == UserAuth::SUCCESS);
89     IAM_LOGI("end brightness increase task");
90 }
91 
92 } // namespace FaceAuth
93 } // namespace UserIam
94 } // namespace OHOS
95