diff --git a/src/org/linphone/HistorySimpleFragment.java b/src/org/linphone/HistorySimpleFragment.java index 58641d02c..25d631746 100644 --- a/src/org/linphone/HistorySimpleFragment.java +++ b/src/org/linphone/HistorySimpleFragment.java @@ -151,7 +151,10 @@ public class HistorySimpleFragment extends Fragment implements OnClickListener, } else { address = log.getTo(); } - LinphoneActivity.instance().displayHistoryDetail(address.asStringUriOnly(), log); + + if (LinphoneActivity.isInstanciated()) { + LinphoneActivity.instance().displayHistoryDetail(address.asStringUriOnly(), log); + } } } diff --git a/src/org/linphone/setup/SetupActivity.java b/src/org/linphone/setup/SetupActivity.java index c2fcd99f5..ac44d7024 100644 --- a/src/org/linphone/setup/SetupActivity.java +++ b/src/org/linphone/setup/SetupActivity.java @@ -127,8 +127,8 @@ public class SetupActivity extends FragmentActivity implements OnClickListener { public void logIn(String username, String password, String domain) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - if (imm != null) { - imm.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0); + if (imm != null && getCurrentFocus() != null) { + imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); } saveCreatedAccount(username, password, domain); diff --git a/tests/.classpath b/tests/.classpath new file mode 100644 index 000000000..93cfbc5bf --- /dev/null +++ b/tests/.classpath @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tests/.project b/tests/.project new file mode 100644 index 000000000..a965ac946 --- /dev/null +++ b/tests/.project @@ -0,0 +1,34 @@ + + + linphone-android-test + + + linphone-android-newUI + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml new file mode 100644 index 000000000..30c743114 --- /dev/null +++ b/tests/AndroidManifest.xml @@ -0,0 +1,19 @@ + + + + /> + + + + + + + + \ No newline at end of file diff --git a/tests/README b/tests/README new file mode 100644 index 000000000..4c9aa6c2c --- /dev/null +++ b/tests/README @@ -0,0 +1 @@ +This is a JUnit test project for Linphone's Android application. diff --git a/tests/call.py b/tests/monkeyrruner/call.py similarity index 100% rename from tests/call.py rename to tests/monkeyrruner/call.py diff --git a/tests/config.py b/tests/monkeyrruner/config.py similarity index 100% rename from tests/config.py rename to tests/monkeyrruner/config.py diff --git a/tests/install.py b/tests/monkeyrruner/install.py similarity index 100% rename from tests/install.py rename to tests/monkeyrruner/install.py diff --git a/tests/lib/LinphoneTest.py b/tests/monkeyrruner/lib/LinphoneTest.py similarity index 100% rename from tests/lib/LinphoneTest.py rename to tests/monkeyrruner/lib/LinphoneTest.py diff --git a/tests/lib/__init__.py b/tests/monkeyrruner/lib/__init__.py similarity index 100% rename from tests/lib/__init__.py rename to tests/monkeyrruner/lib/__init__.py diff --git a/tests/proguard-project.txt b/tests/proguard-project.txt new file mode 100644 index 000000000..f2fe1559a --- /dev/null +++ b/tests/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/tests/project.properties b/tests/project.properties new file mode 100644 index 000000000..9b84a6b4b --- /dev/null +++ b/tests/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-16 diff --git a/tests/res/drawable-hdpi/ic_launcher.png b/tests/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 000000000..96a442e5b Binary files /dev/null and b/tests/res/drawable-hdpi/ic_launcher.png differ diff --git a/tests/res/drawable-ldpi/ic_launcher.png b/tests/res/drawable-ldpi/ic_launcher.png new file mode 100644 index 000000000..99238729d Binary files /dev/null and b/tests/res/drawable-ldpi/ic_launcher.png differ diff --git a/tests/res/drawable-mdpi/ic_launcher.png b/tests/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 000000000..359047dfa Binary files /dev/null and b/tests/res/drawable-mdpi/ic_launcher.png differ diff --git a/tests/res/drawable-xhdpi/ic_launcher.png b/tests/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 000000000..71c6d760f Binary files /dev/null and b/tests/res/drawable-xhdpi/ic_launcher.png differ diff --git a/tests/res/values/strings.xml b/tests/res/values/strings.xml new file mode 100644 index 000000000..1bed75b44 --- /dev/null +++ b/tests/res/values/strings.xml @@ -0,0 +1,6 @@ + + + + Linphone-android-testTest + + \ No newline at end of file diff --git a/tests/src/org/linphone/test/AccountsTest.java b/tests/src/org/linphone/test/AccountsTest.java new file mode 100644 index 000000000..dbff0c1f7 --- /dev/null +++ b/tests/src/org/linphone/test/AccountsTest.java @@ -0,0 +1,83 @@ +package org.linphone.test; + +import junit.framework.Assert; + +import org.linphone.LinphoneActivity; +import org.linphone.R; +import org.linphone.setup.SetupActivity; + +import android.content.SharedPreferences; +import android.preference.PreferenceManager; +import android.test.ActivityInstrumentationTestCase2; +import android.widget.EditText; +import android.widget.ListView; + +import com.jayway.android.robotium.solo.Solo; + +public class AccountsTest extends + ActivityInstrumentationTestCase2 { + + private Solo solo; + + @SuppressWarnings("deprecation") + public AccountsTest() { + super("org.linphone", LinphoneActivity.class); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + solo = new Solo(getInstrumentation(), getActivity()); + } + + public void testConfigureExistingAccount() { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + int nbAccountsBefore = prefs.getInt(getActivity().getString(R.string.pref_extra_accounts), 0); + + solo.assertCurrentActivity("Expected Linphone Activity", LinphoneActivity.class); + + solo.clickOnView(solo.getView(R.id.settings)); + solo.clickOnText("Account Setup Assistant"); + + solo.assertCurrentActivity("Expected Setup Activity", SetupActivity.class); + solo.clickOnView(solo.getView(R.id.setup_next)); + solo.clickOnText("I already have a linphone.org account"); + solo.enterText((EditText) solo.getView(R.id.setup_username), "wizard15"); + solo.enterText((EditText) solo.getView(R.id.setup_password), "wizard15"); + solo.clickOnText("Apply"); + + solo.waitForActivity("LinphoneActivity", 2000); + Assert.assertTrue(solo.searchText("wizard15@sip.linphone.org")); + + int nbAccountsAfter = prefs.getInt(getActivity().getString(R.string.pref_extra_accounts), 0); + Assert.assertEquals(nbAccountsBefore + 1, nbAccountsAfter); + } + + public void testDeleteConfiguredAccount() { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + int nbAccountsBefore = prefs.getInt(getActivity().getString(R.string.pref_extra_accounts), 0); + + solo.assertCurrentActivity("Expected Linphone Activity", LinphoneActivity.class); + solo.clickOnView(solo.getView(R.id.settings)); + Assert.assertTrue(solo.searchText("wizard15@sip.linphone.org")); + + solo.clickOnText("wizard15@sip.linphone.org"); + + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + ListView list = (ListView) solo.getView(android.R.id.list); + list.setSelection(7); + } + }); + solo.clickOnText("Delete this account"); + + int nbAccountsAfter = prefs.getInt(getActivity().getString(R.string.pref_extra_accounts), 0); + Assert.assertEquals(nbAccountsBefore - 1, nbAccountsAfter); + } + + @Override + public void tearDown() throws Exception { + solo.finishOpenedActivities(); + } +} diff --git a/tests/src/org/linphone/test/CallTest.java b/tests/src/org/linphone/test/CallTest.java new file mode 100644 index 000000000..955dcecf9 --- /dev/null +++ b/tests/src/org/linphone/test/CallTest.java @@ -0,0 +1,48 @@ +package org.linphone.test; + +import junit.framework.Assert; + +import org.linphone.InCallActivity; +import org.linphone.LinphoneActivity; +import org.linphone.R; + +import android.test.ActivityInstrumentationTestCase2; +import android.widget.EditText; + +import com.jayway.android.robotium.solo.Solo; + +public class CallTest extends + ActivityInstrumentationTestCase2 { + + private Solo solo; + + @SuppressWarnings("deprecation") + public CallTest() { + super("org.linphone", LinphoneActivity.class); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + solo = new Solo(getInstrumentation(), getActivity()); + } + + public void testOutgoingCallToCotcot() { + solo.assertCurrentActivity("Expected Linphone Activity", LinphoneActivity.class); + + solo.clickOnView(solo.getView(R.id.Adress)); + solo.enterText((EditText) solo.getView(R.id.Adress), "cotcot@sip.linphone.org"); + solo.clickOnView(solo.getView(R.id.Call)); + + solo.waitForActivity("InCallActivity", 2000); + solo.assertCurrentActivity("Expected InCall Activity", InCallActivity.class); + Assert.assertTrue(solo.searchText("Simon MORLAT")); + } + + @Override + public void tearDown() throws Exception { + solo.clickOnView(solo.getView(R.id.hangUp)); + solo.waitForActivity("LinphoneActivity", 2000); + solo.finishOpenedActivities(); + } +}