From 7035265262d98e6fd79304e123f078c81619f3f3 Mon Sep 17 00:00:00 2001 From: zhjs Date: Sun, 20 Oct 2024 10:25:06 +0800 Subject: [PATCH 1/3] TDD repair Signed-off-by: zhjs --- surface/test/unittest/native_window_test.cpp | 28 +++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/surface/test/unittest/native_window_test.cpp b/surface/test/unittest/native_window_test.cpp index 3603faa..7668249 100644 --- a/surface/test/unittest/native_window_test.cpp +++ b/surface/test/unittest/native_window_test.cpp @@ -1337,9 +1337,11 @@ HWTEST_F(NativeWindowTest, OH_NativeWindow_SetMetadataValue005, Function | Mediu } NativeWindowBuffer *nativeWindowbuffer1 = nullptr; int fenceFd = -1; - int32_t err = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowbuffer1, &fenceFd); - ASSERT_EQ(err, GSERROR_OK); - auto ret = OH_NativeWindow_SetMetadataValue(nativeWindow, OH_HDR_STATIC_METADATA, (int32_t)len, buff); + auto ret = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowbuffer1, &fenceFd); + if (ret != GSERROR_HDI_ERROR) { + ASSERT_EQ(ret, GSERROR_OK); + } + ret = OH_NativeWindow_SetMetadataValue(nativeWindow, OH_HDR_STATIC_METADATA, (int32_t)len, buff); if (ret != GSERROR_NOT_SUPPORT) { // some device not support set colorspace ASSERT_EQ(ret, GSERROR_OK); } @@ -2091,16 +2093,18 @@ HWTEST_F(NativeWindowTest, NativeWindowSetRequestWidthAndHeight001, Function | M //分支1:走使用requestWidth/Height新建config分支 ASSERT_EQ(NativeWindowSetRequestWidthAndHeight(nativeWindow, 100, 200), OHOS::GSERROR_OK); NativeWindowBuffer *nativeWindowBuffer1 = nullptr; - ASSERT_EQ(OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowBuffer1, &fence), GSERROR_OK); - ASSERT_EQ(nativeWindowBuffer1->sfbuffer->GetWidth(), 100); - ASSERT_EQ(nativeWindowBuffer1->sfbuffer->GetHeight(), 200); - ASSERT_EQ(NativeWindowCancelBuffer(nativeWindow, nativeWindowBuffer1), GSERROR_OK); + auto ret = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowBuffer1, &fence); + if (ret != GSERROR_HDI_ERROR) { + ASSERT_EQ(ret, GSERROR_OK); + ASSERT_EQ(nativeWindowBuffer1->sfbuffer->GetWidth(), 100); + ASSERT_EQ(nativeWindowBuffer1->sfbuffer->GetHeight(), 200); + ASSERT_EQ(NativeWindowCancelBuffer(nativeWindow, nativeWindowBuffer1), GSERROR_OK); + } //分支2:使用surface成员变量windowConfig_(未初始化) ASSERT_EQ(NativeWindowSetRequestWidthAndHeight(nativeWindow, 0, 200), OHOS::GSERROR_OK); - ASSERT_EQ(OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowBuffer1, &fence), - SURFACE_ERROR_UNKOWN); + ASSERT_NE(OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowBuffer1, &fence), + OHOS::GSERROR_OK); ASSERT_EQ(NativeWindowSetRequestWidthAndHeight(nativeWindow, 100, 0), OHOS::GSERROR_OK); - ASSERT_EQ(OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowBuffer1, &fence), - SURFACE_ERROR_UNKOWN); -} + ASSERT_NE(OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowBuffer1, &fence), + OHOS::GSERROR_OK); } -- Gitee From 9b7c3f46a90028eaf762482a327e0a3a1c753e97 Mon Sep 17 00:00:00 2001 From: zhjs Date: Sun, 20 Oct 2024 10:48:47 +0800 Subject: [PATCH 2/3] TDD repair Signed-off-by: zhjs --- surface/test/unittest/native_window_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/surface/test/unittest/native_window_test.cpp b/surface/test/unittest/native_window_test.cpp index 7668249..736a94c 100644 --- a/surface/test/unittest/native_window_test.cpp +++ b/surface/test/unittest/native_window_test.cpp @@ -2108,3 +2108,4 @@ HWTEST_F(NativeWindowTest, NativeWindowSetRequestWidthAndHeight001, Function | M ASSERT_NE(OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowBuffer1, &fence), OHOS::GSERROR_OK); } +} \ No newline at end of file -- Gitee From ecac713879b36cda0a9436cac54ebd956fe1ad07 Mon Sep 17 00:00:00 2001 From: zhjs Date: Sun, 20 Oct 2024 11:04:59 +0800 Subject: [PATCH 3/3] TDD repair Signed-off-by: zhjs --- surface/test/unittest/native_window_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/surface/test/unittest/native_window_test.cpp b/surface/test/unittest/native_window_test.cpp index 736a94c..285026c 100644 --- a/surface/test/unittest/native_window_test.cpp +++ b/surface/test/unittest/native_window_test.cpp @@ -1338,7 +1338,7 @@ HWTEST_F(NativeWindowTest, OH_NativeWindow_SetMetadataValue005, Function | Mediu NativeWindowBuffer *nativeWindowbuffer1 = nullptr; int fenceFd = -1; auto ret = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowbuffer1, &fenceFd); - if (ret != GSERROR_HDI_ERROR) { + if (ret != GSERROR_TYPE_ERROR) { ASSERT_EQ(ret, GSERROR_OK); } ret = OH_NativeWindow_SetMetadataValue(nativeWindow, OH_HDR_STATIC_METADATA, (int32_t)len, buff); @@ -2094,7 +2094,7 @@ HWTEST_F(NativeWindowTest, NativeWindowSetRequestWidthAndHeight001, Function | M ASSERT_EQ(NativeWindowSetRequestWidthAndHeight(nativeWindow, 100, 200), OHOS::GSERROR_OK); NativeWindowBuffer *nativeWindowBuffer1 = nullptr; auto ret = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowBuffer1, &fence); - if (ret != GSERROR_HDI_ERROR) { + if (ret != GSERROR_TYPE_ERROR) { ASSERT_EQ(ret, GSERROR_OK); ASSERT_EQ(nativeWindowBuffer1->sfbuffer->GetWidth(), 100); ASSERT_EQ(nativeWindowBuffer1->sfbuffer->GetHeight(), 200); -- Gitee