• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "hilog_wrapper.h"
18 #define private public
19 #define protected public
20 #include "js_ui_ability.h"
21 #undef private
22 #undef protected
23 #include "js_runtime_utils.h"
24 
25 using namespace testing;
26 using namespace testing::ext;
27 using namespace OHOS::AAFwk;
28 using namespace OHOS::AbilityRuntime;
29 
30 namespace OHOS {
31 namespace AbilityRuntime {
32 
33 class JsUiAbilityTest : public testing::Test {
34 public:
35     static void SetUpTestCase();
36     static void TearDownTestCase();
37     void SetUp() override;
38     void TearDown() override;
39 };
40 
SetUpTestCase()41 void JsUiAbilityTest::SetUpTestCase() {}
42 
TearDownTestCase()43 void JsUiAbilityTest::TearDownTestCase() {}
44 
SetUp()45 void JsUiAbilityTest::SetUp() {}
46 
TearDown()47 void JsUiAbilityTest::TearDown() {}
48 
49 /**
50  * @tc.name: JSUIAbility_OnWillForeground_0100
51  * @tc.desc: OnWillForeground test
52  * @tc.desc: Verify function OnWillForeground.
53  */
54 HWTEST_F(JsUiAbilityTest, JSUIAbility_OnWillForeground_0100, TestSize.Level1)
55 {
56     GTEST_LOG_(INFO) << "JSUIAbility_OnWillForeground_0100 start";
57     AbilityRuntime::Runtime::Options options;
58     options.lang = AbilityRuntime::Runtime::Language::JS;
59     auto runtime = AbilityRuntime::Runtime::Create(options);
60     auto ability = AbilityRuntime::JsUIAbility::Create(runtime);
61     ASSERT_NE(ability, nullptr);
62     ability->OnWillForeground();
63     GTEST_LOG_(INFO) << "JSUIAbility_OnWillForeground_0100 end";
64 }
65 /**
66  * @tc.name: JSUIAbility_OnDidForeground_0100
67  * @tc.desc: OnDidForeground test
68  * @tc.desc: Verify function OnDidForeground.
69  */
70 HWTEST_F(JsUiAbilityTest, JSUIAbility_OnDidForeground_0100, TestSize.Level1)
71 {
72     GTEST_LOG_(INFO) << "JSUIAbility_OnDidForeground_0100 start";
73     AbilityRuntime::Runtime::Options options;
74     options.lang = AbilityRuntime::Runtime::Language::JS;
75     auto runtime = AbilityRuntime::Runtime::Create(options);
76     auto ability = AbilityRuntime::JsUIAbility::Create(runtime);
77     ASSERT_NE(ability, nullptr);
78     ability->OnDidForeground();
79     GTEST_LOG_(INFO) << "JSUIAbility_OnDidForeground_0100 end";
80 }
81 
82 /**
83  * @tc.name: JSUIAbility_OnWillBackground_0100
84  * @tc.desc: OnWillBackground test
85  * @tc.desc: Verify function OnWillBackground.
86  */
87 HWTEST_F(JsUiAbilityTest, JSUIAbility_OnWillBackground_0100, TestSize.Level1)
88 {
89     GTEST_LOG_(INFO) << "JSUIAbility_OnWillBackground_0100 start";
90     AbilityRuntime::Runtime::Options options;
91     options.lang = AbilityRuntime::Runtime::Language::JS;
92     auto runtime = AbilityRuntime::Runtime::Create(options);
93     auto ability = AbilityRuntime::JsUIAbility::Create(runtime);
94     ASSERT_NE(ability, nullptr);
95     ability->OnWillBackground();
96     GTEST_LOG_(INFO) << "JSUIAbility_OnWillBackground_0100 end";
97 }
98 
99 /**
100  * @tc.name: JSUIAbility_OnDidBackground_0100
101  * @tc.desc: OnDidBackground test
102  * @tc.desc: Verify function OnDidBackground.
103  */
104 HWTEST_F(JsUiAbilityTest, JSUIAbility_OnDidBackground_0100, TestSize.Level1)
105 {
106     GTEST_LOG_(INFO) << "JSUIAbility_OnDidBackground_0100 start";
107     AbilityRuntime::Runtime::Options options;
108     options.lang = AbilityRuntime::Runtime::Language::JS;
109     auto runtime = AbilityRuntime::Runtime::Create(options);
110     auto ability = AbilityRuntime::JsUIAbility::Create(runtime);
111     ASSERT_NE(ability, nullptr);
112     ability->OnDidBackground();
113     GTEST_LOG_(INFO) << "JSUIAbility_OnDidBackground_0100 end";
114 }
115 } // namespace AbilityRuntime
116 } // namespace OHOS