From 0ad8db08b641a3d9d833ef8fc77ae85a5fde64f7 Mon Sep 17 00:00:00 2001 From: redking-zhong Date: Wed, 8 Nov 2023 09:34:00 +0800 Subject: [PATCH 1/3] tdd1108 Signed-off-by: redking-zhong --- .../test/unittest/screen_session_test.cpp | 158 ++++++++++++++++-- 1 file changed, 140 insertions(+), 18 deletions(-) diff --git a/window_scene/test/unittest/screen_session_test.cpp b/window_scene/test/unittest/screen_session_test.cpp index 3f6575626c..9599644c97 100644 --- a/window_scene/test/unittest/screen_session_test.cpp +++ b/window_scene/test/unittest/screen_session_test.cpp @@ -471,30 +471,152 @@ HWTEST_F(ScreenSessionTest, SetVirtualPixelRatio, Function | SmallTest | Level2) } /** - * @tc.name: CalcRotation + * @tc.name: screen_session_test001 * @tc.desc: normal function * @tc.type: FUNC */ -HWTEST_F(ScreenSessionTest, CalcRotation, Function | SmallTest | Level2) +HWTEST_F(ScreenSessionTest, screen_session_test001, Function | SmallTest | Level2) { - GTEST_LOG_(INFO) << "ScreenSessionTest: CalcRotation start"; + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test001 start"; + sptr session = new(std::nothrow) ScreenSession(); + IScreenChangeListener* screenChangeListener = nullptr; + session->screenState_ = ScreenState::CONNECTION; + int res = 0; + session->RegisterScreenChangeListener(screenChangeListener); + ASSERT_EQ(res, 0); + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test001 end"; +} + +/** + * @tc.name: screen_session_test002 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, screen_session_test002, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test002 start"; + sptr session = new(std::nothrow) ScreenSession(); + ScreenId res = session->GetScreenId(); + ASSERT_EQ(res, session->screenId_); + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test002 end"; +} + +/** + * @tc.name: screen_session_test003 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, screen_session_test003, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test003 start"; + sptr session = new(std::nothrow) ScreenSession(); + DMError res = session->SetScreenColorTransform(); + ASSERT_EQ(res, DMError::DM_OK); + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test003 end"; +} + +/** + * @tc.name: screen_session_test004 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, screen_session_test004, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test004 start"; + sptr session = new(std::nothrow) ScreenSession(); + RRect bounds; + RRect phyBounds; + int res = 0; + session->UpdatePropertyByFoldControl(bounds, phyBounds); + ASSERT_EQ(res, 0); + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test004 end"; +} + +/** + * @tc.name: screen_session_test005 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, screen_session_test005, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test005 start"; + sptr session = new(std::nothrow) ScreenSession(); + ScreenProperty newProperty; + ScreenPropertyChangeReason reason = ScreenPropertyChangeReason::CHANGE_MODE; + int res = 0; + session->PropertyChange(newProperty, reason); + ASSERT_EQ(res, 0); + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test005 end"; +} + +/** + * @tc.name: screen_session_test006 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, screen_session_test006, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test006 start"; + sptr session = new(std::nothrow) ScreenSession(); + Rotation sensorRotation = Rotation::ROTATION_90; + float res = session->ConvertRotationToFloat(sensorRotation); + ASSERT_EQ(res, 90.f); + sensorRotation = Rotation::ROTATION_180; + res = session->ConvertRotationToFloat(sensorRotation); + ASSERT_EQ(res, 180.f); + sensorRotation = Rotation::ROTATION_270; + res = session->ConvertRotationToFloat(sensorRotation); + ASSERT_EQ(res, 270.f); + sensorRotation = Rotation::ROTATION_0; + res = session->ConvertRotationToFloat(sensorRotation); + ASSERT_EQ(res, 0.f); + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test006 end"; +} + +/** + * @tc.name: screen_session_test007 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, screen_session_test007, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test007 start"; sptr session = new(std::nothrow) ScreenSession(); Orientation orientation = Orientation::UNSPECIFIED; - Rotation res = session->CalcRotation(orientation); - ASSERT_EQ(res, Rotation::ROTATION_0); - orientation = Orientation::VERTICAL; - res = session->CalcRotation(orientation); - ASSERT_EQ(res, Rotation::ROTATION_0); - orientation = Orientation::HORIZONTAL; - res = session->CalcRotation(orientation); - ASSERT_EQ(res, Rotation::ROTATION_0); - orientation = Orientation::REVERSE_VERTICAL; - res = session->CalcRotation(orientation); - ASSERT_EQ(res, Rotation::ROTATION_0); - orientation = Orientation::REVERSE_HORIZONTAL; - res = session->CalcRotation(orientation); - ASSERT_EQ(res, Rotation::ROTATION_0); - GTEST_LOG_(INFO) << "ScreenSessionTest: CalcRotation end"; + int res = 0; + session->ScreenOrientationChange(orientation); + ASSERT_EQ(res, 0); + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test007 end"; +} + +/** + * @tc.name: screen_session_test008 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, screen_session_test008, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test008 start"; + sptr session = new(std::nothrow) ScreenSession(); + bool res = session->HasPrivateSessionForeground(); + ASSERT_EQ(res, false); + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test008 end"; +} + +/** + * @tc.name: screen_session_test009 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, screen_session_test009, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test009 start"; + sptr session = new(std::nothrow) ScreenSession(); + Rotation rotation = Rotation::ROTATION_90; + session->SetRotation(rotation); + Rotation res = session->GetRotation(); + ASSERT_EQ(res, rotation); + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test009 end"; } } // namespace } // namespace Rosen -- Gitee From af005c1f6ddaeb9f04007fa442aa134ad1bb4d41 Mon Sep 17 00:00:00 2001 From: redking-zhong Date: Wed, 8 Nov 2023 14:23:19 +0800 Subject: [PATCH 2/3] updata tdd Signed-off-by: redking-zhong --- .../test/unittest/screen_session_test.cpp | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/window_scene/test/unittest/screen_session_test.cpp b/window_scene/test/unittest/screen_session_test.cpp index 9599644c97..248cf30684 100644 --- a/window_scene/test/unittest/screen_session_test.cpp +++ b/window_scene/test/unittest/screen_session_test.cpp @@ -618,6 +618,53 @@ HWTEST_F(ScreenSessionTest, screen_session_test009, Function | SmallTest | Level ASSERT_EQ(res, rotation); GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test009 end"; } + +/** + * @tc.name: screen_session_test010 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, screen_session_test010, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test010 start"; + ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE); + ScreenId childScreen = 1; + bool res = sessionGroup.HasChild(childScreen); + ASSERT_EQ(res, false); + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test010 end"; +} + +/** + * @tc.name: screen_session_test011 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, screen_session_test011, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test011 start"; + ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE); + int ret = 0; + std::vector> res = sessionGroup.GetChildren(); + ASSERT_EQ(ret, 0); + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test011 end"; +} + +/** + * @tc.name: screen_session_test012 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, screen_session_test012, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test012 start"; + sptr session = new(std::nothrow) ScreenSession(); + int res = 0; + RectF rect = RectF(0, 0, 0, 0); + uint32_t offsetY = 0; + session->SetDisplayBoundary(rect, offsetY); + ASSERT_EQ(res, 0); + GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test012 end"; +} } // namespace } // namespace Rosen } // namespace OHOS -- Gitee From 4282376791a0a0dd95bafeda0d95189979d65282 Mon Sep 17 00:00:00 2001 From: redking-zhong Date: Thu, 9 Nov 2023 10:14:10 +0800 Subject: [PATCH 3/3] updata 1109 Signed-off-by: redking-zhong --- window_scene/test/unittest/screen_session_test.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/window_scene/test/unittest/screen_session_test.cpp b/window_scene/test/unittest/screen_session_test.cpp index 248cf30684..8bc3fb4dd3 100644 --- a/window_scene/test/unittest/screen_session_test.cpp +++ b/window_scene/test/unittest/screen_session_test.cpp @@ -478,8 +478,8 @@ HWTEST_F(ScreenSessionTest, SetVirtualPixelRatio, Function | SmallTest | Level2) HWTEST_F(ScreenSessionTest, screen_session_test001, Function | SmallTest | Level2) { GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test001 start"; - sptr session = new(std::nothrow) ScreenSession(); IScreenChangeListener* screenChangeListener = nullptr; + sptr session = new(std::nothrow) ScreenSession(); session->screenState_ = ScreenState::CONNECTION; int res = 0; session->RegisterScreenChangeListener(screenChangeListener); @@ -643,9 +643,8 @@ HWTEST_F(ScreenSessionTest, screen_session_test011, Function | SmallTest | Level { GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test011 start"; ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE); - int ret = 0; std::vector> res = sessionGroup.GetChildren(); - ASSERT_EQ(ret, 0); + ASSERT_EQ(res.empty(), true); GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test011 end"; } -- Gitee