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 );
83 int UtcConnectionTrackerDisconnectAllP(void)
85 TestApplication app; // Create core for debug logging
87 TestButton* button = new TestButton(1);
89 button->DownSignal().Connect(&testApp,&TestApp::OnButtonPress);
91 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 1 );
93 testApp.DisconnectAll();
95 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 0 );
100 int UtcConnectionTrackerDisconnectAllN(void)
102 TestApplication app; // Create core for debug logging
104 TestButton* button = new TestButton(1);
106 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 0 );
107 testApp.DisconnectAll();
108 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 0 );
113 int UtcConnectionTrackerSignalConnectedP(void)
115 TestApplication app; // Create core for debug logging
117 TestButton* button = new TestButton(1);
119 button->DownSignal().Connect(&testApp,&TestApp::OnButtonPress);
121 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 1 );
126 int UtcConnectionTrackerSignalConnectedN(void)
128 TestApplication app; // Create core for debug logging
130 TestButton* button = new TestButton(1);
131 TestApp* testApp( NULL );
135 // connect to a null connection tracker
136 button->DownSignal().Connect( testApp, &TestApp::OnButtonPress);
138 catch (Dali::DaliException& e)
140 // Tests that a negative test of an assertion succeeds
141 DALI_TEST_PRINT_ASSERT( e );
142 tet_result(TET_PASS);
149 int UtcConnectionTrackerSignalDisconnectP(void)
151 TestApplication app; // Create core for debug logging
153 TestButton* button = new TestButton(1);
155 button->DownSignal().Connect(&testApp,&TestApp::OnButtonPress);
157 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 1 );
159 button->DownSignal().Disconnect(&testApp,&TestApp::OnButtonPress);
160 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 0 );
167 int UtcConnectionTrackerSignalDisconnectN(void)
169 TestApplication app; // Create core for debug logging
171 TestButton* button = new TestButton(1);
173 button->DownSignal().Connect(&testApp,&TestApp::OnButtonPress);
175 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 1 );
179 app.SignalDisconnected( NULL, NULL );
180 tet_result( TET_FAIL );
182 catch (Dali::DaliException& e)
184 tet_result( TET_PASS );
192 int UtcConnectionTrackerGetConnectionCountP(void)
194 TestApplication app; // Create core for debug logging
196 TestButton* button = new TestButton(1);
198 button->DownSignal().Connect(&testApp,&TestApp::OnButtonPress);
199 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 1 );
203 int UtcConnectionTrackerGetConnectionCountN(void)
205 TestApplication app; // Create core for debug logging
207 TestButton* button = new TestButton(1);
208 DALI_TEST_CHECK( button->DownSignal().GetConnectionCount( ) == 0 );