diff options
author | Guang Zhu <guangzhu@google.com> | 2010-08-17 17:05:47 -0700 |
---|---|---|
committer | Guang Zhu <guangzhu@google.com> | 2010-08-17 17:10:12 -0700 |
commit | 179b9a1fe98d371dc2064322ec227ba13065f921 (patch) | |
tree | 0de20dcc9e6ba265f9323aee7a1550f8b74febe6 | |
parent | db8a53fa5eda4ba60733775ca62e4dd914259c52 (diff) | |
download | android_packages_apps_Gello-179b9a1fe98d371dc2064322ec227ba13065f921.tar.gz android_packages_apps_Gello-179b9a1fe98d371dc2064322ec227ba13065f921.tar.bz2 android_packages_apps_Gello-179b9a1fe98d371dc2064322ec227ba13065f921.zip |
improvement test app's handling of irregular status file
if it reads an empty line, or have reached end of file, it
will default to the start from beginning scenario.
Change-Id: Ife2e49bf8adf70d6caba7a1d65094401990325a2
-rw-r--r-- | tests/src/com/android/browser/PopularUrlsTest.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/tests/src/com/android/browser/PopularUrlsTest.java b/tests/src/com/android/browser/PopularUrlsTest.java index 547cb9f4..98a0e9fc 100644 --- a/tests/src/com/android/browser/PopularUrlsTest.java +++ b/tests/src/com/android/browser/PopularUrlsTest.java @@ -274,16 +274,26 @@ public class PopularUrlsTest extends ActivityInstrumentationTestCase2<BrowserAct mFile = new File(file); FileReader input = null; BufferedReader reader = null; + isRecovery = false; + iteration = 0; + page = 0; try { input = new FileReader(mFile); isRecovery = true; reader = new BufferedReader(input); - iteration = Integer.parseInt(reader.readLine()); - page = Integer.parseInt(reader.readLine()); + String line = reader.readLine(); + if (line == null) + return; + iteration = Integer.parseInt(line); + line = reader.readLine(); + if (line == null) + return; + page = Integer.parseInt(line); } catch (FileNotFoundException ex) { - isRecovery = false; - iteration = 0; - page = 0; + return; + } catch (NumberFormatException nfe) { + Log.wtf(TAG, "unexpected data in status file, will start from begining"); + return; } finally { try { if (reader != null) { |