OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.android_webview.unittest; |
| 6 |
| 7 import org.chromium.base.CalledByNative; |
| 8 |
| 9 import java.io.InputStream; |
| 10 import java.io.IOException; |
| 11 |
| 12 class InputStreamUnittest { |
| 13 private InputStreamUnittest() { |
| 14 } |
| 15 |
| 16 @CalledByNative |
| 17 static InputStream getEmptyStream() { |
| 18 return new InputStream() { |
| 19 @Override |
| 20 public int read() { |
| 21 return -1; |
| 22 } |
| 23 }; |
| 24 } |
| 25 |
| 26 @CalledByNative |
| 27 static InputStream getCountingStream(final int size) { |
| 28 return new InputStream() { |
| 29 private int count = 0; |
| 30 |
| 31 @Override |
| 32 public int read() { |
| 33 if (count < size) |
| 34 return count++ % 256; |
| 35 else |
| 36 return -1; |
| 37 } |
| 38 }; |
| 39 } |
| 40 } |
OLD | NEW |