Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "android_webview/native/input_stream_impl.h" | 5 #include "android_webview/native/input_stream_impl.h" |
| 6 #include "base/android/jni_android.h" | 6 #include "base/android/jni_android.h" |
| 7 #include "base/android/scoped_java_ref.h" | 7 #include "base/android/scoped_java_ref.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "jni/InputStreamUnittest_jni.h" | 9 #include "jni/InputStreamUnittest_jni.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 } | 82 } |
| 83 | 83 |
| 84 TEST_F(InputStreamTest, ReadStreamCompletely) { | 84 TEST_F(InputStreamTest, ReadStreamCompletely) { |
| 85 const int bytes_requested = 42; | 85 const int bytes_requested = 42; |
| 86 int bytes_read = 0; | 86 int bytes_read = 0; |
| 87 DoReadCountedStreamTest(bytes_requested, bytes_requested, &bytes_read); | 87 DoReadCountedStreamTest(bytes_requested, bytes_requested, &bytes_read); |
| 88 EXPECT_EQ(bytes_requested, bytes_read); | 88 EXPECT_EQ(bytes_requested, bytes_read); |
| 89 } | 89 } |
| 90 | 90 |
| 91 TEST_F(InputStreamTest, TryReadMoreThanBuffer) { | 91 TEST_F(InputStreamTest, TryReadMoreThanBuffer) { |
| 92 const int bytes_requested = 3 * InputStreamImpl::kBufferSize; | 92 const int buffer_size = 3 * InputStreamImpl::kBufferSize; |
| 93 int bytes_read = 0; | 93 int bytes_read = 0; |
| 94 DoReadCountedStreamTest(bytes_requested, bytes_requested, &bytes_read); | 94 DoReadCountedStreamTest(buffer_size, buffer_size * 2, &bytes_read); |
| 95 EXPECT_EQ(InputStreamImpl::kBufferSize, bytes_read); | 95 EXPECT_EQ(buffer_size, bytes_read); |
| 96 } | 96 } |
| 97 | 97 |
| 98 TEST_F(InputStreamTest, CheckContentsReadCorrectly) { | 98 TEST_F(InputStreamTest, CheckContentsReadCorrectly) { |
| 99 const int bytes_requested = 256; | 99 const int bytes_requested = 256; |
| 100 int bytes_read = 0; | 100 int bytes_read = 0; |
| 101 scoped_refptr<IOBuffer> buffer = | 101 scoped_refptr<IOBuffer> buffer = |
| 102 DoReadCountedStreamTest(bytes_requested, bytes_requested, &bytes_read); | 102 DoReadCountedStreamTest(bytes_requested, bytes_requested, &bytes_read); |
| 103 EXPECT_EQ(bytes_requested, bytes_read); | 103 EXPECT_EQ(bytes_requested, bytes_read); |
| 104 for (int i = 0; i < bytes_requested; ++i) { | 104 for (int i = 0; i < bytes_requested; ++i) { |
| 105 EXPECT_EQ(i, (unsigned char)buffer->data()[i]); | 105 EXPECT_EQ(i, (unsigned char)buffer->data()[i]); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | |
| 109 TEST_F(InputStreamTest, ReadLargeStreamPartial) { | |
| 110 const int bytes_requested = 16 * 1024; | |
|
mkosiba (inactive)
2013/09/19 01:58:01
sorry for the late feedback. could we maybe expres
Primiano Tucci (use gerrit)
2013/09/19 01:58:55
Done.
| |
| 111 int bytes_read = 0; | |
| 112 DoReadCountedStreamTest(bytes_requested + 32, bytes_requested, &bytes_read); | |
| 113 EXPECT_EQ(bytes_requested, bytes_read); | |
| 114 } | |
| 115 | |
| 116 TEST_F(InputStreamTest, ReadLargeStreamCompletely) { | |
| 117 const int bytes_requested = 16 * 1024; | |
| 118 int bytes_read = 0; | |
| 119 DoReadCountedStreamTest(bytes_requested, bytes_requested, &bytes_read); | |
| 120 EXPECT_EQ(bytes_requested, bytes_read); | |
| 121 } | |
| OLD | NEW |