From 9f3c15e452bfb51e83504409146db95ed417c93f Mon Sep 17 00:00:00 2001 From: zhangbirong Date: Mon, 18 Nov 2024 15:04:49 +0800 Subject: [PATCH] ut assert Signed-off-by: zhangbirong --- .../test/unittest/egl_blob_test.cpp | 7 ++++++- .../unittest/egl_system_layers_manager_test.cpp | 7 ++++--- .../test/unittest/egl_wrapper_layer_test.cpp | 17 +++-------------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/frameworks/opengl_wrapper/test/unittest/egl_blob_test.cpp b/frameworks/opengl_wrapper/test/unittest/egl_blob_test.cpp index 5da5e2963c..3826b3baf3 100644 --- a/frameworks/opengl_wrapper/test/unittest/egl_blob_test.cpp +++ b/frameworks/opengl_wrapper/test/unittest/egl_blob_test.cpp @@ -168,6 +168,7 @@ HWTEST_F(EglBlobTest, EglBlobInit005, Level1) HWTEST_F(EglBlobTest, destructBlobCacheTest001, Level1) { auto cache = new BlobCache(); + EXPECT_NE(cache, nullptr); cache->blobCache_ = nullptr; delete cache; cache = nullptr; @@ -183,6 +184,7 @@ HWTEST_F(EglBlobTest, EglBlobInit005, Level1) auto cache = new BlobCache(); cache->blobCache_ = nullptr; BlobCache::Get(); + EXPECT_NE(cache->blobCache_, nullptr); delete cache; cache = nullptr; } @@ -210,6 +212,7 @@ HWTEST_F(EglBlobTest, EglBlobInit005, Level1) ret->Init(nullptr); ret->initStatus_ = false; ret->Init(nullptr); + EXPECT_FALSE(ret->initStatus_); } /** @@ -221,7 +224,7 @@ HWTEST_F(EglBlobTest, EglBlobInit005, Level1) { BlobCache* ret = BlobCache::Get(); ret->SetBlob(nullptr, 0, nullptr, 0); - ret->GetBlob(nullptr, 0, nullptr, 0); + EXPECT_EQ(ret->GetBlob(nullptr, 0, nullptr, 0), 0); } /** @@ -232,6 +235,7 @@ HWTEST_F(EglBlobTest, EglBlobInit005, Level1) HWTEST_F(EglBlobTest, SetCacheDirTest, Level1) { BlobCache* ret = BlobCache::Get(); + EXPECT_NE(ret, nullptr); ret->SetCacheDir("SetCacheDirTest"); } @@ -246,5 +250,6 @@ HWTEST_F(EglBlobTest, EglBlobInit005, Level1) ret->SetCacheShaderSize(0); ret->SetCacheShaderSize(MAX_SHADER + 1); ret->SetCacheShaderSize(1); + EXPECT_EQ(ret->blobSizeMax_, 1); } } // OHOS::Rosen diff --git a/frameworks/opengl_wrapper/test/unittest/egl_system_layers_manager_test.cpp b/frameworks/opengl_wrapper/test/unittest/egl_system_layers_manager_test.cpp index e3a6a1c97d..8d7030ba4e 100644 --- a/frameworks/opengl_wrapper/test/unittest/egl_system_layers_manager_test.cpp +++ b/frameworks/opengl_wrapper/test/unittest/egl_system_layers_manager_test.cpp @@ -40,7 +40,7 @@ HWTEST_F(EglSystemLayersManagerTest, getJsonConfigtTest001, Level1) { EglSystemLayersManager manager; Json::Value val{Json::nullValue}; - manager.GetJsonConfig(val); + EXPECT_TRUE(manager.GetJsonConfig(val)); } /** @@ -52,7 +52,8 @@ HWTEST_F(EglSystemLayersManagerTest, getSystemLayersFromConfigTest, Level1) { EglSystemLayersManager manager; Json::Value val{Json::nullValue}; - manager.GetSystemLayersFromConfig(val, "testName"); + std::vector config = manager.GetSystemLayersFromConfig(val, "testName"); + EXPECT_TRUE(config.empty()); } /** @@ -65,6 +66,6 @@ HWTEST_F(EglSystemLayersManagerTest, getSystemLayersTest, Level1) EglSystemLayersManager manager; manager.GetSystemLayers(); Json::Value val{true}; - manager.GetStringVectorFromJson(val); + EXPECT_TRUE(manager.GetStringVectorFromJson(val).empty()); } } // OHOS::Rosen \ No newline at end of file diff --git a/frameworks/opengl_wrapper/test/unittest/egl_wrapper_layer_test.cpp b/frameworks/opengl_wrapper/test/unittest/egl_wrapper_layer_test.cpp index e11185c422..1c70fd901b 100644 --- a/frameworks/opengl_wrapper/test/unittest/egl_wrapper_layer_test.cpp +++ b/frameworks/opengl_wrapper/test/unittest/egl_wrapper_layer_test.cpp @@ -42,7 +42,7 @@ HWTEST_F(EglWrapperLayerTest, Init001, Level1) { EglWrapperDispatchTable dispatchTable; auto result = EglWrapperLayer::GetInstance().Init(&dispatchTable); - EXPECT_FALSE(result); + EXPECT_TRUE(result); } /** @@ -75,6 +75,7 @@ HWTEST_F(EglWrapperLayerTest, InitLayers001, Level1) return [](){}; }; layer.layerInit_.push_back(initFunc); + EXPECT_FALSE(layer.layerInit_.empty()); layer.layerSetup_ = {}; layer.InitLayers(&dispatchTable); LayerSetupFunc setupFunc = [](const char* data, EglWrapperFuncPointer getAddr) -> EglWrapperFuncPointer { @@ -96,7 +97,7 @@ HWTEST_F(EglWrapperLayerTest, LoadLayers001, Level1) EglWrapperDispatchTable dispatchTable; bool result = EglWrapperLayer::GetInstance().LoadLayers(); - ASSERT_FALSE(result); + ASSERT_TRUE(result); } /** @@ -110,16 +111,4 @@ HWTEST_F(EglWrapperLayerTest, InitBundleInfo001, Level1) bool result = EglWrapperLayer::GetInstance().InitBundleInfo(); ASSERT_FALSE(result); } - -/** - * @tc.name: SetupLayerFuncTbl001 - * @tc.desc: - * @tc.type: FUNC - */ -HWTEST_F(EglWrapperLayerTest, SetupLayerFuncTbl001, Level1) -{ - EglWrapperDispatchTable dispatchTable; - auto& layer = EglWrapperLayer::GetInstance(); - layer.SetupLayerFuncTbl(&dispatchTable); -} } // OHOS::Rosen \ No newline at end of file