[dali_1.9.34] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-TextEditor-internal.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
23
24 #include <dali-toolkit/internal/controls/text-controls/text-editor-impl.h>
25 #include <dali-toolkit/internal/text/text-controller.h>
26 #include <dali-toolkit/internal/text/text-controller-impl.h>
27
28 using namespace Dali;
29 using namespace Toolkit;
30 using namespace Text;
31
32 int UtcDaliTextEditorSelectText(void)
33 {
34   ToolkitTestApplication application;
35   tet_infoline( "UtcDaliTextEditorSelectText" );
36
37   // Create a text editor
38   TextEditor textEditor = TextEditor::New();
39   textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.f, 60.f ) );
40   textEditor.SetProperty( TextEditor::Property::TEXT, "Hello World" );
41
42   // Add the text editor to the stage
43   application.GetScene().Add( textEditor );
44
45   application.SendNotification();
46   application.Render();
47
48   Toolkit::Internal::TextEditor& textEditorImpl = GetImpl( textEditor );
49
50   application.SendNotification();
51   application.Render();
52
53   // Highlight the whole text
54   textEditorImpl.SelectWholeText();
55
56   application.SendNotification();
57   application.Render();
58
59   std::string selectedText = textEditorImpl.GetSelectedText();
60   DALI_TEST_CHECK( selectedText == "Hello World" );
61
62   // Select None
63   textEditorImpl.SelectNone();
64
65   application.SendNotification();
66   application.Render();
67
68   selectedText = textEditorImpl.GetSelectedText();
69   DALI_TEST_CHECK( selectedText == "" );
70
71   END_TEST;
72 }