Skip to content

Commit b2ada85

Browse files
committed
Auto stash before merge of "master" and "origin/master"
1 parent 976ed21 commit b2ada85

6 files changed

Lines changed: 81 additions & 52 deletions

File tree

extra/RIPRRi18n.jar

30 Bytes
Binary file not shown.

extra/RIPi18n.jar

30 Bytes
Binary file not shown.

src/uniandes/tsdl/itdroid/ITDroid.java

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
import uniandes.tsdl.itdroid.helper.ASTHelper;
1919
import uniandes.tsdl.itdroid.helper.EmulatorHelper;
2020
import uniandes.tsdl.itdroid.helper.Helper;
21+
import uniandes.tsdl.itdroid.helper.ITDroidException;
2122
import uniandes.tsdl.itdroid.helper.LanguageBundle;
2223
import uniandes.tsdl.itdroid.helper.RIPHelper;
24+
import uniandes.tsdl.itdroid.helper.RipException;
2325
import uniandes.tsdl.itdroid.helper.XMLComparator;
2426
import uniandes.tsdl.itdroid.model.LayoutGraph;
2527
import uniandes.tsdl.itdroid.model.LayoutGraphComparision;
@@ -49,10 +51,10 @@ public static void main(String[] args) {
4951
// print report
5052
if(outputPath!=null) {
5153
try (FileWriter file = new FileWriter(outputPath + File.separator+"report.json")) {
52-
54+
5355
file.write(report.toJSONString());
5456
file.flush();
55-
57+
5658
} catch (IOException e) {
5759
e.printStackTrace();
5860
}
@@ -61,7 +63,7 @@ public static void main(String[] args) {
6163
}
6264

6365
@SuppressWarnings("unchecked")
64-
public static void runITDroid(String[] args) throws Exception {
66+
public static void runITDroid(String[] args) throws RipException, Exception {
6567
// Usage Error
6668
if (args.length != 7) {
6769
System.out.println("******* ERROR: INCORRECT USAGE *******");
@@ -124,7 +126,7 @@ public static void runITDroid(String[] args) throws Exception {
124126
if (!baseStrings.exists()) {
125127
report.put("error", "Your application do not have a strings.xml file.");
126128
System.out.println("Your application do not have a strings.xml file.");
127-
throw new Exception("Your application do not have a strings.xml file.");
129+
throw new ITDroidException("Your application do not have a strings.xml file.");
128130
}
129131
XMLComparator xmlc = new XMLComparator(stringFiles, alpha, langsDir);
130132

@@ -167,6 +169,7 @@ public static void runITDroid(String[] args) throws Exception {
167169

168170
String deftLanguage = lngBundle.getBundle().getObject("defaultLng").toString();
169171
report.put("dfltLang", deftLanguage);
172+
170173
// Explore app using default language
171174
String resultFolderPath = RIPHelper.runRIPI18N(deftLanguage, outputPath, true, extraPath, newApkPath,deftLanguage);
172175
//EmulatorHelper.changeLanguage(deftLanguage, deftLanguage, extraPath);
@@ -190,24 +193,33 @@ public static void runITDroid(String[] args) throws Exception {
190193

191194
String lang = pathsMap.get(translatedFiles.get(i));
192195
System.out.println("Processing " + lang + " app version");
193-
//EmulatorHelper.changeLanguage(lang, lngBundle.getBundle().getString(lang), extraPath);
194-
// call RIP R&R
195-
String resultFolderPathh = RIPHelper.runRIPRRi18n(lang, outputPath, true, extraPath, newApkPath,resultFolderPath,lngBundle.getBundle().getString(lang));
196-
// Builds the graph for given language
197-
LayoutGraph langGraph = new LayoutGraph(lang, resultFolderPathh);
196+
// Wipes package data
197+
EmulatorHelper.wipePackageData(appName);
198+
EmulatorHelper.changeLanguage(lang, lngBundle.getBundle().getString(lang), extraPath);
198199
JSONObject dfltLangJSONTrans = new JSONObject();
199-
dfltLangJSONTrans.put("lang", lngBundle.getBundle().getString(lang));
200-
dfltLangJSONTrans.put("amStates", langGraph.getStates().size());
201-
dfltLangJSONTrans.put("amTrans", langGraph.getTransitions().size());
202-
graphs.put(lang, langGraph);
203-
204-
// Compares the default graph with the current language graph
205-
LayoutGraphComparision lgc = new LayoutGraphComparision(deftLanguage, defltGraph,
206-
lngBundle.getBundle().getString(lang), lang, langGraph, resultFolderPathh, outputPath,
207-
dfltLangJSONTrans);
208-
lgcomparisions.put(lang, lgc);
200+
try {
201+
// call RIP R&R
202+
String resultFolderPathh = RIPHelper.runRIPRRi18n(lang, outputPath, true, extraPath, newApkPath,resultFolderPath);
203+
204+
// Builds the graph for given language
205+
LayoutGraph langGraph = new LayoutGraph(lang, resultFolderPathh);
206+
dfltLangJSONTrans.put("lang", lngBundle.getBundle().getString(lang));
207+
dfltLangJSONTrans.put("amStates", langGraph.getStates().size());
208+
dfltLangJSONTrans.put("amTrans", langGraph.getTransitions().size());
209+
graphs.put(lang, langGraph);
210+
211+
// Compares the default graph with the current language graph
212+
LayoutGraphComparision lgc = new LayoutGraphComparision(deftLanguage, defltGraph,
213+
lngBundle.getBundle().getString(lang), lang, langGraph, resultFolderPathh, outputPath,
214+
dfltLangJSONTrans);
215+
lgcomparisions.put(lang, lgc);
216+
217+
} catch (RipException e) {
218+
dfltLangJSONTrans.put("error", e.getMessage());
219+
}
209220

210221
lngsResults.put(lang, dfltLangJSONTrans);
222+
211223
}
212224

213225
System.out.println("Inspecting non translated versions");
@@ -216,24 +228,30 @@ public static void runITDroid(String[] args) throws Exception {
216228

217229
String lang = pathsMap.get(notTrnsltdFiles.get(i));
218230
System.out.println("Processing " + lang + " app version");
219-
//EmulatorHelper.changeLanguage(lang, lngBundle.getBundle().getString(lang), extraPath);
220-
// call RIP R&R
221-
String resultFolderPathh = RIPHelper.runRIPRRi18n(lang, outputPath, false, extraPath, newApkPath, resultFolderPath,lngBundle.getBundle().getString(lang));
222-
223-
// Builds the graph for given language
224-
LayoutGraph langGraph = new LayoutGraph(lang, resultFolderPathh);
231+
// Wipes package data
232+
EmulatorHelper.wipePackageData(appName);
233+
EmulatorHelper.changeLanguage(lang, lngBundle.getBundle().getString(lang), extraPath);
225234
JSONObject dfltLangJSONTrans = new JSONObject();
226-
dfltLangJSONTrans.put("lang", lngBundle.getBundle().getString(lang));
227-
dfltLangJSONTrans.put("amStates", langGraph.getStates().size());
228-
dfltLangJSONTrans.put("amTrans", langGraph.getTransitions().size());
229-
graphs.put(lang, langGraph);
230-
231-
// Compares the default graph with the current language graph
232-
LayoutGraphComparision lgc = new LayoutGraphComparision(deftLanguage, defltGraph,
233-
lngBundle.getBundle().getString(lang), lang, langGraph, resultFolderPathh, outputPath,
234-
dfltLangJSONTrans);
235-
lgcomparisions.put(lang, lgc);
236-
235+
try {
236+
// call RIP R&R
237+
String resultFolderPathh = RIPHelper.runRIPRRi18n(lang, outputPath, false, extraPath, newApkPath,
238+
resultFolderPath);
239+
240+
// Builds the graph for given language
241+
LayoutGraph langGraph = new LayoutGraph(lang, resultFolderPathh);
242+
dfltLangJSONTrans.put("lang", lngBundle.getBundle().getString(lang));
243+
dfltLangJSONTrans.put("amStates", langGraph.getStates().size());
244+
dfltLangJSONTrans.put("amTrans", langGraph.getTransitions().size());
245+
graphs.put(lang, langGraph);
246+
247+
// Compares the default graph with the current language graph
248+
LayoutGraphComparision lgc = new LayoutGraphComparision(deftLanguage, defltGraph,
249+
lngBundle.getBundle().getString(lang), lang, langGraph, resultFolderPathh, outputPath,
250+
dfltLangJSONTrans);
251+
lgcomparisions.put(lang, lgc);
252+
} catch(RipException e) {
253+
dfltLangJSONTrans.put("error", e.getMessage());
254+
}
237255
lngsResults.put(lang, dfltLangJSONTrans);
238256
}
239257
report.put("langsReport", lngsResults);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package uniandes.tsdl.itdroid.helper;
2+
3+
public class ITDroidException extends Exception{
4+
5+
public ITDroidException(String errorMessage) {
6+
super(errorMessage);
7+
8+
}
9+
10+
}

src/uniandes/tsdl/itdroid/helper/RIPHelper.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static String runRIPRR(String language, String outputFolder, boolean tran
6767
return tempFolder.getCanonicalPath();
6868
}
6969

70-
public static String runRIPRRi18n(String language, String outputFolder, boolean translated, String extraPath, String apkLocation, String resultPath, String expresiveLanguage) throws IOException, InterruptedException,Exception{
70+
public static String runRIPRRi18n(String language, String outputFolder, boolean translated, String extraPath, String apkLocation, String resultPath) throws IOException, InterruptedException, RipException{
7171
String decodedPath = Helper.getInstance().getCurrentDirectory();
7272
// Creates folder for decoded app
7373
// System.out.println(decodedPath);
@@ -88,23 +88,14 @@ public static String runRIPRRi18n(String language, String outputFolder, boolean
8888
Process ps = pB.start();
8989
System.out.print("Going through your app");
9090
BufferedReader reader = new BufferedReader(new InputStreamReader(ps.getInputStream()));
91-
String line;
92-
93-
//Error handling
94-
//TODO revisar cómo volver esto un IPF (?)
95-
String err;
96-
while((err = reader.readLine()) != null){
97-
if (err.contains("OLD TRANSITIONS EMPTY")){
98-
throw new Exception("OLD TRANSITIONS EMPTY");
99-
}
100-
if(err.contains("EXITING EXECUTION. START STATE != CURRENT STATE")){
101-
throw new Exception("EXITING EXECUTION. START STATE != CURRENT STATE");
102-
}
103-
}
104-
105-
while ((line = reader.readLine())!=null) {
91+
BufferedReader errorReader = new BufferedReader(new InputStreamReader(ps.getErrorStream()));
92+
String line, errorLine = "";
93+
while ((line = reader.readLine())!=null || (errorLine = errorReader.readLine())!= null) {
10694
// System.out.println(line);
10795
System.out.print(".");
96+
if(errorLine != null && !errorLine.contains("OLD TRANSITIONS EMPTY")) {
97+
throw new RipException("New replay failure");
98+
}
10899
}
109100

110101
ps.waitFor();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package uniandes.tsdl.itdroid.helper;
2+
3+
public class RipException extends Exception{
4+
5+
public RipException(String errorMessage) {
6+
super(errorMessage);
7+
8+
}
9+
10+
}

0 commit comments

Comments
 (0)