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 "napi_base_context.h"
19 #include "hilog_tag_wrapper.h"
20
21 using namespace testing::ext;
22
23 namespace OHOS {
24 namespace AbilityRuntime {
25 class NapiBaseContextTest : public testing::Test {
26 public:
27 static void SetUpTestCase();
28 static void TearDownTestCase();
29 void SetUp() override;
30 void TearDown() override;
31 };
32
SetUpTestCase(void)33 void NapiBaseContextTest::SetUpTestCase(void)
34 {}
35
TearDownTestCase(void)36 void NapiBaseContextTest::TearDownTestCase(void)
37 {}
38
SetUp()39 void NapiBaseContextTest::SetUp()
40 {}
41
TearDown()42 void NapiBaseContextTest::TearDown()
43 {}
44
45 /**
46 * @tc.name: IsStageContext_0100
47 * @tc.desc: basic function test.
48 * @tc.type: FUNC
49 */
50 HWTEST_F(NapiBaseContextTest, IsStageContext_0100, TestSize.Level1)
51 {
52 TAG_LOGI(AAFwkTag::TEST, "IsStageContext start");
53
54 napi_env env = nullptr;
55 bool stageMode = false;
56 napi_value args[0] = {};
57 napi_status status = OHOS::AbilityRuntime::IsStageContext(env, args[0], stageMode);
58 EXPECT_NE(status, napi_ok);
59 EXPECT_FALSE(stageMode);
60
61 TAG_LOGI(AAFwkTag::TEST, "IsStageContext end");
62 }
63
64 /**
65 * @tc.name: GetStageModeContext_0100
66 * @tc.desc: basic function test.
67 * @tc.type: FUNC
68 */
69 HWTEST_F(NapiBaseContextTest, GetStageModeContext_0100, TestSize.Level1)
70 {
71 TAG_LOGI(AAFwkTag::TEST, "GetStageModeContext start");
72
73 napi_env env = nullptr;
74 napi_value argv[0] = {};
75 auto context = OHOS::AbilityRuntime::GetStageModeContext(env, argv[0]);
76 EXPECT_EQ(context, nullptr);
77
78 TAG_LOGI(AAFwkTag::TEST, "GetStageModeContext end");
79 }
80
81 /**
82 * @tc.name: GetCurrentAbility_0100
83 * @tc.desc: basic function test.
84 * @tc.type: FUNC
85 */
86 HWTEST_F(NapiBaseContextTest, GetCurrentAbility_0100, TestSize.Level1)
87 {
88 TAG_LOGI(AAFwkTag::TEST, "GetCurrentAbility start");
89
90 napi_env env = nullptr;
91 auto ability = OHOS::AbilityRuntime::GetCurrentAbility(env);
92 EXPECT_EQ(ability, nullptr);
93
94 TAG_LOGI(AAFwkTag::TEST, "GetCurrentAbility end");
95 }
96
97 } // namespace AbilityRuntime
98 } // namespace OHOS
99