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:
ant partial-clean
$(MAKE) -C tests
$(MAKE) -C tests run-basic-tests
run-all-tests:
ant partial-clean
$(MAKE) -C tests
$(MAKE) -C tests run-all-tests
clean-ndk-build:
$(NDK_PATH)/ndk-build clean $(LIBLINPHONE_OPTIONS)

View file

@ -106,23 +106,40 @@ public class LinphonePreferences {
}
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);
try {
LinphoneAddress addr = LinphoneCoreFactory.instance().createLinphoneAddress(prxCfg.getIdentity());
return getLc().findAuthInfo(addr.getUserName(), null);
} catch (LinphoneCoreException e) { }
return null;
}
else if (n < 0 || n >= authsInfos.length) {
return null;
LinphoneProxyConfig prxCfg = getProxyConfig(n);
try {
LinphoneAddress addr = LinphoneCoreFactory.instance().createLinphoneAddress(prxCfg.getIdentity());
LinphoneAuthInfo authInfo = getLc().findAuthInfo(addr.getUserName(), null, addr.getDomain());
return authInfo;
} catch (LinphoneCoreException e) {
e.printStackTrace();
}
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 tempUserId;
private String tempPassword;
@ -151,7 +168,7 @@ public class LinphonePreferences {
} 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().addAuthInfo(authInfo);
@ -175,12 +192,14 @@ public class LinphonePreferences {
public void setAccountUsername(int n, String username) {
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 {
LinphoneProxyConfig prxCfg = getProxyConfig(n);
prxCfg.setIdentity(identity);
prxCfg.done();
info.setUsername(username);
saveAuthInfo(info);
} catch (LinphoneCoreException e) {
e.printStackTrace();
}
@ -196,7 +215,9 @@ public class LinphonePreferences {
}
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) {
@ -209,7 +230,9 @@ public class LinphonePreferences {
}
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) {
@ -226,6 +249,10 @@ public class LinphonePreferences {
String proxy = "sip:" + domain;
try {
LinphoneAuthInfo authInfo = getClonedAuthInfo(n);
authInfo.setDomain(domain);
saveAuthInfo(authInfo);
LinphoneProxyConfig prxCfg = getProxyConfig(n);
prxCfg.setIdentity(identity);
prxCfg.setProxy(proxy);

View file

@ -431,6 +431,7 @@ public class ApiFivePlus {
}
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 ../
ant debug
ant installd
ant test
adb shell am instrument -w -e size small org.linphone.test/android.test.InstrumentationTestRunner
run-all-tests:
$(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_email">wizard42@linphone.org</string>
<string name="account_test_calls_login">viish</string>
<string name="account_test_calls_pwd">lucifer</string>
<string name="account_test_calls_login">wizard13</string>
<string name="account_test_calls_pwd">wizard13</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_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_received">Pong!</string>
<string name="conference_account_login">elviish</string>
<string name="conference_account_password">lucifer</string>
<string name="conference_account_login">wizard16</string>
<string name="conference_account_password">wizard16</string>
<string name="conference_account_domain">sip.linphone.org</string>
</resources>

View file

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

View file

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

View file

@ -20,7 +20,7 @@ public class AinitTestEnv extends SampleTest {
LinphoneTestManager.createAndStart(aContext, iContext, 1);
solo.sleep(2000);
Assert.assertEquals(1, LinphoneTestManager.getLc().getProxyConfigList().length);
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.LinphoneCoreException;
import org.linphone.core.PayloadType;
import org.linphone.mediastream.Log;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest;
@ -42,6 +43,8 @@ public class CallsAudio extends SampleTest {
@MediumTest
@LargeTest
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.clickOnView(solo.getView(org.linphone.R.id.Call));
@ -56,7 +59,7 @@ public class CallsAudio extends SampleTest {
@LargeTest
public void testCDTMFRFC2833InPCMUCall() {
disableAllEnabledAudioCodecs();
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_pcmu));
solo.clickOnText("PCMU");
goBackToDialerAfterCodecChanges();
solo.sleep(1000);
@ -360,8 +363,11 @@ public class CallsAudio extends SampleTest {
solo.sleep(2000);
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
if (call.getState() == LinphoneCall.State.OutgoingProgress) {
solo.sleep(3000);
int retry = 0;
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());
@ -395,72 +401,72 @@ public class CallsAudio extends SampleTest {
goToAudioCodecsSettings();
if (isAudioCodecEnabled("opus", 48000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_opus));
solo.clickOnText("opus");
solo.sleep(500);
}
if (isAudioCodecEnabled("speex", 16000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_speex16));
solo.clickOnText("speex");
solo.sleep(500);
}
if (isAudioCodecEnabled("speex", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_speex8));
solo.clickOnText("speex", 1);
solo.sleep(500);
}
if (isAudioCodecEnabled("ilbc", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_ilbc));
if (isAudioCodecEnabled("iLBC", 8000)) {
solo.clickOnText("iLBC");
solo.sleep(500);
}
if (isAudioCodecEnabled("AMR", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_amr));
solo.clickOnText("AMR");
solo.sleep(500);
}
if (isAudioCodecEnabled("AMRWB", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_amrwb));
solo.clickOnText("AMRWB");
solo.sleep(500);
}
if (isAudioCodecEnabled("G729", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_g729));
solo.clickOnText("G729");
solo.sleep(500);
}
if (isAudioCodecEnabled("GSM", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_gsm));
solo.clickOnText("GSM");
solo.sleep(500);
}
if (isAudioCodecEnabled("G722", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_g722));
solo.clickOnText("G722");
solo.sleep(500);
}
if (isAudioCodecEnabled("SILK", 24000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_silk24));
solo.clickOnText("SILK");
solo.sleep(500);
}
if (isAudioCodecEnabled("SILK", 16000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_silk16));
solo.clickOnText("SILK", 1);
solo.sleep(500);
}
if (isAudioCodecEnabled("SILK", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_silk8));
solo.clickOnText("SILK", 2);
solo.sleep(500);
}
if (isAudioCodecEnabled("PCMU", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_pcmu));
solo.clickOnText("PCMU");
solo.sleep(500);
}
if (isAudioCodecEnabled("PCMA", 8000)) {
solo.clickOnText(aContext.getString(org.linphone.R.string.pref_codec_pcma));
solo.clickOnText("PCMA");
solo.sleep(500);
}
}

