1818import uniandes .tsdl .itdroid .helper .ASTHelper ;
1919import uniandes .tsdl .itdroid .helper .EmulatorHelper ;
2020import uniandes .tsdl .itdroid .helper .Helper ;
21+ import uniandes .tsdl .itdroid .helper .ITDroidException ;
2122import uniandes .tsdl .itdroid .helper .LanguageBundle ;
2223import uniandes .tsdl .itdroid .helper .RIPHelper ;
24+ import uniandes .tsdl .itdroid .helper .RipException ;
2325import uniandes .tsdl .itdroid .helper .XMLComparator ;
2426import uniandes .tsdl .itdroid .model .LayoutGraph ;
2527import 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 );
0 commit comments