Bug fix which makes applications crash when adding a renderer to an on stage actor 66/43366/5
authorFerran Sole <ferran.sole@samsung.com>
Wed, 8 Jul 2015 10:56:10 +0000 (11:56 +0100)
committerFerran Sole <ferran.sole@samsung.com>
Fri, 10 Jul 2015 14:50:12 +0000 (07:50 -0700)
Change-Id: I8db74fac8cad03cc3a8fa5d2f86267882c1baa93

automated-tests/src/dali-devel/CMakeLists.txt
automated-tests/src/dali-devel/utc-Dali-Actor.cpp [new file with mode: 0644]
dali/internal/update/nodes/node.cpp

index 44e1966c825b519f8ea7e295f48b095a3ef13660..bb60af1983f360f1ec80641f34e285ad23b0e456 100644 (file)
@@ -6,6 +6,7 @@ SET(RPM_NAME "core-${PKG_NAME}-tests")
 SET(CAPI_LIB "dali-devel")
 
 SET(TC_SOURCES
+        utc-Dali-Actor.cpp
         utc-Dali-Atlas.cpp
         utc-Dali-Context.cpp
         utc-Dali-Constrainer.cpp
diff --git a/automated-tests/src/dali-devel/utc-Dali-Actor.cpp b/automated-tests/src/dali-devel/utc-Dali-Actor.cpp
new file mode 100644 (file)
index 0000000..7322fa4
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+#include <mesh-builder.h>
+
+//& set: DaliActor
+
+using std::string;
+using namespace Dali;
+
+
+int UtcDaliActorAddRendererP(void)
+{
+  tet_infoline("Testing Actor::AddRenderer");
+  TestApplication application;
+
+  Actor actor = Actor::New();
+
+  DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+  Geometry geometry = CreateQuadGeometry();
+  Material material = CreateMaterial(1.0f);
+  Renderer renderer = Renderer::New(geometry, material);
+
+  actor.AddRenderer( renderer );
+  DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliActorAddRendererN(void)
+{
+  tet_infoline("Testing Actor::AddRenderer");
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  Renderer renderer;
+
+  // try illegal Add
+  try
+  {
+    actor.AddRenderer( renderer );
+    tet_printf("Assertion test failed - no Exception\n" );
+    tet_result(TET_FAIL);
+  }
+  catch(Dali::DaliException& e)
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
+    DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+  }
+  catch(...)
+  {
+    tet_printf("Assertion test failed - wrong Exception\n" );
+    tet_result(TET_FAIL);
+  }
+
+  END_TEST;
+}
+
+int UtcDaliActorAddRendererOnStage(void)
+{
+  tet_infoline("Testing Actor::AddRenderer");
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  Stage::GetCurrent().Add(actor);
+
+  application.SendNotification();
+  application.Render(0);
+
+  Geometry geometry = CreateQuadGeometry();
+  Material material = CreateMaterial(1.0f);
+  Renderer renderer = Renderer::New(geometry, material);
+
+  application.SendNotification();
+  application.Render(0);
+
+  try
+  {
+    actor.AddRenderer( renderer );
+    tet_result(TET_PASS);
+  }
+  catch(...)
+  {
+    tet_result(TET_FAIL);
+  }
+
+  END_TEST;
+}
+
+int UtcDaliActorRemoveRendererP(void)
+{
+  tet_infoline("Testing Actor::RemoveRenderer");
+  TestApplication application;
+
+  Actor actor = Actor::New();
+
+  DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+  Geometry geometry = CreateQuadGeometry();
+  Material material = CreateMaterial(1.0f);
+  Renderer renderer = Renderer::New(geometry, material);
+
+  actor.AddRenderer( renderer );
+  DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
+
+  actor.RemoveRenderer(0);
+  DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+
+  END_TEST;
+}
index 1b74e67cc16dae13e96ed65489903dad0b1ff7b5..225c1d81bd975fa03fc01ece2159aecad0ffa6b1 100644 (file)
@@ -95,6 +95,11 @@ void Node::Attach( NodeAttachment& object )
 
   mAttachment = &object;
   SetAllDirtyFlags();
+
+  if( mIsActive )
+  {
+    mAttachment->ConnectedToSceneGraph();
+  }
 }
 
 void Node::SetRoot(bool isRoot)