2 * Copyright (c) 2016 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.
17 #include <dali/devel-api/adaptor-framework/style-monitor.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>
30 using namespace Dali::Toolkit;
34 const char* defaultTheme =
43 " \"textlabelFontSize0\":\n"
47 " \"textlabelFontSize1\":\n"
51 " \"textlabelFontSize2\":\n"
55 " \"textlabelFontSize3\":\n"
59 " \"textlabelFontSize4\":\n"
66 " \"pointSize\":18,\n"
67 " \"primaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
68 " \"secondaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
69 " \"cursorWidth\":3,\n"
70 " \"selectionHighlightColor\":[0.75,0.96,1.0,1.0],\n"
71 " \"grabHandleImage\" : \"{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png\",\n"
72 " \"selectionHandleImageLeft\" : {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png\" },\n"
73 " \"selectionHandleImageRight\": {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png\" }\n"
76 " \"textfieldFontSize0\":\n"
80 " \"textfieldFontSize1\":\n"
84 " \"textfieldFontSize2\":\n"
88 " \"textfieldFontSize3\":\n"
92 " \"textfieldFontSize4\":\n"
96 " \"textselectionpopup\":\n"
98 " \"popupMaxSize\":[656,72],\n"
99 " \"optionDividerSize\":[2,0],\n"
100 " \"popupDividerColor\":[0.23,0.72,0.8,0.11],\n"
101 " \"popupIconColor\":[1.0,1.0,1.0,1.0],\n"
102 " \"popupPressedColor\":[0.24,0.72,0.8,0.11],\n"
103 " \"background\": {\n"
104 " \"rendererType\": \"nPatch\",\n"
105 " \"imageUrl\": \"{DALI_IMAGE_DIR}selection-popup-bg.9.png\"\n"
107 " \"popupFadeInDuration\":0.25,\n"
108 " \"popupFadeOutDuration\":0.25\n"
110 " \"textselectionpopupbutton\":\n"
114 " \"pointSize\":8,\n"
115 " \"fontStyle\":\"{\\\\""weight\\\\"":\\\\""light\\\\""}\"\n"
118 " \"textselectiontoolbar\":\n"
120 " \"enableOvershoot\":true,\n"
123 " \"overshootAnimationSpeed\":360.0,\n"
124 " \"overshootSize\":[720.0,130.0]\n"
129 " \"overshootEffectColor\":\"B018\",\n"
130 " \"overshootAnimationSpeed\":360.0,\n"
131 " \"overshootSize\":[720.0,130.0]\n"
135 " \"overshootEffectColor\":\"B018\",\n"
136 " \"overshootAnimationSpeed\":360.0,\n"
137 " \"overshootSize\":[720.0,130.0]\n"
141 " \"pointSize\":18,\n"
142 " \"primaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
143 " \"secondaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
144 " \"cursorWidth\":3,\n"
145 " \"selectionHighlightColor\":[0.75,0.96,1.0,1.0],\n"
146 " \"grabHandleImage\" : \"{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png\",\n"
147 " \"selectionHandleImageLeft\" : {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png\" },\n"
148 " \"selectionHandleImageRight\": {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png\" }\n"
153 } // anonymous namespace
157 void dali_style_manager_startup(void)
159 test_return_value = TET_UNDEF;
162 void dali_style_manager_cleanup(void)
164 test_return_value = TET_PASS;
167 int UtcDaliStyleManagerConstructorP(void)
169 ToolkitTestApplication application;
171 tet_infoline(" UtcDaliStyleManagerConstructorP");
172 StyleManager styleManager;
173 DALI_TEST_CHECK( !styleManager);
177 int UtcDaliStyleManagerCopyConstructorP(void)
179 TestApplication application;
181 StyleManager styleManager = StyleManager::Get();
182 StyleManager copyOfStyleManager( styleManager );
184 DALI_TEST_CHECK( copyOfStyleManager );
188 int UtcDaliStyleManagerAssignmentOperatorP(void)
190 TestApplication application;
192 StyleManager styleManager = StyleManager::Get();
193 StyleManager copyOfStyleManager = styleManager;
195 DALI_TEST_CHECK( copyOfStyleManager );
196 DALI_TEST_CHECK( copyOfStyleManager == styleManager );
200 int UtcDaliStyleManagerGet(void)
202 ToolkitTestApplication application;
204 tet_infoline(" UtcDaliStyleManagerGet");
208 type = TypeRegistry::Get().GetTypeInfo( "StyleManager" );
209 DALI_TEST_CHECK( type );
210 BaseHandle handle = type.CreateInstance();
211 DALI_TEST_CHECK( handle );
213 StyleManager manager;
215 manager = StyleManager::Get();
216 DALI_TEST_CHECK(manager);
218 StyleManager newManager = StyleManager::Get();
219 DALI_TEST_CHECK(newManager);
221 // Check that focus manager is a singleton
222 DALI_TEST_CHECK(manager == newManager);
229 class StyleChangedSignalChecker : public ConnectionTracker
232 StyleChangedSignalChecker()
237 void OnStyleChanged(StyleManager styleManager, StyleChange::Type type)
251 } // anonymous namespace
253 int UtcDaliStyleManagerApplyTheme(void)
255 ToolkitTestApplication application;
257 tet_infoline( "Testing StyleManager ApplyTheme" );
265 " \"backgroundColor\":[1.0,1.0,0.0,1.0],\n"
266 " \"foregroundColor\":[0.0,0.0,1.0,1.0]\n"
277 " \"backgroundColor\":[1.0,0.0,0.0,1.0],\n"
278 " \"foregroundColor\":[0.0,1.0,1.0,1.0]\n"
283 // Add 2 buttons to test how many times the signal is sent
284 Test::TestButton testButton = Test::TestButton::New();
285 Test::TestButton testButton2 = Test::TestButton::New();
286 Stage::GetCurrent().Add( testButton );
287 Stage::GetCurrent().Add( testButton2 );
288 StyleChangedSignalChecker styleChangedSignalHandler;
289 StyleChangedSignalChecker styleChangedSignalHandler2;
290 StyleManager styleManager = StyleManager::Get();
292 styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
295 application.SendNotification();
296 application.Render();
298 tet_infoline("Apply the style");
300 std::string themeFile("ThemeOne");
301 Test::StyleMonitor::SetThemeFileOutput(themeFile, json1);
302 StyleManager::Get().ApplyTheme(themeFile);
304 Property::Value bgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) );
305 Property::Value fgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) );
307 DALI_TEST_EQUALS( bgColor, Property::Value(Color::YELLOW), 0.001, TEST_LOCATION );
308 DALI_TEST_EQUALS( fgColor, Property::Value(Color::BLUE), 0.001, TEST_LOCATION );
310 tet_infoline("Testing that the signal handler is called only once");
311 DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
313 tet_infoline("Override the background property");
314 testButton.SetProperty( Test::TestButton::Property::BACKGROUND_COLOR, Color::GREEN );
315 bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
316 fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
317 DALI_TEST_EQUALS( bgColor, Property::Value(Color::GREEN), 0.001, TEST_LOCATION );
318 DALI_TEST_EQUALS( fgColor, Property::Value(Color::BLUE), 0.001, TEST_LOCATION );
321 application.SendNotification();
322 application.Render();
324 tet_infoline("Apply the style again");
326 styleChangedSignalHandler.signalCount = 0;
327 StyleManager::Get().ApplyTheme(themeFile);
329 bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
330 fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
332 tet_infoline("Check that the property is changed");
333 DALI_TEST_EQUALS( bgColor, Property::Value(Color::YELLOW), 0.001, TEST_LOCATION );
334 DALI_TEST_EQUALS( fgColor, Property::Value(Color::BLUE), 0.001, TEST_LOCATION );
335 tet_infoline("Testing that the signal handler is called only once");
336 DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
338 tet_infoline( "Load a different stylesheet");
340 tet_infoline("Apply the new style");
341 std::string themeFile2("ThemeTwo");
342 Test::StyleMonitor::SetThemeFileOutput(themeFile2, json2);
344 styleChangedSignalHandler.signalCount = 0;
345 StyleManager::Get().ApplyTheme(themeFile2);
347 bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
348 fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
350 tet_infoline("Check that the properties change, but the signal gets sent only once");
351 DALI_TEST_EQUALS( bgColor, Property::Value(Color::RED), 0.001, TEST_LOCATION );
352 DALI_TEST_EQUALS( fgColor, Property::Value(Color::CYAN), 0.001, TEST_LOCATION );
353 DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
359 int UtcDaliStyleManagerApplyDefaultTheme(void)
361 tet_infoline( "Testing StyleManager ApplyTheme" );
363 const char* defaultTheme =
369 " \"backgroundColor\":[1.0,1.0,0.0,1.0],\n"
370 " \"foregroundColor\":[0.0,0.0,1.0,1.0]\n"
374 // Bg: Yellow, Fg: Blue
376 const char* appTheme =
382 " \"backgroundColor\":[1.0,0.0,1.0,1.0],\n"
383 " \"foregroundColor\":[0.0,1.0,0.0,1.0]\n"
387 // Bg::Magenta, Fg:Green
389 std::string filepath(TEST_RESOURCE_DIR "");
391 Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json",
393 ToolkitTestApplication application;
395 Test::TestButton testButton = Test::TestButton::New();
396 Stage::GetCurrent().Add( testButton );
397 StyleChangedSignalChecker styleChangedSignalHandler;
398 StyleManager styleManager = StyleManager::Get();
400 styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
403 application.SendNotification();
404 application.Render();
407 Property::Value defaultBgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) );
408 Property::Value defaultFgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) );
410 tet_infoline("Apply the style");
412 std::string themeFile("ThemeOne");
413 Test::StyleMonitor::SetThemeFileOutput(themeFile, appTheme);
414 StyleManager::Get().ApplyTheme(themeFile);
416 Property::Value bgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) );
417 Property::Value fgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) );
419 DALI_TEST_EQUALS( bgColor, Property::Value(Color::MAGENTA), 0.001, TEST_LOCATION );
420 DALI_TEST_EQUALS( fgColor, Property::Value(Color::GREEN), 0.001, TEST_LOCATION );
422 tet_infoline("Testing that the signal handler is called only once");
423 DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
424 tet_infoline("Revert the style");
426 styleChangedSignalHandler.signalCount = 0;
427 StyleManager::Get().ApplyDefaultTheme();
429 bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
430 fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
432 tet_infoline("Check that the property is reverted");
433 DALI_TEST_EQUALS( bgColor, defaultBgColor, 0.001, TEST_LOCATION );
434 DALI_TEST_EQUALS( fgColor, defaultFgColor, 0.001, TEST_LOCATION );
435 DALI_TEST_EQUALS( bgColor, Property::Value(Color::YELLOW), 0.001, TEST_LOCATION );
436 DALI_TEST_EQUALS( fgColor, Property::Value(Color::BLUE), 0.001, TEST_LOCATION );
437 tet_infoline("Testing that the signal handler is called only once");
438 DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
444 int UtcDaliStyleManagerSetStyleConstantP(void)
446 ToolkitTestApplication application;
448 tet_infoline( " UtcDaliStyleManagerSetStyleConstantP" );
450 StyleManager manager = StyleManager::Get();
452 std::string key( "key" );
453 Property::Value value( 100 );
455 manager.SetStyleConstant( key, value );
457 Property::Value returnedValue;
458 manager.GetStyleConstant( key, returnedValue );
460 DALI_TEST_CHECK( value.Get<int>() == returnedValue.Get<int>() );
465 int UtcDaliStyleManagerGetStyleConstantP(void)
467 ToolkitTestApplication application;
469 tet_infoline( " UtcDaliStyleManagerGetStyleConstantP" );
471 StyleManager manager = StyleManager::Get();
473 std::string key( "key" );
474 Property::Value value( 100 );
476 manager.SetStyleConstant( key, value );
478 Property::Value returnedValue;
479 manager.GetStyleConstant( key, returnedValue );
481 DALI_TEST_CHECK( value.Get<int>() == returnedValue.Get<int>() );
485 int UtcDaliStyleManagerGetStyleConstantN(void)
487 ToolkitTestApplication application;
489 tet_infoline( " UtcDaliStyleManagerGetStyleConstantN" );
491 StyleManager manager = StyleManager::Get();
493 std::string key2( "key2" );
494 Property::Value returnedValue2;
495 DALI_TEST_CHECK( !manager.GetStyleConstant( key2, returnedValue2 ) );
500 int UtcDaliStyleManagerApplyStyle(void)
502 ToolkitTestApplication application;
504 tet_infoline( "UtcDaliStyleManagerApplyStyle - test that a style can be applied to a single button" );
512 " \"backgroundColor\":[1.0,1.0,0.0,1.0],\n"
513 " \"foregroundColor\":[0.0,0.0,1.0,1.0]\n"
524 " \"backgroundColor\":[1.0,0.0,0.0,1.0],\n"
525 " \"foregroundColor\":[0.0,1.0,1.0,1.0]\n"
531 Test::TestButton testButton = Test::TestButton::New();
532 Test::TestButton testButton2 = Test::TestButton::New();
533 Stage::GetCurrent().Add( testButton );
534 Stage::GetCurrent().Add( testButton2 );
535 StyleChangedSignalChecker styleChangedSignalHandler;
536 StyleManager styleManager = StyleManager::Get();
538 styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
540 tet_infoline("Apply the style");
542 std::string themeFile("ThemeOne");
543 Test::StyleMonitor::SetThemeFileOutput(themeFile, json1);
544 styleManager.ApplyTheme(themeFile);
547 application.SendNotification();
548 application.Render();
550 Property::Value themedBgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) );
551 Property::Value themedFgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) );
553 // Apply the style to the test button:
554 std::string themeFile2("ThemeTwo");
555 Test::StyleMonitor::SetThemeFileOutput(themeFile2, json2);
556 styleManager.ApplyStyle( testButton, themeFile2, "testbutton" );
558 tet_infoline("Check that the properties change for the first button");
559 Property::Value bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
560 Property::Value fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
561 DALI_TEST_EQUALS( bgColor, Property::Value(Color::RED), 0.001, TEST_LOCATION );
562 DALI_TEST_EQUALS( fgColor, Property::Value(Color::CYAN), 0.001, TEST_LOCATION );
564 DALI_TEST_NOT_EQUALS( bgColor, themedBgColor, 0.001, TEST_LOCATION );
565 DALI_TEST_NOT_EQUALS( fgColor, themedFgColor, 0.001, TEST_LOCATION );
567 tet_infoline("Check that the properties remain the same for the second button");
568 bgColor = testButton2.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
569 fgColor = testButton2.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
570 DALI_TEST_EQUALS( bgColor, themedBgColor, 0.001, TEST_LOCATION );
571 DALI_TEST_EQUALS( fgColor, themedFgColor, 0.001, TEST_LOCATION );
577 int UtcDaliStyleManagerStyleChangedSignalFontFamily(void)
579 tet_infoline("Test that the StyleChange signal is fired when the font family is altered" );
580 Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json",
583 ToolkitTestApplication application;
585 std::string labelStr("Label");
586 Toolkit::TextLabel label = Toolkit::TextLabel::New(labelStr);
587 Stage::GetCurrent().Add( label );
589 Toolkit::TextLabel label2 = Toolkit::TextLabel::New(labelStr);
590 Stage::GetCurrent().Add( label2 );
592 StyleChangedSignalChecker styleChangedSignalHandler;
593 Dali::StyleMonitor styleMonitor = Dali::StyleMonitor::Get();
594 StyleManager styleManager = StyleManager::Get();
596 styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
598 Test::StyleMonitor::SetDefaultFontFamily("Times New Roman");
600 styleMonitor.StyleChangeSignal().Emit( styleMonitor, StyleChange::DEFAULT_FONT_CHANGE);
602 tet_infoline("Test that the StyleChanged signal is received only once");
604 DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
606 // Check that the label's font style has been altered
607 Property::Value family = label.GetProperty(TextLabel::Property::FONT_FAMILY);
608 std::string familyStr;
609 family.Get( familyStr );
611 DALI_TEST_EQUALS( familyStr, "Times New Roman", TEST_LOCATION);
616 int UtcDaliStyleManagerStyleChangedSignalFontSize(void)
618 tet_infoline("Test that the StyleChange signal is fired when the font size is altered" );
620 const char* defaultTheme =
624 " \"textlabelFontSize0\":\n"
626 " \"pointSize\":10\n"
628 " \"textlabelFontSize1\":\n"
630 " \"pointSize\":10\n"
632 " \"textlabelFontSize2\":\n"
634 " \"pointSize\":12\n"
636 " \"textlabelFontSize3\":\n"
638 " \"pointSize\":14\n"
640 " \"textlabelFontSize4\":\n"
642 " \"pointSize\":16\n"
647 Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json", defaultTheme );
649 ToolkitTestApplication application;
651 std::string labelStr("Label");
652 Toolkit::TextLabel label = Toolkit::TextLabel::New(labelStr);
653 Stage::GetCurrent().Add( label );
655 Toolkit::TextLabel label2 = Toolkit::TextLabel::New(labelStr);
656 Stage::GetCurrent().Add( label2 );
658 StyleChangedSignalChecker styleChangedSignalHandler;
659 StyleMonitor styleMonitor = StyleMonitor::Get();
660 StyleManager styleManager = StyleManager::Get();
662 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.0f);
664 styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
666 Test::StyleMonitor::SetDefaultFontSize(2);
667 styleMonitor.StyleChangeSignal().Emit( styleMonitor, StyleChange::DEFAULT_FONT_SIZE_CHANGE);
669 tet_infoline("Test that the StyleChanged signal is received only once");
670 DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
672 tet_infoline("Test that the label's font size has been altered\n");
673 Property::Value pointSizeValue = label.GetProperty(TextLabel::Property::POINT_SIZE);
675 pointSizeValue.Get( pointSize );
677 DALI_TEST_EQUALS( pointSize, 12.0f, 0.001, TEST_LOCATION );
679 styleChangedSignalHandler.signalCount = 0;
681 Test::StyleMonitor::SetDefaultFontSize(4);
682 styleMonitor.StyleChangeSignal().Emit( styleMonitor, StyleChange::DEFAULT_FONT_SIZE_CHANGE);
684 tet_infoline("Test that the StyleChanged signal is received only once");
685 DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
687 // Check that the label's font style has been altered
688 pointSizeValue = label.GetProperty(TextLabel::Property::POINT_SIZE);
689 pointSizeValue.Get( pointSize );
691 DALI_TEST_EQUALS( pointSize, 16.0f, 0.001, TEST_LOCATION );
698 int UtcDaliStyleManagerStyleChangedSignalFontSizeTextField(void)
700 tet_infoline("Test that the StyleChange signal is fired when the font size is altered" );
702 const char* defaultTheme =
706 " \"textfieldFontSize0\":\n"
710 " \"textfieldFontSize1\":\n"
712 " \"pointSize\":10\n"
714 " \"textfieldFontSize2\":\n"
716 " \"pointSize\":12\n"
718 " \"textfieldFontSize3\":\n"
720 " \"pointSize\":14\n"
722 " \"textfieldFontSize4\":\n"
724 " \"pointSize\":16\n"
729 Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json", defaultTheme );
731 ToolkitTestApplication application;
733 std::string fieldStr("Field");
734 Toolkit::TextField field = Toolkit::TextField::New();
735 field.SetProperty( Toolkit::TextField::Property::TEXT, fieldStr );
736 Stage::GetCurrent().Add( field );
738 Toolkit::TextField field2 = Toolkit::TextField::New();
739 Stage::GetCurrent().Add( field2 );
740 field2.SetProperty( Toolkit::TextField::Property::TEXT, fieldStr );
742 StyleChangedSignalChecker styleChangedSignalHandler;
743 StyleMonitor styleMonitor = StyleMonitor::Get();
744 StyleManager styleManager = StyleManager::Get();
746 field.SetProperty(TextField::Property::POINT_SIZE, 10.0f);
748 styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
750 Test::StyleMonitor::SetDefaultFontSize(2);
751 styleMonitor.StyleChangeSignal().Emit( styleMonitor, StyleChange::DEFAULT_FONT_SIZE_CHANGE);
753 tet_infoline("Test that the StyleChanged signal is received only once");
754 DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
756 tet_infoline("Test that the field's font size has been altered\n");
757 Property::Value pointSizeValue = field.GetProperty(TextField::Property::POINT_SIZE);
759 pointSizeValue.Get( pointSize );
761 DALI_TEST_EQUALS( pointSize, 12.0f, 0.001, TEST_LOCATION );
763 styleChangedSignalHandler.signalCount = 0;
765 Test::StyleMonitor::SetDefaultFontSize(4);
766 styleMonitor.StyleChangeSignal().Emit( styleMonitor, StyleChange::DEFAULT_FONT_SIZE_CHANGE);
768 tet_infoline("Test that the StyleChanged signal is received only once");
769 DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
771 // Check that the field's font style has been altered
772 pointSizeValue = field.GetProperty(TextField::Property::POINT_SIZE);
773 pointSizeValue.Get( pointSize );
775 DALI_TEST_EQUALS( pointSize, 16.0f, 0.001, TEST_LOCATION );
781 int UtcDaliStyleManagerStyleChangedSignalFontSizeTextEditor(void)
783 tet_infoline("Test that the StyleChange signal is fired when the font size is altered" );
785 const char* defaultTheme =
789 " \"texteditorFontSize0\":\n"
791 " \"pointSize\":10\n"
793 " \"texteditorFontSize1\":\n"
795 " \"pointSize\":12\n"
797 " \"texteditorFontSize2\":\n"
799 " \"pointSize\":14\n"
801 " \"texteditorFontSize3\":\n"
803 " \"pointSize\":18\n"
805 " \"texteditorFontSize4\":\n"
807 " \"pointSize\":25\n"
812 Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json", defaultTheme );
814 ToolkitTestApplication application;
816 std::string editorStr("Editor");
817 Toolkit::TextEditor editor = Toolkit::TextEditor::New();
818 editor.SetProperty( Toolkit::TextEditor::Property::TEXT, editorStr );
819 Stage::GetCurrent().Add( editor );
821 Toolkit::TextEditor editor2 = Toolkit::TextEditor::New();
822 Stage::GetCurrent().Add( editor2 );
823 editor2.SetProperty( Toolkit::TextEditor::Property::TEXT, editorStr );
825 StyleChangedSignalChecker styleChangedSignalHandler;
826 StyleMonitor styleMonitor = StyleMonitor::Get();
827 StyleManager styleManager = StyleManager::Get();
829 editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.0f);
831 styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
833 Test::StyleMonitor::SetDefaultFontSize(2);
834 styleMonitor.StyleChangeSignal().Emit( styleMonitor, StyleChange::DEFAULT_FONT_SIZE_CHANGE);
836 tet_infoline("Test that the StyleChanged signal is received only once");
837 DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
839 tet_infoline("Test that the editor's font size has been altered\n");
840 Property::Value pointSizeValue = editor.GetProperty(TextEditor::Property::POINT_SIZE);
842 pointSizeValue.Get( pointSize );
844 DALI_TEST_EQUALS( pointSize, 14.0f, 0.001, TEST_LOCATION );
846 styleChangedSignalHandler.signalCount = 0;
848 Test::StyleMonitor::SetDefaultFontSize(4);
849 styleMonitor.StyleChangeSignal().Emit( styleMonitor, StyleChange::DEFAULT_FONT_SIZE_CHANGE);
851 tet_infoline("Test that the StyleChanged signal is received only once");
852 DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
854 // Check that the editor's font style has been altered
855 pointSizeValue = editor.GetProperty(TextEditor::Property::POINT_SIZE);
856 pointSizeValue.Get( pointSize );
858 DALI_TEST_EQUALS( pointSize, 25.0f, 0.001, TEST_LOCATION );