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.
23 #include <dali/public-api/dali-core.h>
24 #include <dali-test-suite-utils.h>
25 #include <signal-helper.h>
30 void utc_dali_conenction_tracker_startup(void)
32 test_return_value = TET_UNDEF;
35 void utc_dali_conenction_tracker_cleanup(void)
37 test_return_value = TET_PASS;
46 /*******************************************
48 * Start of Utc test cases.
49 * Test cases performed in order of API listed in dali-signal.h
50 * UtcDaliSignal + FunctionName + P=positive test, N = Negative test
54 int UtcConnectionTrackerConstructorP(void)
56 TestApplication app; // Create core for debug logging
58 ConnectionTracker tracker;
60 DALI_TEST_CHECK( tracker.GetConnectionCount() == 0 );
65 int UtcConnectionTrackerDestructorP(void)
67 TestApplication app; // Create core for debug logging
68 // make sure the ConnectionTracker disconnects form a signal when it
70 TestButton* button = new TestButton(1);
73 button->DownSignal().Connect(&testApp,&TestApp::OnButtonPress);
74 DALI_TEST_CHECK( testApp.GetConnectionCount() == 1 );
75 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( )== 1 );
77 // testApp out of scope it should have been disconnected
78 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 0 );
85 int UtcConnectionTrackerDisconnectAllP(void)
87 TestApplication app; // Create core for debug logging
89 TestButton* button = new TestButton(1);
91 button->DownSignal().Connect(&testApp,&TestApp::OnButtonPress);
93 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 1 );
95 testApp.DisconnectAll();
97 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 0 );
104 int UtcConnectionTrackerDisconnectAllN(void)
106 TestApplication app; // Create core for debug logging
108 TestButton* button = new TestButton(1);
110 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 0 );
111 testApp.DisconnectAll();
112 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 0 );
119 int UtcConnectionTrackerSignalConnectedP(void)
121 TestApplication app; // Create core for debug logging
123 TestButton* button = new TestButton(1);
125 button->DownSignal().Connect(&testApp,&TestApp::OnButtonPress);
127 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 1 );
134 int UtcConnectionTrackerSignalConnectedN(void)
136 TestApplication app; // Create core for debug logging
138 TestButton* button = new TestButton(1);
139 TestApp* testApp( NULL );
143 // connect to a null connection tracker
144 button->DownSignal().Connect( testApp, &TestApp::OnButtonPress);
146 catch (Dali::DaliException& e)
148 // Tests that a negative test of an assertion succeeds
149 DALI_TEST_PRINT_ASSERT( e );
150 tet_result(TET_PASS);
159 int UtcConnectionTrackerSignalDisconnectP(void)
161 TestApplication app; // Create core for debug logging
163 TestButton* button = new TestButton(1);
165 button->DownSignal().Connect(&testApp,&TestApp::OnButtonPress);
167 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 1 );
169 button->DownSignal().Disconnect(&testApp,&TestApp::OnButtonPress);
170 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 0 );
178 int UtcConnectionTrackerSignalDisconnectN(void)
180 TestApplication app; // Create core for debug logging
182 TestButton* button = new TestButton(1);
184 button->DownSignal().Connect(&testApp,&TestApp::OnButtonPress);
186 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 1 );
190 app.SignalDisconnected( NULL, NULL );
191 tet_result( TET_FAIL );
193 catch (Dali::DaliException& e)
195 tet_result( TET_PASS );
204 int UtcConnectionTrackerGetConnectionCountP(void)
206 TestApplication app; // Create core for debug logging
208 TestButton* button = new TestButton(1);
210 button->DownSignal().Connect(&testApp,&TestApp::OnButtonPress);
211 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 1 );
218 int UtcConnectionTrackerGetConnectionCountN(void)
220 TestApplication app; // Create core for debug logging
222 TestButton* button = new TestButton(1);
223 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 0 );