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 #include <gtest/gtest.h> 16 #include "dm_common.h" 17 #include "ws_common.h" 18 #include "common/include/session_helper.h" 19 20 using namespace testing; 21 using namespace testing::ext; 22 23 namespace OHOS { 24 namespace Rosen { 25 class SessionHelperTest : public testing::Test { 26 public: SessionHelperTest()27 SessionHelperTest() {} ~SessionHelperTest()28 ~SessionHelperTest() {} 29 }; 30 namespace { 31 /** 32 * @tc.name: ConvertDisplayOrientationToFloat 33 * @tc.desc: normal function 34 * @tc.type: FUNC 35 */ 36 HWTEST_F(SessionHelperTest, ConvertDisplayOrientationToFloat, TestSize.Level1) 37 { 38 DisplayOrientation orientation = DisplayOrientation::LANDSCAPE; 39 EXPECT_EQ(SessionHelper::ConvertDisplayOrientationToFloat(orientation), 90.f); // degree 90 40 orientation = DisplayOrientation::PORTRAIT_INVERTED; 41 EXPECT_EQ(SessionHelper::ConvertDisplayOrientationToFloat(orientation), 180.f); // degree 180 42 orientation = DisplayOrientation::LANDSCAPE_INVERTED; 43 EXPECT_EQ(SessionHelper::ConvertDisplayOrientationToFloat(orientation), 270.f); // degree 270 44 orientation = DisplayOrientation::UNKNOWN; 45 EXPECT_EQ(SessionHelper::ConvertDisplayOrientationToFloat(orientation), 0.f); // degree 0 46 } 47 48 /** 49 * @tc.name: GetAreaTypeForScaleResize 50 * @tc.desc: normal function 51 * @tc.type: FUNC 52 */ 53 HWTEST_F(SessionHelperTest, GetAreaTypeForScaleResize, TestSize.Level1) 54 { 55 int32_t pointWinX = 1249; 56 int32_t pointWinY = 2717; 57 int outside = 7; 58 const WSRect& rect = {579, -418, 1260, 2720}; 59 // RIGHT_BOTTOM 60 EXPECT_EQ(SessionHelper::GetAreaTypeForScaleResize(pointWinX, pointWinY, outside, rect), AreaType::RIGHT_BOTTOM); 61 62 pointWinX = 6; 63 pointWinY = 2707; 64 outside = 7; 65 const WSRect& rect2 = {614, -342, 1260, 2720}; 66 // LEFT_BOTTOM 67 EXPECT_EQ(SessionHelper::GetAreaTypeForScaleResize(pointWinX, pointWinY, outside, rect2), AreaType::LEFT_BOTTOM); 68 69 pointWinX = 1255; 70 pointWinY = 15; 71 outside = 7; 72 const WSRect& rect3 = {659, -440, 1260, 2720}; 73 // RIGHT_TOP 74 EXPECT_EQ(SessionHelper::GetAreaTypeForScaleResize(pointWinX, pointWinY, outside, rect3), AreaType::RIGHT_TOP); 75 76 pointWinX = -3; 77 pointWinY = 10; 78 outside = 7; 79 const WSRect& rect4 = {697, -522, 1260, 2720}; 80 // LEFT_TOP 81 EXPECT_EQ(SessionHelper::GetAreaTypeForScaleResize(pointWinX, pointWinY, outside, rect4), AreaType::LEFT_TOP); 82 } 83 } // namespace 84 } // namespace Rosen 85 } // namespace OHOS