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 #include <memory>
18
19 #define private public
20 #define protected public
21 #include "exit_reason.h"
22 #undef private
23 #undef protected
24
25 #include "ability_config.h"
26 #include "ability_manager_errors.h"
27 #include "ability_scheduler.h"
28 #include "ability_util.h"
29 #include "bundlemgr/mock_bundle_manager.h"
30 #include "hilog_tag_wrapper.h"
31 #include "mock_ability_connect_callback.h"
32 #include "mock_sa_call.h"
33 #include "mock_task_handler_wrap.h"
34 #include "sa_mgr_client.h"
35 #include "system_ability_definition.h"
36 #include <thread>
37 #include <chrono>
38
39 using namespace testing::ext;
40 using namespace OHOS::AppExecFwk;
41 using testing::_;
42 using testing::Return;
43
44 namespace {
45 const int32_t SLEEP_TIME = 10000;
46 }
47 namespace OHOS {
48 namespace AAFwk {
49
50 class ExitReasonTest : public testing::Test {
51 public:
52 static void SetUpTestCase(void);
53 static void TearDownTestCase(void);
54 void SetUp();
55 void TearDown();
56 };
57
SetUpTestCase(void)58 void ExitReasonTest::SetUpTestCase(void)
59 {}
TearDownTestCase(void)60 void ExitReasonTest::TearDownTestCase(void)
61 {}
62
SetUp()63 void ExitReasonTest::SetUp()
64 {}
TearDown()65 void ExitReasonTest::TearDown()
66 {}
67
68 /*
69 * Feature: ExitReasonTest
70 * Function: Unmarshalling
71 * SubFunction: NA
72 * FunctionPoints: Unmarshalling
73 * EnvConditions:NA
74 * CaseDescription: Verify the normal process of Unmarshalling
75 */
HWTEST_F(ExitReasonTest, Unmarshalling_001, TestSize.Level1)76 HWTEST_F(ExitReasonTest, Unmarshalling_001, TestSize.Level1)
77 {
78 TAG_LOGD(AAFwkTag::TEST, "Unmarshalling_001 called. start");
79 Reason reason = Reason::REASON_JS_ERROR;
80 std::string exitMsg = "JsError";
81 ExitReason info(reason, exitMsg);
82 Parcel parcel;
83 ExitReason * res = info.Unmarshalling(parcel);
84 EXPECT_EQ(res, nullptr);
85 TAG_LOGD(AAFwkTag::TEST, "Unmarshalling_001 called. end");
86 }
87
88 } // namespace AAFwk
89 } // namespace OHOS
90