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.
24 #include <dali-test-suite-utils.h>
25 #include <dali/public-api/dali-core.h>
26 #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;
44 /*******************************************
46 * Start of Utc test cases.
47 * Test cases performed in order of API listed in dali-signal.h
48 * UtcDaliSignal + FunctionName + P=positive test, N = Negative test
52 int UtcConnectionTrackerConstructorP(void)
54 TestApplication application; // Create core for debug logging
56 ConnectionTracker tracker;
58 DALI_TEST_CHECK(tracker.GetConnectionCount() == 0);
63 int UtcConnectionTrackerDestructorP(void)
65 TestApplication application; // Create core for debug logging
66 // make sure the ConnectionTracker disconnects form a signal when it
68 TestButton* button = new TestButton(1);
71 button->DownSignal().Connect(&testApp, &TestApp::OnButtonPress);
72 DALI_TEST_CHECK(testApp.GetConnectionCount() == 1);
73 DALI_TEST_CHECK(button->DownSignal().GetConnectionCount() == 1);
75 // testApp out of scope it should have been disconnected
76 DALI_TEST_CHECK(button->DownSignal().GetConnectionCount() == 0);
83 int UtcConnectionTrackerDisconnectAllP(void)
85 TestApplication application; // 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);
102 int UtcConnectionTrackerDisconnectAllN(void)
104 TestApplication application; // Create core for debug logging
106 TestButton* button = new TestButton(1);
108 DALI_TEST_CHECK(button->DownSignal().GetConnectionCount() == 0);
109 testApp.DisconnectAll();
110 DALI_TEST_CHECK(button->DownSignal().GetConnectionCount() == 0);
117 int UtcConnectionTrackerSignalConnectedP(void)
119 TestApplication application; // Create core for debug logging
121 TestButton* button = new TestButton(1);
123 button->DownSignal().Connect(&testApp, &TestApp::OnButtonPress);
125 DALI_TEST_CHECK(button->DownSignal().GetConnectionCount() == 1);
131 int UtcConnectionTrackerSignalConnectedN(void)
133 TestApplication application; // Create core for debug logging
135 TestButton* button = new TestButton(1);
136 TestApp* testApp(NULL);
140 // connect to a null connection tracker
141 button->DownSignal().Connect(testApp, &TestApp::OnButtonPress);
143 catch(Dali::DaliException& e)
145 // Tests that a negative test of an assertion succeeds
146 DALI_TEST_PRINT_ASSERT(e);
147 tet_result(TET_PASS);
155 int UtcConnectionTrackerSignalDisconnectP(void)
157 TestApplication application; // Create core for debug logging
159 TestButton* button = new TestButton(1);
161 button->DownSignal().Connect(&testApp, &TestApp::OnButtonPress);
163 DALI_TEST_CHECK(button->DownSignal().GetConnectionCount() == 1);
165 button->DownSignal().Disconnect(&testApp, &TestApp::OnButtonPress);
166 DALI_TEST_CHECK(button->DownSignal().GetConnectionCount() == 0);
173 int UtcConnectionTrackerSignalDisconnectN(void)
175 TestApplication application; // Create core for debug logging
177 TestButton* button = new TestButton(1);
179 button->DownSignal().Connect(&testApp, &TestApp::OnButtonPress);
181 DALI_TEST_CHECK(button->DownSignal().GetConnectionCount() == 1);
185 application.SignalDisconnected(NULL, NULL);
186 tet_result(TET_FAIL);
188 catch(Dali::DaliException& e)
190 tet_result(TET_PASS);
198 int UtcConnectionTrackerGetConnectionCountP(void)
200 TestApplication application; // Create core for debug logging
202 TestButton* button = new TestButton(1);
204 button->DownSignal().Connect(&testApp, &TestApp::OnButtonPress);
205 DALI_TEST_CHECK(button->DownSignal().GetConnectionCount() == 1);
212 int UtcConnectionTrackerGetConnectionCountN(void)
214 TestApplication application; // Create core for debug logging
216 TestButton* button = new TestButton(1);
217 DALI_TEST_CHECK(button->DownSignal().GetConnectionCount() == 0);