forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
+1
-21
@@ -274,27 +274,7 @@ public class CreateAndSendTrackTest extends ActivityInstrumentationTestCase2<Tra
|
|||||||
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.send_google_send_now),
|
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.send_google_send_now),
|
||||||
true, true);
|
true, true);
|
||||||
|
|
||||||
// Check whether no account is binded with this device.
|
if(!GoogleUtils.checkAccountStatusDialog()) {
|
||||||
if (EndToEndTestUtils.SOLO.waitForText(
|
|
||||||
activityMyTracks.getString(R.string.send_google_no_account_title), 1,
|
|
||||||
EndToEndTestUtils.SHORT_WAIT_TIME)) {
|
|
||||||
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true,
|
|
||||||
true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check whether need to choose account.
|
|
||||||
if (EndToEndTestUtils.SOLO.waitForText(
|
|
||||||
activityMyTracks.getString(R.string.send_google_choose_account_title), 1,
|
|
||||||
EndToEndTestUtils.SHORT_WAIT_TIME)) {
|
|
||||||
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), false,
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check whether no account permission.
|
|
||||||
if (EndToEndTestUtils.SOLO.waitForText(
|
|
||||||
activityMyTracks.getString(R.string.send_google_no_account_permission), 1,
|
|
||||||
EndToEndTestUtils.SHORT_WAIT_TIME)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import com.google.android.apps.mytracks.io.gdata.maps.XmlMapsGDataParserFactory;
|
|||||||
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
||||||
import com.google.android.apps.mytracks.util.SystemUtils;
|
import com.google.android.apps.mytracks.util.SystemUtils;
|
||||||
import com.google.android.common.gdata.AndroidXmlParserFactory;
|
import com.google.android.common.gdata.AndroidXmlParserFactory;
|
||||||
|
import com.google.android.maps.mytracks.R;
|
||||||
import com.google.api.client.googleapis.GoogleHeaders;
|
import com.google.api.client.googleapis.GoogleHeaders;
|
||||||
import com.google.api.client.googleapis.MethodOverride;
|
import com.google.api.client.googleapis.MethodOverride;
|
||||||
import com.google.api.client.http.GenericUrl;
|
import com.google.api.client.http.GenericUrl;
|
||||||
@@ -361,5 +362,38 @@ public class GoogleUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the status of account is right to use.
|
||||||
|
*
|
||||||
|
* @return true means the status of account is good for sending
|
||||||
|
*/
|
||||||
|
public static boolean checkAccountStatusDialog() {
|
||||||
|
// Check whether no account is binded with this device.
|
||||||
|
if (EndToEndTestUtils.SOLO.waitForText(
|
||||||
|
EndToEndTestUtils.activityMytracks.getString(R.string.send_google_no_account_title), 1,
|
||||||
|
EndToEndTestUtils.SHORT_WAIT_TIME)) {
|
||||||
|
EndToEndTestUtils.getButtonOnScreen(EndToEndTestUtils.activityMytracks.getString(R.string.generic_ok), true,
|
||||||
|
true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check whether need to choose account.
|
||||||
|
if (EndToEndTestUtils.SOLO.waitForText(
|
||||||
|
EndToEndTestUtils.activityMytracks.getString(R.string.send_google_choose_account_title), 1,
|
||||||
|
EndToEndTestUtils.SHORT_WAIT_TIME)) {
|
||||||
|
EndToEndTestUtils.getButtonOnScreen(EndToEndTestUtils.activityMytracks.getString(R.string.generic_ok), false,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check whether no account permission.
|
||||||
|
if (EndToEndTestUtils.SOLO.waitForText(
|
||||||
|
EndToEndTestUtils.activityMytracks.getString(R.string.send_google_no_account_permission), 1,
|
||||||
|
EndToEndTestUtils.SHORT_WAIT_TIME)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,12 @@ import com.google.android.maps.mytracks.R;
|
|||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.Instrumentation;
|
import android.app.Instrumentation;
|
||||||
|
import android.content.Intent;
|
||||||
import android.test.ActivityInstrumentationTestCase2;
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests some menu items of MyTracks.
|
* Tests some menu items of MyTracks.
|
||||||
@@ -90,6 +94,63 @@ public class MenuItemsTest extends ActivityInstrumentationTestCase2<TrackListAct
|
|||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
assertEquals(1, EndToEndTestUtils.SOLO.getCurrentListViews().size());
|
assertEquals(1, EndToEndTestUtils.SOLO.getCurrentListViews().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the share menu item. This test to check whether crash will happen during the share.
|
||||||
|
*/
|
||||||
|
public void testShareActivity() {
|
||||||
|
// Try all share item.
|
||||||
|
for (int i = 0;; i++) {
|
||||||
|
View oneItemView = findShareItem(i);
|
||||||
|
if (oneItemView == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EndToEndTestUtils.SOLO.clickOnView(oneItemView);
|
||||||
|
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true,
|
||||||
|
true);
|
||||||
|
if(!GoogleUtils.checkAccountStatusDialog()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Waiting the send is finish.
|
||||||
|
while (EndToEndTestUtils.SOLO.waitForText(
|
||||||
|
activityMyTracks.getString(R.string.generic_progress_title), 1,
|
||||||
|
EndToEndTestUtils.SHORT_WAIT_TIME)) {}
|
||||||
|
|
||||||
|
// Check whether data is correct on Google Map and then delete it.
|
||||||
|
assertTrue(GoogleUtils.deleteMap(EndToEndTestUtils.trackName, activityMyTracks));
|
||||||
|
|
||||||
|
// Display the MyTracks activity for the share item may startup other
|
||||||
|
// applications.
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.setClass(activityMyTracks.getApplicationContext(), TrackListActivity.class);
|
||||||
|
activityMyTracks.getApplicationContext().startActivity(intent);
|
||||||
|
EndToEndTestUtils.sleep(EndToEndTestUtils.NORMAL_WAIT_TIME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the view to click the share item by item index.
|
||||||
|
* @param index of a share item
|
||||||
|
* @return null when no such item
|
||||||
|
*/
|
||||||
|
private View findShareItem(int index) {
|
||||||
|
EndToEndTestUtils.createTrackIfEmpty(0, false);
|
||||||
|
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_share), true);
|
||||||
|
ArrayList<View> cc = EndToEndTestUtils.SOLO.getViews();
|
||||||
|
int i = 0;
|
||||||
|
for (View view : cc) {
|
||||||
|
String name = view.getParent().getClass().getName();
|
||||||
|
// Each share item is in one Linear layout which is the child view of
|
||||||
|
if (name.indexOf("RecycleListView") > 0) {
|
||||||
|
if (index == i) {
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user