Commit a0e78310 authored by Martin LOISEAU's avatar Martin LOISEAU 🎄
Browse files

Add test scenario xml fail and create scneario loader object

parent b765416f
package com.example.qrquest;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.qrquest", appContext.getPackageName());
}
}
......@@ -2,6 +2,7 @@ package com.example.qrquest;
import android.Manifest;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.media.MediaPlayer;
......@@ -39,6 +40,11 @@ import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.StringWriter;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
......@@ -150,6 +156,10 @@ public class MainActivity extends AppCompatActivity {
OpenNodes.add(n1);
Log.d("Debug2", "Nodes initialized");
ScenarioLoader scenario = new ScenarioLoader(getApplicationInfo().dataDir + "/scenario.xml");
EveryNode = scenario.GetNodes();
OpenNodes.add(EveryNode.get(0));
}
public void CheckOpenNodes() {
......
package com.example.qrquest;
import com.example.qrquest.node.Node;
import org.xmlpull.v1.XmlPullParser;
import java.util.ArrayList;
public class ScenarioLoader {
/*
* The goal of the com.example.qrquest.ScenarioLoader is to get the list of every node from a scenario xml file
*/
ArrayList<Node> ScenarioNodes;
public ScenarioLoader(String xml_path)
{
ScenarioNodes = new ArrayList<Node>();
/*
private static final String ns = null;
public List parse(InputStream in) throws XmlPullParserException, IOException {
try {
XmlPullParser parser = Xml.newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
parser.setInput(in, null);
parser.nextTag();
return readFeed(parser);
} finally {
in.close();
}
}
private List readFeed(XmlPullParser parser) throws XmlPullParserException, IOException {
List entries = new ArrayList();
parser.require(XmlPullParser.START_TAG, ns, "feed");
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = parser.getName();
// Starts by looking for the entry tag
if (name.equals("entry")) {
entries.add(readEntry(parser));
} else {
skip(parser);
}
}
return entries;
}
*/
}
public ArrayList<Node> GetNodes() { return ScenarioNodes; }
}
<?xml version="1.0" encoding="utf-8"?>
<liste>
<node>
<id>1</id>
<required_atoms>
</required_atoms>
<action_list>
<TTSReading>
<text_to_read type="text">"Bonjour 3" <text_to_read>
</TTSReading>
<ClearNodes> </ClearNodes>
<action>
</action_list>
</node>
<node id="2">
<required_atoms>
</required_atoms>
<action_list>
</action_list>
</node>
<node id="3">
</node>
</liste>
\ No newline at end of file
package com.example.qrquest;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment