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/integration-api/events/touch-event-integ.h>
22 #include <dali-toolkit/dali-toolkit.h>
25 using namespace Toolkit;
27 void dali_button_startup(void)
29 test_return_value = TET_UNDEF;
32 void dali_button_cleanup(void)
34 test_return_value = TET_PASS;
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 );
47 static bool gObjectCreatedCallBackCalled;
49 static void TestObjectCreatedCallback(BaseHandle handle)
51 gObjectCreatedCallBackCalled = true;
58 // Positive test case for a method
59 int UtcDaliButtonNew(void)
61 ToolkitTestApplication application;
62 tet_infoline(" UtcDaliButtonNew");
64 CheckBoxButton checkBoxButton = CheckBoxButton::New();
65 DALI_TEST_CHECK( checkBoxButton );
67 CheckBoxButton checkBoxButton2( checkBoxButton );
68 DALI_TEST_CHECK( checkBoxButton2 );
69 checkBoxButton2.Reset();
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 );
76 gObjectCreatedCallBackCalled = false;
77 registry.ObjectCreatedSignal().Connect( &TestObjectCreatedCallback );
79 CheckBoxButton checkBoxButton = CheckBoxButton::New();
81 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
83 gObjectCreatedCallBackCalled = false;
84 registry.ObjectCreatedSignal().Connect( &TestObjectCreatedCallback );
86 PushButton pushButton = PushButton::New();
88 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
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 );
99 int UtcDaliButtonProperties(void)
101 tet_infoline("UtcDaliButtonSetProperty: ");
102 ToolkitTestApplication application;
104 CheckBoxButton checkBoxButton = CheckBoxButton::New();
105 PushButton pushButton = PushButton::New();
107 //Test various properties
108 checkBoxButton.SetProperty( checkBoxButton.GetPropertyIndex("dimmed"), false );
109 DALI_TEST_CHECK( false == checkBoxButton.IsDimmed() );
111 checkBoxButton.SetProperty( checkBoxButton.GetPropertyIndex("dimmed"), true );
112 DALI_TEST_CHECK( true == checkBoxButton.IsDimmed() );
116 int UtcDaliButtonSetGetDimmed(void)
118 ToolkitTestApplication application;
119 tet_infoline(" UtcDaliButtonSetGetDimmed");
121 CheckBoxButton checkBoxButton = CheckBoxButton::New();
122 checkBoxButton.SetDimmed( true );
124 DALI_TEST_CHECK( checkBoxButton.IsDimmed() );
125 checkBoxButton.SetDimmed( false );
127 DALI_TEST_CHECK( !checkBoxButton.IsDimmed() );
128 checkBoxButton.SetDimmed( true );
130 DALI_TEST_CHECK( checkBoxButton.IsDimmed() );
131 checkBoxButton.SetDimmed( false );
133 DALI_TEST_CHECK( !checkBoxButton.IsDimmed() );