* #39226: restore Tests module

This commit reactivate unit testing in SFLphone android.
Tests are trivial for now, but will contribute in setting up the whole
testing process with jenkins.
diff --git a/.gitignore b/.gitignore
index 7629bd7..d095108 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
 /libs
 /bin
 /gen
+/out
 /.idea
 *.swp
 tags
diff --git a/Tests/AndroidManifest.xml b/Tests/AndroidManifest.xml
new file mode 100644
index 0000000..28379ff
--- /dev/null
+++ b/Tests/AndroidManifest.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="org.sflphone.tests"
+          android:versionCode="1"
+          android:versionName="1.0">
+    <!-- We add an application tag here just so that we can indicate that
+         this package needs to link against the android.test library,
+         which is needed when building test cases. -->
+    <application>
+        <uses-library android:name="android.test.runner"/>
+    </application>
+
+    <uses-sdk
+            android:minSdkVersion="14"
+            android:targetSdkVersion="19" />
+    <!--
+    This declares that this application uses the instrumentation test runner targeting
+    the package of org.sflphone.  To run the tests use the command:
+    "adb shell am instrument -w org.sflphone.tests/android.test.InstrumentationTestRunner"
+    -->
+    <instrumentation
+            android:name="android.test.InstrumentationTestRunner"
+            android:targetPackage="org.sflphone"
+            android:label="Tests for org.sflphone"/>
+</manifest>
diff --git a/Tests/Tests.iml b/Tests/Tests.iml
new file mode 100644
index 0000000..52f8906
--- /dev/null
+++ b/Tests/Tests.iml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="android" name="Android">
+      <configuration>
+        <option name="PACK_TEST_CODE" value="true" />
+        <option name="UPDATE_PROPERTY_FILES" value="true" />
+      </configuration>
+    </facet>
+  </component>
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="SFLPhone" scope="PROVIDED" />
+  </component>
+</module>
+
diff --git a/tests/build.xml b/Tests/build.xml
similarity index 90%
rename from tests/build.xml
rename to Tests/build.xml
index 34f5357..e6e4c09 100644
--- a/tests/build.xml
+++ b/Tests/build.xml
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project name="sflphoneTest" default="help">
+<project name="Tests" default="help">
 
     <!-- The local.properties file is created and updated by the 'android' tool.
          It contains the path to the SDK. It should *NOT* be checked into
          Version Control Systems. -->
-    <property file="local.properties" />
+    <property file="local.properties"/>
 
     <!-- The ant.properties file can be created by you. It is only edited by the
          'android' tool to add properties to it.
@@ -26,15 +26,15 @@
          application and should be checked into Version Control Systems.
 
          -->
-    <property file="ant.properties" />
+    <property file="ant.properties"/>
 
     <!-- if sdk.dir was not set from one of the property file, then
          get it from the ANDROID_HOME env var.
          This must be done before we load project.properties since
          the proguard config can use sdk.dir -->
-    <property environment="env" />
+    <property environment="env"/>
     <condition property="sdk.dir" value="${env.ANDROID_HOME}">
-        <isset property="env.ANDROID_HOME" />
+        <isset property="env.ANDROID_HOME"/>
     </condition>
 
     <!-- The project.properties file is created and updated by the 'android'
@@ -46,13 +46,13 @@
 
          This file is an integral part of the build system for your
          application and should be checked into Version Control Systems. -->
-    <loadproperties srcFile="project.properties" />
+    <loadproperties srcFile="project.properties"/>
 
     <!-- quick check on sdk.dir -->
     <fail
             message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
             unless="sdk.dir"
-    />
+            />
 
     <!--
         Import per project custom build rules if present at the root of the project.
@@ -66,7 +66,7 @@
             -post-build
             -pre-clean
     -->
-    <import file="custom_rules.xml" optional="true" />
+    <import file="custom_rules.xml" optional="true"/>
 
     <!-- Import the actual build file.
 
@@ -87,6 +87,6 @@
          in order to avoid having your file be overridden by tools such as "android update project"
     -->
     <!-- version-tag: 1 -->
-    <import file="${sdk.dir}/tools/ant/build.xml" />
+    <import file="${sdk.dir}/tools/ant/build.xml"/>
 
 </project>
