• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 <gtest/gtest.h>
17 #include <memory>
18 #include "appfreeze_state.h"
19 
20 #define private public
21 #include "appfreeze_inner.h"
22 #undef private
23 
24 using namespace testing;
25 using namespace testing::ext;
26 using namespace OHOS::AbilityRuntime;
27 using namespace OHOS::AppExecFwk;
28 
29 namespace OHOS {
30 namespace AbilityRuntime {
31 class AppFreezeStateTest : public testing::Test {
32 public:
AppFreezeStateTest()33     AppFreezeStateTest()
34     {}
~AppFreezeStateTest()35     ~AppFreezeStateTest()
36     {}
37     static void SetUpTestCase(void);
38     static void TearDownTestCase(void);
39     void SetUp();
40     void TearDown();
41 };
42 
SetUpTestCase(void)43 void AppFreezeStateTest::SetUpTestCase(void)
44 {}
45 
TearDownTestCase(void)46 void AppFreezeStateTest::TearDownTestCase(void)
47 {}
48 
SetUp(void)49 void AppFreezeStateTest::SetUp(void)
50 {}
51 
TearDown(void)52 void AppFreezeStateTest::TearDown(void)
53 {}
54 
55 /**
56  * @tc.number: AppfreezeStateTest_001
57  * @tc.desc: Verify that function SetAppFreezeState and CancelAppFreezeState.
58  * @tc.type: FUNC
59  */
60 HWTEST_F(AppFreezeStateTest, AppfreezeStateTest_001, TestSize.Level0)
61 {
62     GTEST_LOG_(INFO) << "AppfreezeStateTest_001 start";
63     uint32_t flag = 1;
64     auto appFreezeState = std::make_shared<AbilityRuntime::AppFreezeState> ();
65     auto inner = AppfreezeInner::GetInstance();
66     appFreezeState->SetAppFreezeState(flag);
67     EXPECT_FALSE(inner->IsHandleAppfreeze());
68 
69     flag = -1;
70     appFreezeState->CancelAppFreezeState(flag);
71     EXPECT_TRUE(inner->IsHandleAppfreeze());
72     GTEST_LOG_(INFO) << "AppfreezeStateTest_001 end";
73 }
74 }  // namespace AbilityRuntime
75 }  // namespace OHOS
76