New call tests + feature to auto fill email filed in wizard using google account email

This commit is contained in:
Sylvain Berfini 2013-06-18 15:24:39 +02:00
parent 72fc5d9046
commit fdbe887fc7
7 changed files with 188 additions and 9 deletions

View file

@ -34,6 +34,8 @@
<!-- Needed to route the audio to the bluetooth headset if available -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<!-- Needed to pre fill the wizard email field (only if enabled in custom settings) -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true"/>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout"
xmlns:linphone="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -68,6 +69,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="80dip" />
android:layout_marginBottom="80dp" />
</RelativeLayout>

View file

@ -51,6 +51,7 @@
<bool name="disable_options_in_call">false</bool>
<!-- Behavior Settings -->
<bool name="pre_fill_email_in_wizard">true</bool> <!-- Set the email field of the wizard with one of the gmail account registered on the device -->
<bool name="allow_chat_multiline">false</bool>
<bool name="call_last_log_if_adress_is_empty">true</bool>
<bool name="allow_ringing_while_early_media">true</bool>

View file

@ -18,17 +18,21 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import java.net.URL;
import java.util.regex.Pattern;
import org.linphone.LinphoneManager;
import org.linphone.LinphoneService;
import org.linphone.R;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Patterns;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@ -86,6 +90,18 @@ public class WizardFragment extends Fragment {
}
});
if (getResources().getBoolean(R.bool.pre_fill_email_in_wizard)) {
Account[] accounts = AccountManager.get(getActivity()).getAccountsByType("com.google");
for (Account account: accounts) {
if (isEmailCorrect(account.name)) {
String possibleEmail = account.name;
email.setText(possibleEmail);
break;
}
}
}
return view;
}
@ -152,7 +168,8 @@ public class WizardFragment extends Fragment {
}
private boolean isEmailCorrect(String email) {
return email.matches("^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\\.-][a-z0-9]+)*)+\\.[a-z]{2,}$");
Pattern emailPattern = Patterns.EMAIL_ADDRESS;
return emailPattern.matcher(email).matches();
}
private boolean isPasswordCorrect(String password) {

View file

@ -3,15 +3,19 @@ package org.linphone.test;
import junit.framework.Assert;
import org.linphone.InCallActivity;
import org.linphone.IncomingCallActivity;
import org.linphone.LinphoneActivity;
import org.linphone.LinphoneManager;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCoreException;
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;
import android.util.DisplayMetrics;
import android.view.View;
/**
* @author Sylvain Berfini
@ -174,18 +178,59 @@ public class CallsAudio extends SampleTest {
LinphoneTestManager.getInstance().declineCall = false;
}
@MediumTest // TODO: Remove
@SmallTest
@MediumTest
@LargeTest
public void testIIncomingAudioCall() {
LinphoneTestManager.getInstance().declineCall = false; // Just in case
LinphoneTestManager.getLc().enableVideo(false, false);
solo.sleep(2000);
try {
LinphoneTestManager.getLc().invite("sip:" + iContext.getString(org.linphone.test.R.string.account_linphone_login) + "@" + iContext.getString(org.linphone.test.R.string.account_linphone_domain));
} catch (LinphoneCoreException e) {
e.printStackTrace();
}
solo.waitForActivity("IncomingCallActivity", 5000);
solo.assertCurrentActivity("Expected Incoming Call Activity", IncomingCallActivity.class);
solo.sleep(1000);
View topLayout = solo.getView(org.linphone.R.id.topLayout);
int topLayoutHeigh = topLayout.getMeasuredHeight();
DisplayMetrics dm = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
int topOffset = dm.heightPixels - topLayoutHeigh;
int slidersTop = topLayoutHeigh - 80 - topOffset; // 80 is the bottom margin set in incoming.xml
solo.drag(10, topLayout.getMeasuredWidth() - 10, slidersTop, slidersTop, 10);
assertCallIsCorrectlyRunning();
}
@MediumTest // TODO: Remove
@LargeTest
public void testJIncomingVideoCall() {
LinphoneTestManager.getLc().enableVideo(true, true);
solo.sleep(2000);
try {
LinphoneTestManager.getLc().invite("sip:" + iContext.getString(org.linphone.test.R.string.account_linphone_login) + "@" + iContext.getString(org.linphone.test.R.string.account_linphone_domain));
} catch (LinphoneCoreException e) {
e.printStackTrace();
}
solo.waitForActivity("IncomingCallActivity", 5000);
solo.assertCurrentActivity("Expected Incoming Call Activity", IncomingCallActivity.class);
solo.sleep(1000);
View topLayout = solo.getView(org.linphone.R.id.topLayout);
int topLayoutHeigh = topLayout.getMeasuredHeight();
DisplayMetrics dm = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
int topOffset = dm.heightPixels - topLayoutHeigh;
int slidersTop = topLayoutHeigh - 80 - topOffset; // 80 is the bottom margin set in incoming.xml
solo.drag(10, topLayout.getMeasuredWidth() - 10, slidersTop, slidersTop, 10);
assertCallIsCorrectlyRunning();
}
@MediumTest
@ -236,7 +281,6 @@ public class CallsAudio extends SampleTest {
solo.assertCurrentActivity("Expected Linphone Activity", LinphoneActivity.class);
}
@MediumTest
@LargeTest
public void testMSwitchOnVideoInCallIsNotAllowed() {
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));
@ -251,6 +295,62 @@ public class CallsAudio extends SampleTest {
solo.assertCurrentActivity("Expected Linphone Activity", LinphoneActivity.class);
}
@LargeTest
public void testNDeclineIncomingCall() {
LinphoneTestManager.getInstance().declineCall = false; // Just in case
LinphoneTestManager.getLc().enableVideo(false, false);
solo.sleep(2000);
try {
LinphoneTestManager.getLc().invite("sip:" + iContext.getString(org.linphone.test.R.string.account_linphone_login) + "@" + iContext.getString(org.linphone.test.R.string.account_linphone_domain));
} catch (LinphoneCoreException e) {
e.printStackTrace();
}
solo.waitForActivity("IncomingCallActivity", 5000);
solo.assertCurrentActivity("Expected Incoming Call Activity", IncomingCallActivity.class);
solo.sleep(1000);
View topLayout = solo.getView(org.linphone.R.id.topLayout);
int topLayoutHeigh = topLayout.getMeasuredHeight();
DisplayMetrics dm = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
int topOffset = dm.heightPixels - topLayoutHeigh;
int slidersTop = topLayoutHeigh - 80 - topOffset; // 80 is the bottom margin set in incoming.xml
solo.drag(topLayout.getMeasuredWidth() - 10, 10, slidersTop, slidersTop, 10);
}
@MediumTest
@LargeTest
public void testOCancelledIncomingCall() {
LinphoneTestManager.getInstance().declineCall = false; // Just in case
LinphoneTestManager.getLc().enableVideo(false, false);
solo.sleep(2000);
try {
LinphoneTestManager.getLc().invite("sip:" + iContext.getString(org.linphone.test.R.string.account_linphone_login) + "@" + iContext.getString(org.linphone.test.R.string.account_linphone_domain));
} catch (LinphoneCoreException e) {
e.printStackTrace();
}
solo.waitForActivity("IncomingCallActivity", 5000);
solo.assertCurrentActivity("Expected Incoming Call Activity", IncomingCallActivity.class);
LinphoneTestManager.getLc().terminateAllCalls();
solo.waitForActivity("LinphoneActivity", 5000);
solo.assertCurrentActivity("Expected Linphone Activity", LinphoneActivity.class);
}
@MediumTest
@LargeTest
public void testPDisplayMissedCallsNumber() {
solo.waitForActivity("LinphoneActivity", 5000);
solo.assertCurrentActivity("Expected Linphone Activity", LinphoneActivity.class);
Assert.assertTrue(solo.searchText("1"));
}
//TODO: Test each audio codec
private void assertCallIsCorrectlyRunning() {
@ -259,6 +359,11 @@ public class CallsAudio extends SampleTest {
solo.sleep(2000);
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
if (call.getState() == LinphoneCall.State.OutgoingProgress) {
solo.sleep(3000);
}
Assert.assertEquals(LinphoneCall.State.StreamsRunning, call.getState());
}
@ -342,8 +447,7 @@ public class CallsAudio extends SampleTest {
}
}
private void goBackToDialerAfterCodecChanges()
{
private void goBackToDialerAfterCodecChanges() {
solo.goBack();
solo.goBack();

View file

@ -3,15 +3,19 @@ package org.linphone.test;
import junit.framework.Assert;
import org.linphone.InCallActivity;
import org.linphone.IncomingCallActivity;
import org.linphone.LinphoneActivity;
import org.linphone.LinphoneManager;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCoreException;
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;
import android.util.DisplayMetrics;
import android.view.View;
/**
* @author Sylvain Berfini
@ -174,19 +178,58 @@ public class CallsVideo extends SampleTest {
LinphoneTestManager.getInstance().declineCall = false;
}
@MediumTest // TODO: Remove
@LargeTest
public void testIIncomingAudioCall() {
LinphoneTestManager.getInstance().declineCall = false; // Just in case
LinphoneTestManager.getLc().enableVideo(false, false);
solo.sleep(2000);
try {
LinphoneTestManager.getLc().invite("sip:" + iContext.getString(org.linphone.test.R.string.account_linphone_login) + "@" + iContext.getString(org.linphone.test.R.string.account_linphone_domain));
} catch (LinphoneCoreException e) {
e.printStackTrace();
}
solo.waitForActivity("IncomingCallActivity", 5000);
solo.assertCurrentActivity("Expected Incoming Call Activity", IncomingCallActivity.class);
solo.sleep(1000);
View topLayout = solo.getView(org.linphone.R.id.topLayout);
int topLayoutHeigh = topLayout.getMeasuredHeight();
DisplayMetrics dm = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
int topOffset = dm.heightPixels - topLayoutHeigh;
int slidersTop = topLayoutHeigh - 80 - topOffset; // 80 is the bottom margin set in incoming.xml
solo.drag(10, topLayout.getMeasuredWidth() - 10, slidersTop, slidersTop, 10);
assertCallIsCorrectlyRunning();
}
@MediumTest // TODO: Remove
@MediumTest
@LargeTest
public void testJIncomingVideoCall() {
LinphoneTestManager.getLc().enableVideo(true, true);
solo.sleep(2000);
try {
LinphoneTestManager.getLc().invite("sip:" + iContext.getString(org.linphone.test.R.string.account_linphone_login) + "@" + iContext.getString(org.linphone.test.R.string.account_linphone_domain));
} catch (LinphoneCoreException e) {
e.printStackTrace();
}
solo.waitForActivity("IncomingCallActivity", 5000);
solo.assertCurrentActivity("Expected Incoming Call Activity", IncomingCallActivity.class);
solo.sleep(1000);
View topLayout = solo.getView(org.linphone.R.id.topLayout);
int topLayoutHeigh = topLayout.getMeasuredHeight();
DisplayMetrics dm = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
int topOffset = dm.heightPixels - topLayoutHeigh;
int slidersTop = topLayoutHeigh - 80 - topOffset; // 80 is the bottom margin set in incoming.xml
solo.drag(10, topLayout.getMeasuredWidth() - 10, slidersTop, slidersTop, 10);
assertCallIsCorrectlyRunning();
}
//TODO: Test each video codec
@ -262,6 +305,11 @@ public class CallsVideo extends SampleTest {
solo.sleep(2000);
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
if (call.getState() == LinphoneCall.State.OutgoingProgress) {
solo.sleep(3000);
}
Assert.assertEquals(LinphoneCall.State.StreamsRunning, call.getState());
}

View file

@ -1,5 +1,10 @@
package org.linphone.test;
import static android.content.Intent.ACTION_MAIN;
import org.linphone.LinphoneService;
import android.content.Intent;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
@ -14,6 +19,7 @@ public class ZShutdownTestEnv extends SampleTest {
@LargeTest
public void testZShutDownLinphoneCore() {
LinphoneTestManager.destroy();
aContext.stopService(new Intent(ACTION_MAIN).setClass(aContext, LinphoneService.class));
}
}