diff --git a/Tests/gen/org/sflphone/tests/BuildConfig.java b/Tests/gen/org/sflphone/tests/BuildConfig.java
new file mode 100644
index 0000000..880f80f
--- /dev/null
+++ b/Tests/gen/org/sflphone/tests/BuildConfig.java
@@ -0,0 +1,8 @@
+/*___Generated_by_IDEA___*/
+
+package org.sflphone.tests;
+
+/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
+public final class BuildConfig {
+  public final static boolean DEBUG = Boolean.parseBoolean(null);
+}
\ No newline at end of file
diff --git a/Tests/gen/org/sflphone/tests/Manifest.java b/Tests/gen/org/sflphone/tests/Manifest.java
new file mode 100644
index 0000000..297935d
--- /dev/null
+++ b/Tests/gen/org/sflphone/tests/Manifest.java
@@ -0,0 +1,7 @@
+/*___Generated_by_IDEA___*/
+
+package org.sflphone.tests;
+
+/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
+public final class Manifest {
+}
\ No newline at end of file
diff --git a/Tests/gen/org/sflphone/tests/R.java b/Tests/gen/org/sflphone/tests/R.java
new file mode 100644
index 0000000..8956400
--- /dev/null
+++ b/Tests/gen/org/sflphone/tests/R.java
@@ -0,0 +1,7 @@
+/*___Generated_by_IDEA___*/
+
+package org.sflphone.tests;
+
+/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
+public final class R {
+}
\ No newline at end of file
diff --git a/tests/proguard-project.txt b/Tests/proguard-project.txt
similarity index 100%
rename from tests/proguard-project.txt
rename to Tests/proguard-project.txt
diff --git a/tests/project.properties b/Tests/project.properties
similarity index 96%
rename from tests/project.properties
rename to Tests/project.properties
index 0840b4a..4ab1256 100644
--- a/tests/project.properties
+++ b/Tests/project.properties
@@ -11,4 +11,4 @@
 #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
 
 # Project target.
-target=android-15
+target=android-19
diff --git a/Tests/src/org/sflphone/client/HomeActivityTest.java b/Tests/src/org/sflphone/client/HomeActivityTest.java
new file mode 100644
index 0000000..ecde418
--- /dev/null
+++ b/Tests/src/org/sflphone/client/HomeActivityTest.java
@@ -0,0 +1,28 @@
+package org.sflphone.client;
+
+import android.test.ActivityInstrumentationTestCase2;
+import junit.framework.Assert;
+
+/**
+ * This is a simple framework for a test of an Application.  See
+ * {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on
+ * how to write and extend Application tests.
+ * <p/>
+ * To run this test, you can type:
+ * adb shell am instrument -w \
+ * -e class org.sflphone.client.HomeActivityTest \
+ * org.sflphone.tests/android.test.InstrumentationTestRunner
+ */
+public class HomeActivityTest extends ActivityInstrumentationTestCase2<HomeActivity> {
+
+    public HomeActivityTest() {
+        super(HomeActivity.class);
+    }
+
+
+    public void testStringForDisplay() throws Exception {
+        HomeActivity act_ = getActivity();
+        Assert.assertTrue(act_.getService() != null);
+    }
+
+}
diff --git a/tests/src/com/savoirfairelinux/sflphone/client/ManagerImplTest.java b/Tests/src/org/sflphone/client/ManagerImplTest.java
similarity index 68%
rename from tests/src/com/savoirfairelinux/sflphone/client/ManagerImplTest.java
rename to Tests/src/org/sflphone/client/ManagerImplTest.java
index f93f3c8..6f4f5d4 100644
--- a/tests/src/com/savoirfairelinux/sflphone/client/ManagerImplTest.java
+++ b/Tests/src/org/sflphone/client/ManagerImplTest.java
@@ -1,3 +1,4 @@
+package org.sflphone.client;
 /**
  * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
  *
@@ -29,15 +30,13 @@
  * as that of the covered work.
  */
 
-package com.savoirfairelinux.sflphone;
 
-import java.lang.Thread;
-import android.test.AndroidTestCase;
+        import java.lang.Thread;
+        import android.test.AndroidTestCase;
+        import org.sflphone.service.*;
 
-import com.savoirfairelinux.sflphone.client.ManagerImpl;
 
 public class ManagerImplTest extends AndroidTestCase {
-    public static final String PACKAGE_NAME = "com.savoirfairelinux.sflphone";
     public static final String ACCOUNT_ID = "IP2IP";
     public static final String CALLING_VALID_IP = "127.0.0.1";
     public static final String CALLING_BAD_IP = "123.234.123.234";
@@ -46,70 +45,65 @@
 
     static {
         System.loadLibrary("gnustl_shared");
-        System.loadLibrary("expat");
-        System.loadLibrary("yaml");
-        System.loadLibrary("ccgnu2");
         System.loadLibrary("crypto");
         System.loadLibrary("ssl");
-        System.loadLibrary("ccrtp1");
-        System.loadLibrary("dbus");
-        System.loadLibrary("dbus-c++-1");
-        System.loadLibrary("samplerate"); 
-        System.loadLibrary("codec_ulaw");
-        System.loadLibrary("codec_alaw");
-        System.loadLibrary("speexresampler");
         System.loadLibrary("sflphone");
     }
 
-    ManagerImpl managerimpl;
+    ManagerImpl managerImpl;
+    private CallManager callManagerJNI;
+    private ConfigurationManager configurationManagerJNI;
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
+        managerImpl = SFLPhoneservice.instance();
+        /* set static AppPath before calling manager.init */
+        // managerImpl.setPath(getApplication().getFilesDir().getAbsolutePath());
+        callManagerJNI = new CallManager();
+        configurationManagerJNI = new ConfigurationManager();
+        /*managerImpl.init("");*/
 
-        managerimpl = new ManagerImpl();
-        managerimpl.initN("");
+        assertTrue(managerImpl != null);
+        assertTrue(callManagerJNI != null);
+        assertTrue(configurationManagerJNI != null);
     }
 
