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