2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
19 #include <dali-toolkit-test-suite-utils.h>
20 #include <dali/integration-api/events/touch-event-integ.h>
21 #include <dali-toolkit/dali-toolkit.h>
24 using namespace Toolkit;
26 void dali_button_startup(void)
28 test_return_value = TET_UNDEF;
31 void dali_button_cleanup(void)
33 test_return_value = TET_PASS;
39 const Dali::TouchPoint pointDownInside( 0, TouchPoint::Down, 240, 400 );
40 const Dali::TouchPoint pointUpInside( 0, TouchPoint::Up, 240, 400 );
41 const Dali::TouchPoint pointLeave( 0, TouchPoint::Leave, 240, 400 );
42 const Dali::TouchPoint pointEnter( 0, TouchPoint::Motion, 240, 400 );
43 const Dali::TouchPoint pointDownOutside( 0, TouchPoint::Down, 10, 10 );
44 const Dali::TouchPoint pointUpOutside( 0, TouchPoint::Up, 10, 10 );
46 static bool gObjectCreatedCallBackCalled;
48 static void TestObjectCreatedCallback(BaseHandle handle)
50 gObjectCreatedCallBackCalled = true;
57 // Positive test case for a method
58 int UtcDaliButtonNew(void)
60 ToolkitTestApplication application;
61 tet_infoline(" UtcDaliButtonNew");
63 CheckBoxButton checkBoxButton = CheckBoxButton::New();
64 DALI_TEST_CHECK( checkBoxButton );
66 CheckBoxButton checkBoxButton2( checkBoxButton );
67 DALI_TEST_CHECK( checkBoxButton2 );
68 checkBoxButton2 = NULL;
71 //Additional check to ensure object is created by checking if it's registered
72 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
73 DALI_TEST_CHECK( registry );
75 gObjectCreatedCallBackCalled = false;
76 registry.ObjectCreatedSignal().Connect( &TestObjectCreatedCallback );
78 CheckBoxButton checkBoxButton = CheckBoxButton::New();
80 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
82 gObjectCreatedCallBackCalled = false;
83 registry.ObjectCreatedSignal().Connect( &TestObjectCreatedCallback );
85 PushButton pushButton = PushButton::New();
87 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
90 Handle handleButton = checkBoxButton;
91 Button downCastCheckBoxButton = Button::DownCast( handleButton );
92 DALI_TEST_CHECK( downCastCheckBoxButton );
93 CheckBoxButton downCastCheckBoxButton2 = CheckBoxButton::DownCast( handleButton );
94 DALI_TEST_CHECK( downCastCheckBoxButton2 );
98 int UtcDaliButtonProperties(void)
100 tet_infoline("UtcDaliButtonSetProperty: ");
101 ToolkitTestApplication application;
103 CheckBoxButton checkBoxButton = CheckBoxButton::New();
104 PushButton pushButton = PushButton::New();
106 //Test various properties
107 checkBoxButton.SetProperty( checkBoxButton.GetPropertyIndex("dimmed"), false );
108 DALI_TEST_CHECK( false == checkBoxButton.IsDimmed() );
110 checkBoxButton.SetProperty( checkBoxButton.GetPropertyIndex("dimmed"), true );
111 DALI_TEST_CHECK( true == checkBoxButton.IsDimmed() );
115 int UtcDaliButtonSetGetDimmed(void)
117 ToolkitTestApplication application;
118 tet_infoline(" UtcDaliButtonSetGetDimmed");
120 CheckBoxButton checkBoxButton = CheckBoxButton::New();
121 checkBoxButton.SetDimmed( true );
123 DALI_TEST_CHECK( checkBoxButton.IsDimmed() );
124 checkBoxButton.SetDimmed( false );
126 DALI_TEST_CHECK( !checkBoxButton.IsDimmed() );
127 checkBoxButton.SetDimmed( true );
129 DALI_TEST_CHECK( checkBoxButton.IsDimmed() );
130 checkBoxButton.SetDimmed( false );
132 DALI_TEST_CHECK( !checkBoxButton.IsDimmed() );