2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
23 #include <dali/public-api/dali-core.h>
24 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali/integration-api/events/key-event-integ.h>
31 #include <dali-toolkit/internal/controls/text-input/text-input-impl.h>
34 using namespace Dali::Toolkit;
36 static void Startup();
37 static void Cleanup();
40 void (*tet_startup)() = Startup;
41 void (*tet_cleanup)() = Cleanup;
45 POSITIVE_TC_IDX = 0x01,
49 #define MAX_NUMBER_OF_TESTS 10000
51 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
54 // Add test functionality for all APIs in the class (Positive and Negative)
55 TEST_FUNCTION( UtcDaliInternalTextInputTextSelection, POSITIVE_TC_IDX );
56 TEST_FUNCTION( UtcDaliTextInputSetGetExceedEnabled, POSITIVE_TC_IDX );
57 // TEST_FUNCTION( UtcDaliTextInputMethod02, NEGATIVE_TC_IDX );
59 // Called only once before first test is run.
64 // Called only once after last test is run
71 * Test: Selected is replaced by new input text.
73 static void UtcDaliInternalTextInputTextSelection()
75 const char* testChar = "v";
77 ToolkitTestApplication application;
79 tet_infoline("Testing Text Selection with replace.");
81 Toolkit::TextInput textInput = Toolkit::TextInput::New();
83 DALI_TEST_CHECK(textInput);
85 Stage::GetCurrent().Add(textInput);
87 textInput.SetInitialText("Test String");
89 std::string initialText = textInput.GetText();
91 tet_printf("Set Initial text: %s\n", initialText.c_str() );
93 textInput.SetKeyInputFocus();
95 GetImpl(textInput).SelectText(0,11);
97 tet_printf("Select all of Initial text\n");
99 Integration::KeyEvent event(testChar, testChar, 0, 0, 0, Integration::KeyEvent::Down );
101 application.ProcessEvent( event );
103 tet_printf("Simulate pressing of a key: %s\n", testChar );
105 std::string newText = textInput.GetText();
107 tet_printf("Check current text (%s) is the new text \n", newText.c_str() );
109 DALI_TEST_EQUALS("v",textInput.GetText(), TEST_LOCATION);
112 static void UtcDaliTextInputSetGetExceedEnabled()
114 tet_infoline("UtcDaliTextInputSetGetExceedEnabled: ");
116 ToolkitTestApplication application;
118 Toolkit::TextInput textInput = Toolkit::TextInput::New();
119 textInput.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
120 textInput.SetWidthExceedPolicy( Toolkit::TextView::Split );
121 textInput.SetHeightExceedPolicy( Toolkit::TextView::Original );
123 DALI_TEST_CHECK( textInput.GetExceedEnabled() );
125 Toolkit::Internal::TextInput& textInputImpl = static_cast<Toolkit::Internal::TextInput&>( textInput.GetImplementation() );
127 textInput.SetSize( 50.f, 50.f );
128 textInput.SetExceedEnabled( false );
130 DALI_TEST_CHECK( !textInput.GetExceedEnabled() );
133 textInputImpl.InsertAt( Text("He"), 0 );
135 DALI_TEST_EQUALS("He",textInput.GetText(), TEST_LOCATION);
137 textInputImpl.InsertAt( Text("llo"), 2 );
139 DALI_TEST_EQUALS("Hello",textInput.GetText(), TEST_LOCATION);
141 textInputImpl.InsertAt( Text(" world! hello world hello world hello world"), 5 ); // Doesn't fit so is not added.
143 DALI_TEST_EQUALS("Hello",textInput.GetText(), TEST_LOCATION);