summaryrefslogtreecommitdiffstats
path: root/core/tests
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2013-01-31 18:26:20 -0800
committerJeff Sharkey <jsharkey@android.com>2013-01-31 18:27:00 -0800
commit8e7b3b15f7a4f888d55f080d3ed61860cd5fab55 (patch)
treef3c5584dc0b56b7640691aa448bf9dd82991a038 /core/tests
parent1b0e29aec6a9401c224f3fa3a5e05abc487e2e79 (diff)
downloadframeworks_base-8e7b3b15f7a4f888d55f080d3ed61860cd5fab55.zip
frameworks_base-8e7b3b15f7a4f888d55f080d3ed61860cd5fab55.tar.gz
frameworks_base-8e7b3b15f7a4f888d55f080d3ed61860cd5fab55.tar.bz2
Support optional values in ProcFileReader.
When new values are added to proc files, we need to handle reading them from both old and new kernels. This change supports optionally reading long values. Tests to verify. Bug: 7903145 Change-Id: I9fe250c0486c3cce3cf3d8624f01af01128d1191
Diffstat (limited to 'core/tests')
-rw-r--r--core/tests/coretests/src/com/android/internal/util/ProcFileReaderTest.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/core/tests/coretests/src/com/android/internal/util/ProcFileReaderTest.java b/core/tests/coretests/src/com/android/internal/util/ProcFileReaderTest.java
index 386a78d..a81bb4b 100644
--- a/core/tests/coretests/src/com/android/internal/util/ProcFileReaderTest.java
+++ b/core/tests/coretests/src/com/android/internal/util/ProcFileReaderTest.java
@@ -134,7 +134,7 @@ public class ProcFileReaderTest extends AndroidTestCase {
fail("somehow read a string value?");
} catch (IOException e) {
// expected
- assertTrue(e.getMessage().contains("end of stream"));
+ assertTrue(e.getMessage().contains("End of stream"));
}
}
@@ -152,6 +152,20 @@ public class ProcFileReaderTest extends AndroidTestCase {
}
}
+ public void testOptionalLongs() throws Exception {
+ final ProcFileReader reader = buildReader("123 456\n789\n");
+
+ assertEquals(123L, reader.nextLong());
+ assertEquals(456L, reader.nextOptionalLong(-1L));
+ assertEquals(-1L, reader.nextOptionalLong(-1L));
+ assertEquals(-1L, reader.nextOptionalLong(-1L));
+ assertEquals(-1L, reader.nextOptionalLong(-1L));
+ reader.finishLine();
+
+ assertEquals(789L, reader.nextOptionalLong(-1L));
+ assertEquals(-1L, reader.nextOptionalLong(-1L));
+ }
+
private static ProcFileReader buildReader(String string) throws IOException {
return buildReader(string, 2048);
}