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.
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23 #include <dali/devel-api/common/singleton-service.h>
30 class TestHandle : public BaseHandle
34 TestHandle( BaseObject* object ) : BaseHandle( object ) {}
37 class TestObject : public BaseObject
41 } // unnamed namespace
43 void utc_dali_singleton_service_startup(void)
45 test_return_value = TET_UNDEF;
48 void utc_dali_singleton_service_cleanup(void)
50 test_return_value = TET_PASS;
53 int UtcDaliSingletonServiceGet(void)
55 // Attempt to retrieve SingletonService before creating application
56 SingletonService singletonService;
57 singletonService = SingletonService::Get();
58 DALI_TEST_CHECK( !singletonService );
60 // Create Application class, should be able to retrieve SingletonService now
61 TestApplication application;
62 singletonService = SingletonService::Get();
63 DALI_TEST_CHECK( singletonService );
68 int UtcDaliSingletonServiceRegisterAndGetSingleton(void)
70 TestApplication application;
71 SingletonService singletonService( SingletonService::Get() );
73 // Attempt to register an empty handle
75 singletonService.Register( typeid( handle ), handle );
76 DALI_TEST_CHECK( !singletonService.GetSingleton( typeid( handle ) ) );
78 // Create an actor instance and retrieve, should be valid this time
79 handle = TestHandle( new TestObject );
80 singletonService.Register( typeid( handle ), handle );
81 DALI_TEST_CHECK( singletonService.GetSingleton( typeid( handle ) ) );