(Buttons) Fix build break for automated tests & remove unused function
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-unmanaged / utc-Dali-Button.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/integration-api/events/touch-event-integ.h>
22 #include <dali-toolkit/dali-toolkit.h>
23
24 using namespace Dali;
25 using namespace Toolkit;
26
27 void dali_button_startup(void)
28 {
29   test_return_value = TET_UNDEF;
30 }
31
32 void dali_button_cleanup(void)
33 {
34   test_return_value = TET_PASS;
35 }
36
37
38 namespace
39 {
40 const Dali::TouchPoint pointDownInside( 0, TouchPoint::Down, 240, 400 );
41 const Dali::TouchPoint pointUpInside( 0, TouchPoint::Up, 240, 400 );
42 const Dali::TouchPoint pointLeave( 0, TouchPoint::Leave, 240, 400 );
43 const Dali::TouchPoint pointEnter( 0, TouchPoint::Motion, 240, 400 );
44 const Dali::TouchPoint pointDownOutside( 0, TouchPoint::Down, 10, 10 );
45 const Dali::TouchPoint pointUpOutside( 0, TouchPoint::Up, 10, 10 );
46
47 static bool gObjectCreatedCallBackCalled;
48
49 static void TestObjectCreatedCallback(BaseHandle handle)
50 {
51   gObjectCreatedCallBackCalled = true;
52 }
53
54 } // namespace
55
56
57
58 // Positive test case for a method
59 int UtcDaliButtonNew(void)
60 {
61   ToolkitTestApplication application;
62   tet_infoline(" UtcDaliButtonNew");
63
64   CheckBoxButton checkBoxButton = CheckBoxButton::New();
65   DALI_TEST_CHECK( checkBoxButton );
66
67   CheckBoxButton checkBoxButton2( checkBoxButton );
68   DALI_TEST_CHECK( checkBoxButton2 );
69   checkBoxButton2.Reset();
70
71
72   //Additional check to ensure object is created by checking if it's registered
73   ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
74   DALI_TEST_CHECK( registry );
75
76   gObjectCreatedCallBackCalled = false;
77   registry.ObjectCreatedSignal().Connect( &TestObjectCreatedCallback );
78   {
79     CheckBoxButton checkBoxButton = CheckBoxButton::New();
80   }
81   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
82
83   gObjectCreatedCallBackCalled = false;
84   registry.ObjectCreatedSignal().Connect( &TestObjectCreatedCallback );
85   {
86     PushButton pushButton = PushButton::New();
87   }
88   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
89
90   // Test down cast
91   Handle handleButton = checkBoxButton;
92   Button downCastCheckBoxButton = Button::DownCast( handleButton );
93   DALI_TEST_CHECK( downCastCheckBoxButton );
94   CheckBoxButton downCastCheckBoxButton2 = CheckBoxButton::DownCast( handleButton );
95   DALI_TEST_CHECK( downCastCheckBoxButton2 );
96   END_TEST;
97 }
98
99 int UtcDaliButtonProperties(void)
100 {
101   tet_infoline("UtcDaliButtonSetProperty: ");
102   ToolkitTestApplication application;
103
104   CheckBoxButton checkBoxButton = CheckBoxButton::New();
105   PushButton pushButton = PushButton::New();
106
107   //Test various properties
108   checkBoxButton.SetProperty( checkBoxButton.GetPropertyIndex("disabled"), false );
109   DALI_TEST_CHECK( false == checkBoxButton.IsDisabled() );
110
111   checkBoxButton.SetProperty( checkBoxButton.GetPropertyIndex("disabled"), true );
112   DALI_TEST_CHECK( true == checkBoxButton.IsDisabled() );
113   END_TEST;
114 }
115
116 int UtcDaliButtonSetGetDimmed(void)
117 {
118   ToolkitTestApplication application;
119   tet_infoline(" UtcDaliButtonSetGetDimmed");
120
121   CheckBoxButton checkBoxButton = CheckBoxButton::New();
122   checkBoxButton.SetDisabled( true );
123
124   DALI_TEST_CHECK( checkBoxButton.IsDisabled() );
125   checkBoxButton.SetDisabled( false );
126
127   DALI_TEST_CHECK( !checkBoxButton.IsDisabled() );
128   checkBoxButton.SetDisabled( true );
129
130   DALI_TEST_CHECK( checkBoxButton.IsDisabled() );
131   checkBoxButton.SetDisabled( false );
132
133   DALI_TEST_CHECK( !checkBoxButton.IsDisabled() );
134   END_TEST;
135 }