forked from upstream-mirrors/OpenTracks
Add checks in testShareActivity_withDrive about the share result in the destination account.
This commit is contained in:
+42
-2
@@ -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.TrackListActivity;
|
||||||
import com.google.android.apps.mytracks.endtoendtest.EndToEndTestUtils;
|
import com.google.android.apps.mytracks.endtoendtest.EndToEndTestUtils;
|
||||||
import com.google.android.apps.mytracks.endtoendtest.GoogleUtils;
|
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.android.maps.mytracks.R;
|
||||||
|
import com.google.api.services.drive.Drive;
|
||||||
|
|
||||||
import android.app.Instrumentation;
|
import android.app.Instrumentation;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -26,6 +29,7 @@ import android.test.ActivityInstrumentationTestCase2;
|
|||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
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.createSimpleTrack(0, false);
|
||||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
|
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
|
||||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_sharing));
|
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.findMenuItem(activityMyTracks.getString(R.string.menu_share), true);
|
||||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.generic_yes));
|
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.generic_yes));
|
||||||
|
|
||||||
|
boolean isAccount2Bound = false;
|
||||||
// If Choose account dialog prompt, choose the first account.
|
// If Choose account dialog prompt, choose the first account.
|
||||||
if (EndToEndTestUtils.SOLO.waitForText(
|
if (EndToEndTestUtils.SOLO.waitForText(
|
||||||
activityMyTracks.getString(R.string.send_google_choose_account_title), 1,
|
activityMyTracks.getString(R.string.send_google_choose_account_title), 1,
|
||||||
EndToEndTestUtils.SHORT_WAIT_TIME)) {
|
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.SOLO.clickOnText(GoogleUtils.ACCOUNT_NAME_1);
|
||||||
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true,
|
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true,
|
||||||
true);
|
true);
|
||||||
@@ -163,6 +189,20 @@ public class MenuItemsTest extends ActivityInstrumentationTestCase2<TrackListAct
|
|||||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(EndToEndTestUtils.SOLO
|
assertTrue(EndToEndTestUtils.SOLO.waitForText(EndToEndTestUtils.SOLO
|
||||||
.getString(R.string.generic_success_title)));
|
.getString(R.string.generic_success_title)));
|
||||||
EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.SOLO.getString(R.string.generic_ok));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user