• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 
18 #define private public
19 #include "app_lifecycle_deal.h"
20 #include "mock_app_scheduler.h"
21 #undef private
22 
23 using namespace testing;
24 using namespace testing::ext;
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 class AppLifecycleDealTest : public testing::Test {
29 public:
30     static void SetUpTestCase();
31     static void TearDownTestCase();
32     void SetUp() override;
33     void TearDown() override;
34 };
35 
SetUpTestCase(void)36 void AppLifecycleDealTest::SetUpTestCase(void)
37 {}
38 
TearDownTestCase(void)39 void AppLifecycleDealTest::TearDownTestCase(void)
40 {}
41 
SetUp()42 void AppLifecycleDealTest::SetUp()
43 {}
44 
TearDown()45 void AppLifecycleDealTest::TearDown()
46 {}
47 
48 /**
49  * @tc.name: NotifyAppFault_001
50  * @tc.desc: Verify that the NotifyAppFault interface calls normally
51  * @tc.type: FUNC
52  */
53 HWTEST_F(AppLifecycleDealTest, NotifyAppFault_001, TestSize.Level1)
54 {
55     auto appLifeCycle = std::make_shared<AppLifeCycleDeal>();
56     FaultData faultData;
57     int32_t result = appLifeCycle->NotifyAppFault(faultData);
58     EXPECT_EQ(result, ERR_INVALID_VALUE);
59 }
60 
61 /**
62  * @tc.name: NotifyAppFault_002
63  * @tc.desc: Verify that the NotifyAppFault interface calls normally
64  * @tc.type: FUNC
65  */
66 HWTEST_F(AppLifecycleDealTest, NotifyAppFault_002, TestSize.Level1)
67 {
68     auto appLifeCycle = std::make_shared<AppLifeCycleDeal>();
69     sptr<MockAppScheduler> mockAppScheduler = new (std::nothrow) MockAppScheduler();
70     appLifeCycle->SetApplicationClient(mockAppScheduler);
71     FaultData faultData;
72     auto retsult = appLifeCycle->NotifyAppFault(faultData);
73     EXPECT_EQ(ERR_OK, retsult);
74 }
75 } // namespace AppExecFwk
76 } // namespace OHOS
77