Merge changes I75f2d974,Ib8d53cf7 into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-styling / utc-Dali-StyleManager.cpp
1  /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
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 <dali/devel-api/adaptor-framework/style-monitor.h>
18
19 #include <iostream>
20 #include <stdlib.h>
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali-toolkit/devel-api/builder/builder.h>
25 #include <test-button.h>
26 #include <test-animation-data.h>
27 #include <toolkit-style-monitor.h>
28 #include <dummy-control.h>
29 #include <dali-toolkit/devel-api/controls/control-devel.h>
30 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
31
32 using namespace Dali;
33 using namespace Dali::Toolkit;
34
35 namespace
36 {
37 const char* defaultTheme =
38 "{\n"
39 "  \"constants\":\n"
40 "  {\n"
41 "    \"CONFIG_SCRIPT_LOG_LEVEL\":\"NoLogging\"\n"
42 "  },\n"
43 "  \"styles\":\n"
44 "  {\n"
45 "    \"textlabel\":\n"
46 "    {\n"
47 "      \"pointSize\":18\n"
48 "    },\n"
49 "\n"
50 "    \"textlabelFontSize0\":\n"
51 "    {\n"
52 "      \"pointSize\":8\n"
53 "    },\n"
54 "    \"textlabelFontSize1\":\n"
55 "    {\n"
56 "      \"pointSize\":10\n"
57 "    },\n"
58 "    \"textlabelFontSize2\":\n"
59 "    {\n"
60 "      \"pointSize\":15\n"
61 "    },\n"
62 "    \"textlabelFontSize3\":\n"
63 "    {\n"
64 "      \"pointSize\":19\n"
65 "    },\n"
66 "    \"textlabelFontSize4\":\n"
67 "    {\n"
68 "      \"pointSize\":25\n"
69 "    },\n"
70 "\n"
71 "    \"textfield\":\n"
72 "    {\n"
73 "      \"pointSize\":18,\n"
74 "      \"primaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
75 "      \"secondaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
76 "      \"cursorWidth\":3,\n"
77 "      \"selectionHighlightColor\":[0.75,0.96,1.0,1.0],\n"
78 "      \"grabHandleImage\" : \"{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png\",\n"
79 "      \"selectionHandleImageLeft\" : {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png\" },\n"
80 "      \"selectionHandleImageRight\": {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png\" }\n"
81 "    },\n"
82 "\n"
83 "    \"textfieldFontSize0\":\n"
84 "    {\n"
85 "      \"pointSize\":10\n"
86 "    },\n"
87 "    \"textfieldFontSize1\":\n"
88 "    {\n"
89 "      \"pointSize\":10\n"
90 "    },\n"
91 "    \"textfieldFontSize2\":\n"
92 "    {\n"
93 "      \"pointSize\":10\n"
94 "    },\n"
95 "    \"textfieldFontSize3\":\n"
96 "    {\n"
97 "      \"pointSize\":10\n"
98 "    },\n"
99 "    \"textfieldFontSize4\":\n"
100 "    {\n"
101 "      \"pointSize\":10\n"
102 "    },\n"
103 "    \"textselectionpopup\":\n"
104 "    {\n"
105 "      \"popupMaxSize\":[656,72],\n"
106 "      \"optionDividerSize\":[2,0],\n"
107 "      \"popupDividerColor\":[0.23,0.72,0.8,0.11],\n"
108 "      \"popupIconColor\":[1.0,1.0,1.0,1.0],\n"
109 "      \"popupPressedColor\":[0.24,0.72,0.8,0.11],\n"
110 "      \"background\": {\n"
111 "        \"rendererType\": \"nPatch\",\n"
112 "        \"imageUrl\": \"{DALI_IMAGE_DIR}selection-popup-bg.9.png\"\n"
113 "        },\n"
114 "      \"popupFadeInDuration\":0.25,\n"
115 "      \"popupFadeOutDuration\":0.25\n"
116 "    },\n"
117 "    \"textselectionpopupbutton\":\n"
118 "    {\n"
119 "      \"label\":\n"
120 "      {\n"
121 "        \"pointSize\":8,\n"
122 "        \"fontStyle\":\"{\\\\""weight\\\\"":\\\\""light\\\\""}\"\n"
123 "      }\n"
124 "    },\n"
125 "    \"textselectiontoolbar\":\n"
126 "    {\n"
127 "      \"enableOvershoot\":true,\n"
128 "      \"scrollView\":\n"
129 "      {\n"
130 "        \"overshootAnimationSpeed\":360.0,\n"
131 "        \"overshootSize\":[720.0,130.0]\n"
132 "      }\n"
133 "    },\n"
134 "    \"scrollview\":\n"
135 "    {\n"
136 "      \"overshootEffectColor\":\"B018\",\n"
137 "      \"overshootAnimationSpeed\":360.0,\n"
138 "      \"overshootSize\":[720.0,130.0]\n"
139 "    },\n"
140 "    \"itemview\":\n"
141 "    {\n"
142 "      \"overshootEffectColor\":\"B018\",\n"
143 "      \"overshootAnimationSpeed\":360.0,\n"
144 "      \"overshootSize\":[720.0,130.0]\n"
145 "    },\n"
146 "    \"texteditor\":\n"
147 "    {\n"
148 "      \"pointSize\":18,\n"
149 "      \"primaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
150 "      \"secondaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
151 "      \"cursorWidth\":3,\n"
152 "      \"selectionHighlightColor\":[0.75,0.96,1.0,1.0],\n"
153 "      \"grabHandleImage\" : \"{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png\",\n"
154 "      \"selectionHandleImageLeft\" : {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png\" },\n"
155 "      \"selectionHandleImageRight\": {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png\" }\n"
156 "    },\n"
157 "    \"ComplexControl\":\n"
158 "    {\n"
159 "      \"states\":\n"
160 "      {\n"
161 "        \"NORMAL\":\n"
162 "        {\n"
163 "          \"states\":\n"
164 "          {\n"
165 "            \"SELECTED\":\n"
166 "            {\n"
167 "              \"visuals\":\n"
168 "              {\n"
169 "                \"foregroundVisual\":\n"
170 "                {\n"
171 "                  \"visualType\":\"GRADIENT\",\n"
172 "                  \"startPosition\": [-1, -1],\n"
173 "                  \"endPosition\": [1, 1],\n"
174 "                  \"spreadMethod\": \"REPEAT\",\n"
175 "                  \"stopOffset\": [0.2, 0.8],\n"
176 "                  \"stopColor\": [ [ 1,0,0,1], [0,1,0,1] ]\n"
177 "                }\n"
178 "              }\n"
179 "            },\n"
180 "            \"UNSELECTED\":\n"
181 "            {\n"
182 "              \"visuals\":\n"
183 "              {\n"
184 "                \"foregroundVisual\":\n"
185 "                {\n"
186 "                  \"visualType\":\"COLOR\",\n"
187 "                  \"mixColor\": [ 1,0,0,1]\n"
188 "                }\n"
189 "              }\n"
190 "            }\n"
191 "          },\n"
192 "          \"transitions\":\n"
193 "          {\n"
194 "            \"visualName\":\"*\",\n"
195 "            \"effect\":\"CROSSFADE\",\n"
196 "            \"animator\":\n"
197 "            {\n"
198 "              \"alphaFunction\":\"EASE_IN_OUT\",\n"
199 "              \"duration\":0.3\n"
200 "            }\n"
201 "          }\n"
202 "        },\n"
203 "        \"FOCUSED\":\n"
204 "        {\n"
205 "          \"visuals\":\n"
206 "          {\n"
207 "            \"foregroundVisual\":\n"
208 "            {\n"
209 "              \"visualType\":\"GRADIENT\",\n"
210 "              \"startPosition\": [-1, -1],\n"
211 "              \"endPosition\": [1, 1],\n"
212 "              \"spreadMethod\": \"REPEAT\",\n"
213 "              \"stopOffset\": [0.3, 0.9],\n"
214 "              \"stopColor\": [ [ 0,0,1,1], [0,1,1,1] ]\n"
215 "            },\n"
216 "            \"focusVisual\":\n"
217 "            {\n"
218 "              \"visualType\":\"IMAGE\",\n"
219 "              \"url\": \"focus.png\"\n"
220 "            }\n"
221 "          },\n"
222 "          \"entryTransition\":\n"
223 "          {\n"
224 "            \"target\":\"focusVisual\",\n"
225 "            \"property\":\"mixColor\",\n"
226 "            \"initialValue\":[0,0,0,0],\n"
227 "            \"targetValue\":[1,1,1,1],\n"
228 "            \"animator\":\n"
229 "            {\n"
230 "              \"alphaFunction\":\"EASE_IN_OUT_SINE\",\n"
231 "              \"timePeriod\": \n"
232 "              {\n"
233 "                \"duration\":0.5,\n"
234 "                \"delay\":0\n"
235 "              }\n"
236 "            }\n"
237 "          },\n"
238 "          \"exitTransition\":\n"
239 "          {\n"
240 "            \"target\":\"focusVisual\",\n"
241 "            \"property\":\"mixColor\",\n"
242 "            \"initialValue\":[1,1,1,1],\n"
243 "            \"targetValue\":[0,0,0,0],\n"
244 "            \"animator\":\n"
245 "            {\n"
246 "              \"alphaFunction\":\"EASE_IN_OUT_SINE\",\n"
247 "              \"timePeriod\": \n"
248 "              {\n"
249 "                \"duration\":0.5,\n"
250 "                \"delay\":0\n"
251 "              }\n"
252 "            }\n"
253 "          }\n"
254 "        },\n"
255 "        \"DISABLED\":\n"
256 "        {\n"
257 "          \"visuals\":\n"
258 "          {\n"
259 "            \"foregroundVisual\":\n"
260 "            {\n"
261 "              \"visualType\":\"COLOR\",\n"
262 "              \"mixColor\": [1,0,0,1]\n"
263 "            }\n"
264 "          }\n"
265 "        }\n"
266 "      },\n"
267 "      \"transitions\":\n"
268 "      [\n"
269 "        {\n"
270 "          \"effect\":\"CROSSFADE\",\n"
271 "          \"animator\":\n"
272 "          {\n"
273 "            \"alphaFunction\":\"EASE_IN_OUT\",\n"
274 "            \"duration\":0.3\n"
275 "          }\n"
276 "        }\n"
277 "      ]\n"
278 "    },\n"
279 "    \"BasicControl\":\n"
280 "    {\n"
281 "      \"states\":\n"
282 "      {\n"
283 "        \"NORMAL\":\n"
284 "        {\n"
285 "          \"visuals\":\n"
286 "          {\n"
287 "            \"foregroundVisual\":\n"
288 "            {\n"
289 "              \"visualType\":\"GRADIENT\",\n"
290 "              \"startPosition\": [-1, -1],\n"
291 "              \"endPosition\": [1, 1],\n"
292 "              \"spreadMethod\": \"REPEAT\",\n"
293 "              \"stopOffset\": [0.2, 0.8],\n"
294 "              \"stopColor\": [ [ 1,0,0,1], [0,1,0,1] ]\n"
295 "            }\n"
296 "          }\n"
297 "        },\n"
298 "        \"FOCUSED\":\n"
299 "        {\n"
300 "          \"visuals\":\n"
301 "          {\n"
302 "            \"foregroundVisual\":\n"
303 "            {\n"
304 "              \"visualType\":\"GRADIENT\",\n"
305 "              \"startPosition\": [-1, -1],\n"
306 "              \"endPosition\": [1, 1],\n"
307 "              \"spreadMethod\": \"REPEAT\",\n"
308 "              \"stopOffset\": [0.3, 0.9],\n"
309 "              \"stopColor\": [ [ 0,0,1,1], [0,1,1,1] ]\n"
310 "            },\n"
311 "            \"focusVisual\":\n"
312 "            {\n"
313 "              \"visualType\":\"IMAGE\",\n"
314 "              \"url\": \"focus.png\"\n"
315 "            }\n"
316 "          },\n"
317 "          \"entryTransition\":\n"
318 "          {\n"
319 "            \"target\":\"focusVisual\",\n"
320 "            \"property\":\"mixColor\",\n"
321 "            \"initialValue\":[0,0,0,0],\n"
322 "            \"targetValue\":[1,1,1,1],\n"
323 "            \"animator\":\n"
324 "            {\n"
325 "              \"alphaFunction\":\"EASE_IN_OUT_SINE\",\n"
326 "              \"timePeriod\": \n"
327 "              {\n"
328 "                \"duration\":0.5,\n"
329 "                \"delay\":0\n"
330 "              }\n"
331 "            }\n"
332 "          },\n"
333 "          \"exitTransition\":\n"
334 "          {\n"
335 "            \"target\":\"focusVisual\",\n"
336 "            \"property\":\"mixColor\",\n"
337 "            \"initialValue\":[1,1,1,1],\n"
338 "            \"targetValue\":[0,0,0,0],\n"
339 "            \"animator\":\n"
340 "            {\n"
341 "              \"alphaFunction\":\"EASE_IN_OUT_SINE\",\n"
342 "              \"timePeriod\": \n"
343 "              {\n"
344 "                \"duration\":0.5,\n"
345 "                \"delay\":0\n"
346 "              }\n"
347 "            }\n"
348 "          }\n"
349 "        },\n"
350 "        \"DISABLED\":\n"
351 "        {\n"
352 "          \"visuals\":\n"
353 "          {\n"
354 "            \"foregroundVisual\":\n"
355 "            {\n"
356 "              \"visualType\":\"COLOR\",\n"
357 "              \"mixColor\": [1,0,0,1]\n"
358 "            }\n"
359 "          }\n"
360 "        }\n"
361 "      },\n"
362 "      \"transitions\":\n"
363 "      [\n"
364 "        {\n"
365 "          \"effect\":\"CROSSFADE\",\n"
366 "          \"animator\":\n"
367 "          {\n"
368 "            \"alphaFunction\":\"EASE_IN_OUT\",\n"
369 "            \"duration\":0.3\n"
370 "          }\n"
371 "        }\n"
372 "      ]\n"
373 "    }\n"
374 "  }\n"
375 "}\n";
376
377 } // anonymous namespace
378
379
380
381
382 void dali_style_manager_startup(void)
383 {
384   test_return_value = TET_UNDEF;
385 }
386
387 void dali_style_manager_cleanup(void)
388 {
389   test_return_value = TET_PASS;
390 }
391
392 int UtcDaliStyleManagerConstructorP(void)
393 {
394   ToolkitTestApplication application;
395
396   tet_infoline(" UtcDaliStyleManagerConstructorP");
397   StyleManager styleManager;
398   DALI_TEST_CHECK( !styleManager);
399   END_TEST;
400 }
401
402 int UtcDaliStyleManagerCopyConstructorP(void)
403 {
404   TestApplication application;
405
406   StyleManager styleManager = StyleManager::Get();
407   StyleManager copyOfStyleManager( styleManager );
408
409   DALI_TEST_CHECK( copyOfStyleManager );
410   END_TEST;
411 }
412
413 int UtcDaliStyleManagerAssignmentOperatorP(void)
414 {
415   TestApplication application;
416
417   StyleManager styleManager = StyleManager::Get();
418   StyleManager copyOfStyleManager = styleManager;
419
420   DALI_TEST_CHECK( copyOfStyleManager );
421   DALI_TEST_CHECK( copyOfStyleManager == styleManager );
422   END_TEST;
423 }
424
425 int UtcDaliStyleManagerGet(void)
426 {
427   ToolkitTestApplication application;
428
429   tet_infoline(" UtcDaliStyleManagerGet");
430
431   // Register Type
432   TypeInfo type;
433   type = TypeRegistry::Get().GetTypeInfo( "StyleManager" );
434   DALI_TEST_CHECK( type );
435   BaseHandle handle = type.CreateInstance();
436   DALI_TEST_CHECK( handle );
437
438   StyleManager manager;
439
440   manager = StyleManager::Get();
441   DALI_TEST_CHECK(manager);
442
443   StyleManager newManager = StyleManager::Get();
444   DALI_TEST_CHECK(newManager);
445
446   // Check that focus manager is a singleton
447   DALI_TEST_CHECK(manager == newManager);
448   END_TEST;
449 }
450
451
452 namespace
453 {
454 class StyleChangedSignalChecker : public ConnectionTracker
455 {
456 public:
457   StyleChangedSignalChecker()
458   : signalCount(0)
459   {
460   }
461
462   void OnStyleChanged(StyleManager styleManager, StyleChange::Type type)
463   {
464     signalCount++;
465   }
466
467   void Reset()
468   {
469     signalCount =0;
470   }
471
472 public:
473   int signalCount;
474 };
475
476 } // anonymous namespace
477
478 int UtcDaliStyleManagerApplyTheme(void)
479 {
480   ToolkitTestApplication application;
481
482   tet_infoline( "Testing StyleManager ApplyTheme" );
483
484   const char* json1 =
485     "{\n"
486     "  \"constants\":\n"
487     "  {\n"
488     "    \"CONFIG_SCRIPT_LOG_LEVEL\":\"Verbose\"\n"
489     "  },\n"
490     "  \"styles\":\n"
491     "  {\n"
492     "    \"testbutton\":\n"
493     "    {\n"
494     "      \"backgroundColor\":[1.0,1.0,0.0,1.0],\n"
495     "      \"foregroundColor\":[0.0,0.0,1.0,1.0]\n"
496     "    }\n"
497     "  }\n"
498     "}\n";
499
500   const char* json2 =
501     "{\n"
502     "  \"styles\":\n"
503     "  {\n"
504     "    \"testbutton\":\n"
505     "    {\n"
506     "      \"backgroundColor\":[1.0,0.0,0.0,1.0],\n"
507     "      \"foregroundColor\":[0.0,1.0,1.0,1.0]\n"
508     "    }\n"
509     "  }\n"
510     "}\n";
511
512   // Add 2 buttons to test how many times the signal is sent
513   Test::TestButton testButton = Test::TestButton::New();
514   Test::TestButton testButton2 = Test::TestButton::New();
515   Stage::GetCurrent().Add( testButton );
516   Stage::GetCurrent().Add( testButton2 );
517   StyleChangedSignalChecker styleChangedSignalHandler;
518   StyleChangedSignalChecker styleChangedSignalHandler2;
519   StyleManager styleManager = StyleManager::Get();
520
521   styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
522
523   // Render and notify
524   application.SendNotification();
525   application.Render();
526
527   tet_infoline("Apply the style");
528
529   std::string themeFile("ThemeOne");
530   Test::StyleMonitor::SetThemeFileOutput(themeFile, json1);
531   StyleManager::Get().ApplyTheme(themeFile);
532
533   Property::Value bgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) );
534   Property::Value fgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) );
535
536   DALI_TEST_EQUALS( bgColor, Property::Value(Color::YELLOW), 0.001, TEST_LOCATION );
537   DALI_TEST_EQUALS( fgColor, Property::Value(Color::BLUE), 0.001, TEST_LOCATION );
538
539   tet_infoline("Testing that the signal handler is called only once");
540   DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
541
542   tet_infoline("Override the background property");
543   testButton.SetProperty( Test::TestButton::Property::BACKGROUND_COLOR, Color::GREEN );
544   bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
545   fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
546   DALI_TEST_EQUALS( bgColor, Property::Value(Color::GREEN), 0.001, TEST_LOCATION );
547   DALI_TEST_EQUALS( fgColor, Property::Value(Color::BLUE), 0.001, TEST_LOCATION );
548
549   // Render and notify
550   application.SendNotification();
551   application.Render();
552
553   tet_infoline("Apply the style again");
554
555   styleChangedSignalHandler.signalCount = 0;
556   StyleManager::Get().ApplyTheme(themeFile);
557
558   bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
559   fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
560
561   tet_infoline("Check that the property is changed");
562   DALI_TEST_EQUALS( bgColor, Property::Value(Color::YELLOW), 0.001, TEST_LOCATION );
563   DALI_TEST_EQUALS( fgColor, Property::Value(Color::BLUE), 0.001, TEST_LOCATION );
564   tet_infoline("Testing that the signal handler is called only once");
565   DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
566
567   tet_infoline( "Load a different stylesheet");
568
569   tet_infoline("Apply the new style");
570   std::string themeFile2("ThemeTwo");
571   Test::StyleMonitor::SetThemeFileOutput(themeFile2, json2);
572
573   styleChangedSignalHandler.signalCount = 0;
574   StyleManager::Get().ApplyTheme(themeFile2);
575
576   bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
577   fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
578
579   tet_infoline("Check that the properties change, but the signal gets sent only once");
580   DALI_TEST_EQUALS( bgColor, Property::Value(Color::RED), 0.001, TEST_LOCATION );
581   DALI_TEST_EQUALS( fgColor, Property::Value(Color::CYAN), 0.001, TEST_LOCATION );
582   DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
583
584   END_TEST;
585 }
586
587
588 int UtcDaliStyleManagerApplyDefaultTheme(void)
589 {
590   tet_infoline( "Testing StyleManager ApplyTheme" );
591
592   const char* defaultTheme =
593     "{\n"
594     "  \"constants\":\n"
595     "  {\n"
596     "    \"CONFIG_SCRIPT_LOG_LEVEL\":\"Concise\"\n"
597     "  },\n"
598     "  \"styles\":\n"
599     "  {\n"
600     "    \"testbutton\":\n"
601     "    {\n"
602     "      \"backgroundColor\":[1.0,1.0,0.0,1.0],\n"
603     "      \"foregroundColor\":[0.0,0.0,1.0,1.0]\n"
604     "    }\n"
605     "  }\n"
606     "}\n";
607   // Bg: Yellow, Fg: Blue
608
609   const char* appTheme =
610     "{\n"
611     "  \"styles\":\n"
612     "  {\n"
613     "    \"testbutton\":\n"
614     "    {\n"
615     "      \"backgroundColor\":[1.0,0.0,1.0,1.0],\n"
616     "      \"foregroundColor\":[0.0,1.0,0.0,1.0]\n"
617     "    }\n"
618     "  }\n"
619     "}\n";
620   // Bg::Magenta, Fg:Green
621
622   std::string filepath(TEST_RESOURCE_DIR "");
623
624   Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json",
625                                           defaultTheme);
626   ToolkitTestApplication application;
627
628   Test::TestButton testButton = Test::TestButton::New();
629   Stage::GetCurrent().Add( testButton );
630   StyleChangedSignalChecker styleChangedSignalHandler;
631   StyleManager styleManager = StyleManager::Get();
632
633   styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
634
635   // Render and notify
636   application.SendNotification();
637   application.Render();
638
639   // Get the default:
640   Property::Value defaultBgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) );
641   Property::Value defaultFgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) );
642
643   tet_infoline("Apply the style");
644
645   std::string themeFile("ThemeOne");
646   Test::StyleMonitor::SetThemeFileOutput(themeFile, appTheme);
647   StyleManager::Get().ApplyTheme(themeFile);
648
649   Property::Value bgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) );
650   Property::Value fgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) );
651
652   DALI_TEST_EQUALS( bgColor, Property::Value(Color::MAGENTA), 0.001, TEST_LOCATION );
653   DALI_TEST_EQUALS( fgColor, Property::Value(Color::GREEN), 0.001, TEST_LOCATION );
654
655   tet_infoline("Testing that the signal handler is called only once");
656   DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
657   tet_infoline("Revert the style");
658
659   styleChangedSignalHandler.signalCount = 0;
660   StyleManager::Get().ApplyDefaultTheme();
661
662   bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
663   fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
664
665   tet_infoline("Check that the property is reverted");
666   DALI_TEST_EQUALS( bgColor, defaultBgColor, 0.001, TEST_LOCATION );
667   DALI_TEST_EQUALS( fgColor, defaultFgColor, 0.001, TEST_LOCATION );
668   DALI_TEST_EQUALS( bgColor, Property::Value(Color::YELLOW), 0.001, TEST_LOCATION );
669   DALI_TEST_EQUALS( fgColor, Property::Value(Color::BLUE), 0.001, TEST_LOCATION );
670   tet_infoline("Testing that the signal handler is called only once");
671   DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
672
673   END_TEST;
674 }
675
676
677 int UtcDaliStyleManagerSetStyleConstantP(void)
678 {
679   ToolkitTestApplication application;
680
681   tet_infoline( " UtcDaliStyleManagerSetStyleConstantP" );
682
683   StyleManager manager = StyleManager::Get();
684
685   std::string key( "key" );
686   Property::Value value( 100 );
687
688   manager.SetStyleConstant( key, value );
689
690   Property::Value returnedValue;
691   manager.GetStyleConstant( key, returnedValue );
692
693   DALI_TEST_CHECK( value.Get<int>() == returnedValue.Get<int>() );
694   END_TEST;
695 }
696
697
698 int UtcDaliStyleManagerGetStyleConstantP(void)
699 {
700   ToolkitTestApplication application;
701
702   tet_infoline( " UtcDaliStyleManagerGetStyleConstantP" );
703
704   StyleManager manager = StyleManager::Get();
705
706   std::string key( "key" );
707   Property::Value value( 100 );
708
709   manager.SetStyleConstant( key, value );
710
711   Property::Value returnedValue;
712   manager.GetStyleConstant( key, returnedValue );
713
714   DALI_TEST_CHECK( value.Get<int>() == returnedValue.Get<int>() );
715   END_TEST;
716 }
717
718 int UtcDaliStyleManagerGetStyleConstantN(void)
719 {
720   ToolkitTestApplication application;
721
722   tet_infoline( " UtcDaliStyleManagerGetStyleConstantN" );
723
724   StyleManager manager = StyleManager::Get();
725
726   std::string key2( "key2" );
727   Property::Value returnedValue2;
728   DALI_TEST_CHECK( !manager.GetStyleConstant( key2, returnedValue2 ) );
729
730   END_TEST;
731 }
732
733 int UtcDaliStyleManagerApplyStyle(void)
734 {
735   ToolkitTestApplication application;
736
737   tet_infoline( "UtcDaliStyleManagerApplyStyle - test that a style can be applied to a single button" );
738
739   const char* json1 =
740     "{\n"
741     "  \"constants\":\n"
742     "  {\n"
743     "    \"CONFIG_SCRIPT_LOG_LEVEL\":\"General\"\n"
744     "  },\n"
745     "  \"styles\":\n"
746     "  {\n"
747     "    \"testbutton\":\n"
748     "    {\n"
749     "      \"backgroundColor\":[1.0,1.0,0.0,1.0],\n"
750     "      \"foregroundColor\":[0.0,0.0,1.0,1.0]\n"
751     "    }\n"
752     "  }\n"
753     "}\n";
754
755   const char* json2 =
756     "{\n"
757     "  \"styles\":\n"
758     "  {\n"
759     "    \"testbutton\":\n"
760     "    {\n"
761     "      \"backgroundColor\":[1.0,0.0,0.0,1.0],\n"
762     "      \"foregroundColor\":[0.0,1.0,1.0,1.0]\n"
763     "    }\n"
764     "  }\n"
765     "}\n";
766
767   // Add 2 buttons
768   Test::TestButton testButton = Test::TestButton::New();
769   Test::TestButton testButton2 = Test::TestButton::New();
770   Stage::GetCurrent().Add( testButton );
771   Stage::GetCurrent().Add( testButton2 );
772   StyleChangedSignalChecker styleChangedSignalHandler;
773   StyleManager styleManager = StyleManager::Get();
774
775   styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
776
777   tet_infoline("Apply the style");
778
779   std::string themeFile("ThemeOne");
780   Test::StyleMonitor::SetThemeFileOutput(themeFile, json1);
781   styleManager.ApplyTheme(themeFile);
782
783   // Render and notify
784   application.SendNotification();
785   application.Render();
786
787   Property::Value themedBgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) );
788   Property::Value themedFgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) );
789
790   // Apply the style to the test button:
791   std::string themeFile2("ThemeTwo");
792   Test::StyleMonitor::SetThemeFileOutput(themeFile2, json2);
793   styleManager.ApplyStyle( testButton, themeFile2, "testbutton" );
794
795   tet_infoline("Check that the properties change for the first button");
796   Property::Value bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
797   Property::Value fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
798   DALI_TEST_EQUALS( bgColor, Property::Value(Color::RED), 0.001, TEST_LOCATION );
799   DALI_TEST_EQUALS( fgColor, Property::Value(Color::CYAN), 0.001, TEST_LOCATION );
800
801   DALI_TEST_NOT_EQUALS( bgColor, themedBgColor, 0.001, TEST_LOCATION );
802   DALI_TEST_NOT_EQUALS( fgColor, themedFgColor, 0.001, TEST_LOCATION );
803
804   tet_infoline("Check that the properties remain the same for the second button");
805   bgColor = testButton2.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
806   fgColor = testButton2.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
807   DALI_TEST_EQUALS( bgColor, themedBgColor, 0.001, TEST_LOCATION );
808   DALI_TEST_EQUALS( fgColor, themedFgColor, 0.001, TEST_LOCATION );
809
810   END_TEST;
811 }
812
813
814 int UtcDaliStyleManagerIncludeStyleP(void)
815 {
816   ToolkitTestApplication application;
817
818   tet_infoline( "UtcDaliStyleManagerIncludeStyle - test that style sheet inclusion works" );
819
820   const char* json1 =
821     "{\n"
822     "  \"includes\":\n"
823     "  [\n"
824     "     \"src/dali-toolkit-styling/theme2.json\"\n"
825     "  ],\n"
826     "  \"styles\":\n"
827     "  {\n"
828     "    \"testbutton\":\n"
829     "    {\n"
830     "      \"foregroundColor\":[0.0,0.0,1.0,1.0]\n"
831     "    }\n"
832     "  }\n"
833     "}\n";
834
835   // Add 2 buttons
836   Test::TestButton testButton = Test::TestButton::New();
837   Test::TestButton testButton2 = Test::TestButton::New();
838   Stage::GetCurrent().Add( testButton );
839   Stage::GetCurrent().Add( testButton2 );
840   StyleChangedSignalChecker styleChangedSignalHandler;
841   StyleManager styleManager = StyleManager::Get();
842
843   styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
844
845   tet_infoline("Apply the style");
846
847   std::string themeFile("ThemeOne");
848   Test::StyleMonitor::SetThemeFileOutput(themeFile, json1);
849
850   styleManager.ApplyTheme(themeFile);
851
852   // Render and notify
853   application.SendNotification();
854   application.Render();
855
856   Property::Value themedBgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) );
857   Property::Value themedFgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) );
858
859   DALI_TEST_EQUALS( themedBgColor, Property::Value(Color::YELLOW), 0.001, TEST_LOCATION );
860   DALI_TEST_EQUALS( themedFgColor, Property::Value(Color::BLUE), 0.001, TEST_LOCATION );
861
862   END_TEST;
863 }
864
865
866 int UtcDaliStyleManagerIncludeStyleN(void)
867 {
868   ToolkitTestApplication application;
869
870   tet_infoline( "UtcDaliStyleManagerIncludeStyle - test that style sheet inclusion works, but included stylesheet is bad json" );
871
872   const char* json1 =
873     "{\n"
874     "  \"includes\":\n"
875     "  [\n"
876     "     \"src/dali-toolkit-styling/theme3.json\"\n"
877     "  ],\n"
878     "  \"styles\":\n"
879     "  {\n"
880     "    \"testbutton\":\n"
881     "    {\n"
882     "      \"foregroundColor\":[0.0,0.0,1.0,1.0]\n"
883     "    }\n"
884     "  }\n"
885     "}\n";
886
887   // Add 2 buttons
888   Test::TestButton testButton = Test::TestButton::New();
889   Test::TestButton testButton2 = Test::TestButton::New();
890   Stage::GetCurrent().Add( testButton );
891   Stage::GetCurrent().Add( testButton2 );
892   StyleChangedSignalChecker styleChangedSignalHandler;
893   StyleManager styleManager = StyleManager::Get();
894
895   styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
896
897   tet_infoline("Apply the style");
898
899   std::string themeFile("ThemeOne");
900   Test::StyleMonitor::SetThemeFileOutput(themeFile, json1);
901
902   try
903   {
904     styleManager.ApplyTheme(themeFile);
905   }
906   catch( Dali::DaliException& e )
907   {
908     DALI_TEST_ASSERT( e, "!\"Cannot parse JSON\"", TEST_LOCATION );
909   }
910
911   END_TEST;
912 }
913
914
915 int UtcDaliStyleManagerStyleChangedSignalFontFamily(void)
916 {
917   tet_infoline("Test that the StyleChange signal is fired when the font family is altered" );
918   Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json",
919                                           defaultTheme );
920
921   ToolkitTestApplication application;
922
923   std::string labelStr("Label");
924   Toolkit::TextLabel label = Toolkit::TextLabel::New(labelStr);
925   Stage::GetCurrent().Add( label );
926
927   Toolkit::TextLabel label2 = Toolkit::TextLabel::New(labelStr);
928   Stage::GetCurrent().Add( label2 );
929
930   StyleChangedSignalChecker styleChangedSignalHandler;
931   Dali::StyleMonitor styleMonitor = Dali::StyleMonitor::Get();
932   StyleManager styleManager = StyleManager::Get();
933
934   styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
935
936   Test::StyleMonitor::SetDefaultFontFamily("Times New Roman");
937
938   styleMonitor.StyleChangeSignal().Emit( styleMonitor,  StyleChange::DEFAULT_FONT_CHANGE);
939
940   tet_infoline("Test that the StyleChanged signal is received only once");
941
942   DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
943
944   // Check that the label's font style has been altered
945   Property::Value family = label.GetProperty(TextLabel::Property::FONT_FAMILY);
946   std::string familyStr;
947   family.Get( familyStr );
948
949   DALI_TEST_EQUALS( familyStr, "Times New Roman", TEST_LOCATION);
950
951   END_TEST;
952 }
953
954 int UtcDaliStyleManagerStyleChangedSignalFontSize(void)
955 {
956   tet_infoline("Test that the StyleChange signal is fired when the font size is altered" );
957
958   const char* defaultTheme =
959     "{\n"
960     "  \"styles\":\n"
961     "  {\n"
962     "    \"textlabelFontSize0\":\n"
963     "    {\n"
964     "      \"pointSize\":10\n"
965     "    },\n"
966     "    \"textlabelFontSize1\":\n"
967     "    {\n"
968     "      \"pointSize\":10\n"
969     "    },\n"
970     "    \"textlabelFontSize2\":\n"
971     "    {\n"
972     "      \"pointSize\":12\n"
973     "    },\n"
974     "    \"textlabelFontSize3\":\n"
975     "    {\n"
976     "      \"pointSize\":14\n"
977     "    },\n"
978     "    \"textlabelFontSize4\":\n"
979     "    {\n"
980     "      \"pointSize\":16\n"
981     "    }\n"
982     "  }\n"
983     "}\n";
984
985   Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json", defaultTheme );
986
987   ToolkitTestApplication application;
988
989   std::string labelStr("Label");
990   Toolkit::TextLabel label = Toolkit::TextLabel::New(labelStr);
991   Stage::GetCurrent().Add( label );
992
993   Toolkit::TextLabel label2 = Toolkit::TextLabel::New(labelStr);
994   Stage::GetCurrent().Add( label2 );
995
996   StyleChangedSignalChecker styleChangedSignalHandler;
997   StyleMonitor styleMonitor = StyleMonitor::Get();
998   StyleManager styleManager = StyleManager::Get();
999
1000   label.SetProperty(TextLabel::Property::POINT_SIZE, 10.0f);
1001
1002   styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
1003
1004   Test::StyleMonitor::SetDefaultFontSize(2);
1005   styleMonitor.StyleChangeSignal().Emit( styleMonitor,  StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1006
1007   tet_infoline("Test that the StyleChanged signal is received only once");
1008   DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
1009
1010   tet_infoline("Test that the label's font size has been altered\n");
1011   Property::Value pointSizeValue = label.GetProperty(TextLabel::Property::POINT_SIZE);
1012   float pointSize;
1013   pointSizeValue.Get( pointSize );
1014
1015   DALI_TEST_EQUALS( pointSize, 12.0f, 0.001, TEST_LOCATION );
1016
1017   styleChangedSignalHandler.signalCount = 0;
1018
1019   Test::StyleMonitor::SetDefaultFontSize(4);
1020   styleMonitor.StyleChangeSignal().Emit( styleMonitor, StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1021
1022   tet_infoline("Test that the StyleChanged signal is received only once");
1023   DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
1024
1025   // Check that the label's font style has been altered
1026   pointSizeValue = label.GetProperty(TextLabel::Property::POINT_SIZE);
1027   pointSizeValue.Get( pointSize );
1028
1029   DALI_TEST_EQUALS( pointSize, 16.0f, 0.001, TEST_LOCATION );
1030
1031
1032   END_TEST;
1033 }
1034
1035
1036 int UtcDaliStyleManagerStyleChangedSignalFontSizeTextField(void)
1037 {
1038   tet_infoline("Test that the StyleChange signal is fired when the font size is altered" );
1039
1040   const char* defaultTheme =
1041     "{\n"
1042     "  \"styles\":\n"
1043     "  {\n"
1044     "    \"textfieldFontSize0\":\n"
1045     "    {\n"
1046     "      \"pointSize\":8\n"
1047     "    },\n"
1048     "    \"textfieldFontSize1\":\n"
1049     "    {\n"
1050     "      \"pointSize\":10\n"
1051     "    },\n"
1052     "    \"textfieldFontSize2\":\n"
1053     "    {\n"
1054     "      \"pointSize\":12\n"
1055     "    },\n"
1056     "    \"textfieldFontSize3\":\n"
1057     "    {\n"
1058     "      \"pointSize\":14\n"
1059     "    },\n"
1060     "    \"textfieldFontSize4\":\n"
1061     "    {\n"
1062     "      \"pointSize\":16\n"
1063     "    }\n"
1064     "  }\n"
1065     "}\n";
1066
1067   Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json", defaultTheme );
1068
1069   ToolkitTestApplication application;
1070
1071   std::string fieldStr("Field");
1072   Toolkit::TextField field = Toolkit::TextField::New();
1073   field.SetProperty( Toolkit::TextField::Property::TEXT, fieldStr );
1074   Stage::GetCurrent().Add( field );
1075
1076   Toolkit::TextField field2 = Toolkit::TextField::New();
1077   Stage::GetCurrent().Add( field2 );
1078   field2.SetProperty( Toolkit::TextField::Property::TEXT, fieldStr );
1079
1080   StyleChangedSignalChecker styleChangedSignalHandler;
1081   StyleMonitor styleMonitor = StyleMonitor::Get();
1082   StyleManager styleManager = StyleManager::Get();
1083
1084   field.SetProperty(TextField::Property::POINT_SIZE, 10.0f);
1085
1086   styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
1087
1088   Test::StyleMonitor::SetDefaultFontSize(2);
1089   styleMonitor.StyleChangeSignal().Emit( styleMonitor,  StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1090
1091   tet_infoline("Test that the StyleChanged signal is received only once");
1092   DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
1093
1094   tet_infoline("Test that the field's font size has been altered\n");
1095   Property::Value pointSizeValue = field.GetProperty(TextField::Property::POINT_SIZE);
1096   float pointSize;
1097   pointSizeValue.Get( pointSize );
1098
1099   DALI_TEST_EQUALS( pointSize, 12.0f, 0.001, TEST_LOCATION );
1100
1101   styleChangedSignalHandler.signalCount = 0;
1102
1103   Test::StyleMonitor::SetDefaultFontSize(4);
1104   styleMonitor.StyleChangeSignal().Emit( styleMonitor, StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1105
1106   tet_infoline("Test that the StyleChanged signal is received only once");
1107   DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
1108
1109   // Check that the field's font style has been altered
1110   pointSizeValue = field.GetProperty(TextField::Property::POINT_SIZE);
1111   pointSizeValue.Get( pointSize );
1112
1113   DALI_TEST_EQUALS( pointSize, 16.0f, 0.001, TEST_LOCATION );
1114
1115
1116   END_TEST;
1117 }
1118
1119 int UtcDaliStyleManagerStyleChangedSignalFontSizeTextEditor(void)
1120 {
1121   tet_infoline("Test that the StyleChange signal is fired when the font size is altered" );
1122
1123   const char* defaultTheme =
1124     "{\n"
1125     "  \"styles\":\n"
1126     "  {\n"
1127     "    \"texteditorFontSize0\":\n"
1128     "    {\n"
1129     "      \"pointSize\":10\n"
1130     "    },\n"
1131     "    \"texteditorFontSize1\":\n"
1132     "    {\n"
1133     "      \"pointSize\":12\n"
1134     "    },\n"
1135     "    \"texteditorFontSize2\":\n"
1136     "    {\n"
1137     "      \"pointSize\":14\n"
1138     "    },\n"
1139     "    \"texteditorFontSize3\":\n"
1140     "    {\n"
1141     "      \"pointSize\":18\n"
1142     "    },\n"
1143     "    \"texteditorFontSize4\":\n"
1144     "    {\n"
1145     "      \"pointSize\":25\n"
1146     "    }\n"
1147     "  }\n"
1148     "}\n";
1149
1150   Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json", defaultTheme );
1151
1152   ToolkitTestApplication application;
1153
1154   std::string editorStr("Editor");
1155   Toolkit::TextEditor editor = Toolkit::TextEditor::New();
1156   editor.SetProperty( Toolkit::TextEditor::Property::TEXT, editorStr );
1157   Stage::GetCurrent().Add( editor );
1158
1159   Toolkit::TextEditor editor2 = Toolkit::TextEditor::New();
1160   Stage::GetCurrent().Add( editor2 );
1161   editor2.SetProperty( Toolkit::TextEditor::Property::TEXT, editorStr );
1162
1163   StyleChangedSignalChecker styleChangedSignalHandler;
1164   StyleMonitor styleMonitor = StyleMonitor::Get();
1165   StyleManager styleManager = StyleManager::Get();
1166
1167   editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.0f);
1168
1169   styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
1170
1171   Test::StyleMonitor::SetDefaultFontSize(2);
1172   styleMonitor.StyleChangeSignal().Emit( styleMonitor,  StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1173
1174   tet_infoline("Test that the StyleChanged signal is received only once");
1175   DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
1176
1177   tet_infoline("Test that the editor's font size has been altered\n");
1178   Property::Value pointSizeValue = editor.GetProperty(TextEditor::Property::POINT_SIZE);
1179   float pointSize;
1180   pointSizeValue.Get( pointSize );
1181
1182   DALI_TEST_EQUALS( pointSize, 14.0f, 0.001, TEST_LOCATION );
1183
1184   styleChangedSignalHandler.signalCount = 0;
1185
1186   Test::StyleMonitor::SetDefaultFontSize(4);
1187   styleMonitor.StyleChangeSignal().Emit( styleMonitor, StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1188
1189   tet_infoline("Test that the StyleChanged signal is received only once");
1190   DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
1191
1192   // Check that the editor's font style has been altered
1193   pointSizeValue = editor.GetProperty(TextEditor::Property::POINT_SIZE);
1194   pointSizeValue.Get( pointSize );
1195
1196   DALI_TEST_EQUALS( pointSize, 25.0f, 0.001, TEST_LOCATION );
1197
1198
1199   END_TEST;
1200 }
1201
1202
1203 int UtcDaliStyleManagerVisualTransitionParsing(void)
1204 {
1205   tet_infoline("Instantiate dummy control and test state/visual/transition capture" );
1206   Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json",
1207                                           defaultTheme );
1208
1209   ToolkitTestApplication application;
1210
1211   StyleChangedSignalChecker styleChangedSignalHandler;
1212   Dali::StyleMonitor styleMonitor = Dali::StyleMonitor::Get();
1213   StyleManager styleManager = StyleManager::Get();
1214
1215   DummyControl actor = DummyControl::New(true);
1216   actor.SetStyleName("BasicControl");
1217   Stage::GetCurrent().Add(actor);
1218
1219   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1220
1221   DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOREGROUND_VISUAL), true, TEST_LOCATION);
1222   Visual::Base visual1 = dummyImpl.GetVisual(DummyControl::Property::FOREGROUND_VISUAL);
1223
1224   actor.SetProperty( DevelControl::Property::STATE, DevelControl::FOCUSED );
1225
1226   DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOREGROUND_VISUAL), true, TEST_LOCATION);
1227   DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOCUS_VISUAL), true, TEST_LOCATION);
1228
1229   Visual::Base visual2 = dummyImpl.GetVisual(DummyControl::Property::FOREGROUND_VISUAL);
1230   DALI_TEST_CHECK( visual1 != visual2 );
1231
1232   actor.SetProperty( DevelControl::Property::STATE, DevelControl::DISABLED );
1233
1234   DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOREGROUND_VISUAL), true, TEST_LOCATION);
1235
1236   Visual::Base visual3 = dummyImpl.GetVisual(DummyControl::Property::FOREGROUND_VISUAL);
1237   Visual::Base focusVisual = dummyImpl.GetVisual(DummyControl::Property::FOCUS_VISUAL);
1238   DALI_TEST_CHECK( !focusVisual );
1239   DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOCUS_VISUAL), false, TEST_LOCATION);
1240
1241   DALI_TEST_CHECK( visual1 != visual3 );
1242   DALI_TEST_CHECK( visual2 != visual3 );
1243
1244   END_TEST;
1245 }
1246
1247
1248 int UtcDaliStyleManagerVisualTransitionParsing02(void)
1249 {
1250   tet_infoline("Instantiate dummy control and test state/visual/transition capture" );
1251   Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json",
1252                                           defaultTheme );
1253
1254   ToolkitTestApplication application;
1255
1256   StyleChangedSignalChecker styleChangedSignalHandler;
1257   Dali::StyleMonitor styleMonitor = Dali::StyleMonitor::Get();
1258   StyleManager styleManager = StyleManager::Get();
1259
1260   DummyControl actor = DummyControl::New(true);
1261   actor.SetProperty(DevelControl::Property::STATE, "FOCUSED");
1262
1263   actor.SetStyleName("ComplexControl");
1264   Stage::GetCurrent().Add(actor);
1265
1266   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1267
1268   DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOREGROUND_VISUAL), true, TEST_LOCATION);
1269   Visual::Base visual1 = dummyImpl.GetVisual(DummyControl::Property::FOREGROUND_VISUAL);
1270   DALI_TEST_CHECK( visual1 );
1271   Property::Map map;
1272   visual1.CreatePropertyMap( map );
1273   Property::Value* value = map.Find( Visual::Property::TYPE );
1274   DALI_TEST_CHECK( value );
1275
1276   int visualType;
1277   value->Get( visualType );
1278
1279   DALI_TEST_EQUALS( visualType, (int)Toolkit::Visual::GRADIENT, TEST_LOCATION );
1280
1281   END_TEST;
1282 }