2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-test-suite-utils.h>
20 #include <dali/devel-api/common/singleton-service.h>
21 #include <dali/public-api/dali-core.h>
30 class TestHandle : public BaseHandle
36 TestHandle(BaseObject* object)
42 class TestObject : public BaseObject
46 } // unnamed namespace
48 void utc_dali_singleton_service_startup(void)
50 test_return_value = TET_UNDEF;
53 void utc_dali_singleton_service_cleanup(void)
55 test_return_value = TET_PASS;
58 int UtcDaliSingletonServiceGet(void)
60 // Attempt to retrieve SingletonService before creating application
61 SingletonService singletonService;
62 singletonService = SingletonService::Get();
63 DALI_TEST_CHECK(!singletonService);
65 // Create Application class, should be able to retrieve SingletonService now
66 TestApplication application;
67 singletonService = SingletonService::Get();
68 DALI_TEST_CHECK(singletonService);
73 int UtcDaliSingletonServiceRegisterAndGetSingleton(void)
75 TestApplication application;
76 SingletonService singletonService(SingletonService::Get());
78 // Attempt to register an empty handle
80 singletonService.Register(typeid(handle), handle);
81 DALI_TEST_CHECK(!singletonService.GetSingleton(typeid(handle)));
83 // Create an actor instance and retrieve, should be valid this time
84 handle = TestHandle(new TestObject);
85 singletonService.Register(typeid(handle), handle);
86 DALI_TEST_CHECK(singletonService.GetSingleton(typeid(handle)));