1 /*
2  * Copyright (c) 2023 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 "print_extension.h"
18 #include "extension_base.h"
19 #include "mock_runtime.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
24 namespace OHOS {
25 namespace AbilityRuntime {
26 class PrintExtensionTest : public testing::Test {
27 public:
28     static void SetUpTestCase(void);
29     static void TearDownTestCase(void);
30     void SetUp();
31     void TearDown();
32 };
33 
SetUpTestCase(void)34 void PrintExtensionTest::SetUpTestCase(void) {}
35 
TearDownTestCase(void)36 void PrintExtensionTest::TearDownTestCase(void) {}
37 
SetUp(void)38 void PrintExtensionTest::SetUp(void) {}
39 
TearDown(void)40 void PrintExtensionTest::TearDown(void) {}
41 
42 /**
43  * @tc.name: PrintExtensionTest_0001
44  * @tc.desc: Verify the capability function.
45  * @tc.type: FUNC
46  * @tc.require:
47  */
48 HWTEST_F(PrintExtensionTest, PrintExtensionTest_0001, TestSize.Level1)
49 {
50     std::unique_ptr<Runtime> runtime = nullptr;
51     EXPECT_NE(PrintExtension::Create(runtime), nullptr);
52 }
53 
54 HWTEST_F(PrintExtensionTest, PrintExtensionTest_0002, TestSize.Level1)
55 {
56     std::unique_ptr<Runtime> runtime = std::make_unique<MockRuntime>();
57     EXPECT_NE(PrintExtension::Create(runtime), nullptr);
58 }
59 
60 HWTEST_F(PrintExtensionTest, PrintExtensionTest_0003, TestSize.Level1)
61 {
62     std::unique_ptr<Runtime> runtime = std::make_unique<MockRuntimeJS>();
63     EXPECT_NE(PrintExtension::Create(runtime), nullptr);
64 }
65 
66 HWTEST_F(PrintExtensionTest, PrintExtensionTest_0004, TestSize.Level1)
67 {
68     std::unique_ptr<Runtime> runtime = std::make_unique<MockRuntime>();
69     std::shared_ptr<AbilityLocalRecord> record = nullptr;
70     std::shared_ptr<OHOSApplication> application = nullptr;
71     std::shared_ptr<AbilityHandler> handler = nullptr;
72     sptr<IRemoteObject> token = nullptr;
73     PrintExtension* printExtension = PrintExtension::Create(runtime);
74     std::shared_ptr<PrintExtensionContext> context;
75     context = printExtension->CreateAndInitContext(record, application, handler, token);
76     EXPECT_NE(context, nullptr);
77 }
78 } // namespace AbilityRuntime
79 } // namespace OHOS