Merge branch 'master' of git.linphone.org:linphone-android

Conflicts:
	submodules/linphone
This commit is contained in:
Simon Morlat 2013-11-05 16:15:24 +01:00
commit 7836e307a3
16 changed files with 183 additions and 104 deletions

View file

@ -339,11 +339,11 @@ run-linphone:
run-basic-tests: run-basic-tests:
ant partial-clean ant partial-clean
$(MAKE) -C tests $(MAKE) -C tests run-basic-tests
run-all-tests: run-all-tests:
ant partial-clean ant partial-clean
$(MAKE) -C tests $(MAKE) -C tests run-all-tests
clean-ndk-build: clean-ndk-build:
$(NDK_PATH)/ndk-build clean $(LIBLINPHONE_OPTIONS) $(NDK_PATH)/ndk-build clean $(LIBLINPHONE_OPTIONS)

View file

@ -106,23 +106,40 @@ public class LinphonePreferences {
} }
private LinphoneAuthInfo getAuthInfo(int n) { private LinphoneAuthInfo getAuthInfo(int n) {
LinphoneAuthInfo[] authsInfos = getLc().getAuthInfosList();
// In case you have multiple proxy configs with same auth info
if (n > 0 && n >= authsInfos.length) {
LinphoneProxyConfig prxCfg = getProxyConfig(n); LinphoneProxyConfig prxCfg = getProxyConfig(n);
try { try {
LinphoneAddress addr = LinphoneCoreFactory.instance().createLinphoneAddress(prxCfg.getIdentity()); LinphoneAddress addr = LinphoneCoreFactory.instance().createLinphoneAddress(prxCfg.getIdentity());
return getLc().findAuthInfo(addr.getUserName(), null); LinphoneAuthInfo authInfo = getLc().findAuthInfo(addr.getUserName(), null, addr.getDomain());
} catch (LinphoneCoreException e) { } return authInfo;
return null; } catch (LinphoneCoreException e) {
} e.printStackTrace();
else if (n < 0 || n >= authsInfos.length) {
return null;
} }
return null; return null;
} }
/**
* Removes a authInfo from the core and returns a copy of it.
* Useful to edit a authInfo (you should call saveAuthInfo after the modifications to save them).
*/
private LinphoneAuthInfo getClonedAuthInfo(int n) {
LinphoneAuthInfo authInfo = getAuthInfo(n);
if (authInfo == null)
return null;
LinphoneAuthInfo cloneAuthInfo = authInfo.clone();
getLc().removeAuthInfo(authInfo);
return cloneAuthInfo;
}
/**
* Saves a authInfo into the core.
* Useful to save the changes made to a cloned authInfo.
*/
private void saveAuthInfo(LinphoneAuthInfo authInfo) {
getLc().addAuthInfo(authInfo);
}
private String tempUsername; private String tempUsername;
private String tempUserId; private String tempUserId;
private String tempPassword; private String tempPassword;
@ -151,7 +168,7 @@ public class LinphonePreferences {
} catch (NumberFormatException nfe) { } } catch (NumberFormatException nfe) { }
} }
LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(tempUsername, tempUserId, tempPassword, null, null); LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(tempUsername, tempUserId, tempPassword, null, null, tempDomain);
getLc().addProxyConfig(prxCfg); getLc().addProxyConfig(prxCfg);
getLc().addAuthInfo(authInfo); getLc().addAuthInfo(authInfo);
@ -175,12 +192,14 @@ public class LinphonePreferences {
public void setAccountUsername(int n, String username) { public void setAccountUsername(int n, String username) {
String identity = "sip:" + username + "@" + getAccountDomain(n); String identity = "sip:" + username + "@" + getAccountDomain(n);
LinphoneAuthInfo info = getAuthInfo(n); // Get the auth info before editing the proxy config to ensure to get the correct auth info LinphoneAuthInfo info = getClonedAuthInfo(n); // Get the auth info before editing the proxy config to ensure to get the correct auth info
try { try {
LinphoneProxyConfig prxCfg = getProxyConfig(n); LinphoneProxyConfig prxCfg = getProxyConfig(n);
prxCfg.setIdentity(identity); prxCfg.setIdentity(identity);
prxCfg.done(); prxCfg.done();
info.setUsername(username); info.setUsername(username);
saveAuthInfo(info);
} catch (LinphoneCoreException e) { } catch (LinphoneCoreException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -196,7 +215,9 @@ public class LinphonePreferences {
} }
public void setAccountUserId(int n, String userId) { public void setAccountUserId(int n, String userId) {
getAuthInfo(n).setUserId(userId); LinphoneAuthInfo info = getClonedAuthInfo(n);
info.setUserId(userId);
saveAuthInfo(info);
} }
public String getAccountUserId(int n) { public String getAccountUserId(int n) {
@ -209,7 +230,9 @@ public class LinphonePreferences {
} }
public void setAccountPassword(int n, String password) { public void setAccountPassword(int n, String password) {
getAuthInfo(n).setPassword(password); LinphoneAuthInfo info = getClonedAuthInfo(n);
info.setPassword(password);
saveAuthInfo(info);
} }
public String getAccountPassword(int n) { public String getAccountPassword(int n) {
@ -226,6 +249,10 @@ public class LinphonePreferences {
String proxy = "sip:" + domain; String proxy = "sip:" + domain;
try { try {
LinphoneAuthInfo authInfo = getClonedAuthInfo(n);
authInfo.setDomain(domain);
saveAuthInfo(authInfo);
LinphoneProxyConfig prxCfg = getProxyConfig(n); LinphoneProxyConfig prxCfg = getProxyConfig(n);
prxCfg.setIdentity(identity); prxCfg.setIdentity(identity);
prxCfg.setProxy(proxy); prxCfg.setProxy(proxy);

View file

@ -431,6 +431,7 @@ public class ApiFivePlus {
} }
public static void setAudioManagerInCallMode(AudioManager manager) { public static void setAudioManagerInCallMode(AudioManager manager) {
manager.setMode(AudioManager.MODE_IN_CALL); /* Do not use MODE_IN_CALL, because it is reserved to GSM. This is causing conflicts on audio system resulting in silenced audio.*/
//manager.setMode(AudioManager.MODE_IN_CALL);
} }
} }

@ -1 +1 @@
Subproject commit 38b76142a0186d393bea57a7f3e7886652900a91 Subproject commit 3d37b480eb8219d64306a8d16ca1c581a946f18e

@ -1 +1 @@
Subproject commit 2c087aa89ed078b94339afb25c825f5870a24691 Subproject commit 32efc7939ce2bddb7fff78537e2daada19c6ae91

View file

@ -7,7 +7,7 @@ run-basic-tests:
$(SDK_PATH)/android update test-project --path . -m ../ $(SDK_PATH)/android update test-project --path . -m ../
ant debug ant debug
ant installd ant installd
ant test adb shell am instrument -w -e size small org.linphone.test/android.test.InstrumentationTestRunner
run-all-tests: run-all-tests:
$(SDK_PLATFORM_TOOLS_PATH)/adb uninstall org.linphone.test $(SDK_PLATFORM_TOOLS_PATH)/adb uninstall org.linphone.test

View file

@ -13,19 +13,19 @@
<string name="account_create_pwd">wizard42</string> <string name="account_create_pwd">wizard42</string>
<string name="account_create_email">wizard42@linphone.org</string> <string name="account_create_email">wizard42@linphone.org</string>
<string name="account_test_calls_login">viish</string> <string name="account_test_calls_login">wizard13</string>
<string name="account_test_calls_pwd">lucifer</string> <string name="account_test_calls_pwd">wizard13</string>
<string name="account_test_calls_domain">sip.linphone.org</string> <string name="account_test_calls_domain">sip.linphone.org</string>
<string name="contact_name">Cot</string> <string name="contact_name">Wizard</string>
<string name="contact_number">+33952636505</string> <string name="contact_number">+33952636505</string>
<string name="contact_sip">viish@sip.linphone.org</string> <string name="contact_sip">wizard@sip.linphone.org</string>
<string name="chat_test_text_sent">Ping!</string> <string name="chat_test_text_sent">Ping!</string>
<string name="chat_test_text_received">Pong!</string> <string name="chat_test_text_received">Pong!</string>
<string name="conference_account_login">elviish</string> <string name="conference_account_login">wizard16</string>
<string name="conference_account_password">lucifer</string> <string name="conference_account_password">wizard16</string>
<string name="conference_account_domain">sip.linphone.org</string> <string name="conference_account_domain">sip.linphone.org</string>
</resources> </resources>

View file

@ -4,13 +4,12 @@ import junit.framework.Assert;
import org.linphone.LinphoneActivity; import org.linphone.LinphoneActivity;
import org.linphone.LinphoneManager; import org.linphone.LinphoneManager;
import org.linphone.LinphonePreferences;
import org.linphone.core.LinphoneCore.RegistrationState; import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneProxyConfig; import org.linphone.core.LinphoneProxyConfig;
import org.linphone.mediastream.video.capture.hwconf.Hacks; import org.linphone.mediastream.video.capture.hwconf.Hacks;
import org.linphone.setup.SetupActivity; import org.linphone.setup.SetupActivity;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest;
@ -51,24 +50,23 @@ public class AccountAssistant extends SampleTest {
solo.sleep(3000); //Wait for registration to be done solo.sleep(3000); //Wait for registration to be done
LinphoneProxyConfig[] proxyConfigs = LinphoneManager.getLc().getProxyConfigList(); LinphoneProxyConfig[] proxyConfigs = LinphoneManager.getLc().getProxyConfigList();
Assert.assertEquals(proxyConfigs.length, 1); Assert.assertEquals(1, proxyConfigs.length);
LinphoneProxyConfig proxyConfig = proxyConfigs[0]; LinphoneProxyConfig proxyConfig = proxyConfigs[0];
Assert.assertEquals(RegistrationState.RegistrationOk, proxyConfig.getState()); Assert.assertEquals(RegistrationState.RegistrationOk, proxyConfig.getState());
//Check the wizard added sip.linphone.org custom settings //Check the wizard added sip.linphone.org custom settings
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); LinphonePreferences prefs = LinphonePreferences.instance();
String stunServer = prefs.getString(aContext.getString(org.linphone.R.string.pref_stun_server_key), ""); String stunServer = prefs.getStunServer();
Assert.assertEquals(stunServer, aContext.getString(org.linphone.R.string.default_stun)); Assert.assertEquals(aContext.getString(org.linphone.R.string.default_stun), stunServer);
String transport = prefs.getString(aContext.getString(org.linphone.R.string.pref_transport_key), aContext.getString(org.linphone.R.string.pref_transport_udp_key)); String transport = prefs.getTransportKey();
Assert.assertEquals(transport, aContext.getString(org.linphone.R.string.pref_transport_tls_key)); Assert.assertEquals(aContext.getString(org.linphone.R.string.pref_transport_tls_key), transport);
String proxy = prefs.getString(aContext.getString(org.linphone.R.string.pref_proxy_key), ""); String proxy = prefs.getAccountProxy(0);
Assert.assertEquals(proxy, aContext.getString(org.linphone.R.string.default_domain) + ":5223"); Assert.assertEquals(aContext.getString(org.linphone.R.string.default_domain) + ":5223", proxy);
boolean outboundproxy = prefs.getBoolean(aContext.getString(org.linphone.R.string.pref_enable_outbound_proxy_key), false); Assert.assertEquals(true, prefs.isAccountOutboundProxySet(0));
Assert.assertEquals(outboundproxy, true);
boolean ice = prefs.getBoolean(aContext.getString(org.linphone.R.string.pref_ice_enable_key), false); boolean ice = prefs.isIceEnabled();
Assert.assertEquals(ice, true); Assert.assertEquals(ice, true);
} }

View file

@ -5,6 +5,7 @@ import junit.framework.Assert;
import org.linphone.FragmentsAvailable; import org.linphone.FragmentsAvailable;
import org.linphone.LinphoneActivity; import org.linphone.LinphoneActivity;
import org.linphone.LinphoneManager; import org.linphone.LinphoneManager;
import org.linphone.LinphonePreferences;
import org.linphone.core.LinphoneCore.RegistrationState; import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneProxyConfig; import org.linphone.core.LinphoneProxyConfig;
@ -51,7 +52,7 @@ public class AccountManagement extends SampleTest {
solo.goBack(); solo.goBack();
LinphoneProxyConfig[] proxyConfigs = LinphoneManager.getLc().getProxyConfigList(); LinphoneProxyConfig[] proxyConfigs = LinphoneManager.getLc().getProxyConfigList();
Assert.assertEquals(proxyConfigs.length, 1); Assert.assertEquals(1, proxyConfigs.length);
} }
@LargeTest @LargeTest
@ -64,8 +65,7 @@ public class AccountManagement extends SampleTest {
solo.goBack(); solo.goBack();
solo.goBack(); solo.goBack();
LinphoneProxyConfig[] proxyConfigs = LinphoneManager.getLc().getProxyConfigList(); Assert.assertFalse(LinphonePreferences.instance().isAccountEnabled(0));
Assert.assertEquals(proxyConfigs.length, 0);
} }
@LargeTest @LargeTest
@ -78,8 +78,7 @@ public class AccountManagement extends SampleTest {
solo.goBack(); solo.goBack();
solo.goBack(); solo.goBack();
LinphoneProxyConfig[] proxyConfigs = LinphoneManager.getLc().getProxyConfigList(); Assert.assertTrue(LinphonePreferences.instance().isAccountEnabled(0));
Assert.assertEquals(proxyConfigs.length, 1);
} }
private void goToSettings() { private void goToSettings() {

View file

@ -20,7 +20,7 @@ public class AinitTestEnv extends SampleTest {
LinphoneTestManager.createAndStart(aContext, iContext, 1); LinphoneTestManager.createAndStart(aContext, iContext, 1);
solo.sleep(2000); solo.sleep(2000);
Assert.assertEquals(1, LinphoneTestManager.getLc().getProxyConfigList().length);
Assert.assertEquals(RegistrationState.RegistrationOk, LinphoneTestManager.getLc().getProxyConfigList()[0].getState()); Assert.assertEquals(RegistrationState.RegistrationOk, LinphoneTestManager.getLc().getProxyConfigList()[0].getState());
} }
} }

View file

@ -10,6 +10,7 @@ import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCore; import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCoreException; import org.linphone.core.LinphoneCoreException;
import org.linphone.core.PayloadType; import org.linphone.core.PayloadType;
import org.linphone.mediastream.Log;
import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest;
@ -42,6 +43,8 @@ public class CallsAudio extends SampleTest {
@MediumTest @MediumTest
@LargeTest @LargeTest
public void testBOutgoingCallWithDefaultConfig() { public void testBOutgoingCallWithDefaultConfig() {
LinphoneTestManager.getInstance().declineCall = false; // Just in case
solo.enterText(0, iContext.getString(org.linphone.test.R.string.account_test_calls_login) + "@" + iContext.getString(org.linphone.test.R.string.account_test_calls_domain)); solo.enterText(0, iContext.getString(org.linphone.test.R.string.account_test_calls_login) + "@" + iContext.getString(org.linphone.test.R.string.account_test_calls_domain));
solo.clickOnView(solo.getView(org.linphone.R.id.Call)); solo.clickOnView(solo.getView(org.linphone.R.id.Call));
@ -56,7 +59,7 @@ public class CallsAudio extends SampleTest {
@LargeTest @LargeTest
public void testCDTMFRFC2833InPCMUCall() { public void testCDTMFRFC2833InPCMUCall() {
disableAllEnabledAudioCodecs(); disableAllEnabledAudioCodecs();
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_pcmu)); solo.clickOnText("PCMU");
goBackToDialerAfterCodecChanges(); goBackToDialerAfterCodecChanges();
solo.sleep(1000); solo.sleep(1000);
@ -360,8 +363,11 @@ public class CallsAudio extends SampleTest {
solo.sleep(2000); solo.sleep(2000);
LinphoneCall call = LinphoneManager.getLc().getCalls()[0]; LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
if (call.getState() == LinphoneCall.State.OutgoingProgress) { int retry = 0;
solo.sleep(3000); while ((call.getState() == LinphoneCall.State.OutgoingProgress || call.getState() == LinphoneCall.State.IncomingReceived) && retry < 5) {
solo.sleep(1000);
retry++;
Log.w("Call in progress but not running, retry = " + retry);
} }
Assert.assertEquals(LinphoneCall.State.StreamsRunning, call.getState()); Assert.assertEquals(LinphoneCall.State.StreamsRunning, call.getState());
@ -395,72 +401,72 @@ public class CallsAudio extends SampleTest {
goToAudioCodecsSettings(); goToAudioCodecsSettings();
if (isAudioCodecEnabled("opus", 48000)) { if (isAudioCodecEnabled("opus", 48000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_opus)); solo.clickOnText("opus");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("speex", 16000)) { if (isAudioCodecEnabled("speex", 16000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_speex16)); solo.clickOnText("speex");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("speex", 8000)) { if (isAudioCodecEnabled("speex", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_speex8)); solo.clickOnText("speex", 1);
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("ilbc", 8000)) { if (isAudioCodecEnabled("iLBC", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_ilbc)); solo.clickOnText("iLBC");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("AMR", 8000)) { if (isAudioCodecEnabled("AMR", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_amr)); solo.clickOnText("AMR");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("AMRWB", 8000)) { if (isAudioCodecEnabled("AMRWB", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_amrwb)); solo.clickOnText("AMRWB");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("G729", 8000)) { if (isAudioCodecEnabled("G729", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_g729)); solo.clickOnText("G729");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("GSM", 8000)) { if (isAudioCodecEnabled("GSM", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_gsm)); solo.clickOnText("GSM");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("G722", 8000)) { if (isAudioCodecEnabled("G722", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_g722)); solo.clickOnText("G722");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("SILK", 24000)) { if (isAudioCodecEnabled("SILK", 24000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_silk24)); solo.clickOnText("SILK");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("SILK", 16000)) { if (isAudioCodecEnabled("SILK", 16000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_silk16)); solo.clickOnText("SILK", 1);
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("SILK", 8000)) { if (isAudioCodecEnabled("SILK", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_silk8)); solo.clickOnText("SILK", 2);
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("PCMU", 8000)) { if (isAudioCodecEnabled("PCMU", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_pcmu)); solo.clickOnText("PCMU");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("PCMA", 8000)) { if (isAudioCodecEnabled("PCMA", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_pcma)); solo.clickOnText("PCMA");
solo.sleep(500); solo.sleep(500);
} }
} }

View file

@ -10,6 +10,7 @@ import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCore; import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCoreException; import org.linphone.core.LinphoneCoreException;
import org.linphone.core.PayloadType; import org.linphone.core.PayloadType;
import org.linphone.mediastream.Log;
import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest;
@ -26,6 +27,8 @@ public class CallsVideo extends SampleTest {
@MediumTest @MediumTest
@LargeTest @LargeTest
public void testAInit() { public void testAInit() {
LinphoneTestManager.getLc().enableVideo(true, true); // Just in case
//Disable video //Disable video
goToSettings(); goToSettings();
@ -42,6 +45,8 @@ public class CallsVideo extends SampleTest {
@MediumTest @MediumTest
@LargeTest @LargeTest
public void testBOutgoingCallWithDefaultConfig() { public void testBOutgoingCallWithDefaultConfig() {
LinphoneTestManager.getInstance().declineCall = false; // Just in case
solo.enterText(0, iContext.getString(org.linphone.test.R.string.account_test_calls_login) + "@" + iContext.getString(org.linphone.test.R.string.account_test_calls_domain)); solo.enterText(0, iContext.getString(org.linphone.test.R.string.account_test_calls_login) + "@" + iContext.getString(org.linphone.test.R.string.account_test_calls_domain));
solo.clickOnView(solo.getView(org.linphone.R.id.Call)); solo.clickOnView(solo.getView(org.linphone.R.id.Call));
@ -205,6 +210,7 @@ public class CallsVideo extends SampleTest {
assertCallIsCorrectlyRunning(); assertCallIsCorrectlyRunning();
} }
@SmallTest
@MediumTest @MediumTest
@LargeTest @LargeTest
public void testJIncomingVideoCall() { public void testJIncomingVideoCall() {
@ -306,11 +312,15 @@ public class CallsVideo extends SampleTest {
solo.sleep(2000); solo.sleep(2000);
LinphoneCall call = LinphoneManager.getLc().getCalls()[0]; LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
if (call.getState() == LinphoneCall.State.OutgoingProgress) { int retry = 0;
solo.sleep(3000); while ((call.getState() == LinphoneCall.State.OutgoingProgress || call.getState() == LinphoneCall.State.IncomingReceived) && retry < 5) {
solo.sleep(1000);
retry++;
Log.w("Call in progress but not running, retry = " + retry);
} }
Assert.assertEquals(LinphoneCall.State.StreamsRunning, call.getState()); Assert.assertEquals(LinphoneCall.State.StreamsRunning, call.getState());
Assert.assertTrue(call.getCurrentParamsCopy().getVideoEnabled());
} }
private void goToSettings() { private void goToSettings() {
@ -352,72 +362,72 @@ public class CallsVideo extends SampleTest {
goToAudioCodecsSettings(); goToAudioCodecsSettings();
if (isAudioCodecEnabled("opus", 48000)) { if (isAudioCodecEnabled("opus", 48000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_opus)); solo.clickOnText("opus");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("speex", 16000)) { if (isAudioCodecEnabled("speex", 16000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_speex16)); solo.clickOnText("speex");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("speex", 8000)) { if (isAudioCodecEnabled("speex", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_speex8)); solo.clickOnText("speex", 1);
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("ilbc", 8000)) { if (isAudioCodecEnabled("iLBC", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_ilbc)); solo.clickOnText("iLBC");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("AMR", 8000)) { if (isAudioCodecEnabled("AMR", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_amr)); solo.clickOnText("AMR");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("AMRWB", 8000)) { if (isAudioCodecEnabled("AMRWB", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_amrwb)); solo.clickOnText("AMRWB");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("G729", 8000)) { if (isAudioCodecEnabled("G729", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_g729)); solo.clickOnText("G729");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("GSM", 8000)) { if (isAudioCodecEnabled("GSM", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_gsm)); solo.clickOnText("GSM");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("G722", 8000)) { if (isAudioCodecEnabled("G722", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_g722)); solo.clickOnText("G722");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("SILK", 24000)) { if (isAudioCodecEnabled("SILK", 24000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_silk24)); solo.clickOnText("SILK");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("SILK", 16000)) { if (isAudioCodecEnabled("SILK", 16000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_silk16)); solo.clickOnText("SILK", 1);
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("SILK", 8000)) { if (isAudioCodecEnabled("SILK", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_silk8)); solo.clickOnText("SILK", 2);
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("PCMU", 8000)) { if (isAudioCodecEnabled("PCMU", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_pcmu)); solo.clickOnText("PCMU");
solo.sleep(500); solo.sleep(500);
} }
if (isAudioCodecEnabled("PCMA", 8000)) { if (isAudioCodecEnabled("PCMA", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_pcma)); solo.clickOnText("PCMA");
solo.sleep(500); solo.sleep(500);
} }
} }

View file

@ -2,6 +2,7 @@ package org.linphone.test;
import junit.framework.Assert; import junit.framework.Assert;
import org.linphone.ChatStorage;
import org.linphone.LinphoneActivity; import org.linphone.LinphoneActivity;
import org.linphone.core.LinphoneChatMessage; import org.linphone.core.LinphoneChatMessage;
import org.linphone.core.LinphoneChatMessage.State; import org.linphone.core.LinphoneChatMessage.State;
@ -17,8 +18,22 @@ import android.test.suitebuilder.annotation.SmallTest;
*/ */
public class Chat extends SampleTest { public class Chat extends SampleTest {
@SmallTest
@MediumTest
@LargeTest @LargeTest
public void testBEmptyChatHistory() { public void testAEmptyChatHistory() {
goToChat();
ChatStorage chatStorage = ChatStorage.getInstance();
for (String conversation : chatStorage.getChatList()) {
chatStorage.removeDiscussion(conversation);
}
Assert.assertEquals(0, chatStorage.getUnreadMessageCount());
}
@LargeTest
public void testBDisplayEmptyChatHistory() {
goToChat(); goToChat();
Assert.assertTrue(solo.searchText(aContext.getString(org.linphone.R.string.no_chat_history))); Assert.assertTrue(solo.searchText(aContext.getString(org.linphone.R.string.no_chat_history)));
@ -42,7 +57,7 @@ public class Chat extends SampleTest {
} }
@LargeTest @LargeTest
public void testDNotEmptyChatHistory() { public void testDIsNotEmptyChatHistory() {
goToChat(); goToChat();
Assert.assertTrue(solo.searchText(iContext.getString(org.linphone.test.R.string.account_test_calls_login))); Assert.assertTrue(solo.searchText(iContext.getString(org.linphone.test.R.string.account_test_calls_login)));

View file

@ -11,6 +11,7 @@ import org.linphone.LinphoneManager;
import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCore.RegistrationState; import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCoreException; import org.linphone.core.LinphoneCoreException;
import org.linphone.mediastream.Log;
import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest;
@ -45,6 +46,7 @@ public class ConferenceAndMultiCall extends SampleTest {
@MediumTest @MediumTest
@LargeTest @LargeTest
public void testBSimpleConference() { public void testBSimpleConference() {
LinphoneTestManager.getInstance().declineCall = false; // Just in case
startConference(); startConference();
solo.clickOnView(solo.getView(org.linphone.R.id.hangUp)); solo.clickOnView(solo.getView(org.linphone.R.id.hangUp));
@ -255,14 +257,13 @@ public class ConferenceAndMultiCall extends SampleTest {
private void startTwoCalls() { private void startTwoCalls() {
solo.enterText(0, iContext.getString(org.linphone.test.R.string.account_test_calls_login) + "@" + iContext.getString(org.linphone.test.R.string.account_test_calls_domain)); solo.enterText(0, iContext.getString(org.linphone.test.R.string.account_test_calls_login) + "@" + iContext.getString(org.linphone.test.R.string.account_test_calls_domain));
solo.clickOnView(solo.getView(org.linphone.R.id.Call)); solo.clickOnView(solo.getView(org.linphone.R.id.Call));
assertCallIsCorrectlyRunning(1); assertCallIsCorrectlyRunning(1);
solo.clickOnView(solo.getView(org.linphone.R.id.options)); solo.clickOnView(solo.getView(org.linphone.R.id.options));
solo.clickOnView(solo.getView(org.linphone.R.id.addCall)); solo.clickOnView(solo.getView(org.linphone.R.id.addCall));
solo.enterText(0, iContext.getString(org.linphone.test.R.string.conference_account_login) + "@" + iContext.getString(org.linphone.test.R.string.conference_account_domain)); solo.enterText(0, iContext.getString(org.linphone.test.R.string.conference_account_login) + "@" + iContext.getString(org.linphone.test.R.string.conference_account_domain));
solo.clickOnView(solo.getView(org.linphone.R.id.Call)); solo.clickOnView(solo.getView(org.linphone.R.id.Call));
assertCallIsCorrectlyRunning(2); assertCallIsCorrectlyRunning(2);
} }
@ -282,10 +283,14 @@ public class ConferenceAndMultiCall extends SampleTest {
solo.assertCurrentActivity("Expected InCall Activity", InCallActivity.class); solo.assertCurrentActivity("Expected InCall Activity", InCallActivity.class);
solo.sleep(2000); solo.sleep(2000);
Assert.assertEquals(1, LinphoneTestManager.getLc(lcId).getCallsNb());
LinphoneCall call = LinphoneTestManager.getLc(lcId).getCalls()[0]; LinphoneCall call = LinphoneTestManager.getLc(lcId).getCalls()[0];
if (call.getState() == LinphoneCall.State.OutgoingProgress || call.getState() == LinphoneCall.State.IncomingReceived) { int retry = 0;
solo.sleep(3000); while ((call.getState() == LinphoneCall.State.OutgoingProgress || call.getState() == LinphoneCall.State.IncomingReceived) && retry < 5) {
solo.sleep(1000);
retry++;
Log.w("Call in progress but not running, retry = " + retry);
} }
Assert.assertEquals(LinphoneCall.State.StreamsRunning, call.getState()); Assert.assertEquals(LinphoneCall.State.StreamsRunning, call.getState());

View file

@ -20,6 +20,7 @@ import org.linphone.core.LinphoneCore.EcCalibratorStatus;
import org.linphone.core.LinphoneCore.GlobalState; import org.linphone.core.LinphoneCore.GlobalState;
import org.linphone.core.LinphoneCore.MediaEncryption; import org.linphone.core.LinphoneCore.MediaEncryption;
import org.linphone.core.LinphoneCore.RegistrationState; import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCore.Transports;
import org.linphone.core.LinphoneCoreException; import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory; import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListener; import org.linphone.core.LinphoneCoreListener;
@ -37,15 +38,13 @@ import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration.AndroidCamera; import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration.AndroidCamera;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
public class LinphoneTestManager implements LinphoneCoreListener { public class LinphoneTestManager implements LinphoneCoreListener {
private static LinphoneTestManager instance; private static LinphoneTestManager instance;
private Context mIContext; private Context mAContext, mIContext;
private LinphoneCore mLc1, mLc2; private LinphoneCore mLc1, mLc2;
public String lastMessageReceived; public String lastMessageReceived;
@ -53,10 +52,12 @@ public class LinphoneTestManager implements LinphoneCoreListener {
public boolean autoAnswer = true; public boolean autoAnswer = true;
public boolean declineCall = false; public boolean declineCall = false;
private Timer mTimer = new Timer("Linphone scheduler"); private Timer mTimer1 = new Timer("Linphone scheduler 1");
private Timer mTimer2 = new Timer("Linphone scheduler 2");
private LinphoneTestManager(Context ac, Context ic) { private LinphoneTestManager(Context ac, Context ic) {
mIContext = ic; mIContext = ic;
mAContext = ac;
} }
public static LinphoneTestManager createAndStart(Context ac, Context ic, int id) { public static LinphoneTestManager createAndStart(Context ac, Context ic, int id) {
@ -77,7 +78,8 @@ public class LinphoneTestManager implements LinphoneCoreListener {
try { try {
LinphoneCoreFactory.instance().setDebugMode(true, "LinphoneTester"); LinphoneCoreFactory.instance().setDebugMode(true, "LinphoneTester");
final LinphoneCore mLc = LinphoneCoreFactory.instance().createLinphoneCore(this); String basePath = mAContext.getFilesDir().getAbsolutePath();
final LinphoneCore mLc = LinphoneCoreFactory.instance().createLinphoneCore(this, basePath + "/.linphonerc" + id, null, null);
if (id == 2) { if (id == 2) {
mLc2 = mLc; mLc2 = mLc;
} else { } else {
@ -114,10 +116,12 @@ public class LinphoneTestManager implements LinphoneCoreListener {
mLc.iterate(); mLc.iterate();
} }
}; };
mTimer.scheduleAtFixedRate(lTask, 0, 20);
IntentFilter lFilter = new IntentFilter(Intent.ACTION_SCREEN_ON); if (id == 2) {
lFilter.addAction(Intent.ACTION_SCREEN_OFF); mTimer2.scheduleAtFixedRate(lTask, 0, 20);
} else {
mTimer1.scheduleAtFixedRate(lTask, 0, 20);
}
resetCameraFromPreferences(); resetCameraFromPreferences();
} }
@ -137,9 +141,18 @@ public class LinphoneTestManager implements LinphoneCoreListener {
LinphoneManager.getLc().setVideoDevice(camId); LinphoneManager.getLc().setVideoDevice(camId);
} }
public void initFromConf(LinphoneCore mLc) throws LinphoneConfigException { public void initFromConf(LinphoneCore mLc) throws LinphoneConfigException, LinphoneCoreException {
LinphoneCoreFactory.instance().setDebugMode(true, "LinphoneTester"); LinphoneCoreFactory.instance().setDebugMode(true, "LinphoneTester");
// Use TCP with Random port
Transports transports = getLc().getSignalingTransportPorts();
transports.tcp = -1;
transports.udp = 0;
transports.tls = 0;
mLc.setSignalingTransportPorts(transports);
initAccounts(mLc);
mLc.setVideoPolicy(true, true); mLc.setVideoPolicy(true, true);
boolean isVideoEnabled = true; boolean isVideoEnabled = true;
mLc.enableVideo(isVideoEnabled, isVideoEnabled); mLc.enableVideo(isVideoEnabled, isVideoEnabled);
@ -169,7 +182,7 @@ public class LinphoneTestManager implements LinphoneCoreListener {
mLc.setMediaEncryption(me); mLc.setMediaEncryption(me);
} }
public void initAccounts(LinphoneCore mLc) throws LinphoneCoreException { private void initAccounts(LinphoneCore mLc) throws LinphoneCoreException {
mLc.clearAuthInfos(); mLc.clearAuthInfos();
mLc.clearProxyConfigs(); mLc.clearProxyConfigs();
@ -183,7 +196,7 @@ public class LinphoneTestManager implements LinphoneCoreListener {
password = mIContext.getString(org.linphone.test.R.string.conference_account_password); password = mIContext.getString(org.linphone.test.R.string.conference_account_password);
domain = mIContext.getString(org.linphone.test.R.string.conference_account_domain); domain = mIContext.getString(org.linphone.test.R.string.conference_account_domain);
} }
LinphoneAuthInfo lAuthInfo = LinphoneCoreFactory.instance().createAuthInfo(username, password, null); LinphoneAuthInfo lAuthInfo = LinphoneCoreFactory.instance().createAuthInfo(username, password, null, domain);
mLc.addAuthInfo(lAuthInfo); mLc.addAuthInfo(lAuthInfo);
String identity = "sip:" + username +"@" + domain; String identity = "sip:" + username +"@" + domain;
String proxy = "sip:" + domain; String proxy = "sip:" + domain;
@ -243,7 +256,8 @@ public class LinphoneTestManager implements LinphoneCoreListener {
private void doDestroy() { private void doDestroy() {
try { try {
mTimer.cancel(); mTimer1.cancel();
mTimer2.cancel();
mLc1.destroy(); mLc1.destroy();
mLc2.destroy(); mLc2.destroy();
} }

View file

@ -2,6 +2,7 @@ package org.linphone.test;
import org.linphone.LinphoneLauncherActivity; import org.linphone.LinphoneLauncherActivity;
import org.linphone.LinphoneManager; import org.linphone.LinphoneManager;
import org.linphone.core.LinphoneCore;
import android.content.Context; import android.content.Context;
import android.test.ActivityInstrumentationTestCase2; import android.test.ActivityInstrumentationTestCase2;
@ -32,7 +33,10 @@ public abstract class SampleTest extends ActivityInstrumentationTestCase2<Linpho
@Override @Override
public void tearDown() throws Exception { public void tearDown() throws Exception {
LinphoneManager.getLcIfManagerNotDestroyedOrNull().terminateAllCalls(); LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null) {
lc.terminateAllCalls();
}
solo.finishOpenedActivities(); solo.finishOpenedActivities();
} }