(StyleManager) Create a style manager
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-unmanaged / utc-Dali-StyleManager.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 #include <iostream>
18 #include <stdlib.h>
19 #include <dali-toolkit-test-suite-utils.h>
20 #include <dali-toolkit/dali-toolkit.h>
21 #include <dali/integration-api/events/touch-event-integ.h>
22
23
24 using namespace Dali;
25 using namespace Dali::Toolkit;
26
27 void dali_style_manager_startup(void)
28 {
29   test_return_value = TET_UNDEF;
30 }
31
32 void dali_style_manager_cleanup(void)
33 {
34   test_return_value = TET_PASS;
35 }
36
37 int UtcDaliStyleManagerGet(void)
38 {
39   ToolkitTestApplication application;
40
41   tet_infoline(" UtcDaliStyleManagerGet");
42
43   // Register Type
44   TypeInfo type;
45   type = TypeRegistry::Get().GetTypeInfo( "StyleManager" );
46   DALI_TEST_CHECK( type );
47   BaseHandle handle = type.CreateInstance();
48   DALI_TEST_CHECK( handle );
49
50   StyleManager manager;
51
52   manager = StyleManager::Get();
53   DALI_TEST_CHECK(manager);
54
55   StyleManager newManager = StyleManager::Get();
56   DALI_TEST_CHECK(newManager);
57
58   // Check that focus manager is a singleton
59   DALI_TEST_CHECK(manager == newManager);
60   END_TEST;
61 }
62
63 int UtcDaliStyleManagerSetOrientationValue(void)
64 {
65   ToolkitTestApplication application;
66
67   tet_infoline( " UtcDaliStyleManagerSetOrientationValue" );
68
69   StyleManager manager = StyleManager::Get();
70
71   int orientation1 = 0;
72   manager.SetOrientationValue( orientation1 );
73   DALI_TEST_CHECK( manager.GetOrientationValue() == orientation1 );
74
75   int orientation2 = 180;
76   manager.SetOrientationValue( orientation2 );
77   DALI_TEST_CHECK( manager.GetOrientationValue() == orientation2 );
78
79   END_TEST;
80 }
81
82 int UtcDaliStyleManagerSetOrientation(void)
83 {
84   ToolkitTestApplication application;
85
86   tet_infoline( " UtcDaliStyleManagerSetOrientation" );
87
88   StyleManager manager = StyleManager::Get();
89
90   Orientation orientation;
91
92   manager.SetOrientation( orientation );
93
94   DALI_TEST_CHECK( manager.GetOrientation() == orientation );
95
96   END_TEST;
97 }
98
99 int UtcDaliStyleManagerSetStyleConstant(void)
100 {
101   ToolkitTestApplication application;
102
103   tet_infoline( " UtcDaliStyleManagerSetStyleConstant" );
104
105   StyleManager manager = StyleManager::Get();
106
107   std::string key( "key" );
108   Property::Value value( 100 );
109
110   manager.SetStyleConstant( key, value );
111
112   Property::Value returnedValue;
113   manager.GetStyleConstant( key, returnedValue );
114
115   DALI_TEST_CHECK( value.Get<int>() == returnedValue.Get<int>() );
116
117   std::string key2( "key2" );
118   Property::Value returnedValue2;
119   DALI_TEST_CHECK( !manager.GetStyleConstant( key2, returnedValue2 ) );
120
121   END_TEST;
122 }