blob: f93f3c88841d8cb9394d3f4f0dc3e402c89d768d [file] [log] [blame]
Alexandre Savard974363d2012-08-30 15:20:49 -04001/**
2 * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
3 *
4 * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * Additional permission under GNU GPL version 3 section 7:
21 *
22 * If you modify this program, or any covered work, by linking or
23 * combining it with the OpenSSL project's OpenSSL library (or a
24 * modified version of that library), containing parts covered by the
25 * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
26 * grants you additional permission to convey the resulting work.
27 * Corresponding Source for a non-source form of such a combination
28 * shall include the source code for the parts of OpenSSL used as well
29 * as that of the covered work.
30 */
31
32package com.savoirfairelinux.sflphone;
33
Alexandre Savardedf48bd2012-08-30 17:00:38 -040034import java.lang.Thread;
Alexandre Savard974363d2012-08-30 15:20:49 -040035import android.test.AndroidTestCase;
36
37import com.savoirfairelinux.sflphone.client.ManagerImpl;
38
39public class ManagerImplTest extends AndroidTestCase {
40 public static final String PACKAGE_NAME = "com.savoirfairelinux.sflphone";
Alexandre Savardedf48bd2012-08-30 17:00:38 -040041 public static final String ACCOUNT_ID = "IP2IP";
42 public static final String CALLING_VALID_IP = "127.0.0.1";
43 public static final String CALLING_BAD_IP = "123.234.123.234";
44 public static final String CALL_ID = "1234567";
45 public static final int CALL_SLEEP_TIME = 1000; // in ms
46
47 static {
48 System.loadLibrary("gnustl_shared");
49 System.loadLibrary("expat");
50 System.loadLibrary("yaml");
51 System.loadLibrary("ccgnu2");
52 System.loadLibrary("crypto");
53 System.loadLibrary("ssl");
54 System.loadLibrary("ccrtp1");
55 System.loadLibrary("dbus");
56 System.loadLibrary("dbus-c++-1");
57 System.loadLibrary("samplerate");
58 System.loadLibrary("codec_ulaw");
59 System.loadLibrary("codec_alaw");
60 System.loadLibrary("speexresampler");
61 System.loadLibrary("sflphone");
62 }
Alexandre Savard974363d2012-08-30 15:20:49 -040063
64 ManagerImpl managerimpl;
65
66 @Override
67 protected void setUp() throws Exception {
68 super.setUp();
69
70 managerimpl = new ManagerImpl();
Alexandre Savardedf48bd2012-08-30 17:00:38 -040071 managerimpl.initN("");
Alexandre Savard974363d2012-08-30 15:20:49 -040072 }
73
74 @Override
75 protected void tearDown() throws Exception {
76 super.tearDown();
77 }
78
79 public void testGetAppPath() {
80 managerimpl.setAppPath(PACKAGE_NAME);
81 assertTrue(managerimpl.getAppPath() == PACKAGE_NAME);
82 }
Alexandre Savardedf48bd2012-08-30 17:00:38 -040083
84 public void testPlaceCallSuccessful() {
85 try {
86 managerimpl.placeCall(ACCOUNT_ID, CALL_ID, CALLING_VALID_IP);
87 assertTrue(true);
88
89 // FIXME: We should have a method returning the call state
90 // and wait for the call to be in state CURRENT.
91 Thread.sleep(CALL_SLEEP_TIME);
92
93 managerimpl.hangUp(CALL_ID);
94 assertTrue(true);
95
96 } catch (InterruptedException e) {
97 assertTrue(false);
98 }
99 }
100
101 public void testPlaceCallBad() {
102 try {
103 managerimpl.placeCall(ACCOUNT_ID, CALL_ID, CALLING_BAD_IP);
104 assertTrue(true);
105
106 Thread.sleep(CALL_SLEEP_TIME);
107
108 managerimpl.hangUp(CALL_ID);
109 assertTrue(true);
110
111 } catch (InterruptedException e) {
112 assertTrue(false);
113 }
114 }
Alexandre Savard974363d2012-08-30 15:20:49 -0400115}