X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-styling%2Futc-Dali-StyleManager.cpp;h=45e1c6432eed06fcfae10f33da80d51d4766297e;hp=e8348f13e2e2ddb302f5c93a507552c13e95d7b4;hb=f25afa77b0b54726b8e12d91e8fdb84f6172d666;hpb=76f9ffa0234acd1b72f3d92c631052a5b4147a83 diff --git a/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp b/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp index e8348f1..45e1c64 100644 --- a/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp +++ b/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,12 +29,8 @@ #include #include #include -#include -#include #include #include -#include -#include #include #include @@ -71,7 +67,7 @@ Visual::Base CheckVisual( Impl::DummyControl& dummyImpl, Property::Index visualI DALI_TEST_EQUALS( (bool)visual, true, location ); Property::Map map; visual.CreatePropertyMap( map ); - Property::Value* value = map.Find( Visual::Property::TYPE ); + Property::Value* value = map.Find( Toolkit::Visual::Property::TYPE ); DALI_TEST_EQUALS( value != NULL, true, location ); int visualType; @@ -92,7 +88,7 @@ Integration::Bitmap* CreateBitmap( unsigned int imageWidth, unsigned int imageHe return bitmap; } -Integration::ResourcePointer CustomizeNinePatch( TestApplication& application, +Integration::ResourcePointer CustomizeNinePatch( ToolkitTestApplication& application, unsigned int ninePatchImageWidth, unsigned int ninePatchImageHeight) { @@ -123,7 +119,7 @@ int UtcDaliStyleManagerConstructorP(void) int UtcDaliStyleManagerCopyConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; StyleManager styleManager = StyleManager::Get(); StyleManager copyOfStyleManager( styleManager ); @@ -134,7 +130,7 @@ int UtcDaliStyleManagerCopyConstructorP(void) int UtcDaliStyleManagerAssignmentOperatorP(void) { - TestApplication application; + ToolkitTestApplication application; StyleManager styleManager = StyleManager::Get(); StyleManager copyOfStyleManager = styleManager; @@ -234,14 +230,20 @@ int UtcDaliStyleManagerApplyTheme(void) // Add 2 buttons to test how many times the signal is sent Test::TestButton testButton = Test::TestButton::New(); Test::TestButton testButton2 = Test::TestButton::New(); - Stage::GetCurrent().Add( testButton ); - Stage::GetCurrent().Add( testButton2 ); + application.GetScene().Add( testButton ); + application.GetScene().Add( testButton2 ); StyleChangedSignalChecker styleChangedSignalHandler; StyleChangedSignalChecker styleChangedSignalHandler2; StyleManager styleManager = StyleManager::Get(); styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged); + // To ensure we make VisualFactory + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT ); + Visual::Base textVisual = factory.CreateVisual( propertyMap ); + // Render and notify application.SendNotification(); application.Render(); @@ -348,7 +350,7 @@ int UtcDaliStyleManagerApplyDefaultTheme(void) ToolkitTestApplication application; Test::TestButton testButton = Test::TestButton::New(); - Stage::GetCurrent().Add( testButton ); + application.GetScene().Add( testButton ); StyleChangedSignalChecker styleChangedSignalHandler; StyleManager styleManager = StyleManager::Get(); @@ -489,8 +491,8 @@ int UtcDaliStyleManagerApplyStyle(void) // Add 2 buttons Test::TestButton testButton = Test::TestButton::New(); Test::TestButton testButton2 = Test::TestButton::New(); - Stage::GetCurrent().Add( testButton ); - Stage::GetCurrent().Add( testButton2 ); + application.GetScene().Add( testButton ); + application.GetScene().Add( testButton2 ); StyleChangedSignalChecker styleChangedSignalHandler; StyleManager styleManager = StyleManager::Get(); @@ -557,8 +559,8 @@ int UtcDaliStyleManagerIncludeStyleP(void) // Add 2 buttons Test::TestButton testButton = Test::TestButton::New(); Test::TestButton testButton2 = Test::TestButton::New(); - Stage::GetCurrent().Add( testButton ); - Stage::GetCurrent().Add( testButton2 ); + application.GetScene().Add( testButton ); + application.GetScene().Add( testButton2 ); StyleChangedSignalChecker styleChangedSignalHandler; StyleManager styleManager = StyleManager::Get(); @@ -609,8 +611,8 @@ int UtcDaliStyleManagerIncludeStyleN(void) // Add 2 buttons Test::TestButton testButton = Test::TestButton::New(); Test::TestButton testButton2 = Test::TestButton::New(); - Stage::GetCurrent().Add( testButton ); - Stage::GetCurrent().Add( testButton2 ); + application.GetScene().Add( testButton ); + application.GetScene().Add( testButton2 ); StyleChangedSignalChecker styleChangedSignalHandler; StyleManager styleManager = StyleManager::Get(); @@ -644,13 +646,13 @@ int UtcDaliStyleManagerStyleChangedSignalFontFamily(void) std::string labelStr("Label"); Toolkit::TextLabel label = Toolkit::TextLabel::New(labelStr); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); Toolkit::TextField field = Toolkit::TextField::New(); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); Toolkit::TextEditor editor = Toolkit::TextEditor::New(); - Stage::GetCurrent().Add( editor ); + application.GetScene().Add( editor ); StyleChangedSignalChecker styleChangedSignalHandler; Dali::StyleMonitor styleMonitor = Dali::StyleMonitor::Get(); @@ -725,10 +727,10 @@ int UtcDaliStyleManagerStyleChangedSignalFontSize(void) std::string labelStr("Label"); Toolkit::TextLabel label = Toolkit::TextLabel::New(labelStr); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); Toolkit::TextLabel label2 = Toolkit::TextLabel::New(labelStr); - Stage::GetCurrent().Add( label2 ); + application.GetScene().Add( label2 ); StyleChangedSignalChecker styleChangedSignalHandler; StyleMonitor styleMonitor = StyleMonitor::Get(); @@ -808,10 +810,10 @@ int UtcDaliStyleManagerStyleChangedSignalFontSizeTextField(void) std::string fieldStr("Field"); Toolkit::TextField field = Toolkit::TextField::New(); field.SetProperty( Toolkit::TextField::Property::TEXT, fieldStr ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); Toolkit::TextField field2 = Toolkit::TextField::New(); - Stage::GetCurrent().Add( field2 ); + application.GetScene().Add( field2 ); field2.SetProperty( Toolkit::TextField::Property::TEXT, fieldStr ); StyleChangedSignalChecker styleChangedSignalHandler; @@ -891,10 +893,10 @@ int UtcDaliStyleManagerStyleChangedSignalFontSizeTextEditor(void) std::string editorStr("Editor"); Toolkit::TextEditor editor = Toolkit::TextEditor::New(); editor.SetProperty( Toolkit::TextEditor::Property::TEXT, editorStr ); - Stage::GetCurrent().Add( editor ); + application.GetScene().Add( editor ); Toolkit::TextEditor editor2 = Toolkit::TextEditor::New(); - Stage::GetCurrent().Add( editor2 ); + application.GetScene().Add( editor2 ); editor2.SetProperty( Toolkit::TextEditor::Property::TEXT, editorStr ); StyleChangedSignalChecker styleChangedSignalHandler; @@ -951,7 +953,7 @@ int UtcDaliStyleManagerSetState01(void) DummyControl actor = DummyControl::New(true); actor.SetStyleName("BasicControl"); - Stage::GetCurrent().Add(actor); + application.GetScene().Add(actor); Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); Integration::ResourcePointer ninePatch = CustomizeNinePatch( application, 30, 30 ); @@ -1027,7 +1029,7 @@ int UtcDaliStyleManagerSetState02(void) DummyControl actor = DummyControl::New(true); actor.SetStyleName("BasicControl"); - Stage::GetCurrent().Add(actor); + application.GetScene().Add(actor); Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); Integration::ResourcePointer ninePatch = CustomizeNinePatch( application, 30, 30 ); @@ -1107,7 +1109,7 @@ int UtcDaliStyleManagerSetState03N(void) DummyControl actor = DummyControl::New(true); actor.SetStyleName("NoStyles"); - Stage::GetCurrent().Add(actor); + application.GetScene().Add(actor); Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); Property::Map propertyMap; @@ -1156,7 +1158,7 @@ int UtcDaliStyleManagerSetState04N(void) DummyControl actor = DummyControl::New(true); actor.SetStyleName("NoStateStyle"); - Stage::GetCurrent().Add(actor); + application.GetScene().Add(actor); Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); Property::Map propertyMap; @@ -1206,7 +1208,7 @@ int UtcDaliStyleManagerSetSubState01(void) actor.SetProperty(DevelControl::Property::STATE, "NORMAL"); actor.SetProperty(DevelControl::Property::SUB_STATE, "SELECTED"); actor.SetStyleName("ComplexControl"); - Stage::GetCurrent().Add(actor); + application.GetScene().Add(actor); Integration::ResourcePointer ninePatch = CustomizeNinePatch( application, 30, 30 ); @@ -1250,7 +1252,7 @@ int UtcDaliStyleManagerSetSubState02(void) tet_infoline( "Setting state to NORMAL/SELECTED before re-styling\n"); actor.SetStyleName("ComplexControl"); - Stage::GetCurrent().Add(actor); + application.GetScene().Add(actor); Integration::ResourcePointer ninePatch = CustomizeNinePatch( application, 30, 30 ); @@ -1269,13 +1271,13 @@ int UtcDaliStyleManagerSetSubState02(void) tet_infoline( "Changing state to FOCUSED - check visual changes\n"); Visual::Base fgVisual1 = CheckVisual( dummyImpl, DummyControl::Property::FOREGROUND_VISUAL, Toolkit::Visual::GRADIENT, TEST_LOCATION); - Visual::Base focusVisual1 = CheckVisual( dummyImpl, DummyControl::Property::FOCUS_VISUAL, Toolkit::DevelVisual::N_PATCH, TEST_LOCATION); + Visual::Base focusVisual1 = CheckVisual( dummyImpl, DummyControl::Property::FOCUS_VISUAL, Toolkit::Visual::N_PATCH, TEST_LOCATION); actor.SetProperty(DevelControl::Property::SUB_STATE, "SELECTED"); tet_infoline( "Changing substate to SELECTED - Expect no change\n"); Visual::Base fgVisual2 = CheckVisual( dummyImpl, DummyControl::Property::FOREGROUND_VISUAL, Toolkit::Visual::GRADIENT, TEST_LOCATION); - Visual::Base focusVisual2 = CheckVisual( dummyImpl, DummyControl::Property::FOCUS_VISUAL, Toolkit::DevelVisual::N_PATCH, TEST_LOCATION); + Visual::Base focusVisual2 = CheckVisual( dummyImpl, DummyControl::Property::FOCUS_VISUAL, Toolkit::Visual::N_PATCH, TEST_LOCATION); DALI_TEST_CHECK( fgVisual1 == fgVisual2 ); DALI_TEST_CHECK( focusVisual1 == focusVisual2 ); @@ -1310,8 +1312,13 @@ int UtcDaliStyleManagerConfigSectionTest(void) const char* defaultTheme = "{\n" + " \"constants\":\n" + " {\n" + " \"TEST\":\"broken\"\n" + " },\n" " \"config\":\n" " {\n" + " \"brokenImageUrl\":\"{TEST}|{TEST}|{TEST|TEST.png\",\n" " \"alwaysShowFocus\":false,\n" " \"clearFocusOnEscape\":false\n" " },\n" @@ -1331,15 +1338,17 @@ int UtcDaliStyleManagerConfigSectionTest(void) DALI_TEST_CHECK( !alwaysShowFocus ); bool clearFocusOnEscape = config["clearFocusOnEscape"].Get(); DALI_TEST_CHECK( !clearFocusOnEscape ); + std::string brokenImageUrl = config["brokenImageUrl"].Get(); + DALI_TEST_CHECK( brokenImageUrl.compare( "broken|broken|{TEST|TEST.png" ) == 0 ); // For coverage Toolkit::TextEditor editor = Toolkit::TextEditor::New(); - editor.SetKeyboardFocusable( true ); - Stage::GetCurrent().Add( editor ); + editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true ); + application.GetScene().Add( editor ); Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( editor ); - application.ProcessEvent( Integration::KeyEvent( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) ); + application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE ) ); application.SendNotification(); application.Render();