Allow text-selection scroll indicator to have a different style
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextSelectionPopup.cpp
1 /*
2  * Copyright (c) 2014 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 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
22 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
23 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.h>
24
25 using namespace Dali;
26 using namespace Toolkit;
27
28 void dali_textselectionpopup_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void dali_textselectionpopup_cleanup(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38 int UtcDaliToolkitTextSelectionPopupNewP(void)
39 {
40   ToolkitTestApplication application;
41   TextSelectionPopup textSelectionPopup;
42
43   DALI_TEST_CHECK( !textSelectionPopup );
44
45   textSelectionPopup = TextSelectionPopup::New( NULL );
46
47   DALI_TEST_CHECK( textSelectionPopup );
48   END_TEST;
49 }
50
51 int UtcDaliToolkitTextSelectionPopupConstructorP(void)
52 {
53   TextSelectionPopup textSelectionPopup;
54
55   DALI_TEST_CHECK( !textSelectionPopup );
56
57   END_TEST;
58 }
59
60 int UtcDaliToolkitTextSelectionPopupCopyConstructorP(void)
61 {
62   ToolkitTestApplication application;
63   TextSelectionPopup textSelectionPopup;
64
65   textSelectionPopup = TextSelectionPopup::New( NULL );
66   TextSelectionPopup copy( textSelectionPopup );
67
68   DALI_TEST_CHECK( copy == textSelectionPopup );
69
70   END_TEST;
71 }
72
73
74 int UtcDaliToolkitTextSelectionPopupDestructorP(void)
75 {
76   ToolkitTestApplication application;
77   TextSelectionPopup* textSelectionPopup = new TextSelectionPopup;
78   delete textSelectionPopup;
79
80   DALI_TEST_CHECK( true );
81
82   END_TEST;
83 }
84
85 int UtcDaliToolkitTextSelectionPopupAssignmentOperatorP(void)
86 {
87   ToolkitTestApplication application;
88   TextSelectionPopup textSelectionPopup;
89   textSelectionPopup = TextSelectionPopup::New(  NULL );
90   TextSelectionPopup copy;
91   copy = textSelectionPopup;
92
93   DALI_TEST_CHECK( copy == textSelectionPopup );
94   END_TEST;
95 }
96
97 int UtcDaliToolkitTextSelectionPopupDownCastP(void)
98 {
99   ToolkitTestApplication application;
100   TextSelectionPopup textSelectionPopup;
101   textSelectionPopup = TextSelectionPopup::New( NULL );
102
103   TextSelectionPopup cast = TextSelectionPopup::DownCast( textSelectionPopup );
104
105   DALI_TEST_CHECK( cast );
106
107   END_TEST;
108 }
109
110 // TextSelectionToolBar is used TextSelectionPopup, below tests it individually
111
112 int UtcDaliToolkitTextSelectionToolBarP(void)
113 {
114   // Creates Toolbar, adds 2 options and a divider then resizes divider
115   ToolkitTestApplication application;
116
117   TextSelectionToolbar toolbar = TextSelectionToolbar::New();
118
119   toolbar.SetProperty( Toolkit::TextSelectionToolbar::Property::MAX_SIZE, Size( 100.0f, 60.0f) );
120
121   Toolkit::PushButton option = Toolkit::PushButton::New();
122   option.SetName( "test-option" );
123   option.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
124   toolbar.AddOption( option );
125
126   Toolkit::Control divider = Toolkit::Control::New();
127   divider.SetSize( 2.0f, 0.0f );
128   divider.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
129   toolbar.AddDivider( divider );
130
131   Toolkit::PushButton option2 = Toolkit::PushButton::New();
132   option2.SetName( "test-option-2" );
133   option2.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
134   toolbar.AddOption( option2 );
135
136   Size newSize =  Size(3.0f, 0.0f);
137   toolbar.ResizeDividers( newSize );
138
139   DALI_TEST_CHECK( toolbar );
140   END_TEST;
141 }
142
143 int UtcDaliToolkitTextSelectionToolBarScrollBarP(void)
144 {
145   // Creates Toolbar, adds 2 options and a divider then resizes divider
146   ToolkitTestApplication application;
147
148   TextSelectionToolbar toolbar = TextSelectionToolbar::New();
149
150   toolbar.SetProperty( Toolkit::TextSelectionToolbar::Property::MAX_SIZE, Size( 100.0f, 60.0f) );
151
152   Toolkit::PushButton option = Toolkit::PushButton::New();
153   option.SetName( "test-option" );
154   option.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
155   toolbar.AddOption( option );
156
157   // Add a scroll-bar
158   toolbar.SetProperty( Toolkit::TextSelectionToolbar::Property::ENABLE_SCROLL_BAR, true );
159
160   bool enabled = toolbar.GetProperty<bool>( Toolkit::TextSelectionToolbar::Property::ENABLE_SCROLL_BAR );
161   DALI_TEST_CHECK( enabled );
162
163   DALI_TEST_CHECK( toolbar );
164   END_TEST;
165 }