forked from upstream-mirrors/OpenTracks
Change some code style.
This commit is contained in:
@@ -62,9 +62,11 @@ public class DeleteTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_delete_all), true);
|
||||
instrumentation.waitForIdleSync();
|
||||
EndToEndTestUtils.rotateAllActivities();
|
||||
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
|
||||
EndToEndTestUtils
|
||||
.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
|
||||
instrumentation.waitForIdleSync();
|
||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks.getString(R.string.track_list_empty_message)));
|
||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
|
||||
.getString(R.string.track_list_empty_message)));
|
||||
// There is no track now.
|
||||
trackListView = EndToEndTestUtils.SOLO.getCurrentListViews();
|
||||
assertEquals(0, trackListView.get(0).getCount());
|
||||
@@ -75,7 +77,8 @@ public class DeleteTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
EndToEndTestUtils.GPX.toUpperCase()));
|
||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
|
||||
.getString(R.string.sd_card_save_error_no_track)));
|
||||
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
|
||||
EndToEndTestUtils
|
||||
.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,7 +94,7 @@ public class DeleteTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
EndToEndTestUtils.SOLO.clickOnView(trackListView.get(0).getChildAt(0));
|
||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_delete), true);
|
||||
EndToEndTestUtils
|
||||
.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
|
||||
.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
|
||||
instrumentation.waitForIdleSync();
|
||||
trackListView = EndToEndTestUtils.SOLO.getCurrentListViews();
|
||||
int trackNumberNew = trackListView.get(0).getCount();
|
||||
|
||||
+23
-23
@@ -192,24 +192,24 @@ public class EndToEndTestUtils {
|
||||
setIsEmulator();
|
||||
EndToEndTestUtils.instrumentation = instrumentation;
|
||||
EndToEndTestUtils.activityMytracks = activityMyTracks;
|
||||
EndToEndTestUtils.SOLO = new Solo(EndToEndTestUtils.instrumentation,
|
||||
SOLO = new Solo(EndToEndTestUtils.instrumentation,
|
||||
EndToEndTestUtils.activityMytracks);
|
||||
// Check if open MyTracks first time after install. If so, there would be a
|
||||
// welcome view with accept buttons. And makes sure only check once.
|
||||
if (!EndToEndTestUtils.isCheckedFirstLaunch) {
|
||||
if ((EndToEndTestUtils.getButtonOnScreen(EndToEndTestUtils.activityMytracks
|
||||
if (!isCheckedFirstLaunch) {
|
||||
if ((getButtonOnScreen(EndToEndTestUtils.activityMytracks
|
||||
.getString(R.string.eula_accept), false, false) != null)) {
|
||||
EndToEndTestUtils.verifyFirstLaunch();
|
||||
} else if (EndToEndTestUtils.SOLO.waitForText(
|
||||
verifyFirstLaunch();
|
||||
} else if (SOLO.waitForText(
|
||||
// After reset setting, welcome page will show again.
|
||||
activityMytracks.getString(R.string.welcome_title), 0, 500)) {
|
||||
resetPreferredUnits();
|
||||
}
|
||||
checkLanguage();
|
||||
EndToEndTestUtils.isCheckedFirstLaunch = true;
|
||||
EndToEndTestUtils.setHasActionBar();
|
||||
EndToEndTestUtils.resetAllSettings(activityMyTracks, false);
|
||||
} else if (EndToEndTestUtils.SOLO.waitForText(
|
||||
isCheckedFirstLaunch = true;
|
||||
setHasActionBar();
|
||||
resetAllSettings(activityMyTracks, false);
|
||||
} else if (SOLO.waitForText(
|
||||
// After reset setting, welcome page will show again.
|
||||
activityMytracks.getString(R.string.welcome_title), 0, 500)) {
|
||||
resetPreferredUnits();
|
||||
@@ -266,7 +266,7 @@ public class EndToEndTestUtils {
|
||||
*/
|
||||
static void createSimpleTrack(int numberOfGpsData) {
|
||||
startRecording();
|
||||
EndToEndTestUtils.sendGps(numberOfGpsData);
|
||||
sendGps(numberOfGpsData);
|
||||
instrumentation.waitForIdleSync();
|
||||
stopRecording(true);
|
||||
}
|
||||
@@ -301,11 +301,11 @@ public class EndToEndTestUtils {
|
||||
* activity
|
||||
*/
|
||||
static void createTrackIfEmpty(int gpsNumber, boolean showTrackList) {
|
||||
if (EndToEndTestUtils.isTrackListEmpty(!showTrackList)) {
|
||||
if (isTrackListEmpty(!showTrackList)) {
|
||||
// Create a simple track.
|
||||
EndToEndTestUtils.createSimpleTrack(gpsNumber);
|
||||
createSimpleTrack(gpsNumber);
|
||||
if (showTrackList) {
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
SOLO.goBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,17 +374,17 @@ public class EndToEndTestUtils {
|
||||
SOLO.clickOnText(activityMytracks.getString(R.string.menu_stop_recording));
|
||||
}
|
||||
if (isSave) {
|
||||
EndToEndTestUtils.SOLO.waitForText(activityMytracks.getString(R.string.generic_save), 1, 5000);
|
||||
SOLO.waitForText(activityMytracks.getString(R.string.generic_save), 1, 5000);
|
||||
// Make every track name is unique to make sure every check can be
|
||||
// trusted.
|
||||
EndToEndTestUtils.trackName = EndToEndTestUtils.TRACK_NAME_PREFIX
|
||||
trackName = TRACK_NAME_PREFIX
|
||||
+ System.currentTimeMillis();
|
||||
SOLO.sendKey(KeyEvent.KEYCODE_DEL);
|
||||
SOLO.enterText(0, trackName);
|
||||
SOLO.enterText(1, DEFAULTACTIVITY);
|
||||
if(!EndToEndTestUtils.isEmulator) {
|
||||
if(!isEmulator) {
|
||||
// Close soft keyboard.
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
SOLO.goBack();
|
||||
}
|
||||
SOLO.clickLongOnText(activityMytracks.getString(R.string.generic_save));
|
||||
instrumentation.waitForIdleSync();
|
||||
@@ -494,7 +494,7 @@ public class EndToEndTestUtils {
|
||||
* Rotates the current activity.
|
||||
*/
|
||||
static void rotateCurrentActivity() {
|
||||
EndToEndTestUtils.rotateActivity(SOLO.getCurrentActivity());
|
||||
rotateActivity(SOLO.getCurrentActivity());
|
||||
instrumentation.waitForIdleSync();
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ public class EndToEndTestUtils {
|
||||
static void rotateAllActivities() {
|
||||
ArrayList<Activity> allActivities = SOLO.getAllOpenedActivities();
|
||||
for (Activity activity : allActivities) {
|
||||
EndToEndTestUtils.rotateActivity(activity);
|
||||
rotateActivity(activity);
|
||||
}
|
||||
|
||||
instrumentation.waitForIdleSync();
|
||||
@@ -588,7 +588,7 @@ public class EndToEndTestUtils {
|
||||
* @return the text view, null means can not find it
|
||||
*/
|
||||
static TextView findTextView(String findText, View parent) {
|
||||
ArrayList<TextView> textViews = EndToEndTestUtils.SOLO.getCurrentTextViews(parent);
|
||||
ArrayList<TextView> textViews = SOLO.getCurrentTextViews(parent);
|
||||
for (TextView textView : textViews) {
|
||||
String text = (String) textView.getText();
|
||||
if (textView.isShown() && text.endsWith(findText)) {
|
||||
@@ -604,7 +604,7 @@ public class EndToEndTestUtils {
|
||||
* @return the ChartView or null if not find
|
||||
*/
|
||||
static ChartView getChartView() {
|
||||
ArrayList<View> views = EndToEndTestUtils.SOLO.getViews();
|
||||
ArrayList<View> views = SOLO.getViews();
|
||||
for (View view : views) {
|
||||
if (view instanceof ChartView) {
|
||||
return (ChartView) view;
|
||||
@@ -620,13 +620,13 @@ public class EndToEndTestUtils {
|
||||
* @param keepInSettingList whether keep in setting list or not
|
||||
*/
|
||||
public static void resetAllSettings(Activity activityMyTracks, boolean keepInSettingList) {
|
||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
|
||||
findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
|
||||
SOLO.waitForText(activityMyTracks.getString(R.string.settings_reset));
|
||||
SOLO.clickOnText(activityMyTracks.getString(R.string.settings_reset));
|
||||
getButtonOnScreen(activityMytracks.getString(R.string.generic_ok), true, true);
|
||||
instrumentation.waitForIdleSync();
|
||||
if (!keepInSettingList) {
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
SOLO.goBack();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,17 +62,20 @@ import java.util.Locale;
|
||||
* @author Youtao Liu
|
||||
*/
|
||||
public class GoogleUtils {
|
||||
private static Account account;
|
||||
public static final String LOG_TAG = "MyTracksTest";
|
||||
public static final String DOCUMENT_NAME_PREFIX = "My Tracks";
|
||||
public static final String SPREADSHEET_NAME = DOCUMENT_NAME_PREFIX + "-" + EndToEndTestUtils.DEFAULTACTIVITY;
|
||||
|
||||
/**
|
||||
* Gets the account to access Google Services.
|
||||
*
|
||||
* @param context context used to get account
|
||||
* @return the first account which is bound with current device
|
||||
*/
|
||||
private static Account getAccount(Context context) {
|
||||
return account == null ? account = AccountManager.get(context).getAccountsByType(
|
||||
Constants.ACCOUNT_TYPE)[0] : account;
|
||||
return AccountManager.get(context).getAccountsByType(Constants.ACCOUNT_TYPE)[0];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets Google maps of a user.
|
||||
*
|
||||
@@ -81,7 +84,6 @@ public class GoogleUtils {
|
||||
* @return true means set successfully
|
||||
*/
|
||||
private static ArrayList<MapsMapMetadata> getMaps(Context context, MapsClient mapsClient) {
|
||||
// Reset the per request states
|
||||
String authToken = null;
|
||||
ArrayList<String> mapIds = new ArrayList<String>();
|
||||
ArrayList<MapsMapMetadata> mapData = new ArrayList<MapsMapMetadata>();
|
||||
@@ -176,7 +178,7 @@ public class GoogleUtils {
|
||||
* @param activity to get context
|
||||
* @return the entry of the document, null means can not find the spreadsheet.
|
||||
*/
|
||||
private static Entry searchSepeadsheetByTitle(String title, Activity activity) {
|
||||
private static Entry searchSpreadsheetByTitle(String title, Activity activity) {
|
||||
Context context = activity.getApplicationContext();
|
||||
DocumentsClient documentsClient = new DocumentsClient(
|
||||
GDataClientFactory.getGDataClient(context),
|
||||
@@ -214,8 +216,8 @@ public class GoogleUtils {
|
||||
* @param isDelete whether delete the information of this track in the document
|
||||
* @return true means find the track name in the spreadsheet
|
||||
*/
|
||||
public static boolean searchTrackTitleInSpreadsheet(String title, Activity activity, String spreadsheetTitle, boolean isDelete) {
|
||||
String spreadsheetId = searchSepeadsheetByTitle(spreadsheetTitle, activity).getId().replace(SendDocsUtils.SPREADSHEET_ID_PREFIX, "");
|
||||
private static boolean searchTrackTitleInSpreadsheet(String title, Activity activity, String spreadsheetTitle, boolean isDelete) {
|
||||
String spreadsheetId = searchSpreadsheetByTitle(spreadsheetTitle, activity).getId().replace(SendDocsUtils.SPREADSHEET_ID_PREFIX, "");
|
||||
if(spreadsheetId == null) {
|
||||
Log.d(LOG_TAG, "Unable to find the spreadsheet -- " + spreadsheetTitle);
|
||||
return false;
|
||||
@@ -249,6 +251,28 @@ public class GoogleUtils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches a track in spreadsheet.
|
||||
*
|
||||
* @param title the track name to search
|
||||
* @param activity to get context
|
||||
* @return true means find the track name in the spreadsheet
|
||||
*/
|
||||
public static boolean searchTrackInSpreadSheet(String title, Activity activity) {
|
||||
return searchTrackTitleInSpreadsheet(title, activity, GoogleUtils.SPREADSHEET_NAME, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches and deletes a track in spreadsheet.
|
||||
*
|
||||
* @param title the track name to search
|
||||
* @param activity to get context
|
||||
* @return true means find and delete successfully
|
||||
*/
|
||||
public static boolean deleteTrackInSpreadSheet(String title, Activity activity) {
|
||||
return searchTrackTitleInSpreadsheet(title, activity, GoogleUtils.SPREADSHEET_NAME, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches a fusion table in user's Google tables.
|
||||
@@ -276,6 +300,7 @@ public class GoogleUtils {
|
||||
*
|
||||
* @param title the title of a track to drop
|
||||
* @param activity to get context
|
||||
* @return the result of drop
|
||||
*/
|
||||
public static boolean dropFusionTables(String title, Activity activity) {
|
||||
Context context = activity.getApplicationContext();
|
||||
|
||||
Reference in New Issue
Block a user