1 /* 2 * Copyright (c) 2025 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 "dm_common.h" 18 19 using namespace testing::ext; 20 21 namespace OHOS::Rosen { 22 /** 23 * @tc.name: MarshallingUnmarshalling_DefaultValues 24 * @tc.desc: Marshalling and unmarshalling test with default values 25 * @tc.type: FUNC 26 */ 27 HWTEST(PointTest, MarshallingUnmarshalling_DefaultValues, TestSize.Level1) 28 { 29 Point point1; 30 Parcel parcel; 31 bool ret = point1.Marshalling(parcel); 32 ASSERT_TRUE(ret); 33 34 sptr<Point> point2 = Point::Unmarshalling(parcel); 35 ASSERT_NE(point2, nullptr); 36 EXPECT_EQ(point2->posX_, 0); 37 EXPECT_EQ(point2->posY_, 0); 38 } 39 40 /** 41 * @tc.name: MarshallingUnmarshalling_CustomValues 42 * @tc.desc: Marshalling and unmarshalling test with custom values 43 * @tc.type: FUNC 44 */ 45 HWTEST(PointTest, MarshallingUnmarshalling_CustomValues, TestSize.Level1) 46 { 47 Point point1(100, 200); 48 Parcel parcel; 49 bool ret = point1.Marshalling(parcel); 50 ASSERT_TRUE(ret); 51 52 sptr<Point> point2 = Point::Unmarshalling(parcel); 53 ASSERT_NE(point2, nullptr); 54 EXPECT_EQ(point2->posX_, 100); 55 EXPECT_EQ(point2->posY_, 200); 56 } 57 } // namespace OHOS::Rosen 58