X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-TextField.cpp;h=51d27c8f98188d97bf171a06579a70626fe56b60;hp=b83c5e5242c7b926de43ed3594d08c3e8c53df14;hb=4c4f959f023cf5541feeef5c834cfe7e43fa05b2;hpb=43ca048f4200d2f1d6e59c2163af59cd99a45b2e diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp old mode 100755 new mode 100644 index b83c5e5..51d27c8 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -104,6 +104,8 @@ const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGr const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection"; const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup"; const char* const PROPERTY_NAME_BACKGROUND = "textBackground"; +const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale"; +const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor"; const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f ); const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color. @@ -119,6 +121,8 @@ const int KEY_D_CODE = 40; const std::string DEFAULT_DEVICE_NAME("hwKeyboard"); +static bool gAnchorClickedCallBackCalled; +static bool gAnchorClickedCallBackNotCalled; static bool gTextChangedCallBackCalled; static bool gMaxCharactersCallBackCalled; static bool gInputStyleChangedCallbackCalled; @@ -204,6 +208,18 @@ struct CallbackFunctor bool* mCallbackFlag; }; +static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength) +{ + tet_infoline(" TestAnchorClickedCallback"); + + gAnchorClickedCallBackNotCalled = false; + + if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href)) + { + gAnchorClickedCallBackCalled = true; + } +} + static void TestTextChangedCallback( TextField control ) { tet_infoline(" TestTextChangedCallback"); @@ -387,6 +403,23 @@ int UtcDaliToolkitTextFieldCopyConstructorP(void) END_TEST; } +int UtcDaliTextFieldMoveConstructor(void) +{ + ToolkitTestApplication application; + + TextField textField = TextField::New(); + textField.SetProperty( TextEditor::Property::TEXT, "Test" ); + DALI_TEST_CHECK( textField.GetProperty( TextField::Property::TEXT ) == "Test" ); + + TextField moved = std::move( textField ); + DALI_TEST_CHECK( moved ); + DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + DALI_TEST_CHECK( moved.GetProperty( TextField::Property::TEXT ) == "Test" ); + DALI_TEST_CHECK( !textField ); + + END_TEST; +} + int UtcDaliToolkitTextFieldAssignmentOperatorP(void) { ToolkitTestApplication application; @@ -400,6 +433,24 @@ int UtcDaliToolkitTextFieldAssignmentOperatorP(void) END_TEST; } +int UtcDaliTextFieldMoveAssignment(void) +{ + ToolkitTestApplication application; + + TextField textField = TextField::New(); + textField.SetProperty( TextEditor::Property::TEXT, "Test" ); + DALI_TEST_CHECK( textField.GetProperty( TextField::Property::TEXT ) == "Test" ); + + TextField moved; + moved = std::move( textField ); + DALI_TEST_CHECK( moved ); + DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + DALI_TEST_CHECK( moved.GetProperty( TextField::Property::TEXT ) == "Test" ); + DALI_TEST_CHECK( !textField ); + + END_TEST; +} + int UtcDaliTextFieldNewP(void) { ToolkitTestApplication application; @@ -468,11 +519,13 @@ int UtcDaliTextFieldGetPropertyP(void) DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS ); + DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND ); + DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR ); END_TEST; } @@ -502,7 +555,7 @@ int UtcDaliTextFieldSetPropertyP(void) tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP"); TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); // Note - we can't check the defaults since the stylesheets are platform-specific @@ -544,6 +597,10 @@ int UtcDaliTextFieldSetPropertyP(void) field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f ); + DALI_TEST_EQUALS( field.GetProperty( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f ); + // Reset font style. fontStyleMapSet.Clear(); fontStyleMapSet.Insert( "weight", "normal" ); @@ -939,6 +996,10 @@ int UtcDaliTextFieldSetPropertyP(void) field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED ); DALI_TEST_EQUALS( field.GetProperty( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION ); + //Check handle color + field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN ); + DALI_TEST_EQUALS( field.GetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION ); + application.SendNotification(); application.Render(); @@ -959,7 +1020,7 @@ int utcDaliTextFieldAtlasRenderP(void) application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); try { @@ -975,6 +1036,303 @@ int utcDaliTextFieldAtlasRenderP(void) END_TEST; } +// Positive test for the anchorClicked signal. +int utcDaliTextFieldAnchorClicked01(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextFieldAnchorClicked01"); + TextField field = TextField::New(); + DALI_TEST_CHECK(field); + + application.GetScene().Add(field); + + // connect to the anchor clicked signal. + ConnectionTracker* testTracker = new ConnectionTracker(); + DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback); + bool anchorClickedSignal = false; + field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal)); + + gAnchorClickedCallBackCalled = false; + field.SetProperty(TextField::Property::TEXT, "TIZEN"); + field.SetProperty(TextField::Property::ENABLE_MARKUP, true); + field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f)); + field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + + application.SendNotification(); + application.Render(); + field.SetKeyInputFocus(); + + // Create a tap event to touch the text field. + TestGenerateTap(application, 5.0f, 25.0f); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gAnchorClickedCallBackCalled); + DALI_TEST_CHECK(anchorClickedSignal); + + gAnchorClickedCallBackNotCalled = true; + // Tap the outside of anchor, callback should not be called. + TestGenerateTap(application, 150.f, 100.f); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled); + + END_TEST; +} + +// Positive test for the anchorClicked signal. +int utcDaliTextFieldAnchorClicked02(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextFieldAnchorClicked02"); + TextField field = TextField::New(); + DALI_TEST_CHECK(field); + + application.GetScene().Add(field); + + // connect to the anchor clicked signal. + ConnectionTracker* testTracker = new ConnectionTracker(); + DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback); + bool anchorClickedSignal = false; + field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal)); + + gAnchorClickedCallBackCalled = false; + field.SetProperty(TextField::Property::TEXT, "TIZEN"); + field.SetProperty(TextField::Property::ENABLE_MARKUP, true); + field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f)); + field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + + application.SendNotification(); + application.Render(); + field.SetKeyInputFocus(); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE); + + // Create a tap event to touch the text field. + TestGenerateTap(application, 30.0f, 25.0f, 100); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gAnchorClickedCallBackCalled); + DALI_TEST_CHECK(anchorClickedSignal); + + + // For coverage InsertTextAnchor, RemoveTextAnchor + // first index insert + field.SetProperty(TextField::Property::TEXT, "TIZEN"); + field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0); + application.SendNotification(); + application.Render(); + + application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.SendNotification(); + application.Render(); + + gAnchorClickedCallBackCalled = false; + // Create a tap event to touch the text field. + TestGenerateTap(application, 30.0f, 25.0f, 700); + application.SendNotification(); + field.SetKeyInputFocus(); + + DALI_TEST_CHECK(gAnchorClickedCallBackCalled); + + // last index insert + field.SetProperty(TextField::Property::TEXT, "TIZEN"); + field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5); + application.SendNotification(); + application.Render(); + + application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.SendNotification(); + application.Render(); + + gAnchorClickedCallBackCalled = false; + // Create a tap event to touch the text field. + TestGenerateTap(application, 30.0f, 25.0f, 1300); + application.SendNotification(); + field.SetKeyInputFocus(); + + DALI_TEST_CHECK(gAnchorClickedCallBackCalled); + + // mid index insert + field.SetProperty(TextField::Property::TEXT, "TIZEN"); + field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2); + application.SendNotification(); + application.Render(); + + application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.SendNotification(); + application.Render(); + + gAnchorClickedCallBackCalled = false; + // Create a tap event to touch the text field. + TestGenerateTap(application, 30.0f, 25.0f, 1900); + application.SendNotification(); + field.SetKeyInputFocus(); + + DALI_TEST_CHECK(gAnchorClickedCallBackCalled); + + // first index remove + field.SetProperty(TextField::Property::TEXT, "TIZEN"); + field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0); + application.SendNotification(); + application.Render(); + + application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.SendNotification(); + application.Render(); + + gAnchorClickedCallBackCalled = false; + // Create a tap event to touch the text field. + TestGenerateTap(application, 30.0f, 25.0f, 2500); + application.SendNotification(); + field.SetKeyInputFocus(); + + DALI_TEST_CHECK(gAnchorClickedCallBackCalled); + + // last index remove + field.SetProperty(TextField::Property::TEXT, "TIZEN"); + field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5); + application.SendNotification(); + application.Render(); + + application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.SendNotification(); + application.Render(); + + gAnchorClickedCallBackCalled = false; + // Create a tap event to touch the text field. + TestGenerateTap(application, 30.0f, 25.0f, 3100); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gAnchorClickedCallBackCalled); + + // middle index + field.SetProperty(TextField::Property::TEXT, "TIZEN"); + field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2); + application.SendNotification(); + application.Render(); + + application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.SendNotification(); + application.Render(); + + gAnchorClickedCallBackCalled = false; + // Create a tap event to touch the text field. + TestGenerateTap(application, 30.0f, 25.0f, 3700); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gAnchorClickedCallBackCalled); + + // 0 ~ 1 index remove + field.SetProperty(TextField::Property::TEXT, "TIZEN"); + field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0); + field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1); + application.SendNotification(); + application.Render(); + + application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.SendNotification(); + application.Render(); + + gAnchorClickedCallBackCalled = false; + // Create a tap event to touch the text field. + TestGenerateTap(application, 30.0f, 25.0f, 4300); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gAnchorClickedCallBackCalled); + + // 1 ~ 3 index remove + field.SetProperty(TextField::Property::TEXT, "TIZEN"); + field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1); + field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3); + application.SendNotification(); + application.Render(); + + application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.SendNotification(); + application.Render(); + + gAnchorClickedCallBackCalled = false; + // Create a tap event to touch the text field. + TestGenerateTap(application, 30.0f, 25.0f, 4900); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gAnchorClickedCallBackCalled); + + // 3 ~ 4 index remove + field.SetProperty(TextField::Property::TEXT, "TIZEN"); + field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3); + field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4); + application.SendNotification(); + application.Render(); + + application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.SendNotification(); + application.Render(); + + gAnchorClickedCallBackCalled = false; + // Create a tap event to touch the text field. + TestGenerateTap(application, 30.0f, 25.0f, 5500); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gAnchorClickedCallBackCalled); + + // Remove front of anchor + field.SetProperty(TextField::Property::TEXT, "TIZENTIZEN"); + field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3); + application.SendNotification(); + application.Render(); + + application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.SendNotification(); + application.Render(); + + // Remove whole text + field.SetProperty(TextField::Property::TEXT, "TIZEN"); + DevelTextField::SelectWholeText(field); + application.SendNotification(); + application.Render(); + + application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.SendNotification(); + application.Render(); + + // Remove all with backspace + field.SetProperty(TextField::Property::TEXT, "T"); + field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1); + application.SendNotification(); + application.Render(); + + application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.SendNotification(); + application.Render(); + + // Remove all with delete + field.SetProperty(TextField::Property::TEXT, "T"); + field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0); + application.SendNotification(); + application.Render(); + + application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.SendNotification(); + application.Render(); + + END_TEST; +} + // Positive test for the textChanged signal. int utcDaliTextFieldTextChangedP(void) { @@ -983,7 +1341,7 @@ int utcDaliTextFieldTextChangedP(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); // connect to the text changed signal. ConnectionTracker* testTracker = new ConnectionTracker(); @@ -997,16 +1355,100 @@ int utcDaliTextFieldTextChangedP(void) DALI_TEST_CHECK( textChangedSignal ); application.SendNotification(); + field.SetKeyInputFocus(); + + gTextChangedCallBackCalled = false; + application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + DALI_TEST_CHECK( gTextChangedCallBackCalled ); + + // Remove all text + field.SetProperty( TextField::Property::TEXT, "" ); + + // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield. + gTextChangedCallBackCalled = false; + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + DALI_TEST_CHECK( !gTextChangedCallBackCalled ); + + // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield. + gTextChangedCallBackCalled = false; + application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + DALI_TEST_CHECK( !gTextChangedCallBackCalled ); + + END_TEST; +} + +int utcDaliTextFieldTextChangedWithInputMethodContext(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext"); + TextField field = TextField::New(); + DALI_TEST_CHECK( field ); + + + application.GetScene().Add( field ); + + // connect to the text changed signal. + ConnectionTracker* testTracker = new ConnectionTracker(); + field.TextChangedSignal().Connect(&TestTextChangedCallback); + bool textChangedSignal = false; + field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) ); + + + // get InputMethodContext + std::string text; + InputMethodContext::EventData imfEvent; + InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field ); field.SetKeyInputFocus(); + field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true ); + + // input text + gTextChangedCallBackCalled = false; + imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 ); + inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent); + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK( gTextChangedCallBackCalled ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION ); + + gTextChangedCallBackCalled = false; + imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 ); + inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent); + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK( gTextChangedCallBackCalled ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION ); gTextChangedCallBackCalled = false; - application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 ); + inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent); + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK( gTextChangedCallBackCalled ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION ); + + gTextChangedCallBackCalled = false; + imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 ); + inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent); + DALI_TEST_CHECK( !gTextChangedCallBackCalled ); + + imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 ); + inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent); + DALI_TEST_CHECK( !gTextChangedCallBackCalled ); + + imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 ); + inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent); + DALI_TEST_CHECK( !gTextChangedCallBackCalled ); + + application.SendNotification(); + application.Render(); DALI_TEST_CHECK( gTextChangedCallBackCalled ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION ); END_TEST; } + // Negative test for the textChanged signal. int utcDaliTextFieldTextChangedN(void) { @@ -1015,7 +1457,7 @@ int utcDaliTextFieldTextChangedN(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); // connect to the text changed signal. ConnectionTracker* testTracker = new ConnectionTracker(); @@ -1025,6 +1467,8 @@ int utcDaliTextFieldTextChangedN(void) gTextChangedCallBackCalled = false; field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT + application.SendNotification(); + application.Render(); DALI_TEST_CHECK( !gTextChangedCallBackCalled ); DALI_TEST_CHECK( !textChangedSignal ); @@ -1039,7 +1483,7 @@ int utcDaliTextFieldMaxCharactersReachedP(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); const int maxNumberOfCharacters = 1; field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters ); @@ -1054,8 +1498,8 @@ int utcDaliTextFieldMaxCharactersReachedP(void) gMaxCharactersCallBackCalled = false; - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); DALI_TEST_CHECK( gMaxCharactersCallBackCalled ); DALI_TEST_CHECK( maxLengthReachedSignal ); @@ -1071,7 +1515,7 @@ int utcDaliTextFieldMaxCharactersReachedN(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); const int maxNumberOfCharacters = 3; field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters ); @@ -1086,13 +1530,13 @@ int utcDaliTextFieldMaxCharactersReachedN(void) gMaxCharactersCallBackCalled = false; - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); DALI_TEST_CHECK( !gMaxCharactersCallBackCalled ); DALI_TEST_CHECK( !maxLengthReachedSignal ); - application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); DALI_TEST_CHECK( !gMaxCharactersCallBackCalled ); DALI_TEST_CHECK( !maxLengthReachedSignal ); @@ -1139,7 +1583,7 @@ int utcDaliTextFieldInputStyleChanged01(void) bool inputStyleChangedSignal = false; field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); // Render and notify application.SendNotification(); @@ -1347,7 +1791,7 @@ int utcDaliTextFieldInputStyleChanged02(void) bool inputStyleChangedSignal = false; field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); // Render and notify application.SendNotification(); @@ -1395,7 +1839,7 @@ int utcDaliTextFieldInputStyleChanged02(void) gInputStyleMask = TextField::InputStyle::NONE; inputStyleChangedSignal = false; - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -1420,7 +1864,7 @@ int utcDaliTextFieldInputStyleChanged02(void) gInputStyleMask = TextField::InputStyle::NONE; inputStyleChangedSignal = false; - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -1436,7 +1880,7 @@ int utcDaliTextFieldInputStyleChanged02(void) gInputStyleMask = TextField::InputStyle::NONE; inputStyleChangedSignal = false; - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -1487,7 +1931,7 @@ int utcDaliTextFieldInputStyleChanged02(void) DALI_TEST_CHECK( !inputStyleChangedSignal ); // Create a tap event to touch the text field. - TestGenerateTap( application, 63.0f, 25.0f, 300 ); + TestGenerateTap( application, 63.0f, 25.0f, 700 ); // Render and notify application.SendNotification(); @@ -1528,7 +1972,7 @@ int utcDaliTextFieldEvent01(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); @@ -1546,7 +1990,7 @@ int utcDaliTextFieldEvent01(void) application.Render(); // Add a key event but as the text field has not the focus it should do nothing. - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -1562,14 +2006,14 @@ int utcDaliTextFieldEvent01(void) application.Render(); // Pressing delete key should be fine even if there is no text in TextField. - application.ProcessEvent( GenerateKey( "Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); application.Render(); // Now the text field has the focus, so it can handle the key events. - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -1585,7 +2029,7 @@ int utcDaliTextFieldEvent01(void) field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) ); field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f )); - Stage::GetCurrent().Add( field2 ); + application.GetScene().Add( field2 ); // Render and notify application.SendNotification(); @@ -1599,8 +2043,8 @@ int utcDaliTextFieldEvent01(void) application.Render(); // The second text field has the focus. It should handle the key events. - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -1624,7 +2068,7 @@ int utcDaliTextFieldEvent02(void) DALI_TEST_CHECK( field ); LoadMarkerImages(application, field); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); @@ -1651,14 +2095,12 @@ int utcDaliTextFieldEvent02(void) application.Render(); Actor layer = field.GetChildAt( 1u ); - DALI_TEST_CHECK( layer.GetProperty< bool >( Actor::Property::IS_LAYER ) ); - DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor. DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION ); // Now the text field has the focus, so it can handle the key events. - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -1681,7 +2123,7 @@ int utcDaliTextFieldEvent02(void) // Move the cursor and check the position changes. Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ); - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -1690,7 +2132,7 @@ int utcDaliTextFieldEvent02(void) Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ); DALI_TEST_CHECK( position2.x < position1.x ); - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -1701,8 +2143,8 @@ int utcDaliTextFieldEvent02(void) // Move the cursor to the first position. - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -1736,8 +2178,8 @@ int utcDaliTextFieldEvent02(void) DALI_TEST_CHECK( position6.x > position5.x ); // Remove all the text. - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); field.SetProperty( TextField::Property::TEXT, "" ); // Render and notify @@ -1775,7 +2217,7 @@ int utcDaliTextFieldEvent03(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." ); field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); @@ -1832,7 +2274,7 @@ int utcDaliTextFieldEvent04(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); LoadMarkerImages(application, field); // Render and notify application.SendNotification(); @@ -1885,7 +2327,7 @@ int utcDaliTextFieldEvent05(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); LoadMarkerImages(application, field); // Render and notify application.SendNotification(); @@ -1936,7 +2378,7 @@ int utcDaliTextFieldEvent06(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); LoadMarkerImages(application, field); // Render and notify application.SendNotification(); @@ -1987,7 +2429,7 @@ int utcDaliTextFieldEvent07(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); LoadMarkerImages(application, field); // Render and notify application.SendNotification(); @@ -2030,7 +2472,7 @@ int utcDaliTextFieldEvent08(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); LoadMarkerImages(application, field); // Render and notify application.SendNotification(); @@ -2067,7 +2509,7 @@ int utcDaliTextFieldEvent08(void) Wait(application, 500); - Stage stage = Stage::GetCurrent(); + Integration::Scene stage = application.GetScene(); Layer layer = stage.GetRootLayer(); Actor actor = layer.FindChildByName("optionPaste"); @@ -2098,7 +2540,7 @@ int utcDaliTextFieldEvent09(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); LoadMarkerImages(application, field); // Render and notify application.SendNotification(); @@ -2121,14 +2563,14 @@ int utcDaliTextFieldEvent09(void) Property::Map map; map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE; field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map ); - application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); application.SendNotification(); application.Render(); map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL; map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23; field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map ); - application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); application.SendNotification(); application.Render(); @@ -2137,7 +2579,7 @@ int utcDaliTextFieldEvent09(void) field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map ); for( unsigned int index = 0u; index < 5u; ++index ) { - application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); application.SendNotification(); application.Render(); } @@ -2147,7 +2589,7 @@ int utcDaliTextFieldEvent09(void) field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map ); for( unsigned int index = 0u; index < 5u; ++index ) { - application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); application.SendNotification(); application.Render(); } @@ -2155,16 +2597,16 @@ int utcDaliTextFieldEvent09(void) map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER; map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0; field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map ); - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); application.SendNotification(); application.Render(); - application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); application.SendNotification(); application.Render(); map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100; field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map ); - application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); application.SendNotification(); application.Render(); @@ -2185,7 +2627,7 @@ int utcDaliTextFieldStyleWhilstSelected(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); LoadMarkerImages(application, field); // Render and notify application.SendNotification(); @@ -2273,7 +2715,7 @@ int utcDaliTextFieldStyleWhilstSelected(void) DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); // Press Escape to increase coverage - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); application.SendNotification(); application.Render(); @@ -2293,7 +2735,7 @@ int utcDaliTextFieldEscKeyLoseFocus(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); @@ -2307,8 +2749,8 @@ int utcDaliTextFieldEscKeyLoseFocus(void) application.Render(); // Add a key event but as the text field has not the focus it should do nothing. - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -2324,10 +2766,10 @@ int utcDaliTextFieldEscKeyLoseFocus(void) application.Render(); // Now the text field has the focus, so it can handle the key events. - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -2336,8 +2778,8 @@ int utcDaliTextFieldEscKeyLoseFocus(void) DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION ); // Generate a Esc key event. The text field should lose the focus. - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -2346,8 +2788,8 @@ int utcDaliTextFieldEscKeyLoseFocus(void) DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION ); // No more text should be introduced - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -2367,7 +2809,7 @@ int utcDaliTextFieldSomeSpecialKeys(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); LoadMarkerImages(application, field); // Render and notify application.SendNotification(); @@ -2409,24 +2851,24 @@ int utcDaliTextFieldSomeSpecialKeys(void) application.Render(); // Generate a Esc key event. The text field should lose the focus. - application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); application.Render(); // Generate a Esc key event. The text field should lose the focus. - application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); application.Render(); // Generate a Esc key event. The text field should lose the focus. - application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -2446,7 +2888,7 @@ int utcDaliTextFieldSizeUpdate(void) // Checks some special keys when the text is selected. TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); float previousHeight = 0.0f; float currentHeight = 0.0f; @@ -2472,8 +2914,8 @@ int utcDaliTextFieldSizeUpdate(void) DALI_TEST_EQUALS( previousHeight, field.GetProperty( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION ); // Add another script characters ( glyph height is defferent ) - application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); application.SendNotification(); application.Render(); @@ -2496,7 +2938,7 @@ int utcDaliTextFieldExtremlyLargePointSize(void) field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); try { @@ -2517,7 +2959,7 @@ int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void) tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage"); TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); Property::Map fontStyleMapGet; @@ -2543,7 +2985,7 @@ int UtcDaliTextFieldSettingPlaceholder(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); // Check the placeholder property with pixel size Property::Map placeholderPixelSizeMapSet; @@ -2626,7 +3068,7 @@ int UtcDaliTextFieldSetPaddingProperty(void) field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); application.SendNotification(); application.Render(); @@ -2659,7 +3101,7 @@ int UtcDaliTextFieldEnableShiftSelectionProperty(void) field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); application.SendNotification(); application.Render(); @@ -2687,7 +3129,7 @@ int UtcDaliTextFieldEnableGrabHandleProperty(void) field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); application.SendNotification(); application.Render(); @@ -2715,7 +3157,7 @@ int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void) field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); application.SendNotification(); application.Render(); @@ -2743,7 +3185,7 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - Stage::GetCurrent().Add( field ); + application.GetScene().Add( field ); field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); @@ -2802,8 +3244,8 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) application.Render(); // Generate a Esc key event. The text field should lose the focus. - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); - application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); @@ -2832,7 +3274,7 @@ int UtcDaliTextFieldSelectWholeText(void) TextField textField = TextField::New(); - Stage::GetCurrent().Add( textField ); + application.GetScene().Add( textField ); textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); @@ -2884,7 +3326,7 @@ int UtcDaliTextFieldSelectNone(void) TextField textField = TextField::New(); - Stage::GetCurrent().Add( textField ); + application.GetScene().Add( textField ); textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); @@ -2925,3 +3367,265 @@ int UtcDaliTextFieldSelectNone(void) END_TEST; } + +int UtcDaliTextFieldSelectRange(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextFieldSelectRange "); + + TextField textField = TextField::New(); + + application.GetScene().Add( textField ); + + textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + + application.SendNotification(); + application.Render(); + + textField.SetProperty( TextField::Property::TEXT, "Hello world" ); + + application.SendNotification(); + application.Render(); + + textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0); + textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5); + + // Hello is selected + std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get(); + DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION ); + + DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get(), 5, TEST_LOCATION ); + + textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6); + textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11); + + // world is selected + selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get(); + DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION ); + + DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get(), 6, TEST_LOCATION ); + DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get(), 11, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliTextFieldEnableEditing(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextFieldEnableEditing "); + + TextField textField = TextField::New(); + + application.GetScene().Add( textField ); + + textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + + application.SendNotification(); + application.Render(); + + textField.SetKeyInputFocus(); + textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false ); + application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get(), "", TEST_LOCATION ); + DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get(), false, TEST_LOCATION ); + + + textField.SetKeyInputFocus(); + textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true ); + application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get(), "D", TEST_LOCATION ); + DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get(), true, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitTextFieldFontSizeScale(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale"); + + TextField textField = TextField::New(); + textField.SetProperty( TextField::Property::POINT_SIZE, 30.f ); + textField.SetProperty( TextField::Property::TEXT, "Test" ); + Vector3 nonScaledSize = textField.GetNaturalSize(); + + TextField textFieldScaled = TextField::New(); + textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f ); + textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f ); + textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" ); + Vector3 scaledSize = textFieldScaled.GetNaturalSize(); + + DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION ); + + textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f ); + textField.SetProperty( TextField::Property::TEXT, "Test" ); + nonScaledSize = textField.GetNaturalSize(); + + textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f ); + textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f ); + textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" ); + scaledSize = textFieldScaled.GetNaturalSize(); + + DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliTextFieldPrimaryCursorPosition(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition "); + + TextField textField = TextField::New(); + + application.GetScene().Add( textField ); + + textField.SetProperty( TextField::Property::TEXT, "ABCEF"); + textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + + textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3); + application.SendNotification(); + application.Render(); + + application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get(), "ABCDEF", TEST_LOCATION ); + DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get(), 4, TEST_LOCATION ); + + END_TEST; +} + +// test max length when set after setting long text +int utcDaliTextFieldMaxCharactersReachedAfterSetText(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText"); + TextField field = TextField::New(); + DALI_TEST_CHECK( field ); + + application.GetScene().Add( field ); + + field.SetProperty(TextField::Property::TEXT, "123456789"); + + const int maxNumberOfCharacters = 3; + field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters ); + + field.SetKeyInputFocus(); + + // connect to the text max lengh reached signal. + ConnectionTracker* testTracker = new ConnectionTracker(); + bool maxLengthReachedSignal = false; + field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) ); + + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + + DALI_TEST_CHECK( maxLengthReachedSignal ); + + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get(), "123456789", TEST_LOCATION ); + + END_TEST; +} + + + +int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize "); + + // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize + const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2; + const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2; + + // Create a text field + TextField textField = TextField::New(); + + //Set size to avoid automatic eliding + textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025)); + //Set very large font-size using point-size + textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ; + //Specify font-family + textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans"); + //Set text to check if appear or not + textField.SetProperty( TextField::Property::TEXT, "A"); + + application.GetScene().Add( textField ); + + application.SendNotification(); + application.Render(); + //Use GetNaturalSize to verify that size of block does not exceed Atlas size + Vector3 naturalSize = textField.GetNaturalSize(); + + DALI_TEST_GREATER( lessThanWidth, static_cast(naturalSize.width), TEST_LOCATION ); + DALI_TEST_GREATER( lessThanHeight, static_cast(naturalSize.height), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases "); + + // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize + const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2; + const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2; + + Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size + // Create a text editor + TextField textField = TextField::New(); + + //Set size to avoid automatic eliding + textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025)); + textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans"); + textField.SetProperty( TextField::Property::TEXT, "A"); + + const int numberOfCases = 6; + int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500}; + + for (int index=0; index < numberOfCases; index++) + { + tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]); + textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ; + application.GetScene().Add( textField ); + application.SendNotification(); + application.Render(); + naturalSize = textField.GetNaturalSize(); + DALI_TEST_GREATER( lessThanWidth, static_cast(naturalSize.width), TEST_LOCATION ); + DALI_TEST_GREATER( lessThanHeight, static_cast(naturalSize.height), TEST_LOCATION ); + + } + + END_TEST; +} \ No newline at end of file