Loading tests/DumpRenderTree/src/com/android/dumprendertree/FileList.java +51 −22 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,9 @@ import java.util.List; import java.util.Map; import java.util.Map; import java.io.File; import java.io.File; import android.app.AlertDialog; import android.app.ListActivity; import android.app.ListActivity; import android.content.DialogInterface; import android.view.KeyEvent; import android.view.KeyEvent; import android.view.View; import android.view.View; import android.widget.ListView; import android.widget.ListView; Loading Loading @@ -118,17 +120,41 @@ public abstract class FileList extends ListActivity protected void onListItemClick(ListView l, View v, int position, long id) protected void onListItemClick(ListView l, View v, int position, long id) { { Map map = (Map) l.getItemAtPosition(position); Map map = (Map) l.getItemAtPosition(position); String path = (String)map.get("path"); final String path = (String)map.get("path"); if ((new File(path)).isDirectory()) { if ((new File(path)).isDirectory()) { final CharSequence[] items = {"Open", "Run"}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Select an Action"); builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int which) { switch (which) { case OPEN_DIRECTORY: dialog.dismiss(); mPath = path; mPath = path; mFocusFile = null; mFocusFile = null; updateList(); updateList(); break; case RUN_TESTS: dialog.dismiss(); processDirectory(path, false); break; } } }); builder.create().show(); } else { } else { processFile(path, false); processFile(path, false); } } } } /* * This function is called when the user has selected a directory in the * list and wants to perform an action on it instead of navigating into * the directory. */ abstract void processDirectory(String path, boolean selection); /* /* * This function is called when the user has selected a file in the * This function is called when the user has selected a file in the * file list. The selected file could be a file or a directory. * file list. The selected file could be a file or a directory. Loading Loading @@ -164,4 +190,7 @@ public abstract class FileList extends ListActivity protected String mFocusFile; protected String mFocusFile; protected int mFocusIndex; protected int mFocusIndex; private final static int OPEN_DIRECTORY = 0; private final static int RUN_TESTS = 1; } } tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java 0 → 100644 +80 −0 Original line number Original line Diff line number Diff line package com.android.dumprendertree; import android.util.Log; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; public class FsUtils { private static final String LOGTAG = "FsUtils"; private FsUtils() { //no creation of instances } public static void findLayoutTestsRecursively(BufferedOutputStream bos, String dir) throws IOException { Log.v(LOGTAG, "Searching tests under " + dir); File d = new File(dir); if (!d.isDirectory()) { throw new AssertionError("A directory expected, but got " + dir); } String[] files = d.list(); for (int i = 0; i < files.length; i++) { String s = dir + "/" + files[i]; if (FileFilter.ignoreTest(s)) { Log.v(LOGTAG, " Ignoring: " + s); continue; } if (s.toLowerCase().endsWith(".html") || s.toLowerCase().endsWith(".xml")) { bos.write(s.getBytes()); bos.write('\n'); continue; } File f = new File(s); if (f.isDirectory()) { findLayoutTestsRecursively(bos, s); continue; } Log.v(LOGTAG, "Skipping " + s); } } public static void updateTestStatus(String statusFile, String s) { try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(statusFile)); bos.write(s.getBytes()); bos.close(); } catch (Exception e) { Log.e(LOGTAG, "Cannot update file " + statusFile); } } public static String readTestStatus(String statusFile) { // read out the test name it stopped last time. String status = null; File testStatusFile = new File(statusFile); if(testStatusFile.exists()) { try { BufferedReader inReader = new BufferedReader( new FileReader(testStatusFile)); status = inReader.readLine(); inReader.close(); } catch (IOException e) { Log.e(LOGTAG, "Error reading test status.", e); } } return status; } } tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java +5 −50 Original line number Original line Diff line number Diff line Loading @@ -178,15 +178,13 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh private void resumeTestList() { private void resumeTestList() { // read out the test name it stoped last time. // read out the test name it stoped last time. try { try { BufferedReader inReader = new BufferedReader(new FileReader(TEST_STATUS_FILE)); String line = FsUtils.readTestStatus(TEST_STATUS_FILE); String line = inReader.readLine(); for (int i = 0; i < mTestList.size(); i++) { for (int i = 0; i < mTestList.size(); i++) { if (mTestList.elementAt(i).equals(line)) { if (mTestList.elementAt(i).equals(line)) { mTestList = new Vector<String>(mTestList.subList(i+1, mTestList.size())); mTestList = new Vector<String>(mTestList.subList(i+1, mTestList.size())); break; break; } } } } inReader.close(); } catch (Exception e) { } catch (Exception e) { Log.e(LOGTAG, "Error reading " + TEST_STATUS_FILE); Log.e(LOGTAG, "Error reading " + TEST_STATUS_FILE); } } Loading @@ -205,17 +203,6 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh } } } } private void updateTestStatus(String s) { // Write TEST_STATUS_FILE try { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(TEST_STATUS_FILE)); bos.write(s.getBytes()); bos.close(); } catch (Exception e) { Log.e(LOGTAG, "Cannot update file " + TEST_STATUS_FILE); } } private String getResultFile(String test) { private String getResultFile(String test) { String shortName = test.substring(0, test.lastIndexOf('.')); String shortName = test.substring(0, test.lastIndexOf('.')); // Write actual results to result directory. // Write actual results to result directory. Loading Loading @@ -392,12 +379,12 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh // Run tests. // Run tests. for (int i = 0; i < mTestList.size(); i++) { for (int i = 0; i < mTestList.size(); i++) { String s = mTestList.elementAt(i); String s = mTestList.elementAt(i); updateTestStatus(s); FsUtils.updateTestStatus(TEST_STATUS_FILE, s); // Run tests // Run tests runTestAndWaitUntilDone(activity, s, runner.mTimeoutInMillis); runTestAndWaitUntilDone(activity, s, runner.mTimeoutInMillis); } } updateTestStatus("#DONE"); FsUtils.updateTestStatus(TEST_STATUS_FILE, "#DONE"); activity.finish(); activity.finish(); } } Loading @@ -424,7 +411,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh try { try { File tests_list = new File(LAYOUT_TESTS_LIST_FILE); File tests_list = new File(LAYOUT_TESTS_LIST_FILE); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false)); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false)); findTestsRecursively(bos, getTestPath()); FsUtils.findLayoutTestsRecursively(bos, getTestPath()); bos.flush(); bos.flush(); bos.close(); bos.close(); } catch (Exception e) { } catch (Exception e) { Loading @@ -432,38 +419,6 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh } } } } private void findTestsRecursively(BufferedOutputStream bos, String dir) throws IOException { Log.v(LOGTAG, "Searching tests under " + dir); File d = new File(dir); if (!d.isDirectory()) { throw new AssertionError("A directory expected, but got " + dir); } String[] files = d.list(); for (int i = 0; i < files.length; i++) { String s = dir + "/" + files[i]; if (FileFilter.ignoreTest(s)) { Log.v(LOGTAG, " Ignoring: " + s); continue; } if (s.toLowerCase().endsWith(".html") || s.toLowerCase().endsWith(".xml")) { bos.write(s.getBytes()); bos.write('\n'); continue; } File f = new File(s); if (f.isDirectory()) { findTestsRecursively(bos, s); continue; } Log.v(LOGTAG, "Skipping " + s); } } // Running all the layout tests at once sometimes // Running all the layout tests at once sometimes // causes the dumprendertree to run out of memory. // causes the dumprendertree to run out of memory. // So, additional tests are added to run the tests // So, additional tests are added to run the tests Loading tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java +34 −8 Original line number Original line Diff line number Diff line Loading @@ -17,16 +17,20 @@ package com.android.dumprendertree; package com.android.dumprendertree; import android.content.Intent; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.os.Bundle; import android.util.Log; import android.util.Log; import java.io.BufferedOutputStream; import java.io.File; import java.io.File; import java.io.FileOutputStream; public class Menu extends FileList { public class Menu extends FileList { public void onCreate(Bundle icicle) private static final int MENU_START = 0x01; { private static String LOGTAG = "MenuActivity"; static final String LAYOUT_TESTS_LIST_FILE = "/sdcard/android/layout_tests_list.txt"; public void onCreate(Bundle icicle) { super.onCreate(icicle); super.onCreate(icicle); } } Loading @@ -42,13 +46,35 @@ public class Menu extends FileList { return false; return false; } } void processFile(String filename, boolean selection) void processFile(String filename, boolean selection) { { Intent intent = new Intent(Intent.ACTION_VIEW); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass(this, TestShellActivity.class); intent.setClass(this, TestShellActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(TestShellActivity.TEST_URL, "file://" + filename); intent.putExtra(TestShellActivity.TEST_URL, "file://" + filename); startActivity(intent); startActivity(intent); } } @Override void processDirectory(String path, boolean selection) { generateTestList(path); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass(this, TestShellActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(TestShellActivity.UI_AUTO_TEST, LAYOUT_TESTS_LIST_FILE); startActivity(intent); } private void generateTestList(String path) { try { File tests_list = new File(LAYOUT_TESTS_LIST_FILE); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false)); FsUtils.findLayoutTestsRecursively(bos, path); bos.flush(); bos.close(); } catch (Exception e) { Log.e(LOGTAG, "Error when creating test list: " + e.getMessage()); } } } } tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTest.java +3 −32 Original line number Original line Diff line number Diff line Loading @@ -45,7 +45,7 @@ public class ReliabilityTest extends ActivityInstrumentationTestCase2<Reliabilit //always try to resume first, hence cleaning up status will be the //always try to resume first, hence cleaning up status will be the //responsibility of driver scripts //responsibility of driver scripts String lastUrl = readTestStatus(); String lastUrl = FsUtils.readTestStatus(TEST_STATUS_FILE); if(lastUrl != null && !TEST_DONE.equals(lastUrl)) if(lastUrl != null && !TEST_DONE.equals(lastUrl)) fastForward(listReader, lastUrl); fastForward(listReader, lastUrl); Loading @@ -62,7 +62,7 @@ public class ReliabilityTest extends ActivityInstrumentationTestCase2<Reliabilit continue; continue; start = System.currentTimeMillis(); start = System.currentTimeMillis(); Log.v(LOGTAG, "Testing URL: " + url); Log.v(LOGTAG, "Testing URL: " + url); updateTestStatus(url); FsUtils.updateTestStatus(TEST_STATUS_FILE, url); activity.reset(); activity.reset(); //use message to send new URL to avoid interacting with //use message to send new URL to avoid interacting with //WebView in non-UI thread //WebView in non-UI thread Loading Loading @@ -92,7 +92,7 @@ public class ReliabilityTest extends ActivityInstrumentationTestCase2<Reliabilit System.gc(); System.gc(); System.gc(); System.gc(); } } updateTestStatus(TEST_DONE); FsUtils.updateTestStatus(TEST_STATUS_FILE, TEST_DONE); activity.finish(); activity.finish(); listReader.close(); listReader.close(); } } Loading Loading @@ -122,35 +122,6 @@ public class ReliabilityTest extends ActivityInstrumentationTestCase2<Reliabilit } } } } private void updateTestStatus(String s) { // write last tested url into status file try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(TEST_STATUS_FILE)); bos.write(s.getBytes()); bos.close(); } catch (IOException e) { Log.e(LOGTAG, "Cannot update file " + TEST_STATUS_FILE, e); } } private String readTestStatus() { // read out the test name it stopped last time. String status = null; File testStatusFile = new File(TEST_STATUS_FILE); if(testStatusFile.exists()) { try { BufferedReader inReader = new BufferedReader( new FileReader(testStatusFile)); status = inReader.readLine(); inReader.close(); } catch (IOException e) { Log.e(LOGTAG, "Error reading test status.", e); } } return status; } private void fastForward(BufferedReader testListReader, String lastUrl) { private void fastForward(BufferedReader testListReader, String lastUrl) { //fastforward the BufferedReader to the position right after last url //fastforward the BufferedReader to the position right after last url if(lastUrl == null) if(lastUrl == null) Loading Loading
tests/DumpRenderTree/src/com/android/dumprendertree/FileList.java +51 −22 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,9 @@ import java.util.List; import java.util.Map; import java.util.Map; import java.io.File; import java.io.File; import android.app.AlertDialog; import android.app.ListActivity; import android.app.ListActivity; import android.content.DialogInterface; import android.view.KeyEvent; import android.view.KeyEvent; import android.view.View; import android.view.View; import android.widget.ListView; import android.widget.ListView; Loading Loading @@ -118,17 +120,41 @@ public abstract class FileList extends ListActivity protected void onListItemClick(ListView l, View v, int position, long id) protected void onListItemClick(ListView l, View v, int position, long id) { { Map map = (Map) l.getItemAtPosition(position); Map map = (Map) l.getItemAtPosition(position); String path = (String)map.get("path"); final String path = (String)map.get("path"); if ((new File(path)).isDirectory()) { if ((new File(path)).isDirectory()) { final CharSequence[] items = {"Open", "Run"}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Select an Action"); builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int which) { switch (which) { case OPEN_DIRECTORY: dialog.dismiss(); mPath = path; mPath = path; mFocusFile = null; mFocusFile = null; updateList(); updateList(); break; case RUN_TESTS: dialog.dismiss(); processDirectory(path, false); break; } } }); builder.create().show(); } else { } else { processFile(path, false); processFile(path, false); } } } } /* * This function is called when the user has selected a directory in the * list and wants to perform an action on it instead of navigating into * the directory. */ abstract void processDirectory(String path, boolean selection); /* /* * This function is called when the user has selected a file in the * This function is called when the user has selected a file in the * file list. The selected file could be a file or a directory. * file list. The selected file could be a file or a directory. Loading Loading @@ -164,4 +190,7 @@ public abstract class FileList extends ListActivity protected String mFocusFile; protected String mFocusFile; protected int mFocusIndex; protected int mFocusIndex; private final static int OPEN_DIRECTORY = 0; private final static int RUN_TESTS = 1; } }
tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java 0 → 100644 +80 −0 Original line number Original line Diff line number Diff line package com.android.dumprendertree; import android.util.Log; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; public class FsUtils { private static final String LOGTAG = "FsUtils"; private FsUtils() { //no creation of instances } public static void findLayoutTestsRecursively(BufferedOutputStream bos, String dir) throws IOException { Log.v(LOGTAG, "Searching tests under " + dir); File d = new File(dir); if (!d.isDirectory()) { throw new AssertionError("A directory expected, but got " + dir); } String[] files = d.list(); for (int i = 0; i < files.length; i++) { String s = dir + "/" + files[i]; if (FileFilter.ignoreTest(s)) { Log.v(LOGTAG, " Ignoring: " + s); continue; } if (s.toLowerCase().endsWith(".html") || s.toLowerCase().endsWith(".xml")) { bos.write(s.getBytes()); bos.write('\n'); continue; } File f = new File(s); if (f.isDirectory()) { findLayoutTestsRecursively(bos, s); continue; } Log.v(LOGTAG, "Skipping " + s); } } public static void updateTestStatus(String statusFile, String s) { try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(statusFile)); bos.write(s.getBytes()); bos.close(); } catch (Exception e) { Log.e(LOGTAG, "Cannot update file " + statusFile); } } public static String readTestStatus(String statusFile) { // read out the test name it stopped last time. String status = null; File testStatusFile = new File(statusFile); if(testStatusFile.exists()) { try { BufferedReader inReader = new BufferedReader( new FileReader(testStatusFile)); status = inReader.readLine(); inReader.close(); } catch (IOException e) { Log.e(LOGTAG, "Error reading test status.", e); } } return status; } }
tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java +5 −50 Original line number Original line Diff line number Diff line Loading @@ -178,15 +178,13 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh private void resumeTestList() { private void resumeTestList() { // read out the test name it stoped last time. // read out the test name it stoped last time. try { try { BufferedReader inReader = new BufferedReader(new FileReader(TEST_STATUS_FILE)); String line = FsUtils.readTestStatus(TEST_STATUS_FILE); String line = inReader.readLine(); for (int i = 0; i < mTestList.size(); i++) { for (int i = 0; i < mTestList.size(); i++) { if (mTestList.elementAt(i).equals(line)) { if (mTestList.elementAt(i).equals(line)) { mTestList = new Vector<String>(mTestList.subList(i+1, mTestList.size())); mTestList = new Vector<String>(mTestList.subList(i+1, mTestList.size())); break; break; } } } } inReader.close(); } catch (Exception e) { } catch (Exception e) { Log.e(LOGTAG, "Error reading " + TEST_STATUS_FILE); Log.e(LOGTAG, "Error reading " + TEST_STATUS_FILE); } } Loading @@ -205,17 +203,6 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh } } } } private void updateTestStatus(String s) { // Write TEST_STATUS_FILE try { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(TEST_STATUS_FILE)); bos.write(s.getBytes()); bos.close(); } catch (Exception e) { Log.e(LOGTAG, "Cannot update file " + TEST_STATUS_FILE); } } private String getResultFile(String test) { private String getResultFile(String test) { String shortName = test.substring(0, test.lastIndexOf('.')); String shortName = test.substring(0, test.lastIndexOf('.')); // Write actual results to result directory. // Write actual results to result directory. Loading Loading @@ -392,12 +379,12 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh // Run tests. // Run tests. for (int i = 0; i < mTestList.size(); i++) { for (int i = 0; i < mTestList.size(); i++) { String s = mTestList.elementAt(i); String s = mTestList.elementAt(i); updateTestStatus(s); FsUtils.updateTestStatus(TEST_STATUS_FILE, s); // Run tests // Run tests runTestAndWaitUntilDone(activity, s, runner.mTimeoutInMillis); runTestAndWaitUntilDone(activity, s, runner.mTimeoutInMillis); } } updateTestStatus("#DONE"); FsUtils.updateTestStatus(TEST_STATUS_FILE, "#DONE"); activity.finish(); activity.finish(); } } Loading @@ -424,7 +411,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh try { try { File tests_list = new File(LAYOUT_TESTS_LIST_FILE); File tests_list = new File(LAYOUT_TESTS_LIST_FILE); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false)); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false)); findTestsRecursively(bos, getTestPath()); FsUtils.findLayoutTestsRecursively(bos, getTestPath()); bos.flush(); bos.flush(); bos.close(); bos.close(); } catch (Exception e) { } catch (Exception e) { Loading @@ -432,38 +419,6 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh } } } } private void findTestsRecursively(BufferedOutputStream bos, String dir) throws IOException { Log.v(LOGTAG, "Searching tests under " + dir); File d = new File(dir); if (!d.isDirectory()) { throw new AssertionError("A directory expected, but got " + dir); } String[] files = d.list(); for (int i = 0; i < files.length; i++) { String s = dir + "/" + files[i]; if (FileFilter.ignoreTest(s)) { Log.v(LOGTAG, " Ignoring: " + s); continue; } if (s.toLowerCase().endsWith(".html") || s.toLowerCase().endsWith(".xml")) { bos.write(s.getBytes()); bos.write('\n'); continue; } File f = new File(s); if (f.isDirectory()) { findTestsRecursively(bos, s); continue; } Log.v(LOGTAG, "Skipping " + s); } } // Running all the layout tests at once sometimes // Running all the layout tests at once sometimes // causes the dumprendertree to run out of memory. // causes the dumprendertree to run out of memory. // So, additional tests are added to run the tests // So, additional tests are added to run the tests Loading
tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java +34 −8 Original line number Original line Diff line number Diff line Loading @@ -17,16 +17,20 @@ package com.android.dumprendertree; package com.android.dumprendertree; import android.content.Intent; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.os.Bundle; import android.util.Log; import android.util.Log; import java.io.BufferedOutputStream; import java.io.File; import java.io.File; import java.io.FileOutputStream; public class Menu extends FileList { public class Menu extends FileList { public void onCreate(Bundle icicle) private static final int MENU_START = 0x01; { private static String LOGTAG = "MenuActivity"; static final String LAYOUT_TESTS_LIST_FILE = "/sdcard/android/layout_tests_list.txt"; public void onCreate(Bundle icicle) { super.onCreate(icicle); super.onCreate(icicle); } } Loading @@ -42,13 +46,35 @@ public class Menu extends FileList { return false; return false; } } void processFile(String filename, boolean selection) void processFile(String filename, boolean selection) { { Intent intent = new Intent(Intent.ACTION_VIEW); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass(this, TestShellActivity.class); intent.setClass(this, TestShellActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(TestShellActivity.TEST_URL, "file://" + filename); intent.putExtra(TestShellActivity.TEST_URL, "file://" + filename); startActivity(intent); startActivity(intent); } } @Override void processDirectory(String path, boolean selection) { generateTestList(path); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass(this, TestShellActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(TestShellActivity.UI_AUTO_TEST, LAYOUT_TESTS_LIST_FILE); startActivity(intent); } private void generateTestList(String path) { try { File tests_list = new File(LAYOUT_TESTS_LIST_FILE); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false)); FsUtils.findLayoutTestsRecursively(bos, path); bos.flush(); bos.close(); } catch (Exception e) { Log.e(LOGTAG, "Error when creating test list: " + e.getMessage()); } } } }
tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTest.java +3 −32 Original line number Original line Diff line number Diff line Loading @@ -45,7 +45,7 @@ public class ReliabilityTest extends ActivityInstrumentationTestCase2<Reliabilit //always try to resume first, hence cleaning up status will be the //always try to resume first, hence cleaning up status will be the //responsibility of driver scripts //responsibility of driver scripts String lastUrl = readTestStatus(); String lastUrl = FsUtils.readTestStatus(TEST_STATUS_FILE); if(lastUrl != null && !TEST_DONE.equals(lastUrl)) if(lastUrl != null && !TEST_DONE.equals(lastUrl)) fastForward(listReader, lastUrl); fastForward(listReader, lastUrl); Loading @@ -62,7 +62,7 @@ public class ReliabilityTest extends ActivityInstrumentationTestCase2<Reliabilit continue; continue; start = System.currentTimeMillis(); start = System.currentTimeMillis(); Log.v(LOGTAG, "Testing URL: " + url); Log.v(LOGTAG, "Testing URL: " + url); updateTestStatus(url); FsUtils.updateTestStatus(TEST_STATUS_FILE, url); activity.reset(); activity.reset(); //use message to send new URL to avoid interacting with //use message to send new URL to avoid interacting with //WebView in non-UI thread //WebView in non-UI thread Loading Loading @@ -92,7 +92,7 @@ public class ReliabilityTest extends ActivityInstrumentationTestCase2<Reliabilit System.gc(); System.gc(); System.gc(); System.gc(); } } updateTestStatus(TEST_DONE); FsUtils.updateTestStatus(TEST_STATUS_FILE, TEST_DONE); activity.finish(); activity.finish(); listReader.close(); listReader.close(); } } Loading Loading @@ -122,35 +122,6 @@ public class ReliabilityTest extends ActivityInstrumentationTestCase2<Reliabilit } } } } private void updateTestStatus(String s) { // write last tested url into status file try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(TEST_STATUS_FILE)); bos.write(s.getBytes()); bos.close(); } catch (IOException e) { Log.e(LOGTAG, "Cannot update file " + TEST_STATUS_FILE, e); } } private String readTestStatus() { // read out the test name it stopped last time. String status = null; File testStatusFile = new File(TEST_STATUS_FILE); if(testStatusFile.exists()) { try { BufferedReader inReader = new BufferedReader( new FileReader(testStatusFile)); status = inReader.readLine(); inReader.close(); } catch (IOException e) { Log.e(LOGTAG, "Error reading test status.", e); } } return status; } private void fastForward(BufferedReader testListReader, String lastUrl) { private void fastForward(BufferedReader testListReader, String lastUrl) { //fastforward the BufferedReader to the position right after last url //fastforward the BufferedReader to the position right after last url if(lastUrl == null) if(lastUrl == null) Loading