-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9025cbb
commit 664a9e9
Showing
5 changed files
with
232 additions
and
1 deletion.
There are no files selected for viewing
156 changes: 156 additions & 0 deletions
156
src/androidTest/java/de/blau/android/easyedit/ReplaceGeometryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
package de.blau.android.easyedit; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import android.content.Context; | ||
import androidx.annotation.NonNull; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
import androidx.test.filters.LargeTest; | ||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.rule.ActivityTestRule; | ||
import androidx.test.uiautomator.UiDevice; | ||
import de.blau.android.App; | ||
import de.blau.android.LayerUtils; | ||
import de.blau.android.Logic; | ||
import de.blau.android.Main; | ||
import de.blau.android.Map; | ||
import de.blau.android.R; | ||
import de.blau.android.TestUtils; | ||
import de.blau.android.osm.Node; | ||
import de.blau.android.osm.OsmElement; | ||
import de.blau.android.osm.StorageDelegator; | ||
import de.blau.android.osm.Tags; | ||
import de.blau.android.osm.Way; | ||
import de.blau.android.prefs.AdvancedPrefDatabase; | ||
import de.blau.android.prefs.Preferences; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
@LargeTest | ||
public class ReplaceGeometryTest { | ||
|
||
Context context = null; | ||
AdvancedPrefDatabase prefDB = null; | ||
Main main = null; | ||
UiDevice device = null; | ||
Map map = null; | ||
Logic logic = null; | ||
|
||
@Rule | ||
public ActivityTestRule<Main> mActivityRule = new ActivityTestRule<>(Main.class); | ||
|
||
/** | ||
* Pre-test setup | ||
*/ | ||
@Before | ||
public void setup() { | ||
device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); | ||
context = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
main = mActivityRule.getActivity(); | ||
Preferences prefs = new Preferences(context); | ||
LayerUtils.removeImageryLayers(context); | ||
map = main.getMap(); | ||
map.setPrefs(main, prefs); | ||
TestUtils.grantPermissons(device); | ||
TestUtils.dismissStartUpDialogs(device, main); | ||
logic = App.getLogic(); | ||
logic.deselectAll(); | ||
logic.updateStyle(); | ||
map.getDataLayer().setVisible(true); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
private void loadData(@NonNull String data) { | ||
TestUtils.loadTestData(main, data); | ||
TestUtils.stopEasyEdit(main); | ||
map.getViewBox().fitToBoundingBox(map, map.getDataLayer().getExtent()); | ||
TestUtils.zoomToLevel(device, main, 20); | ||
map.invalidate(); | ||
TestUtils.unlock(device); | ||
device.waitForWindowUpdate(null, 2000); | ||
} | ||
|
||
/** | ||
* Post-test teardown | ||
*/ | ||
@After | ||
public void teardown() { | ||
TestUtils.stopEasyEdit(main); | ||
TestUtils.zoomToNullIsland(logic, map); | ||
} | ||
|
||
/** | ||
* Select, replace with way | ||
*/ | ||
@Test | ||
public void replaceNode() { | ||
loadData("replace_geometry3.osm"); | ||
Node node = (Node) App.getDelegator().getOsmElement(Node.NAME, -14L); | ||
assertNotNull(node); | ||
assertTrue(node.hasTag(Tags.KEY_SHOP, "convenience")); | ||
TestUtils.clickAtCoordinates(device, map, node.getLon(), node.getLat(), true); | ||
assertTrue(TestUtils.findText(device, false, context.getString(R.string.actionmode_nodeselect))); | ||
node = App.getLogic().getSelectedNode(); | ||
assertNotNull(node); | ||
assertEquals(-14L, node.getOsmId()); | ||
|
||
assertTrue(TestUtils.clickOverflowButton(device)); | ||
TestUtils.scrollTo(context.getString(R.string.menu_replace_geometry), false); | ||
assertTrue(TestUtils.clickText(device, false, context.getString(R.string.menu_replace_geometry), true, false)); | ||
assertTrue(TestUtils.findText(device, false, context.getString(R.string.actionmode_subtitle_replace_geometry))); | ||
TestUtils.clickAtCoordinates(device, map, 8.3760111D, 47.3981113D); | ||
assertTrue(TestUtils.findText(device, false, context.getString(R.string.actionmode_wayselect))); | ||
|
||
assertFalse(node.hasTag(Tags.KEY_SHOP, "convenience")); | ||
Way w = App.getLogic().getSelectedWay(); | ||
assertEquals(-1, w.getOsmId()); | ||
assertTrue(w.hasTag(Tags.KEY_SHOP, "convenience")); | ||
assertTrue(w.hasNode(node)); | ||
} | ||
|
||
/** | ||
* Select, replace with geometry from way | ||
*/ | ||
@Test | ||
public void replaceWay() { | ||
loadData("replace_geometry2.osm"); | ||
Node node = (Node) App.getDelegator().getOsmElement(Node.NAME, -14L); | ||
assertNotNull(node); | ||
TestUtils.clickAtCoordinates(device, map, 8.3760111D, 47.3981113D); | ||
|
||
assertTrue(TestUtils.findText(device, false, context.getString(R.string.actionmode_wayselect))); | ||
Way way = App.getLogic().getSelectedWay(); | ||
assertNotNull(way); | ||
assertEquals(-1L, way.getOsmId()); | ||
|
||
assertTrue(TestUtils.clickOverflowButton(device)); | ||
TestUtils.scrollTo(context.getString(R.string.menu_replace_geometry), false); | ||
assertTrue(TestUtils.clickText(device, false, context.getString(R.string.menu_replace_geometry), true, false)); | ||
assertTrue(TestUtils.findText(device, false, context.getString(R.string.actionmode_subtitle_replace_geometry))); | ||
TestUtils.clickAtCoordinates(device, map, 8.3761799D, 47.3979480D); | ||
|
||
assertTrue(TestUtils.findText(device, false, context.getString(R.string.remove_geometry_source))); | ||
assertTrue(TestUtils.clickText(device, false, context.getString(R.string.Yes), true, false)); | ||
TestUtils.clickAwayTip(device, context); | ||
assertTrue(TestUtils.findText(device, false, context.getString(R.string.replace_geometry_issue_title))); | ||
assertTrue(TestUtils.clickText(device, false, context.getString(R.string.Done), true, false)); | ||
assertTrue(TestUtils.findText(device, false, context.getString(R.string.actionmode_wayselect))); | ||
|
||
Way w = App.getLogic().getSelectedWay(); | ||
assertEquals(-1, w.getOsmId()); | ||
assertFalse(w.hasNode(node)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version='1.0' encoding='UTF-8' ?><osm generator="Vespucci/20.1.0.0" version="0.6" upload="true"><node id="-1" action="modify" version="1" timestamp="2024-10-15T13:30:51Z" visible="true" lat="47.3981634" lon="8.3759256" /><node id="-2" action="modify" version="1" timestamp="2024-10-15T13:30:54Z" visible="true" lat="47.3982848" lon="8.3760962" /><node id="-3" action="modify" version="1" timestamp="2024-10-15T13:30:59Z" visible="true" lat="47.3981725" lon="8.3762705" /><node id="-4" action="modify" version="1" timestamp="2024-10-15T13:31:01Z" visible="true" lat="47.3980511" lon="8.3760998" /><node id="-5" action="modify" version="1" timestamp="2024-10-15T13:31:37Z" visible="true" lat="47.3979933" lon="8.3759868" /><node id="-6" action="modify" version="1" timestamp="2024-10-15T13:31:39Z" visible="true" lat="47.3978709" lon="8.3758232" /><node id="-7" action="modify" version="1" timestamp="2024-10-15T13:31:42Z" visible="true" lat="47.3978534" lon="8.376082" /><node id="-8" action="modify" version="1" timestamp="2024-10-15T13:32:00Z" visible="true" lat="47.3979862" lon="8.3761558" /><node id="-9" action="modify" version="1" timestamp="2024-10-15T13:32:02Z" visible="true" lat="47.3980389" lon="8.3762294" /><node id="-10" action="modify" version="1" timestamp="2024-10-15T13:32:07Z" visible="true" lat="47.3980361" lon="8.376311" /><node id="-11" action="modify" version="1" timestamp="2024-10-15T13:32:09Z" visible="true" lat="47.3979769" lon="8.3763604" /><node id="-12" action="modify" version="1" timestamp="2024-10-15T13:32:11Z" visible="true" lat="47.3979089" lon="8.3763099" /><node id="-13" action="modify" version="1" timestamp="2024-10-15T13:32:13Z" visible="true" lat="47.3979071" lon="8.3762115" /><way id="-1" action="modify" version="1" timestamp="2024-10-15T13:31:04Z" visible="true"><nd ref="-1" /><nd ref="-2" /><nd ref="-3" /><nd ref="-4" /><nd ref="-1" /></way><way id="-2" action="modify" version="1" timestamp="2024-10-15T13:31:44Z" visible="true"><nd ref="-5" /><nd ref="-6" /><nd ref="-7" /><nd ref="-5" /></way><way id="-3" action="modify" version="1" timestamp="2024-10-15T13:32:14Z" visible="true"><nd ref="-8" /><nd ref="-9" /><nd ref="-10" /><nd ref="-11" /><nd ref="-12" /><nd ref="-13" /><nd ref="-8" /></way></osm> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version='1.0' encoding='UTF-8' ?><osm generator="Vespucci/20.1.0.0" version="0.6" upload="true"><bounds origin="" maxlon="8.3763604" maxlat="47.3982848" minlon="8.3758232" minlat="47.3978534" /><node id="-1" action="modify" version="1" timestamp="2024-10-16T09:06:49Z" visible="true" lat="47.3981634" lon="8.3759256" /><node id="-2" action="modify" version="1" timestamp="2024-10-16T09:06:49Z" visible="true" lat="47.3982848" lon="8.3760962" /><node id="-3" action="modify" version="1" timestamp="2024-10-16T09:06:49Z" visible="true" lat="47.3981725" lon="8.3762705" /><node id="-4" action="modify" version="1" timestamp="2024-10-16T09:06:49Z" visible="true" lat="47.3980511" lon="8.3760998" /><node id="-5" action="modify" version="1" timestamp="2024-10-15T13:31:37Z" visible="true" lat="47.3979933" lon="8.3759868" /><node id="-6" action="modify" version="1" timestamp="2024-10-15T13:31:39Z" visible="true" lat="47.3978709" lon="8.3758232" /><node id="-7" action="modify" version="1" timestamp="2024-10-15T13:31:42Z" visible="true" lat="47.3978534" lon="8.376082" /><node id="-8" action="modify" version="1" timestamp="2024-10-15T13:32:00Z" visible="true" lat="47.3979862" lon="8.3761558" /><node id="-9" action="modify" version="1" timestamp="2024-10-15T13:32:02Z" visible="true" lat="47.3980389" lon="8.3762294" /><node id="-10" action="modify" version="1" timestamp="2024-10-15T13:32:07Z" visible="true" lat="47.3980361" lon="8.376311" /><node id="-11" action="modify" version="1" timestamp="2024-10-15T13:32:09Z" visible="true" lat="47.3979769" lon="8.3763604" /><node id="-12" action="modify" version="1" timestamp="2024-10-15T13:32:11Z" visible="true" lat="47.3979089" lon="8.3763099" /><node id="-13" action="modify" version="1" timestamp="2024-10-15T13:32:13Z" visible="true" lat="47.3979071" lon="8.3762115" /><node id="-14" action="modify" version="1" timestamp="2024-10-16T12:10:03Z" visible="true" lat="47.3981108" lon="8.3761838"><tag k="shop" v="convenience" /></node><way id="-1" action="modify" version="1" timestamp="2024-10-16T09:06:49Z" visible="true"><nd ref="-1" /><nd ref="-2" /><nd ref="-3" /><nd ref="-14" /><nd ref="-4" /><nd ref="-1" /></way><way id="-2" action="modify" version="1" timestamp="2024-10-15T13:31:44Z" visible="true"><nd ref="-5" /><nd ref="-6" /><nd ref="-7" /><nd ref="-5" /></way><way id="-3" action="modify" version="1" timestamp="2024-10-15T13:32:14Z" visible="true"><nd ref="-8" /><nd ref="-9" /><nd ref="-10" /><nd ref="-11" /><nd ref="-12" /><nd ref="-13" /><nd ref="-8" /></way></osm> |