-    @Override
+/*    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
-    }
+    }*/
 
-    public void testGetAppPath() {
-        managerimpl.setAppPath(PACKAGE_NAME);
-        assertTrue(managerimpl.getAppPath() == PACKAGE_NAME);
-    }
 
-    public void testPlaceCallSuccessful() {
+/*    public void testPlaceCallSuccessful() {
         try {
-            managerimpl.placeCall(ACCOUNT_ID, CALL_ID, CALLING_VALID_IP);
+            callManagerJNI.placeCall(ACCOUNT_ID, CALL_ID, CALLING_VALID_IP);
             assertTrue(true);
 
             // FIXME: We should have a method returning the call state
             //        and wait for the call to be in state CURRENT.
             Thread.sleep(CALL_SLEEP_TIME);
 
-            managerimpl.hangUp(CALL_ID); 
+            callManagerJNI.hangUp(CALL_ID);
             assertTrue(true);
 
         } catch (InterruptedException e) {
             assertTrue(false);
         }
-    }
+    }*/
 
-    public void testPlaceCallBad() {
+    /*public void testPlaceCallBad() {
         try {
-            managerimpl.placeCall(ACCOUNT_ID, CALL_ID, CALLING_BAD_IP);
+            callManagerJNI.placeCall(ACCOUNT_ID, CALL_ID, CALLING_BAD_IP);
             assertTrue(true);
 
             Thread.sleep(CALL_SLEEP_TIME);
 
-            managerimpl.hangUp(CALL_ID);
+            callManagerJNI.hangUp(CALL_ID);
             assertTrue(true);
 
         } catch (InterruptedException e) {
             assertTrue(false);
         }
-    }
+    }*/
 }
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
deleted file mode 100644
index dc3b45f..0000000
--- a/tests/AndroidManifest.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="com.savoirfairelinux.sflphone.tests"
-          android:versionCode="1"
-          android:versionName="1.0">
-    <!-- We add an application tag here just so that we can indicate that
-         this package needs to link against the android.test library,
-         which is needed when building test cases. -->
-
-    <uses-sdk
-          android:minSdkVersion="13"
-          android:targetSdkVersion="15" />
-
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-    <!--
-    This declares that this application uses the instrumentation test runner targeting
-    the package of com.savoirfairelinux.sflphone.  To run the tests use the command:
-    "adb shell am instrument -w com.savoirfairelinux.sflphone.tests/android.test.InstrumentationTestRunner"
-    -->
-    <instrumentation android:name="android.test.InstrumentationTestRunner"
-                     android:targetPackage="com.savoirfairelinux.sflphone"
-                     android:label="Tests for com.savoirfairelinux.sflphone"/>
-</manifest>
diff --git a/tests/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeTest.java b/tests/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeTest.java
deleted file mode 100644
index 2e29945..0000000
--- a/tests/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
- *
- * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Additional permission under GNU GPL version 3 section 7:
- *
- * If you modify this program, or any covered work, by linking or
- * combining it with the OpenSSL project's OpenSSL library (or a
- * modified version of that library), containing parts covered by the
- * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
- * grants you additional permission to convey the resulting work.
- * Corresponding Source for a non-source form of such a combination
- * shall include the source code for the parts of OpenSSL used as well
- * as that of the covered work.
- */
-
-package com.savoirfairelinux.sflphone;
-
-import android.test.ActivityInstrumentationTestCase2;
-
-import com.savoirfairelinux.sflphone.client.SFLPhoneHome;
-
-/**
- * This is a simple framework for a test of an Application.  See
- * {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on
- * how to write and extend Application tests.
- * <p/>
- * To run this test, you can type:
- * adb shell am instrument -w \
- * -e class com.savoirfairelinux.sflphone.client.SFLPhoneHomeTest \
- * com.savoirfairelinux.sflphone.tests/android.test.InstrumentationTestRunner
- */
-public class SFLPhoneHomeTest extends ActivityInstrumentationTestCase2<SFLPhoneHome> {
-
-    private SFLPhoneHome mActivity;
-
-    public SFLPhoneHomeTest() {
-        super("com.savoirfairelinux.sflphone", SFLPhoneHome.class);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        setActivityInitialTouchMode(false);
-
-        mActivity = getActivity();
-    }
-}