View file

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

View file

@ -2,6 +2,7 @@ package org.linphone.test;
import junit.framework.Assert;
import org.linphone.ChatStorage;
import org.linphone.LinphoneActivity;
import org.linphone.core.LinphoneChatMessage;
import org.linphone.core.LinphoneChatMessage.State;
@ -17,8 +18,22 @@ import android.test.suitebuilder.annotation.SmallTest;
*/
public class Chat extends SampleTest {
@SmallTest
@MediumTest
@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();
Assert.assertTrue(solo.searchText(aContext.getString(org.linphone.R.string.no_chat_history)));
@ -42,7 +57,7 @@ public class Chat extends SampleTest {
}
@LargeTest
public void testDNotEmptyChatHistory() {
public void testDIsNotEmptyChatHistory() {
goToChat();
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.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCoreException;
import org.linphone.mediastream.Log;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest;
@ -45,6 +46,7 @@ public class ConferenceAndMultiCall extends SampleTest {
@MediumTest
@LargeTest
public void testBSimpleConference() {
LinphoneTestManager.getInstance().declineCall = false; // Just in case
startConference();
solo.clickOnView(solo.getView(org.linphone.R.id.hangUp));
@ -255,14 +257,13 @@ public class ConferenceAndMultiCall extends SampleTest {
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.clickOnView(solo.getView(org.linphone.R.id.Call));
assertCallIsCorrectlyRunning(1);
solo.clickOnView(solo.getView(org.linphone.R.id.options));
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.clickOnView(solo.getView(org.linphone.R.id.Call));
assertCallIsCorrectlyRunning(2);
}
@ -282,10 +283,14 @@ public class ConferenceAndMultiCall extends SampleTest {
solo.assertCurrentActivity("Expected InCall Activity", InCallActivity.class);
solo.sleep(2000);
Assert.assertEquals(1, LinphoneTestManager.getLc(lcId).getCallsNb());
LinphoneCall call = LinphoneTestManager.getLc(lcId).getCalls()[0];
if (call.getState() == LinphoneCall.State.OutgoingProgress || call.getState() == LinphoneCall.State.IncomingReceived) {
solo.sleep(3000);
int retry = 0;
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());

View file

@ -20,6 +20,7 @@ import org.linphone.core.LinphoneCore.EcCalibratorStatus;
import org.linphone.core.LinphoneCore.GlobalState;
import org.linphone.core.LinphoneCore.MediaEncryption;
import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCore.Transports;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
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 android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager.NameNotFoundException;
import android.telephony.TelephonyManager;
public class LinphoneTestManager implements LinphoneCoreListener {
private static LinphoneTestManager instance;
private Context mIContext;
private Context mAContext, mIContext;
private LinphoneCore mLc1, mLc2;
public String lastMessageReceived;
@ -53,10 +52,12 @@ public class LinphoneTestManager implements LinphoneCoreListener {
public boolean autoAnswer = true;
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) {
mIContext = ic;
mAContext = ac;
}
public static LinphoneTestManager createAndStart(Context ac, Context ic, int id) {
@ -77,7 +78,8 @@ public class LinphoneTestManager implements LinphoneCoreListener {
try {
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) {
mLc2 = mLc;
} else {
@ -114,10 +116,12 @@ public class LinphoneTestManager implements LinphoneCoreListener {
mLc.iterate();
}
};
mTimer.scheduleAtFixedRate(lTask, 0, 20);
IntentFilter lFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
lFilter.addAction(Intent.ACTION_SCREEN_OFF);
if (id == 2) {
mTimer2.scheduleAtFixedRate(lTask, 0, 20);
} else {
mTimer1.scheduleAtFixedRate(lTask, 0, 20);
}
resetCameraFromPreferences();
}
@ -137,9 +141,18 @@ public class LinphoneTestManager implements LinphoneCoreListener {
LinphoneManager.getLc().setVideoDevice(camId);
}
public void initFromConf(LinphoneCore mLc) throws LinphoneConfigException {
public void initFromConf(LinphoneCore mLc) throws LinphoneConfigException, LinphoneCoreException {
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);
boolean isVideoEnabled = true;
mLc.enableVideo(isVideoEnabled, isVideoEnabled);
@ -169,7 +182,7 @@ public class LinphoneTestManager implements LinphoneCoreListener {
mLc.setMediaEncryption(me);
}
public void initAccounts(LinphoneCore mLc) throws LinphoneCoreException {
private void initAccounts(LinphoneCore mLc) throws LinphoneCoreException {
mLc.clearAuthInfos();
mLc.clearProxyConfigs();
@ -183,7 +196,7 @@ public class LinphoneTestManager implements LinphoneCoreListener {
password = mIContext.getString(org.linphone.test.R.string.conference_account_password);
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);
String identity = "sip:" + username +"@" + domain;
String proxy = "sip:" + domain;
@ -243,7 +256,8 @@ public class LinphoneTestManager implements LinphoneCoreListener {
private void doDestroy() {
try {
mTimer.cancel();
mTimer1.cancel();
mTimer2.cancel();
mLc1.destroy();
mLc2.destroy();
}

View file

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