Protecting test cases from memory scribbling 20/254820/3
authorDavid Steele <david.steele@samsung.com>
Tue, 9 Mar 2021 15:52:25 +0000 (15:52 +0000)
committerDavid Steele <david.steele@samsung.com>
Thu, 11 Mar 2021 13:11:33 +0000 (13:11 +0000)
Modified 3 tcs which have scribbling on shutdown (VisualFactory
Singleton destroyed before visuals, due to scene still owning
actors with visuals).

Change-Id: I02c200d0094d6eb9803e617effc125ddb78faf46

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h
automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp
automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp

index b64b9ee..22ffcfb 100644 (file)
@@ -27,7 +27,7 @@ TestGraphicsBuffer::TestGraphicsBuffer(TraceCallStack& callStack, TestGlAbstract
   mGl(glAbstraction),
   mUsage(usage)
 {
   mGl(glAbstraction),
   mUsage(usage)
 {
-  memory.reserve(size);
+  memory.resize(size);
   mGl.GetBufferTrace().EnableLogging(true);
 }
 
   mGl.GetBufferTrace().EnableLogging(true);
 }
 
index 782835e..f970525 100644 (file)
@@ -759,7 +759,11 @@ Graphics::UniquePtr<Graphics::Program> TestGraphicsController::CreateProgram(con
     for(auto& shader : *(programCreateInfo.shaderState))
     {
       auto graphicsShader = Uncast<TestGraphicsShader>(shader.shader);
     for(auto& shader : *(programCreateInfo.shaderState))
     {
       auto graphicsShader = Uncast<TestGraphicsShader>(shader.shader);
-      if(memcmp(cacheEntry.shaders[shader.pipelineStage], graphicsShader->mCreateInfo.sourceData, graphicsShader->mCreateInfo.sourceSize))
+      std::vector<uint8_t> source;
+      source.resize(graphicsShader->mCreateInfo.sourceSize);
+      memcpy(&source[0], graphicsShader->mCreateInfo.sourceData, graphicsShader->mCreateInfo.sourceSize);
+
+      if(!std::equal(source.begin(), source.end(), cacheEntry.shaders[shader.pipelineStage].begin()))
       {
         found = false;
         break;
       {
         found = false;
         break;
@@ -776,7 +780,8 @@ Graphics::UniquePtr<Graphics::Program> TestGraphicsController::CreateProgram(con
   for(auto& shader : *(programCreateInfo.shaderState))
   {
     auto graphicsShader                                = Uncast<TestGraphicsShader>(shader.shader);
   for(auto& shader : *(programCreateInfo.shaderState))
   {
     auto graphicsShader                                = Uncast<TestGraphicsShader>(shader.shader);
-    mProgramCache.back().shaders[shader.pipelineStage] = graphicsShader->mCreateInfo.sourceData;
+    mProgramCache.back().shaders[shader.pipelineStage].resize( graphicsShader->mCreateInfo.sourceSize );
+    memcpy(&mProgramCache.back().shaders[shader.pipelineStage][0], graphicsShader->mCreateInfo.sourceData, graphicsShader->mCreateInfo.sourceSize);
   }
   return Graphics::MakeUnique<TestGraphicsProgram>(mProgramCache.back().programImpl);
 }
   }
   return Graphics::MakeUnique<TestGraphicsProgram>(mProgramCache.back().programImpl);
 }
index cbe78ec..14429ef 100644 (file)
@@ -337,8 +337,8 @@ public:
 
   struct ProgramCache
   {
 
   struct ProgramCache
   {
-    std::map<Graphics::PipelineStage, const void*> shaders;
-    TestGraphicsProgramImpl*                       programImpl;
+    std::map<Graphics::PipelineStage, std::vector<uint8_t>> shaders;
+    TestGraphicsProgramImpl* programImpl;
   };
   std::vector<ProgramCache> mProgramCache;
 
   };
   std::vector<ProgramCache> mProgramCache;
 
index e9cc39b..de98918 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -261,6 +261,8 @@ int UtcDaliSliderSignals1(void)
   DALI_TEST_CHECK(gSliderValueChangedCallBackCalled);
   DALI_TEST_CHECK(gSliderMarkCallBackCalled);
   DALI_TEST_CHECK(gSliderSlidingFinishedCallBackCalled);
   DALI_TEST_CHECK(gSliderValueChangedCallBackCalled);
   DALI_TEST_CHECK(gSliderMarkCallBackCalled);
   DALI_TEST_CHECK(gSliderSlidingFinishedCallBackCalled);
+
+  UnparentAndReset(slider);
   END_TEST;
 }
 
   END_TEST;
 }
 
@@ -446,6 +448,7 @@ int UtcDaliSetPropertyP(void)
     DALI_TEST_EQUALS( *url, "popupArrow2.png", TEST_LOCATION );
   }
 
     DALI_TEST_EQUALS( *url, "popupArrow2.png", TEST_LOCATION );
   }
 
+  UnparentAndReset(slider);
   END_TEST;
 }
 
   END_TEST;
 }
 
index 0b7704c..ab67b9d 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1150,6 +1150,7 @@ int UtcDaliNPatchVisualAuxiliaryImage01(void)
   Renderer renderer = dummy.GetRendererAt( 0 );
   auto textures = renderer.GetTextures();
   DALI_TEST_EQUALS( textures.GetTextureCount(), 2, TEST_LOCATION );
   Renderer renderer = dummy.GetRendererAt( 0 );
   auto textures = renderer.GetTextures();
   DALI_TEST_EQUALS( textures.GetTextureCount(), 2, TEST_LOCATION );
+  UnparentAndReset(dummy);
 
   END_TEST;
 }
 
   END_TEST;
 }
@@ -1204,10 +1205,13 @@ int UtcDaliVisualFactoryGetNPatchVisualN1(void)
   TraceCallStack& textureTrace = gl.GetTextureTrace();
   textureTrace.Enable(true);
 
   TraceCallStack& textureTrace = gl.GetTextureTrace();
   textureTrace.Enable(true);
 
-  DummyControl actor = DummyControl::New(true);
-  TestVisualAsynchronousRender( application, actor, visual );
+  {
+    DummyControl actor = DummyControl::New(true);
+    TestVisualAsynchronousRender( application, actor, visual );
 
 
-  DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+    DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+    UnparentAndReset(actor);
+  }
 
   END_TEST;
 }
 
   END_TEST;
 }