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 "base/test/mock/mock_asset_manager.h"
19 #include "core/components/test/unittest/mock/mock_render_common.h"
20 #define private public
21 #define protected public
22 #include "bridge/card_frontend/card_frontend_delegate.h"
23 #undef private
24 #undef protected
25 #include "bridge/common/utils/utils.h"
26
27 using namespace testing;
28 using namespace testing::ext;
29
30 namespace OHOS::Ace::Framework {
31 class CardFrontendDelegateTest : public testing::Test {
32 public:
33 static void SetUpTestCase();
34 static void TearDownTestCase();
35 void SetUp() override;
36 void TearDown() override;
37 };
38
SetUpTestCase()39 void CardFrontendDelegateTest::SetUpTestCase() {}
TearDownTestCase()40 void CardFrontendDelegateTest::TearDownTestCase() {}
SetUp()41 void CardFrontendDelegateTest::SetUp() {}
TearDown()42 void CardFrontendDelegateTest::TearDown() {}
43
44 /**
45 * @tc.name: FireCardEvent001
46 * @tc.desc: Test card frontend delegate FireCardEvent method.
47 * @tc.type: FUNC
48 */
49 HWTEST_F(CardFrontendDelegateTest, FireCardEvent001, TestSize.Level1)
50 {
51 auto cardFrontendDelegate = AceType::MakeRefPtr<CardFrontendDelegate>();
52 EventMarker event;
53 cardFrontendDelegate->CreatePage(1, ""), cardFrontendDelegate->FireCardEvent(event, "");
54 cardFrontendDelegate->FireCardEvent(event, "test");
55 auto page = cardFrontendDelegate->GetPage();
56 ASSERT_NE(page, nullptr);
57 }
58
59 /**
60 * @tc.name: CreatePage001
61 * @tc.desc: Test card frontend delegate CreatePage method.
62 * @tc.type: FUNC
63 */
64 HWTEST_F(CardFrontendDelegateTest, CreatePage001, TestSize.Level1)
65 {
66 auto cardFrontendDelegate = AceType::MakeRefPtr<CardFrontendDelegate>();
67 cardFrontendDelegate->CreatePage(1, "", nullptr);
68 auto page = cardFrontendDelegate->GetPage();
69 ASSERT_NE(page, nullptr);
70 }
71
72 /**
73 * @tc.name: GetPage001
74 * @tc.desc: Test card frontend delegate GetPage method.
75 * @tc.type: FUNC
76 */
77 HWTEST_F(CardFrontendDelegateTest, GetPage001, TestSize.Level1)
78 {
79 auto cardFrontendDelegate = AceType::MakeRefPtr<CardFrontendDelegate>();
80 cardFrontendDelegate->CreatePage(1, "", nullptr);
81 auto page = cardFrontendDelegate->GetPage();
82 ASSERT_NE(page, nullptr);
83 }
84 } // namespace OHOS::Ace::Framework