2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
22 #include <dali/public-api/dali-core.h>
23 #include <dali-toolkit/dali-toolkit.h>
25 #include <dali-toolkit-test-suite-utils.h>
27 #include <dali/integration-api/events/key-event-integ.h>
30 #include <dali-toolkit/internal/controls/text-input/text-input-impl.h>
33 using namespace Dali::Toolkit;
35 static void Startup();
36 static void Cleanup();
39 void (*tet_startup)() = Startup;
40 void (*tet_cleanup)() = Cleanup;
44 POSITIVE_TC_IDX = 0x01,
48 #define MAX_NUMBER_OF_TESTS 10000
50 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
53 // Add test functionality for all APIs in the class (Positive and Negative)
54 TEST_FUNCTION( UtcDaliInternalTextInputTextSelection, POSITIVE_TC_IDX );
55 TEST_FUNCTION( UtcDaliTextInputSetGetExceedEnabled, POSITIVE_TC_IDX );
56 // TEST_FUNCTION( UtcDaliTextInputMethod02, NEGATIVE_TC_IDX );
58 // Called only once before first test is run.
63 // Called only once after last test is run
70 * Test: Selected is replaced by new input text.
72 static void UtcDaliInternalTextInputTextSelection()
74 const char* testChar = "v";
76 ToolkitTestApplication application;
78 tet_infoline("Testing Text Selection with replace.");
80 Toolkit::TextInput textInput = Toolkit::TextInput::New();
82 DALI_TEST_CHECK(textInput);
84 Stage::GetCurrent().Add(textInput);
86 textInput.SetInitialText("Test String");
88 std::string initialText = textInput.GetText();
90 tet_printf("Set Initial text: %s\n", initialText.c_str() );
92 textInput.SetKeyInputFocus();
94 GetImpl(textInput).SelectText(0,11);
96 tet_printf("Select all of Initial text\n");
98 Integration::KeyEvent event(testChar, testChar, 0, 0, 0, Integration::KeyEvent::Down );
100 application.ProcessEvent( event );
102 tet_printf("Simulate pressing of a key: %s\n", testChar );
104 std::string newText = textInput.GetText();
106 tet_printf("Check current text (%s) is the new text \n", newText.c_str() );
108 DALI_TEST_EQUALS("v",textInput.GetText(), TEST_LOCATION);
111 static void UtcDaliTextInputSetGetExceedEnabled()
113 tet_infoline("UtcDaliTextInputSetGetExceedEnabled: ");
115 ToolkitTestApplication application;
117 Toolkit::TextInput textInput = Toolkit::TextInput::New();
118 textInput.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
119 textInput.SetWidthExceedPolicy( Toolkit::TextView::Split );
120 textInput.SetHeightExceedPolicy( Toolkit::TextView::Original );
122 DALI_TEST_CHECK( textInput.GetExceedEnabled() );
124 Toolkit::Internal::TextInput& textInputImpl = static_cast<Toolkit::Internal::TextInput&>( textInput.GetImplementation() );
126 textInput.SetSize( 50.f, 50.f );
127 textInput.SetExceedEnabled( false );
129 DALI_TEST_CHECK( !textInput.GetExceedEnabled() );
132 textInputImpl.InsertAt( Text("He"), 0 );
134 DALI_TEST_EQUALS("He",textInput.GetText(), TEST_LOCATION);
136 textInputImpl.InsertAt( Text("llo"), 2 );
138 DALI_TEST_EQUALS("Hello",textInput.GetText(), TEST_LOCATION);
140 textInputImpl.InsertAt( Text(" world! hello world hello world hello world"), 5 ); // Doesn't fit so is not added.
142 DALI_TEST_EQUALS("Hello",textInput.GetText(), TEST_LOCATION);