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=b8fd9db652c0882843d4224c56601dcb0ccbeb09;hp=8387811f9ece37413a1be758c37ebff034cec8d2;hb=85b83b75993f7e01302d67c19aa53c3e1fc63586;hpb=bec8228daa1be042b45b6f52eb19215a56fe8589 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index 8387811..b8fd9db 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -72,10 +72,10 @@ const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectio const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decoration-bounding-box"; const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "input-method-settings"; -const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND; +const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND; const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f ); -const Dali::Vector4 LIGHT_BLUE( (0xb2 / 255.0f), (0xeb / 255.0f), (0xf2 / 255.0f), 0.5f ); // The text highlight color. +const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color. const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval const float TO_MILLISECONDS = 1000.f; @@ -267,34 +267,11 @@ int UtcDaliTextFieldSetPropertyP(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - // Check defaults. - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::RENDERING_BACKEND ), DEFAULT_RENDERING_BACKEND, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ), std::string(""), TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::PLACEHOLDER_TEXT ), std::string(""), TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string(""), TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_FAMILY ), std::string(""), TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_STYLE ), std::string(""), TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::POINT_SIZE ), 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::MAX_LENGTH ), 50u, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::EXCEED_POLICY ), TextField::EXCEED_POLICY_CLIP, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::HORIZONTAL_ALIGNMENT ), "BEGIN", TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::VERTICAL_ALIGNMENT ), "TOP", TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT_COLOR ), Color::BLACK, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::SHADOW_OFFSET ), Vector2::ZERO, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR ), PLACEHOLDER_TEXT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::SHADOW_COLOR ), Color::BLACK, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::BLACK, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLACK, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::ENABLE_CURSOR_BLINK ), true, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::CURSOR_BLINK_INTERVAL ), CURSOR_BLINK_INTERVAL * TO_SECONDS, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::CURSOR_BLINK_DURATION ), 0.f, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::SCROLL_THRESHOLD ), SCROLL_THRESHOLD, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::SCROLL_SPEED ), SCROLL_SPEED, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), LIGHT_BLUE, TEST_LOCATION ); + // Note - we can't check the defaults since the stylesheets are platform-specific // Check the render backend property. - field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_BASIC ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_BASIC, TEST_LOCATION ); + field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION ); // Check text property. field.SetProperty( TextField::Property::TEXT, "Setting Text" ); @@ -387,34 +364,6 @@ int UtcDaliTextFieldSetPropertyP(void) END_TEST; } -// Positive Basic Text Renderer test -int utcDaliTextFieldBasicRenderP(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliToolkitTextFieldBasicRenderP"); - TextField field = TextField::New(); - DALI_TEST_CHECK( field ); - - field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN" ); - - application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - - Stage::GetCurrent().Add( field ); - - try - { - // Render some text with the basic backend - field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_BASIC ); - application.SendNotification(); - application.Render(); - } - catch( ... ) - { - tet_result(TET_FAIL); - } - END_TEST; -} - // Positive Atlas Text Renderer test int utcDaliTextFieldAtlasRenderP(void) { @@ -452,7 +401,7 @@ int utcDaliTextFieldTextChangedP(void) tet_infoline(" utcDaliTextFieldTextChangedP"); TextField field = TextField::New(); DALI_TEST_CHECK( field ); -/* + Stage::GetCurrent().Add( field ); field.TextChangedSignal().Connect(&TestTextChangedCallback); @@ -468,7 +417,7 @@ int utcDaliTextFieldTextChangedP(void) gTextChangedCallBackCalled = false; application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) ); DALI_TEST_CHECK( gTextChangedCallBackCalled ); -*/ + END_TEST; } @@ -509,10 +458,10 @@ int utcDaliTextFieldMaxCharactersReachedP(void) gMaxCharactersCallBackCalled = false; field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback); - //application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); - //application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); - //DALI_TEST_CHECK( gMaxCharactersCallBackCalled ); + DALI_TEST_CHECK( gMaxCharactersCallBackCalled ); END_TEST; } @@ -535,10 +484,10 @@ int utcDaliTextFieldMaxCharactersReachedN(void) gMaxCharactersCallBackCalled = false; field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback); - //application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); - //application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); - //DALI_TEST_CHECK( !gMaxCharactersCallBackCalled ); + DALI_TEST_CHECK( !gMaxCharactersCallBackCalled ); END_TEST; } @@ -638,8 +587,9 @@ int utcDaliTextFieldEvent02(void) // Checks if the right number of actors are created. TextField field = TextField::New(); + field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); DALI_TEST_CHECK( field ); -/* + Stage::GetCurrent().Add( field ); field.SetSize( 300.f, 50.f ); @@ -696,7 +646,7 @@ int utcDaliTextFieldEvent02(void) CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) ); DALI_TEST_CHECK( camera ); - RenderableActor renderer = RenderableActor::DownCast( offscreenRoot.GetChildAt( 1u ) ); + Renderer renderer = offscreenRoot.GetChildAt( 1u ).GetRendererAt( 0u ); DALI_TEST_CHECK( renderer ); // Move the cursor and check the position changes. @@ -739,7 +689,7 @@ int utcDaliTextFieldEvent02(void) DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2. - // Try to tap at the end. + // Tap away from the start position. application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 13.f, 25.0f ) ) ); application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 13.0f, 25.0f ) ) ); @@ -747,14 +697,14 @@ int utcDaliTextFieldEvent02(void) application.SendNotification(); application.Render(); - // Cursor position should be the same than position1. Vector3 position5 = cursor.GetCurrentPosition(); - DALI_TEST_EQUALS( position1, position5, TEST_LOCATION ); // Should be in the same position1. + DALI_TEST_CHECK( position5.x > position4.x ); - // Remove some text. + // Remove all the text. application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) ); application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) ); + field.SetProperty( TextField::Property::TEXT, "" ); // Render and notify application.SendNotification(); @@ -763,11 +713,11 @@ int utcDaliTextFieldEvent02(void) // Cursor position should be the same than position2. Vector3 position6 = cursor.GetCurrentPosition(); - DALI_TEST_EQUALS( Vector3( 0.f, position2.y, position2.z ), position6, TEST_LOCATION ); // TODO Should be in the same position2. + DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2. // Should not be renderer. DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor only. -*/ + END_TEST; } @@ -784,6 +734,7 @@ int utcDaliTextFieldEvent03(void) Stage::GetCurrent().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 ); field.SetSize( 30.f, 50.f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); @@ -818,8 +769,8 @@ int utcDaliTextFieldEvent03(void) CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) ); DALI_TEST_CHECK( camera ); - //RenderableActor renderer = RenderableActor::DownCast( offscreenRoot.GetChildAt( 1u ) ); - //DALI_TEST_CHECK( renderer ); + Renderer renderer = offscreenRoot.GetChildAt( 1u ).GetRendererAt( 0u ); + DALI_TEST_CHECK( renderer ); Renderer highlight = offscreenRoot.GetChildAt( 2u ).GetRendererAt( 0u ); DALI_TEST_CHECK( highlight );