Initial removal of Text features
[platform/core/uifw/dali-core.git] / automated-tests / src / dali-unmanaged / utc-Dali-TypeRegistry.cpp
index 2e7265a..5f2ff27 100644 (file)
@@ -1,22 +1,22 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
+/*
+ * Copyright (c) 2014 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 <iostream>
 #include <stdlib.h>
-#include <dali/dali.h>
 #include <dali/public-api/dali-core.h>
 #include <dali-test-suite-utils.h>
 #include <dali/integration-api/events/long-press-gesture-event.h>
@@ -24,6 +24,7 @@
 #include <dali/integration-api/events/pinch-gesture-event.h>
 #include <dali/integration-api/events/tap-gesture-event.h>
 #include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/hover-event-integ.h>
 
 using namespace Dali;
 
@@ -50,7 +51,7 @@ struct SignalData
     receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
     receivedGesture.localPoint = Vector2(0.0f, 0.0f);
 
-    pressedActor = NULL;
+    pressedActor.Reset();
   }
 
   bool functorCalled;
@@ -223,6 +224,10 @@ struct MyTestCustomActor : public CustomActorImpl
   {
     return true;
   }
+  virtual bool OnHoverEvent(const HoverEvent& event)
+  {
+    return true;
+  }
   virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
   {
     return true;
@@ -242,6 +247,11 @@ struct MyTestCustomActor : public CustomActorImpl
     return Actor::New();
   }
 
+  virtual Vector3 GetNaturalSize()
+  {
+    return Vector3( 0.0f, 0.0f, 0.0f );
+  }
+
 public:
 
   SignalType mSignal;
@@ -467,6 +477,16 @@ public:
   }
 };
 
+BaseHandle CreateNamedActorType()
+{
+  Actor actor = Actor::New();
+  actor.SetName( "NamedActor" );
+  return actor;
+}
+
+TypeRegistration namedActorType( "MyNamedActor", typeid(Dali::Actor), CreateNamedActorType );
+PropertyRegistration namedActorPropertyOne( namedActorType, "prop-name", PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
+
 } // Anonymous namespace
 
 
@@ -489,13 +509,6 @@ int UtcDaliTypeRegistryCreateDaliObjects(void)
   Stage::GetCurrent().Add( ia );
   application.Render();
 
-  type = registry.GetTypeInfo( "TextActor" );
-  DALI_TEST_CHECK( type );
-  TextActor ta = TextActor::DownCast(type.CreateInstance());
-  DALI_TEST_CHECK( ta );
-  Stage::GetCurrent().Add( ta );
-  application.Render();
-
   type = registry.GetTypeInfo( "CameraActor" );
   DALI_TEST_CHECK( type );
   CameraActor ca = CameraActor::DownCast(type.CreateInstance());
@@ -587,8 +600,8 @@ int UtcDaliTypeRegistryNames(void)
 // Check named and typeid are equivalent
 int UtcDaliTypeRegistryNameEquivalence(void)
 {
-  TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "TextActor" );
-  TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::TextActor) );
+  TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "ImageActor" );
+  TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::ImageActor) );
 
   DALI_TEST_CHECK( named_type );
   DALI_TEST_CHECK( typeinfo_type );
@@ -620,8 +633,19 @@ int UtcDaliTypeRegistryCustomActor(void)
   MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
   DALI_TEST_CHECK( customHandle );
 
-  DALI_TEST_EQUALS( type.GetActions().size(), TEST_ACTION_COUNT + baseType.GetActions().size(), TEST_LOCATION );
-  DALI_TEST_EQUALS( type.GetSignals().size(), TEST_SIGNAL_COUNT + baseType.GetSignals().size(), TEST_LOCATION );
+  TypeInfo::NameContainer names;
+  type.GetActions(names);
+  TypeInfo::NameContainer baseNames;
+  baseType.GetActions(baseNames);
+  DALI_TEST_EQUALS( names.size(), TEST_ACTION_COUNT + baseNames.size(), TEST_LOCATION );
+
+  names.clear();
+  type.GetSignals(names);
+
+  baseNames.clear();
+  baseType.GetSignals(baseNames);
+
+  DALI_TEST_EQUALS( names.size(), TEST_SIGNAL_COUNT + baseNames.size(), TEST_LOCATION );
 
   {
     TestConnectionTracker tracker;
@@ -675,8 +699,21 @@ int UtcDaliTypeRegistryCustomSignalFailure(void)
   MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
   DALI_TEST_CHECK( customHandle );
 
-  DALI_TEST_EQUALS( type.GetActions().size(), TEST_ACTION_COUNT + baseType.GetActions().size(), TEST_LOCATION );
-  DALI_TEST_EQUALS( type.GetSignals().size(), TEST_SIGNAL_COUNT + baseType.GetSignals().size(), TEST_LOCATION );
+  TypeInfo::NameContainer names;
+  TypeInfo::NameContainer baseNames;
+
+  type.GetActions(names);
+  baseType.GetActions(baseNames);
+
+  DALI_TEST_EQUALS( names.size(), TEST_ACTION_COUNT + baseNames.size(), TEST_LOCATION );
+
+  names.clear();
+  baseNames.clear();
+
+  type.GetSignals(names);
+  baseType.GetSignals(baseNames);
+
+  DALI_TEST_EQUALS( names.size(), TEST_SIGNAL_COUNT + baseNames.size(), TEST_LOCATION );
 
   {
     TestConnectionTracker tracker;
@@ -1109,3 +1146,26 @@ int UtcDaliTapGestureDetectorTypeRegistry(void)
   DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
   END_TEST;
 }
+
+int UtcDaliTypeRegistryNamedType(void)
+{
+  TestApplication application;
+  TypeRegistry typeRegistry = TypeRegistry::Get();
+
+  // Create a normal actor
+  BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
+  DALI_TEST_CHECK( actorHandle );
+  Actor actor( Actor::DownCast( actorHandle ) );
+  DALI_TEST_CHECK( actor );
+  unsigned int actorPropertyCount( actor.GetPropertyCount() );
+
+  // Create Named Actor Type
+  BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
+  DALI_TEST_CHECK( namedHandle );
+  Actor namedActor( Actor::DownCast( namedHandle ) );
+  DALI_TEST_CHECK( namedActor );
+  unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
+
+  DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
+  END_TEST;
+}