1 /*
2  * Copyright (c) 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 "ability_business_error.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace AbilityRuntime {
25 class AbilityBusinessErrorTest : public testing::Test {
26 public:
27     static void SetUpTestCase();
28     static void TearDownTestCase();
29     void SetUp() override;
30     void TearDown() override;
31 };
32 
SetUpTestCase()33 void AbilityBusinessErrorTest::SetUpTestCase()
34 {}
35 
TearDownTestCase()36 void AbilityBusinessErrorTest::TearDownTestCase()
37 {}
38 
SetUp()39 void AbilityBusinessErrorTest::SetUp()
40 {}
41 
TearDown()42 void AbilityBusinessErrorTest::TearDown()
43 {}
44 
45 /**
46  * @tc.name: GetErrorMsg_0100
47  * @tc.desc: GetErrorMsg_0100 Test
48  * @tc.type: FUNC
49  * @tc.require: issueI581SE
50  */
51 HWTEST_F(AbilityBusinessErrorTest, GetErrorMsg_0100, TestSize.Level0)
52 {
53     std::string result = GetErrorMsg(AbilityErrorCode::ERROR_OK);
54     EXPECT_TRUE(result == "OK.");
55 
56     result = GetErrorMsg(static_cast<AbilityErrorCode>(-1000));
57     EXPECT_TRUE(result == "");
58 }
59 
60 /**
61  * @tc.name: GetJsErrorCodeByNativeError_0100
62  * @tc.desc: GetJsErrorCodeByNativeError_0100 Test
63  * @tc.type: FUNC
64  * @tc.require: issueI581RO
65  */
66 HWTEST_F(AbilityBusinessErrorTest, GetJsErrorCodeByNativeError_0100, TestSize.Level0)
67 {
68     AbilityErrorCode result = GetJsErrorCodeByNativeError(0);
69     EXPECT_TRUE(result == AbilityErrorCode::ERROR_OK);
70 
71     result = GetJsErrorCodeByNativeError(-1000);
72     EXPECT_TRUE(result == AbilityErrorCode::ERROR_CODE_INNER);
73 }
74 }  // namespace AAFwk
75 }  // namespace OHOS
76