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

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

Issue 430443003: Use unchecked InputStream methods in the android_webview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove old InputStream jni Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « android_webview/native/input_stream_impl.cc ('k') | android_webview/native/webview_native.gyp » ('j') | 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 DoReadCountedStreamTest(bytes_requested + 32, bytes_requested, &bytes_read); 112 DoReadCountedStreamTest(bytes_requested + 32, bytes_requested, &bytes_read);
113 EXPECT_EQ(bytes_requested, bytes_read); 113 EXPECT_EQ(bytes_requested, bytes_read);
114 } 114 }
115 115
116 TEST_F(InputStreamTest, ReadLargeStreamCompletely) { 116 TEST_F(InputStreamTest, ReadLargeStreamCompletely) {
117 const int bytes_requested = 3 * InputStreamImpl::kBufferSize; 117 const int bytes_requested = 3 * InputStreamImpl::kBufferSize;
118 int bytes_read = 0; 118 int bytes_read = 0;
119 DoReadCountedStreamTest(bytes_requested, bytes_requested, &bytes_read); 119 DoReadCountedStreamTest(bytes_requested, bytes_requested, &bytes_read);
120 EXPECT_EQ(bytes_requested, bytes_read); 120 EXPECT_EQ(bytes_requested, bytes_read);
121 } 121 }
122
123 TEST_F(InputStreamTest, DoesNotCrashWhenExceptionThrown) {
124 ScopedJavaLocalRef<jobject> throw_jstream =
125 Java_InputStreamUnittest_getThrowingStream(env_);
126 EXPECT_FALSE(throw_jstream.is_null());
127
128 scoped_ptr<InputStream> input_stream(new InputStreamImpl(throw_jstream));
129
130 int64_t bytes_skipped;
131 EXPECT_FALSE(input_stream->Skip(10, &bytes_skipped));
132
133 int bytes_available;
134 EXPECT_FALSE(input_stream->BytesAvailable(&bytes_available));
135
136
137 const int bytes_requested = 10;
138 int bytes_read = 0;
139 scoped_refptr<IOBuffer> buffer = new IOBuffer(bytes_requested);
140 EXPECT_FALSE(input_stream->Read(buffer.get(), bytes_requested, &bytes_read));
141 EXPECT_EQ(0, bytes_read);
142
143 // This closes the stream.
144 input_stream.reset(NULL);
145 }
OLDNEW
« no previous file with comments | « android_webview/native/input_stream_impl.cc ('k') | android_webview/native/webview_native.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698