diff options
| author | Jesse Wilson <jessewilson@google.com> | 2009-09-26 11:21:16 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2009-09-26 11:21:16 -0700 |
| commit | c27d57182a5722aba51af700593852b4ab006653 (patch) | |
| tree | aefc97bfe40c826235feaae1cbe79ffe9cdb63fd /tests | |
| parent | b9b6b17d73590e07d9fcfa50671bbd6df0f150cf (diff) | |
| parent | 5648dbb1dabc0231fe953ad45916c067c79986c8 (diff) | |
| download | frameworks_base-c27d57182a5722aba51af700593852b4ab006653.zip frameworks_base-c27d57182a5722aba51af700593852b4ab006653.tar.gz frameworks_base-c27d57182a5722aba51af700593852b4ab006653.tar.bz2 | |
am 5648dbb1: Merge change 27159 into eclair
Merge commit '5648dbb1dabc0231fe953ad45916c067c79986c8' into eclair-plus-aosp
* commit '5648dbb1dabc0231fe953ad45916c067c79986c8':
DO NOT MERGE: Cleaning up the PipedStreamTest
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/CoreTests/android/core/PipedStreamTest.java | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/tests/CoreTests/android/core/PipedStreamTest.java b/tests/CoreTests/android/core/PipedStreamTest.java index 564b337..d98bc10 100644 --- a/tests/CoreTests/android/core/PipedStreamTest.java +++ b/tests/CoreTests/android/core/PipedStreamTest.java @@ -117,7 +117,7 @@ public class PipedStreamTest extends TestCase { for (; ;) { try { reader.join(60 * 1000); - writer.join(1 * 1000); + writer.join(1000); break; } catch (InterruptedException ex) { } @@ -166,11 +166,11 @@ public class PipedStreamTest extends TestCase { int readInt = (((int) readBytes[0] & 0xff) << 24) | (((int) readBytes[1] & 0xff) << 16) | (((int) readBytes[2] & 0xff) << 8) - | (((int) readBytes[3] & 0xff) << 0); + | (((int) readBytes[3] & 0xff)); - assertEquals(readInt, fib.next()); - assertEquals(0, readBytes[4]); + assertEquals("Error at " + countRead, fib.next(), readInt); + assertEquals("Error at " + countRead, 0, readBytes[4]); countRead++; } } @@ -189,7 +189,7 @@ public class PipedStreamTest extends TestCase { writeBytes[0] = (byte) (toWrite >> 24); writeBytes[1] = (byte) (toWrite >> 16); writeBytes[2] = (byte) (toWrite >> 8); - writeBytes[3] = (byte) (toWrite >> 0); + writeBytes[3] = (byte) (toWrite); writeBytes[4] = 0; out.write(writeBytes, 0, writeBytes.length); } @@ -203,37 +203,35 @@ public class PipedStreamTest extends TestCase { for (; ;) { try { reader.join(60 * 1000); - writer.join(1 * 1000); + writer.join(1000); break; } catch (InterruptedException ex) { } } - assertEquals(2000, reader.countRead); - - if (writer.exception != null) { - throw new Exception(writer.exception); - } if (reader.exception != null) { throw new Exception(reader.exception); } + if (writer.exception != null) { + throw new Exception(writer.exception); + } + + assertEquals(2000, reader.countRead); } @SmallTest public void testC() throws Exception { final PipedInputStream in = new PipedInputStream(); final PipedOutputStream out = new PipedOutputStream(in); + final byte readBytes[] = new byte[1024 * 2]; assertEquals(0, in.available()); TestThread reader, writer; reader = new TestThread() { - Fibonacci fib = new Fibonacci(); - @Override public void runTest() throws Exception { - byte readBytes[] = new byte[1024 * 2]; int ret; for (; ;) { @@ -246,17 +244,6 @@ public class PipedStreamTest extends TestCase { } nread += ret; } - - assertEquals(nread, readBytes.length); - - for (int i = 0; i < (readBytes.length - 4); i += 4) { - int readInt = (((int) readBytes[i + 0] & 0xff) << 24) - | (((int) readBytes[i + 1] & 0xff) << 16) - | (((int) readBytes[i + 2] & 0xff) << 8) - | (((int) readBytes[i + 3] & 0xff) << 0); - - assertEquals(readInt, fib.next()); - } } } }; @@ -271,10 +258,10 @@ public class PipedStreamTest extends TestCase { byte writeBytes[] = new byte[1024 * 2]; for (int i = 0; i < (writeBytes.length - 4); i += 4) { int toWrite = fib.next(); - writeBytes[i + 0] = (byte) (toWrite >> 24); + writeBytes[i ] = (byte) (toWrite >> 24); writeBytes[i + 1] = (byte) (toWrite >> 16); writeBytes[i + 2] = (byte) (toWrite >> 8); - writeBytes[i + 3] = (byte) (toWrite >> 0); + writeBytes[i + 3] = (byte) (toWrite); } out.write(writeBytes, 0, writeBytes.length); out.close(); @@ -287,17 +274,27 @@ public class PipedStreamTest extends TestCase { for (; ;) { try { reader.join(60 * 1000); - writer.join(1 * 100); + writer.join(1000); break; } catch (InterruptedException ex) { } } + if (reader.exception != null) { + throw new Exception(reader.exception); + } if (writer.exception != null) { throw new Exception(writer.exception); } - if (reader.exception != null) { - throw new Exception(reader.exception); + + Fibonacci fib = new Fibonacci(); + for (int i = 0; i < (readBytes.length - 4); i += 4) { + int readInt = (((int) readBytes[i] & 0xff) << 24) + | (((int) readBytes[i + 1] & 0xff) << 16) + | (((int) readBytes[i + 2] & 0xff) << 8) + | (((int) readBytes[i + 3] & 0xff)); + + assertEquals("Error at " + i, readInt, fib.next()); } } } |
