Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(854)

Side by Side Diff: android_webview/native/input_stream_unittest.cc

Issue 24082006: [Android WebView] Make InputStreamImpl::Read fill the IOBuffer. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed tests Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « android_webview/native/input_stream_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = 3 * InputStreamImpl::kBufferSize;
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 = 3 * InputStreamImpl::kBufferSize;
118 int bytes_read = 0;
119 DoReadCountedStreamTest(bytes_requested, bytes_requested, &bytes_read);
120 EXPECT_EQ(bytes_requested, bytes_read);
121 }
OLDNEW
« no previous file with comments | « android_webview/native/input_stream_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698