• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define private public
19 #include "auto_fill_manager.h"
20 #include "auto_fill_error.h"
21 #include "auto_fill_extension_callback.h"
22 #include "extension_ability_info.h"
23 #include "hilog_wrapper.h"
24 #undef private
25 
26 using namespace testing;
27 using namespace testing::ext;
28 
29 namespace OHOS {
30 namespace AAFwk {
31 class AutoFillManagerTest : public testing::Test {
32 public:
33     static void SetUpTestCase();
34     static void TearDownTestCase();
35     void SetUp() override;
36     void TearDown() override;
GetUIContent()37     virtual Ace::UIContent* GetUIContent()
38     {
39         return nullptr;
40     }
41 };
42 
SetUpTestCase(void)43 void AutoFillManagerTest::SetUpTestCase(void)
44 {}
45 
TearDownTestCase(void)46 void AutoFillManagerTest::TearDownTestCase(void)
47 {}
48 
SetUp()49 void AutoFillManagerTest::SetUp()
50 {}
51 
TearDown()52 void AutoFillManagerTest::TearDown()
53 {}
54 
55 /**
56  * @tc.name: RequestAutoFill_0100
57  * @tc.desc: RequestAutoFill
58  */
59 HWTEST_F(AutoFillManagerTest, RequestAutoFill_0100, TestSize.Level1)
60 {
61     GTEST_LOG_(INFO) << "AutoFillManagerTest, RequestAutoFill_0100, TestSize.Level1";
62     auto& manager = AbilityRuntime::AutoFillManager::GetInstance();
63     const AbilityBase::AutoFillType autoFillType = AbilityBase::AutoFillType::UNSPECIFIED;
64     const AbilityBase::ViewData viewdata;
65     const std::shared_ptr<AbilityRuntime::IFillRequestCallback> fillCallback = nullptr;
66     int32_t result = manager.RequestAutoFill(autoFillType, GetUIContent(), viewdata, fillCallback);
67     EXPECT_EQ(result, AbilityRuntime::AutoFill::AUTO_FILL_OBJECT_IS_NULL);
68 }
69 
70 /**
71  * @tc.name: RequestAutoSave_0100
72  * @tc.desc: RequestAutoSave
73  */
74 HWTEST_F(AutoFillManagerTest, RequestAutoSave_0100, TestSize.Level1)
75 {
76     GTEST_LOG_(INFO) << "AutoFillManagerTest, RequestAutoSave_0100, TestSize.Level1";
77     auto& manager = AbilityRuntime::AutoFillManager::GetInstance();
78     const AbilityBase::ViewData viewdata;
79     const std::shared_ptr<AbilityRuntime::ISaveRequestCallback> saveCallback = nullptr;
80     int32_t result = manager.RequestAutoSave(GetUIContent(), viewdata, saveCallback);
81     EXPECT_EQ(result, AbilityRuntime::AutoFill::AUTO_FILL_OBJECT_IS_NULL);
82 }
83 
84 /**
85  * @tc.name: HandleRequestExecuteInner_0100
86  * @tc.desc: HandleRequestExecuteInner
87  */
88 HWTEST_F(AutoFillManagerTest, HandleRequestExecuteInner_0100, TestSize.Level1)
89 {
90     GTEST_LOG_(INFO) << "AutoFillManagerTest, HandleRequestExecuteInner_0100, TestSize.Level1";
91     auto& manager = AbilityRuntime::AutoFillManager::GetInstance();
92     const AbilityBase::AutoFillType autoFillType = AbilityBase::AutoFillType::UNSPECIFIED;
93     const AbilityBase::ViewData viewdata;
94     const std::shared_ptr<AbilityRuntime::IFillRequestCallback> fillCallback = nullptr;
95     const std::shared_ptr<AbilityRuntime::ISaveRequestCallback> saveCallback = nullptr;
96     int32_t result =
97         manager.HandleRequestExecuteInner(autoFillType, GetUIContent(), viewdata, fillCallback, saveCallback);
98     EXPECT_EQ(result, AbilityRuntime::AutoFill::AUTO_FILL_OBJECT_IS_NULL);
99 }
100 } // namespace AppExecFwk
101 } // namespace OHOS