Change SendToGoogleTest to ExportSingleTrackTest. Fix strings change issues.

This commit is contained in:
youtaol
2013-06-08 18:03:01 +08:00
parent d1055ef5ee
commit e1d2a09207
3 changed files with 46 additions and 66 deletions
@@ -72,15 +72,13 @@ public class DeleteTest extends ActivityInstrumentationTestCase2<TrackListActivi
assertEquals(0, trackListView.get(0).getCount());
// Export when there is no track.
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_export_all), true);
EndToEndTestUtils.SOLO.clickOnText(String.format(
activityMyTracks.getString(R.string.export_external_storage_option),
EndToEndTestUtils.GPX.toUpperCase()));
EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.GPX.toUpperCase());
EndToEndTestUtils.getButtonOnScreen(
EndToEndTestUtils.activityMytracks.getString(R.string.generic_ok), true, true);
String totalTracks = activityMyTracks.getResources().getQuantityString(R.plurals.tracks, 0, 0);
String directoryName = FileUtils.buildExternalDirectoryPath(EndToEndTestUtils.GPX);
String message = activityMyTracks.getString(
R.string.export_external_storage_error, 0, totalTracks, directoryName);
String message = activityMyTracks.getString(R.string.export_external_storage_error, 0,
totalTracks, directoryName);
assertTrue(EndToEndTestUtils.SOLO.waitForText(
activityMyTracks.getString(R.string.external_storage_not_available), 1,
EndToEndTestUtils.SHORT_WAIT_TIME)
@@ -109,7 +109,7 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
// Click to export tracks(At least one track) to Gpx files.
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_export_all), true);
EndToEndTestUtils.SOLO.clickOnText(String.format(
activityMyTracks.getString(R.string.save_all_selection_option),
activityMyTracks.getString(R.string.export_all_option),
EndToEndTestUtils.GPX.toUpperCase()));
EndToEndTestUtils.getButtonOnScreen(
EndToEndTestUtils.activityMytracks.getString(R.string.generic_ok), true, true);
@@ -210,7 +210,7 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
// Click to export tracks(At least one track) to Gpx files.
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_export_all), true);
EndToEndTestUtils.SOLO.clickOnText(String.format(
activityMyTracks.getString(R.string.save_all_selection_option),
activityMyTracks.getString(R.string.export_all_option),
EndToEndTestUtils.GPX.toUpperCase()));
EndToEndTestUtils.getButtonOnScreen(
EndToEndTestUtils.activityMytracks.getString(R.string.generic_ok), true, true);
@@ -253,7 +253,7 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
trackNumber = EndToEndTestUtils.SOLO.getCurrentListViews().get(0).getCount();
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_export_all), true);
EndToEndTestUtils.SOLO.clickOnText(String.format(
activityMyTracks.getString(R.string.save_all_selection_option),
activityMyTracks.getString(R.string.export_all_option),
EndToEndTestUtils.KML.toUpperCase()));
EndToEndTestUtils.getButtonOnScreen(
EndToEndTestUtils.activityMytracks.getString(R.string.generic_ok), true, true);
@@ -302,7 +302,7 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
String tracks = activityMyTracks.getResources().getQuantityString(R.plurals.tracks, count,
count);
String directoryName = FileUtils.buildExternalDirectoryPath(type);
return activityMyTracks.getString(R.string.save_success, tracks, directoryName);
return activityMyTracks.getString(R.string.export_external_storage_success, tracks, directoryName);
}
private String getImportSuccessMessage(int count, String type) {
@@ -1,47 +1,30 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.android.apps.mytracks.endtoendtest.common;
import com.google.android.apps.mytracks.TrackListActivity;
import com.google.android.apps.mytracks.endtoendtest.EndToEndTestUtils;
import com.google.android.apps.mytracks.endtoendtest.GoogleUtils;
import com.google.android.apps.mytracks.endtoendtest.sync.SyncTestUtils;
import com.google.android.gms.auth.GoogleAuthException;
import com.google.android.maps.mytracks.R;
import com.google.api.services.drive.model.File;
import android.app.Instrumentation;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.CheckBox;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* Tests the logic of send track to Google.
* Tests export single track to Google. Each test would export one track to
* Google Maps, Google Fusion Tables and Google Spreadsheets.
*
* @author Youtao Liu
* @author youtaol
*/
public class SendToGoogleTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
public class ExportSingleTrackTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
private Instrumentation instrumentation;
private TrackListActivity activityMyTracks;
public SendToGoogleTest() {
public ExportSingleTrackTest() {
super(TrackListActivity.class);
}
@@ -62,7 +45,7 @@ public class SendToGoogleTest extends ActivityInstrumentationTestCase2<TrackList
* @throws GoogleAuthException
* @throws IOException
*/
public void testCreateAndSendTrack_send() throws IOException, GoogleAuthException {
public void testCreateAndSendTrack_send() {
// Create a new track.
EndToEndTestUtils.createSimpleTrack(1, false);
instrumentation.waitForIdleSync();
@@ -75,7 +58,7 @@ public class SendToGoogleTest extends ActivityInstrumentationTestCase2<TrackList
* @throws GoogleAuthException
* @throws IOException
*/
public void testCreateAndSendTrack_sendPausedTrack() throws IOException, GoogleAuthException {
public void testCreateAndSendTrack_sendPausedTrack() {
EndToEndTestUtils.deleteAllTracks();
EndToEndTestUtils.createTrackWithPause(3);
instrumentation.waitForIdleSync();
@@ -92,8 +75,12 @@ public class SendToGoogleTest extends ActivityInstrumentationTestCase2<TrackList
GoogleUtils.deleteSpreadsheetByTitle("My Tracks-" + EndToEndTestUtils.activityType,
EndToEndTestUtils.activityMytracks, GoogleUtils.ACCOUNT_NAME_1);
EndToEndTestUtils.createSimpleTrack(1, false);
boolean result = sendToGoogle();
result = result && sendToGoogle();
boolean result = sendToGoogle(activityMyTracks.getString(R.string.export_google_maps))
&& sendToGoogle(activityMyTracks.getString(R.string.export_google_fusion_tables))
&& sendToGoogle(activityMyTracks.getString(R.string.export_google_spreadsheets));
result = result && sendToGoogle(activityMyTracks.getString(R.string.export_google_maps))
&& sendToGoogle(activityMyTracks.getString(R.string.export_google_fusion_tables))
&& sendToGoogle(activityMyTracks.getString(R.string.export_google_spreadsheets));
// Result is true mean has account bound with this device and send
// successful.
@@ -111,14 +98,16 @@ public class SendToGoogleTest extends ActivityInstrumentationTestCase2<TrackList
* @throws GoogleAuthException
* @throws IOException
*/
private void checkSendTrackToGoogle() throws IOException, GoogleAuthException {
if (!sendToGoogle()) {
private void checkSendTrackToGoogle() {
if (!sendToGoogle(activityMyTracks.getString(R.string.export_google_maps))
|| !sendToGoogle(activityMyTracks.getString(R.string.export_google_fusion_tables))
|| !sendToGoogle(activityMyTracks.getString(R.string.export_google_spreadsheets))) {
return;
}
// Check whether all data is correct on Google Drive, Maps, Documents, and
// Spreadsheet.
assertTrue(SyncTestUtils.checkFile(EndToEndTestUtils.trackName, true,
SyncTestUtils.getGoogleDrive(activityMyTracks.getApplicationContext())));
// assertTrue(SyncTestUtils.checkFile(EndToEndTestUtils.trackName, true,
// SyncTestUtils.getGoogleDrive(activityMyTracks.getApplicationContext())));
assertTrue(GoogleUtils.deleteMap(EndToEndTestUtils.trackName, activityMyTracks));
assertTrue(GoogleUtils.searchFusionTableByTitle(EndToEndTestUtils.trackName, activityMyTracks,
GoogleUtils.ACCOUNT_NAME_1, true));
@@ -129,43 +118,31 @@ public class SendToGoogleTest extends ActivityInstrumentationTestCase2<TrackList
/**
* Sends a track to Google.
*
* @param exportDestination destination to export
* @return true means send successfully
*/
private boolean sendToGoogle() {
private boolean sendToGoogle(String exportDestination) {
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_export), true);
EndToEndTestUtils.SOLO.waitForText(activityMyTracks.getString(R.string.export_title));
instrumentation.waitForIdleSync();
ArrayList<CheckBox> checkBoxs = EndToEndTestUtils.SOLO.getCurrentCheckBoxes();
for (int i = 0; i < checkBoxs.size(); i++) {
if (!checkBoxs.get(i).isChecked()) {
EndToEndTestUtils.SOLO.clickOnView(checkBoxs.get(i));
instrumentation.waitForIdleSync();
}
}
if (checkBoxs.size() < 4) {
EndToEndTestUtils.SOLO.scrollDown();
checkBoxs = EndToEndTestUtils.SOLO.getCurrentCheckBoxes();
EndToEndTestUtils.SOLO.clickOnText(exportDestination);
// Choose all Google service.
for (int i = 0; i < checkBoxs.size(); i++) {
if (!checkBoxs.get(i).isChecked()) {
EndToEndTestUtils.SOLO.clickOnCheckBox(i);
}
}
}
instrumentation.waitForIdleSync();
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.menu_export),
true, true);
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.menu_export), true,
true);
instrumentation.waitForIdleSync();
if (!GoogleUtils.isAccountAvailable()) {
return false;
}
// Following check the process of "Send to Google".
// Following check the process of "Send to Google", the second condition is
// in case the export has done.
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
.getString(R.string.generic_progress_title)));
.getString(R.string.generic_progress_title))
|| EndToEndTestUtils.SOLO.waitForText(activityMyTracks
.getString(R.string.generic_success_title)));
// Waiting the send is finish. Should double check it for the progress
// dialog may disappear and display again while switch to next send(There
@@ -178,9 +155,14 @@ public class SendToGoogleTest extends ActivityInstrumentationTestCase2<TrackList
activityMyTracks.getString(R.string.generic_progress_title), 1,
EndToEndTestUtils.SHORT_WAIT_TIME)) {}
// Check whether the result dialog is display.
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
.getString(R.string.share_track_share_url)));
if (exportDestination.endsWith(activityMyTracks.getString(R.string.export_google_maps))) {
// Check whether the result dialog is display.
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
.getString(R.string.share_track_share_url)));
} else {
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
.getString(R.string.generic_success_title)));
}
EndToEndTestUtils
.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
return true;
@@ -192,7 +174,7 @@ public class SendToGoogleTest extends ActivityInstrumentationTestCase2<TrackList
* @throws GoogleAuthException
* @throws IOException
*/
public void testSendLargeTrackToGoogle() throws IOException, GoogleAuthException {
public void testSendLargeTrackToGoogle() {
EndToEndTestUtils.deleteAllTracks();
EndToEndTestUtils.createSimpleTrack(200, false);
instrumentation.waitForIdleSync();
@@ -206,4 +188,4 @@ public class SendToGoogleTest extends ActivityInstrumentationTestCase2<TrackList
super.tearDown();
}
}
}