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(DisplayPhysicalResolutionTest, MarshallingUnmarshalling_DefaultValues, TestSize.Level1) 28 { 29 DisplayPhysicalResolution displayPhysicalResolution1; 30 Parcel parcel; 31 bool ret = displayPhysicalResolution1.Marshalling(parcel); 32 ASSERT_TRUE(ret); 33 34 sptr<DisplayPhysicalResolution> displayPhysicalResolution2 = DisplayPhysicalResolution::Unmarshalling(parcel); 35 ASSERT_NE(displayPhysicalResolution2, nullptr); 36 EXPECT_EQ(displayPhysicalResolution2->foldDisplayMode_, FoldDisplayMode::UNKNOWN); 37 EXPECT_EQ(displayPhysicalResolution2->physicalWidth_, 0); 38 EXPECT_EQ(displayPhysicalResolution2->physicalHeight_, 0); 39 } 40 41 /** 42 * @tc.name: MarshallingUnmarshalling_CustomValues 43 * @tc.desc: Marshalling and unmarshalling test with custom values 44 * @tc.type: FUNC 45 */ 46 HWTEST(DisplayPhysicalResolutionTest, MarshallingUnmarshalling_CustomValues, TestSize.Level1) 47 { 48 DisplayPhysicalResolution dmVirtualScreenOption1(FoldDisplayMode::MAIN, 1920, 1080); 49 50 Parcel parcel; 51 bool ret = dmVirtualScreenOption1.Marshalling(parcel); 52 ASSERT_TRUE(ret); 53 54 sptr<DisplayPhysicalResolution> displayPhysicalResolution2 = DisplayPhysicalResolution::Unmarshalling(parcel); 55 ASSERT_NE(displayPhysicalResolution2, nullptr); 56 EXPECT_EQ(displayPhysicalResolution2->foldDisplayMode_, FoldDisplayMode::MAIN); 57 EXPECT_EQ(displayPhysicalResolution2->physicalWidth_, 1920); 58 EXPECT_EQ(displayPhysicalResolution2->physicalHeight_, 1080); 59 } 60 } // namespace OHOS::Rosen 61