Dali 3D User Interface Engine
utc-Dali-PushButton.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>
20 
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
24 
25 #include <dali.h>
28 
29 using namespace Dali;
30 using namespace Toolkit;
31 
33 {
35 }
36 
38 {
40 }
41 
42 namespace
43 {
44 
45 static bool gPushButtonSelectedState = false;
46 bool PushButtonSelected( Button button )
47 {
48  gPushButtonSelectedState = button.IsSelected();
49  return true;
50 }
51 
52 static bool gPushButtonPressed = false;
53 
54 static bool PushButtonPressed( Button button )
55 {
56  gPushButtonPressed = true;
57  return true;
58 }
59 
60 static bool gPushButtonReleased = false;
61 
62 static bool PushButtonReleased( Button button )
63 {
64  gPushButtonReleased = true;
65  return true;
66 }
67 
69 const Dali::TouchPoint pointUpInside( 0, TouchPoint::Up, 240, 400 );
70 const Dali::TouchPoint pointLeave( 0, TouchPoint::Leave, 240, 400 );
71 const Dali::TouchPoint pointEnter( 0, TouchPoint::Motion, 240, 400 );
75 
76 Image CreateSolidColorImage( const Vector4& color, unsigned int width, unsigned int height )
77 {
78  BufferImage imageData = BufferImage::New( width, height, Pixel::RGBA8888 );
79 
80  // Create the image
81  PixelBuffer* pixbuf = imageData.GetBuffer();
82  unsigned int size = width * height;
83 
84  for( size_t i = 0; i < size; i++ )
85  {
86  pixbuf[i*4+0] = 0xFF * color.r;
87  pixbuf[i*4+1] = 0xFF * color.g;
88  pixbuf[i*4+2] = 0xFF * color.b;
89  pixbuf[i*4+3] = 0xFF * color.a;
90  }
91 
92  imageData.Update();
93 
94  return imageData;
95 }
96 
97 } //namespace
98 
100 {
101  TestApplication application;
102 
103  PushButton button;
104 
105  DALI_TEST_CHECK( !button );
106  END_TEST;
107 }
108 
110 {
111  TestApplication application;
112 
113  // Initialize an object, ref count == 1
114  PushButton button = PushButton::New();
115 
116  PushButton copy( button );
117  DALI_TEST_CHECK( copy );
118  END_TEST;
119 }
120 
122 {
123  TestApplication application;
124 
125  PushButton button = PushButton::New();
126 
127  PushButton copy( button );
128  DALI_TEST_CHECK( copy );
129 
130  DALI_TEST_CHECK( button == copy );
131  END_TEST;
132 }
133 
135 {
136  TestApplication application;
137 
138  PushButton button = PushButton::New();
139 
140  DALI_TEST_CHECK( button );
141  END_TEST;
142 }
143 
145 {
146  TestApplication application;
147 
148  PushButton button = PushButton::New();
149 
150  BaseHandle object(button);
151 
152  PushButton button2 = PushButton::DownCast( object );
153  DALI_TEST_CHECK(button2);
154 
155  PushButton button3 = DownCast< PushButton >(object);
156  DALI_TEST_CHECK(button3);
157  END_TEST;
158 }
159 
161 {
162  TestApplication application;
163 
164  BaseHandle unInitializedObject;
165 
166  PushButton button1 = PushButton::DownCast( unInitializedObject );
167  DALI_TEST_CHECK( !button1 );
168 
169  PushButton button2 = DownCast< PushButton >( unInitializedObject );
170  DALI_TEST_CHECK( !button2 );
171  END_TEST;
172 }
173 
175 {
176  ToolkitTestApplication application;
177  tet_infoline(" UtcDaliPushButtonSetGetAutoRepeating");
178 
179  PushButton pushButton = PushButton::New();
180 
181  pushButton.SetAutoRepeating( true );
182 
183  DALI_TEST_CHECK( pushButton.IsAutoRepeating() );
184 
185  pushButton.SetAutoRepeating( false );
186 
187  DALI_TEST_CHECK( !pushButton.IsAutoRepeating() );
188 
189  pushButton.SetAutoRepeating( true );
190 
191  DALI_TEST_CHECK( pushButton.IsAutoRepeating() );
192  END_TEST;
193 }
194 
196 {
197  ToolkitTestApplication application;
198  tet_infoline(" UtcDaliPushButtonSetGetTogglableButton");
199 
200  PushButton pushButton = PushButton::New();
201 
202  pushButton.SetTogglableButton( true );
203 
204  DALI_TEST_CHECK( pushButton.IsTogglableButton() );
205 
206  pushButton.SetTogglableButton( false );
207 
208  DALI_TEST_CHECK( !pushButton.IsTogglableButton() );
209 
210  pushButton.SetTogglableButton( true );
211 
212  DALI_TEST_CHECK( pushButton.IsTogglableButton() );
213  END_TEST;
214 }
215 
217 {
218  ToolkitTestApplication application;
219  tet_infoline(" UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton");
220 
221  PushButton pushButton = PushButton::New();
222 
223  pushButton.SetAutoRepeating( true );
224  pushButton.SetTogglableButton( true );
225 
226  DALI_TEST_CHECK( pushButton.IsTogglableButton() );
227  DALI_TEST_CHECK( !pushButton.IsAutoRepeating() );
228 
229  pushButton.SetTogglableButton( true );
230  pushButton.SetAutoRepeating( true );
231 
232  DALI_TEST_CHECK( pushButton.IsAutoRepeating() );
233  DALI_TEST_CHECK( !pushButton.IsTogglableButton() );
234  END_TEST;
235 }
236 
238 {
239  ToolkitTestApplication application;
240  tet_infoline(" UtcDaliPushButtonSetGetSelected01");
241 
242  PushButton pushButton = PushButton::New();
243 
244  pushButton.SetTogglableButton( true );
245  pushButton.StateChangedSignal().Connect( &PushButtonSelected );
246 
247  gPushButtonSelectedState = false;
248  pushButton.SetSelected( true );
249 
250  DALI_TEST_CHECK( pushButton.IsSelected() );
252 
253  pushButton.SetSelected( false );
254 
255  DALI_TEST_CHECK( !pushButton.IsSelected() );
257 
258  pushButton.SetSelected( true );
259 
260  DALI_TEST_CHECK( pushButton.IsSelected() );
262  END_TEST;
263 }
264 
266 {
267  ToolkitTestApplication application;
268  tet_infoline(" UtcDaliPushButtonSetGetSelected02");
269 
270  PushButton pushButton = PushButton::New();
271 
272  pushButton.SetTogglableButton( false );
273  pushButton.StateChangedSignal().Connect( &PushButtonSelected );
274 
275  gPushButtonSelectedState = false;
276  pushButton.SetSelected( true );
277 
278  DALI_TEST_CHECK( !pushButton.IsSelected() );
280 
281  pushButton.SetSelected( false );
282 
283  DALI_TEST_CHECK( !pushButton.IsSelected() );
285 
286  pushButton.SetSelected( true );
287 
288  DALI_TEST_CHECK( !pushButton.IsSelected() );
290  END_TEST;
291 }
292 
294 {
295  ToolkitTestApplication application;
296  tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues01");
297 
298  PushButton pushButton = PushButton::New();
299 
300  pushButton.SetAutoRepeating( true );
301 
302  pushButton.SetInitialAutoRepeatingDelay( 1.f );
304 
305  pushButton.SetNextAutoRepeatingDelay( 1.f );
307  END_TEST;
308 }
309 
311 {
312  ToolkitTestApplication application;
313  tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues02");
314 
315  PushButton pushButton = PushButton::New();
316 
317  bool assert1( false );
318  bool assert2( false );
319 
320  pushButton.SetAutoRepeating( true );
321 
322  try
323  {
324  pushButton.SetInitialAutoRepeatingDelay( -1.f );
325  }
326  catch( Dali::DaliException& e )
327  {
329  DALI_TEST_EQUALS(e.condition, "initialAutoRepeatingDelay > 0.f", TEST_LOCATION);
330  assert1 = true;
331  }
332 
333  try
334  {
335  pushButton.SetNextAutoRepeatingDelay( -1.f );
336  }
337  catch( Dali::DaliException& e )
338  {
340  DALI_TEST_EQUALS(e.condition, "nextAutoRepeatingDelay > 0.f", TEST_LOCATION);
341  assert2 = true;
342  }
343 
344  DALI_TEST_CHECK( assert1 && assert2 );
345  END_TEST;
346 }
347 
349 {
350  ToolkitTestApplication application;
351  tet_infoline(" UtcDaliPushButtonSetLabelText");
352 
353  const std::string STR( "Hola!" );
354 
355  PushButton pushButton = PushButton::New();
356 
357  application.SendNotification();
358  application.Render();
359 
360  pushButton.SetLabelText( STR );
361 
362  DALI_TEST_EQUALS( pushButton.GetLabelText(), STR, TEST_LOCATION );
363 
364  END_TEST;
365 }
366 
368 {
369  ToolkitTestApplication application;
370  tet_infoline(" UtcDaliPushButtonPressed");
371 
372  PushButton pushButton = PushButton::New();
375  pushButton.SetPosition( 240, 400 );
376  pushButton.SetSize( 100, 100 );
377 
378  Stage::GetCurrent().Add( pushButton );
379 
380  application.SendNotification();
381  application.Render();
382 
383  gPushButtonPressed = false;
384 
385  // connect to its touch signal
386  pushButton.PressedSignal().Connect( &PushButtonPressed );
387 
388  Dali::Integration::TouchEvent eventDown;
389  eventDown.AddPoint( pointDownInside );
390 
391  // flush the queue and render once
392  application.SendNotification();
393  application.Render();
394  application.ProcessEvent( eventDown );
395 
397  END_TEST;
398 }
399 
401 {
402  ToolkitTestApplication application;
403  tet_infoline(" UtcDaliPushButtonReleased");
404 
405  PushButton pushButton = PushButton::New();
408  pushButton.SetPosition( 240, 400 );
409  pushButton.SetSize( 100, 100 );
410 
411  Stage::GetCurrent().Add( pushButton );
412 
413  application.SendNotification();
414  application.Render();
415 
416  // connect to its touch signal
417  pushButton.ReleasedSignal().Connect( &PushButtonReleased );
418 
419  Dali::Integration::TouchEvent event;
420 
421  // Test1. Touch point down and up inside the button.
422 
423  gPushButtonReleased = false;
424  event = Dali::Integration::TouchEvent();
425  event.AddPoint( pointDownInside );
426  application.ProcessEvent( event );
427 
428  event = Dali::Integration::TouchEvent();
429  event.AddPoint( pointUpInside );
430  application.ProcessEvent( event );
431 
433 
434  // Test2. Touch point down and up outside the button.
435 
436  gPushButtonReleased = false;
437  event = Dali::Integration::TouchEvent();
438  event.AddPoint( pointDownOutside );
439  application.ProcessEvent( event );
440 
441  event = Dali::Integration::TouchEvent();
442  event.AddPoint( pointUpOutside );
443  application.ProcessEvent( event );
444 
446 
447  // Test3. Touch point down inside and up outside the button.
448 
449  gPushButtonReleased = false;
450  event = Dali::Integration::TouchEvent();
451  event.AddPoint( pointDownInside );
452  application.ProcessEvent( event );
453 
454  event = Dali::Integration::TouchEvent();
455  event.AddPoint( pointLeave );
456  application.ProcessEvent( event );
457 
458  event = Dali::Integration::TouchEvent();
459  event.AddPoint( pointUpOutside );
460  application.ProcessEvent( event );
461 
463 
464  // Test4. Touch point down outside and up inside the button.
465 
466  gPushButtonReleased = false;
467  event = Dali::Integration::TouchEvent();
468  event.AddPoint( pointDownOutside );
469  application.ProcessEvent( event );
470 
471  event = Dali::Integration::TouchEvent();
472  event.AddPoint( pointEnter );
473  application.ProcessEvent( event );
474 
475  event = Dali::Integration::TouchEvent();
476  event.AddPoint( pointUpInside );
477  application.ProcessEvent( event );
478 
480  END_TEST;
481 }
482 
484 {
485  ToolkitTestApplication application;
486  tet_infoline(" UtcDaliPushButtonSelected");
487 
488  PushButton pushButton = PushButton::New();
491  pushButton.SetPosition( 240, 400 );
492  pushButton.SetSize( 100, 100 );
493 
494  Stage::GetCurrent().Add( pushButton );
495 
496  application.SendNotification();
497  application.Render();
498 
499  // connect to its touch signal
500  pushButton.StateChangedSignal().Connect( &PushButtonSelected );
501 
502  Dali::Integration::TouchEvent event;
503 
504  // Test1. No togglable button.
505 
506  gPushButtonSelectedState = false;
507  event = Dali::Integration::TouchEvent();
508  event.AddPoint( pointDownInside );
509  application.ProcessEvent( event );
510 
511  event = Dali::Integration::TouchEvent();
512  event.AddPoint( pointUpInside );
513  application.ProcessEvent( event );
514 
516 
517  // Set togglable property.
518  pushButton.SetTogglableButton( true );
519 
520  // Test2. Touch point down and up inside the button twice.
521  gPushButtonSelectedState = false;
522  event = Dali::Integration::TouchEvent();
523  event.AddPoint( pointDownInside );
524  application.ProcessEvent( event );
525 
526  event = Dali::Integration::TouchEvent();
527  event.AddPoint( pointUpInside );
528  application.ProcessEvent( event );
529 
531 
532  event = Dali::Integration::TouchEvent();
533  event.AddPoint( pointDownInside );
534  application.ProcessEvent( event );
535 
536  event = Dali::Integration::TouchEvent();
537  event.AddPoint( pointUpInside );
538  application.ProcessEvent( event );
539 
541 
542  // Test3. Touch point down and up outside the button.
543 
544  gPushButtonSelectedState = false;
545  event = Dali::Integration::TouchEvent();
546  event.AddPoint( pointDownOutside );
547  application.ProcessEvent( event );
548 
549  event = Dali::Integration::TouchEvent();
550  event.AddPoint( pointUpOutside );
551  application.ProcessEvent( event );
552 
554 
555  // Test4. Touch point down inside and up outside the button.
556 
557  gPushButtonSelectedState = false;
558  event = Dali::Integration::TouchEvent();
559  event.AddPoint( pointDownInside );
560  application.ProcessEvent( event );
561 
562  event = Dali::Integration::TouchEvent();
563  event.AddPoint( pointLeave );
564  application.ProcessEvent( event );
565 
566  event = Dali::Integration::TouchEvent();
567  event.AddPoint( pointUpOutside );
568  application.ProcessEvent( event );
569 
571 
572  // Test5. Touch point down outside and up inside the button.
573 
574  gPushButtonSelectedState = false;
575  event = Dali::Integration::TouchEvent();
576  event.AddPoint( pointDownOutside );
577  application.ProcessEvent( event );
578 
579  event = Dali::Integration::TouchEvent();
580  event.AddPoint( pointEnter );
581  application.ProcessEvent( event );
582 
583  event = Dali::Integration::TouchEvent();
584  event.AddPoint( pointUpInside );
585  application.ProcessEvent( event );
586 
588  END_TEST;
589 }
590 
592 {
593  ToolkitTestApplication application;
594  tet_infoline(" UtcDaliPushButtonPropertySetIconAlignment");
595 
596  PushButton pushButton = PushButton::New();
599 
602 
603  END_TEST;
604 }
605 
607 {
608  ToolkitTestApplication application;
609  tet_infoline(" UtcDaliPushButtonPropertySetLabelPadding");
610 
611  PushButton pushButton = PushButton::New();
612  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
614 
615  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
617 
618  END_TEST;
619 }
620 
622 {
623  ToolkitTestApplication application;
624  tet_infoline(" UtcDaliPushButtonPropertySetIconPadding");
625 
626  PushButton pushButton = PushButton::New();
627  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
629 
630  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
632 
633  END_TEST;
634 }
635 
637 {
638  ToolkitTestApplication application;
639  tet_infoline(" UtcDaliPushButtonPaddingLayout");
640 
641  // This test creates padding for an icon and a label.
642  // The icon and label are each enabled and disabled to confirm the correct padding is used.
643  PushButton pushButton = PushButton::New();
644 
645  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
646  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 20.0f, 20.0f, 20.0f, 20.0f ) );
647 
650  pushButton.SetPosition( 0.0f, 0.0f );
652 
653  Stage::GetCurrent().Add( pushButton );
654 
655  application.SendNotification();
656  application.Render();
657 
658  // First test the size is zero.
659  // No padding should be added as there is no label or icon.
660  Vector2 size( Vector2::ZERO );
661  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
662  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
663 
665 
666  // Check label only padding.
667  pushButton.SetLabelText( "Label" );
668 
669  application.SendNotification();
670  application.Render();
671 
672  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
673  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
674 
675  // We should not test against the exact label size, we just make sure it is larger than our label padding so we know the padding has been applied.
676  DALI_TEST_GREATER( size.width, 20.0f, TEST_LOCATION );
677  DALI_TEST_GREATER( size.height, 20.0f, TEST_LOCATION );
678 
679  // Re-initialise the button so we can setup icon-only padding.
680  pushButton.Unparent();
681  pushButton = PushButton::New();
682 
683  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
684  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 20.0f, 20.0f, 20.0f, 20.0f ) );
685 
688  pushButton.SetPosition( 0.0f, 0.0f );
690 
691  Stage::GetCurrent().Add( pushButton );
692 
693  const char* INVALID_IMAGE_FILE_NAME = "invalid-image.jpg";
695  pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, INVALID_IMAGE_FILE_NAME );
696  pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, INVALID_IMAGE_FILE_NAME );
697 
698  application.SendNotification();
699  application.Render();
700 
701  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
702  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
703 
705 
706  // Now test padding for both label and icon simultaneously.
707  pushButton.SetLabelText( "Label" );
708 
709  application.SendNotification();
710  application.Render();
711 
712  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
713  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
714 
715  // We should not test against the exact label size, we just make sure it is larger than our label padding so we know the padding has been applied.
716  // Note we only test the width as we are horizontally aligned and the label my be less high than the icon.
717  // Full directional alignment tests are done in UtcDaliPushButtonAlignmentLayout.
718  DALI_TEST_GREATER( size.width, 60.0f, TEST_LOCATION );
719 
720  END_TEST;
721 }
722 
724 {
725  ToolkitTestApplication application;
726  tet_infoline(" UtcDaliPushButtonAlignmentLayout");
727 
728  /*
729  * This test checks different alignments for the icon against the label.
730  * The icon is then moved around the label in each of it's alignments.
731  * The final relayed out size is checked to confirm the layout has been done correctly.
732  *
733  * There is an Icon which has 0 width and height, but with 75 padding on all sides.
734  * - Therefore total width and height are both 150.
735  *
736  * There is a Label which has "an unknown" width and height, but with 30 padding on all sides.
737  * - Therefore total width and height are 60+x and 60+y respectively.
738  * Where x & y are the width and height of the text.
739  *
740  * The width of the button will always expand to the largest of the icon and label sizes (plus padding).
741  * So We use the padding to help us determine the orientation is correct for each alignment.
742  *
743  * |<- 150 ->| |<-- 60+x -->|
744  *
745  * +---------+ -
746  * | | ^ +------------+ -
747  * | | | | | ^
748  * | Icon | 150 | Label | 60+y
749  * | | | | | v
750  * | | v +------------+ -
751  * +---------+ -
752  */
753  PushButton pushButton = PushButton::New();
754 
755  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 30.0f, 30.0f, 30.0f, 30.0f ) );
756  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 75.0f, 75.0f, 75.0f, 75.0f ) );
757 
760  pushButton.SetPosition( 0.0f, 0.0f );
762 
763  Stage::GetCurrent().Add( pushButton );
764 
765  const char* INVALID_IMAGE_FILE_NAME = "invalid-image.jpg";
767  pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, INVALID_IMAGE_FILE_NAME );
768  pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, INVALID_IMAGE_FILE_NAME );
769 
770  application.SendNotification();
771  application.Render();
772 
773  // First get the base size (without label).
774  Vector2 baseSize( Vector2::ZERO );
775  baseSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
776  baseSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
777 
778  DALI_TEST_EQUALS( baseSize, Vector2( 150.0f, 150.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
779 
780  // Add a label to cause size to be modified in the direction of alignment.
781  pushButton.SetLabelText( "Label" );
782 
783  application.SendNotification();
784  application.Render();
785 
786  Vector2 size( Vector2::ZERO );
787  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
788  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
789 
790 
791  /*
792  * Test Icon right alignment.
793  * Height grows to largest of Icon or Label (+ padding).
794  * Normally this will be Icons height, except with very large font sizes.
795  *
796  * +------------+---------+
797  * |............+ |
798  * | | |
799  * | Label | Icon |
800  * | | |
801  * |............+ |
802  * +------------+---------+
803  */
804  DALI_TEST_GREATER( size.width, 150.0f + 60.0f, TEST_LOCATION );
806 
807  // Now test left alignment matches right for size.
809 
810  application.SendNotification();
811  application.Render();
812 
813  Vector2 compareSize( Vector2::ZERO );
814  compareSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
815  compareSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
816 
817  /*
818  * Test Icon left alignment.
819  * Height grows to largest of Icon or Label (+ padding).
820  * Normally this will be Icons height, except with very large font sizes.
821  *
822  * +---------+------------+
823  * | +............|
824  * | | |
825  * | Icon | Label |
826  * | | |
827  * | +............|
828  * +---------+------------+
829  */
831 
832  // Test top alignment.
834 
835  application.SendNotification();
836  application.Render();
837 
838  compareSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
839  compareSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
840 
841  /*
842  * Test Icon top alignment.
843  * Width grows to largest of Icon or Label (+ padding).
844  *
845  * +---------+
846  * | |
847  * | |
848  * | Icon |
849  * | |
850  * | |
851  * +---------+
852  * | |
853  * | Label |
854  * | |
855  * +---------+
856  *
857  * Note: We subtract a small number as we want to do a >= test.
858  */
860  DALI_TEST_GREATER( compareSize.height, 150.0f + 60.0f, TEST_LOCATION );
861 
862  // Test bottom alignment.
864 
865  application.SendNotification();
866  application.Render();
867 
868  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
869  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
870 
871  /*
872  * Test Icon bottom alignment.
873  * Width grows to largest of Icon or Label (+ padding).
874  *
875  * +---------+
876  * | |
877  * | Label |
878  * | |
879  * +---------+
880  * | |
881  * | |
882  * | Icon |
883  * | |
884  * | |
885  * +---------+
886  */
888 
889  END_TEST;
890 }
Dali Docs Home
Read more about Dali