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 #include <cstdlib>
16 #include <fstream>
17 #include <gtest/gtest.h>
18 #include <iostream>
19 #include "page_node_info.h"
20 #include "session_info.h"
21
22 using namespace testing;
23 using namespace testing::ext;
24
25 namespace OHOS {
26 namespace AbilityBase {
27 namespace {
28 static const std::string TJSON =
29 "{\"autoFillType\":0,\"depth\":-1,\"enableAutoFill\":true,\"id\":-1,\"isFocus\":false,"
30 "\"metadata\":\"\",\"passwordRules\":\"\",\"placeholder\":\"\","
31 "\"rect\":\"{\\\"height\\\":0.0,\\\"left\\\":0.0,\\\"top\\\":0.0,"
32 "\\\"width\\\":0.0}\",\"tag\":\"\",\"value\":\"\"}";
33 } // namespace
34 class PageNodeInfoTest : public testing::Test {
35 public:
36 static void SetUpTestCase();
37 static void TearDownTestCase();
38 void SetUp();
39 void TearDown();
40 };
41
SetUpTestCase()42 void PageNodeInfoTest::SetUpTestCase()
43 {}
44
TearDownTestCase()45 void PageNodeInfoTest::TearDownTestCase()
46 {}
47
SetUp()48 void PageNodeInfoTest::SetUp()
49 {}
50
TearDown()51 void PageNodeInfoTest::TearDown()
52 {}
53
54 /**
55 * @tc.name: FromJsonString_100
56 * @tc.desc: PageNodeInfo test for FromJsonString.
57 * @tc.type: FUNC
58 */
HWTEST_F(PageNodeInfoTest, FromJsonString_100, TestSize.Level1)59 HWTEST_F(PageNodeInfoTest, FromJsonString_100, TestSize.Level1)
60 {
61 std::string jsonStr = "jsonStr";
62 std::shared_ptr<PageNodeInfo> pageNodeInfo = std::make_shared<PageNodeInfo>();
63 EXPECT_TRUE(pageNodeInfo != nullptr);
64 pageNodeInfo->FromJsonString(jsonStr);
65 pageNodeInfo->FromJsonString(TJSON);
66 std::string ret = pageNodeInfo->ToJsonString();
67 EXPECT_EQ(ret, TJSON);
68 }
69
70 /**
71 * @tc.name: Unmarshalling_100
72 * @tc.desc: SessionInfo test for Unmarshalling.
73 * @tc.type: FUNC
74 */
HWTEST_F(PageNodeInfoTest, Unmarshalling_100, TestSize.Level1)75 HWTEST_F(PageNodeInfoTest, Unmarshalling_100, TestSize.Level1)
76 {
77 std::shared_ptr<AAFwk::SessionInfo> sessioninfo = std::make_shared<AAFwk::SessionInfo>();
78 EXPECT_TRUE(sessioninfo != nullptr);
79 Parcel parcel;
80 auto ret = sessioninfo->Unmarshalling(parcel);
81 EXPECT_NE(ret, nullptr);
82 }
83 } // namespace AbilityBase
84 } // namespace OHOS