/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
*
*/
-#include <iostream>
-
-#include <stdlib.h>
#include <dali-test-suite-utils.h>
#include <dali/public-api/dali-core.h>
+#include <stdlib.h>
+
+#include <iostream>
using namespace Dali;
namespace
{
-
// Functors to test whether Object created/destroyed signal is emitted for different types of Objects
struct TestObjectDestroyedCallback
}
}
- bool& mSignalVerified;
+ bool& mSignalVerified;
Dali::RefObject*& mObjectPointer;
};
TestApplication application;
ObjectRegistry registry; // like this for ctor code coverage
- registry= Stage::GetCurrent().GetObjectRegistry();
+ registry = application.GetCore().GetObjectRegistry();
- DALI_TEST_CHECK( registry );
+ DALI_TEST_CHECK(registry);
END_TEST;
}
TestApplication application;
ObjectRegistry myRegistry;
- ObjectRegistry anotherRegistry( myRegistry );
+ ObjectRegistry anotherRegistry(myRegistry);
+
+ DALI_TEST_EQUALS(myRegistry, anotherRegistry, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliObjectRegistryMoveConstructor(void)
+{
+ TestApplication application;
+
+ ObjectRegistry registry = application.GetCore().GetObjectRegistry();
+ DALI_TEST_CHECK(registry);
+ DALI_TEST_EQUALS(2, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+
+ ObjectRegistry move = std::move(registry);
+ DALI_TEST_CHECK(move);
+
+ // Check that object is moved (not copied, so ref count keeps the same)
+ DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+ DALI_TEST_CHECK(!registry);
+
+ END_TEST;
+}
+
+int UtcDaliObjectRegistryMoveAssignment(void)
+{
+ TestApplication application;
+
+ ObjectRegistry registry = application.GetCore().GetObjectRegistry();
+ DALI_TEST_CHECK(registry);
+ DALI_TEST_EQUALS(2, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+
+ ObjectRegistry move;
+ move = std::move(registry);
+ DALI_TEST_CHECK(move);
+
+ // Check that object is moved (not copied, so ref count keeps the same)
+ DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+ DALI_TEST_CHECK(!registry);
- DALI_TEST_EQUALS( myRegistry, anotherRegistry, TEST_LOCATION );
END_TEST;
}
{
tet_infoline("Testing GetObjectRegistry()");
TestApplication application;
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
- DALI_TEST_CHECK( registry );
+ ObjectRegistry registry = application.GetCore().GetObjectRegistry();
+ DALI_TEST_CHECK(registry);
- bool verified = false;
+ bool verified = false;
TestActorCallback test(verified);
- Dali::RefObject* objectPointer = NULL;
+ Dali::RefObject* objectPointer = NULL;
TestObjectDestroyedCallback test2(verified, objectPointer);
registry.ObjectCreatedSignal().Connect(&application, test);
{
Actor actor = Actor::New();
- DALI_TEST_CHECK( test.mSignalVerified );
+ DALI_TEST_CHECK(test.mSignalVerified);
- verified = false;
+ verified = false;
objectPointer = actor.GetObjectPtr();
}
- DALI_TEST_CHECK( test.mSignalVerified );
+ DALI_TEST_CHECK(test.mSignalVerified);
END_TEST;
}
{
TestApplication application;
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
+ ObjectRegistry registry = application.GetCore().GetObjectRegistry();
- bool verified = false;
+ bool verified = false;
TestCameraActorCallback test(verified);
- Dali::RefObject* objectPointer = NULL;
+ Dali::RefObject* objectPointer = NULL;
TestObjectDestroyedCallback test2(verified, objectPointer);
registry.ObjectCreatedSignal().Connect(&application, test);
{
CameraActor actor = CameraActor::New();
- DALI_TEST_CHECK( test.mSignalVerified );
+ DALI_TEST_CHECK(test.mSignalVerified);
- verified = false;
+ verified = false;
objectPointer = actor.GetObjectPtr();
}
- DALI_TEST_CHECK( test.mSignalVerified );
+ DALI_TEST_CHECK(test.mSignalVerified);
END_TEST;
}
int UtcDaliObjectRegistrySignalLayerCreated(void)
{
TestApplication application;
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
+ ObjectRegistry registry = application.GetCore().GetObjectRegistry();
- bool verified = false;
+ bool verified = false;
TestLayerCallback test(verified);
- Dali::RefObject* objectPointer = NULL;
+ Dali::RefObject* objectPointer = NULL;
TestObjectDestroyedCallback test2(verified, objectPointer);
registry.ObjectCreatedSignal().Connect(&application, test);
{
Layer actor = Layer::New();
- DALI_TEST_CHECK( test.mSignalVerified );
+ DALI_TEST_CHECK(test.mSignalVerified);
- verified = false;
+ verified = false;
objectPointer = actor.GetObjectPtr();
}
- DALI_TEST_CHECK( test.mSignalVerified );
+ DALI_TEST_CHECK(test.mSignalVerified);
END_TEST;
}
int UtcDaliObjectRegistrySignalAnimationCreated(void)
{
TestApplication application;
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
+ ObjectRegistry registry = application.GetCore().GetObjectRegistry();
- bool verified = false;
+ bool verified = false;
TestAnimationCallback test(verified);
- Dali::RefObject* objectPointer = NULL;
+ Dali::RefObject* objectPointer = NULL;
TestObjectDestroyedCallback test2(verified, objectPointer);
registry.ObjectCreatedSignal().Connect(&application, test);
{
Animation animation = Animation::New(1.0f);
- DALI_TEST_CHECK( test.mSignalVerified );
+ DALI_TEST_CHECK(test.mSignalVerified);
- verified = false;
+ verified = false;
objectPointer = animation.GetObjectPtr();
}
- DALI_TEST_CHECK( test.mSignalVerified );
+ DALI_TEST_CHECK(test.mSignalVerified);
+ END_TEST;
+}
+
+int UtcDaliObjectRegistryObjectCreatedSignalNegative(void)
+{
+ TestApplication application;
+ Dali::ObjectRegistry instance;
+ try
+ {
+ instance.ObjectCreatedSignal();
+ DALI_TEST_CHECK(false); // Should not get here
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(true); // We expect an assert
+ }
+ END_TEST;
+}
+
+int UtcDaliObjectRegistryObjectDestroyedSignalNegative(void)
+{
+ TestApplication application;
+ Dali::ObjectRegistry instance;
+ try
+ {
+ instance.ObjectDestroyedSignal();
+ DALI_TEST_CHECK(false); // Should not get here
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(true); // We expect an assert
+ }
END_TEST;
}