Skip to content

Commit

Permalink
Click away Tip if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpoole committed Dec 13, 2023
1 parent 55c776c commit 98a1a8f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
17 changes: 15 additions & 2 deletions src/androidTest/java/de/blau/android/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -1577,13 +1579,24 @@ public static void disableTip(@NonNull Context ctx, int res) {
}

/**
* Click away a tip dialod
* Click away a tip dialog
*
* @param device the current UiDevice
* @param ctx an Android Context
*/
public static void clickAwayTip(@NonNull UiDevice device, @NonNull Context ctx) {
if (TestUtils.findText(device, false, ctx.getString(R.string.tip_title))) {
clickAwayTip(device, ctx, 500);
}

/**
* Click away a tip dialog
*
* @param device the current UiDevice
* @param ctx an Android Context
* @param wait time mS to wait for the tip
*/
public static void clickAwayTip(@NonNull UiDevice device, @NonNull Context ctx, long wait) {
if (TestUtils.findText(device, false, ctx.getString(R.string.tip_title), wait)) {
TestUtils.clickText(device, false, ctx.getString(R.string.okay), true, false); // TIP
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.orhanobut.mockwebserverplus.MockWebServerPlus;

import android.app.Instrumentation;
import android.os.Build;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.test.core.app.ApplicationProvider;
Expand Down Expand Up @@ -64,8 +65,8 @@
@LargeTest
public class LayerDialogCustomImageryTest {

public static final int EXTENT_BUTTON = 1;
public static final int MENU_BUTTON = 3;
public static final int EXTENT_BUTTON = 1;
public static final int MENU_BUTTON = 3;

AdvancedPrefDatabase prefDB = null;
Main main = null;
Expand Down Expand Up @@ -158,7 +159,9 @@ public void customImageryMBT() {
assertTrue(TestUtils.findText(device, false, main.getString(R.string.add_layer_title)));
assertTrue(TestUtils.clickResource(device, true, device.getCurrentPackageName() + ":id/file_button", true));
TestUtils.selectFile(device, main, null, fileName, true);
TestUtils.clickAwayTip(device, main, 5000); // only used when the file is imported
assertTrue(TestUtils.findText(device, false, "Vespucci Test"));
TestUtils.findText(device, false, main.getString(R.string.save_and_set), 2000);
assertTrue(TestUtils.clickText(device, false, main.getString(R.string.save_and_set), true));
assertTrue(TestUtils.textGone(device, main.getString(R.string.layer_add_custom_imagery), 2000));
assertTrue(TestUtils.findText(device, false, "Vespucci Test")); // layer dialog
Expand Down Expand Up @@ -188,6 +191,7 @@ public void customImageryLocalPMTiles() {
assertTrue(TestUtils.findText(device, false, main.getString(R.string.add_layer_title)));
assertTrue(TestUtils.clickResource(device, true, device.getCurrentPackageName() + ":id/file_button", true));
TestUtils.selectFile(device, main, null, fileName, true);
TestUtils.clickAwayTip(device, main, 5000); // only used when the file is imported
assertTrue(TestUtils.findText(device, false, "protomaps 2023-01"));
assertTrue(TestUtils.clickText(device, false, main.getString(R.string.save_and_set), true));
assertTrue(TestUtils.textGone(device, main.getString(R.string.layer_add_custom_imagery), 2000));
Expand Down

0 comments on commit 98a1a8f

Please sign in to comment.