Merge "[dali-toolkit]: add texteditor scrolling functionality" into devel/master
authorjoogab yun <joogab.yun@samsung.com>
Fri, 30 Oct 2020 07:36:19 +0000 (07:36 +0000)
committerGerrit Code Review <gerrit@review>
Fri, 30 Oct 2020 07:36:19 +0000 (07:36 +0000)
1  2 
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp

@@@ -2172,54 -2172,6 +2172,54 @@@ int utcDaliTextEditorEvent07(void
    //text is "c"
    DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
  
 +  // select all text
 +  DevelTextEditor::SelectWholeText(editor);
 +
 +  // Render and notify
 +  application.SendNotification();
 +  application.Render();
 +
 +  // Copy the selected text using logical keys
 +  application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
 +  application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
 +
 +  // Render and notify
 +  application.SendNotification();
 +  application.Render();
 +
 +  // select none
 +  DevelTextEditor::SelectNone(editor);
 +
 +  // Render and notify
 +  application.SendNotification();
 +  application.Render();
 +
 +  // Paste the selected using logical keys
 +  application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
 +  application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
 +
 +  //text is "cc"
 +  DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
 +
 +  // select all using logical keys
 +  application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
 +  application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
 +
 +  // Render and notify
 +  application.SendNotification();
 +  application.Render();
 +
 +  // cut text using logical keys
 +  application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
 +  application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
 +
 +  // Render and notify
 +  application.SendNotification();
 +  application.Render();
 +
 +  //text is ""
 +  DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
 +
    END_TEST;
  }
  
@@@ -3084,3 -3036,50 +3084,50 @@@ int UtcDaliTextEditorEnableEditing(void
  
    END_TEST;
  }
+ int UtcDaliTextEditorScrolling(void)
+ {
+   ToolkitTestApplication application;
+   tet_infoline(" UtcDaliTextEditorScrolling ");
+   TextEditor textEditor = TextEditor::New();
+   DALI_TEST_CHECK( textEditor );
+   application.GetScene().Add( textEditor );
+   // Avoid a crash when core load gl resources.
+   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+   application.SendNotification();
+   application.Render();
+   textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
+   textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
+   textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
+   textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
+   application.SendNotification();
+   application.Render();
+   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
+   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
+   DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
+   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
+   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
+   DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
+   DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
+   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
+   textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
+   textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
+   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
+   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
+   END_TEST;
+ }