Dali 3D User Interface Engine
utc-Dali-Slider.cpp
Go to the documentation of this file.
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>
24 
25 using namespace Dali;
26 using namespace Dali::Toolkit;
27 
29 {
31 }
32 
34 {
36 }
37 
38 namespace
39 {
40 
42 
43 static void TestCallback(BaseHandle handle)
44 {
45  gObjectCreatedCallBackCalled = true;
46 }
47 
48 }
49 
51 {
52  ToolkitTestApplication application;
53  tet_infoline(" UtcDaliSliderNew");
54 
55  // Create the Slider actor
56  Slider slider;
57 
58  DALI_TEST_CHECK( !slider );
59 
60  slider = Slider::New();
61 
62  DALI_TEST_CHECK( slider );
63 
64  Slider slider2(slider);
65 
66  DALI_TEST_CHECK( slider2 == slider );
67 
68  //Additional check to ensure object is created by checking if it's registered
70  DALI_TEST_CHECK( registry );
71 
73  registry.ObjectCreatedSignal().Connect( &TestCallback );
74  {
75  Slider slider = Slider::New();
76  }
78  END_TEST;
79 }
80 
82 {
83  ToolkitTestApplication application;
84 
85  Slider* slider = new Slider();
86  delete slider;
87 
88  DALI_TEST_CHECK( true );
89  END_TEST;
90 }
91 
93 {
94  ToolkitTestApplication application;
95 
96  Handle handle = Slider::New();
97 
98  Slider slider = Slider::DownCast( handle );
99 
100  DALI_TEST_CHECK( slider == handle );
101  END_TEST;
102 }
103 
105 static bool OnSliderValueChanged( Slider slider, float value )
106 {
108  return true;
109 }
110 
112 static bool OnSliderMark( Slider slider, int value )
113 {
115  return true;
116 }
117 
119 {
120  ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
121  tet_infoline(" UtcDaliSliderSignals");
122 
123  // Create the Popup actor
124  Slider slider = Slider::New();
125  Stage::GetCurrent().Add( slider );
128  slider.SetSize( Vector2( Stage::GetCurrent().GetSize().x, 20.0f ) );
129  slider.SetPosition( 0.0f, 0.0f );
130 
131  const float MIN_BOUND = 0.0f;
132  const float MAX_BOUND = 1.0f;
133  const int NUM_MARKS = 5;
134  Property::Array marks;
135  for( int i = 0; i < NUM_MARKS; ++i )
136  {
137  marks.PushBack( MIN_BOUND + ( static_cast<float>(i) / ( NUM_MARKS - 1) ) * ( MAX_BOUND - MIN_BOUND ) );
138  }
139  slider.SetProperty( Slider::Property::MARKS, marks );
140  slider.SetProperty( Slider::Property::MARK_TOLERANCE, 0.1f );
141 
142  slider.ValueChangedSignal().Connect( &OnSliderValueChanged );
143  slider.MarkSignal().Connect( &OnSliderMark );
144 
145  application.SendNotification();
146  application.Render();
147 
150 
151  Dali::Integration::TouchEvent event;
152 
153  event = Dali::Integration::TouchEvent();
154 
155  const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 10.0f );
156  event.AddPoint( pointDown );
157 
158  for( int i = 0; i < 5; ++i )
159  {
160  const Dali::TouchPoint pointDown( 0, TouchPoint::Motion, 10.0f + i * 10.0f, 10.0f );
161  event.AddPoint( pointDown );
162  }
163 
164  const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 50.0f, 10.0f );
165  event.AddPoint( pointUp );
166 
167  application.ProcessEvent( event );
168 
169  application.SendNotification();
170  application.Render();
171 
174  END_TEST;
175 }
Dali Docs Home
Read more about Dali