Add checks in testShareActivity_withDrive about the share result in the destination account.

This commit is contained in:
youtaol
2013-05-27 11:02:02 +08:00
parent bc36ac5afe
commit ecbd7ea769
@@ -18,7 +18,10 @@ 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.Drive;
import android.app.Instrumentation;
import android.content.Intent;
@@ -26,6 +29,7 @@ import android.test.ActivityInstrumentationTestCase2;
import android.view.KeyEvent;
import android.view.View;
import java.io.IOException;
import java.util.ArrayList;
/**
@@ -113,9 +117,25 @@ public class MenuItemsTest extends ActivityInstrumentationTestCase2<TrackListAct
}
/**
* Tests the share a track with Google Drive.
* Tests sharing a track with Google Drive.
*
* @throws GoogleAuthException
* @throws IOException
*/
public void testShareActivity_withDrive() {
public void testShareActivity_withDrive() throws IOException, GoogleAuthException {
// Prepare test environment.
SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_NAME_1);
Drive drive1 = SyncTestUtils.getGoogleDrive(EndToEndTestUtils.activityMytracks
.getApplicationContext());
SyncTestUtils.removeKMLFiles(drive1);
EndToEndTestUtils.deleteAllTracks();
SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_NAME_2);
Drive drive2 = SyncTestUtils.getGoogleDrive(EndToEndTestUtils.activityMytracks
.getApplicationContext());
SyncTestUtils.removeKMLFiles(drive2);
EndToEndTestUtils.deleteAllTracks();
EndToEndTestUtils.resetAllSettings(activityMyTracks, false);
EndToEndTestUtils.createSimpleTrack(0, false);
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_sharing));
@@ -139,10 +159,16 @@ public class MenuItemsTest extends ActivityInstrumentationTestCase2<TrackListAct
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_share), true);
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.generic_yes));
boolean isAccount2Bound = false;
// If Choose account dialog prompt, choose the first account.
if (EndToEndTestUtils.SOLO.waitForText(
activityMyTracks.getString(R.string.send_google_choose_account_title), 1,
EndToEndTestUtils.SHORT_WAIT_TIME)) {
// Whether can found account2.
if (EndToEndTestUtils.SOLO.waitForText(GoogleUtils.ACCOUNT_NAME_2, 1,
EndToEndTestUtils.VERY_SHORT_WAIT_TIME)) {
isAccount2Bound = true;
}
EndToEndTestUtils.SOLO.clickOnText(GoogleUtils.ACCOUNT_NAME_1);
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true,
true);
@@ -163,6 +189,20 @@ public class MenuItemsTest extends ActivityInstrumentationTestCase2<TrackListAct
assertTrue(EndToEndTestUtils.SOLO.waitForText(EndToEndTestUtils.SOLO
.getString(R.string.generic_success_title)));
EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.SOLO.getString(R.string.generic_ok));
// Make more checks if the second account is also bound with this device.
if (isAccount2Bound) {
EndToEndTestUtils.SOLO.goBack();
SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_NAME_2);
EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true);
assertTrue(EndToEndTestUtils.SOLO.waitForText(
activityMyTracks.getString(R.string.track_list_shared_with_me), 1,
EndToEndTestUtils.SUPER_LONG_WAIT_TIME));
assertTrue(EndToEndTestUtils.SOLO.waitForText(EndToEndTestUtils.trackName, 1,
EndToEndTestUtils.SUPER_LONG_WAIT_TIME));
}
}
/**