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.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
24 using namespace Toolkit;
29 static bool gCheckBoxButtonState = false;
30 bool CheckBoxButtonClicked( Button button )
32 gCheckBoxButtonState = button.IsSelected();
38 Image CreateSolidColorImage( const Vector4& color, unsigned int width, unsigned int height )
40 BufferImage imageData = BufferImage::New( width, height, Pixel::RGBA8888 );
43 PixelBuffer* pixbuf = imageData.GetBuffer();
44 unsigned int size = width * height;
46 for( size_t i = 0; i < size; i++ )
48 pixbuf[i*4+0] = 0xFF * color.r;
49 pixbuf[i*4+1] = 0xFF * color.g;
50 pixbuf[i*4+2] = 0xFF * color.b;
51 pixbuf[i*4+3] = 0xFF * color.a;
62 void checkbox_button_startup(void)
64 test_return_value = TET_UNDEF;
67 void checkbox_button_cleanup(void)
69 test_return_value = TET_PASS;
72 int UtcDaliCheckBoxButtonSetGetSelected(void)
74 ToolkitTestApplication application;
75 tet_infoline(" UtcDaliCheckBoxButtonSetGetSelected");
77 CheckBoxButton checkBoxButton = CheckBoxButton::New();
78 checkBoxButton.StateChangedSignal().Connect( &CheckBoxButtonClicked );
80 // global var used to check if CheckBoxButtonClicked is called;
81 gCheckBoxButtonState = false;
83 checkBoxButton.SetSelected( true );
85 DALI_TEST_CHECK( checkBoxButton.IsSelected() );
86 DALI_TEST_CHECK( gCheckBoxButtonState );
88 checkBoxButton.SetSelected( false );
90 DALI_TEST_CHECK( !checkBoxButton.IsSelected() );
91 DALI_TEST_CHECK( !gCheckBoxButtonState );
93 checkBoxButton.SetSelected( true );
95 DALI_TEST_CHECK( checkBoxButton.IsSelected() );
96 DALI_TEST_CHECK( gCheckBoxButtonState );
100 int UtcDaliCheckBoxButtonSetImages(void)
102 ToolkitTestApplication application;
103 tet_infoline(" UtcDaliCheckBoxButtonSetImages");
107 Image image01 = CreateSolidColorImage( Color::RED, 10, 10 );
108 ImageActor imageActor01 = CreateSolidColorActor( Color::RED );
109 imageActor01.SetSize( 20, 20 );
111 Image image02 = CreateSolidColorImage( Color::RED, 30, 30 );
112 ImageActor imageActor02 = CreateSolidColorActor( Color::RED );
113 imageActor02.SetSize( 40, 40 );
114 imageActor02.SetName( "imageActor02" );
116 Image image03 = CreateSolidColorImage( Color::RED, 50, 50 );
117 ImageActor imageActor03 = CreateSolidColorActor( Color::RED );
118 imageActor03.SetSize( 60, 60 );
120 Image image04 = CreateSolidColorImage( Color::RED, 70, 70 );
121 ImageActor imageActor04 = CreateSolidColorActor( Color::RED );
122 imageActor04.SetSize( 80, 80 );
125 CheckBoxButton checkBoxButton = CheckBoxButton::New();
126 checkBoxButton.SetName( "UtcDaliCheckBoxButtonSetImages" );
127 Stage::GetCurrent().Add( checkBoxButton );
129 application.SendNotification();
130 application.Render();
132 // Just check if check box button size changes when a bigger image is set.
134 checkBoxButton.SetBackgroundImage( image01 );
136 application.SendNotification();
137 application.Render();
139 size = checkBoxButton.GetCurrentSize();
141 DALI_TEST_EQUALS( size.width, 10.f, TEST_LOCATION );
142 DALI_TEST_EQUALS( size.height, 10.f, TEST_LOCATION );
144 checkBoxButton.SetBackgroundImage( imageActor01 );