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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "android_webview/native/input_stream_impl.h" | 7 #include "android_webview/native/input_stream_impl.h" |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
10 #include "jni/InputStreamUnittest_jni.h" | 10 #include "jni/InputStreamUnittest_jni.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 using testing::_; | 31 using testing::_; |
32 | 32 |
33 class InputStreamTest : public Test { | 33 class InputStreamTest : public Test { |
34 public: | 34 public: |
35 InputStreamTest() { | 35 InputStreamTest() { |
36 } | 36 } |
37 protected: | 37 protected: |
38 void SetUp() override { | 38 void SetUp() override { |
39 env_ = AttachCurrentThread(); | 39 env_ = AttachCurrentThread(); |
40 ASSERT_THAT(env_, NotNull()); | 40 ASSERT_THAT(env_, NotNull()); |
41 ASSERT_TRUE(android_webview::RegisterInputStream(env_)); | |
42 ASSERT_TRUE(RegisterNativesImpl(env_)); | 41 ASSERT_TRUE(RegisterNativesImpl(env_)); |
43 } | 42 } |
44 | 43 |
45 scoped_refptr<IOBuffer> DoReadCountedStreamTest(int stream_size, | 44 scoped_refptr<IOBuffer> DoReadCountedStreamTest(int stream_size, |
46 int bytes_requested, | 45 int bytes_requested, |
47 int* bytes_read) { | 46 int* bytes_read) { |
48 ScopedJavaLocalRef<jobject> counting_jstream = | 47 ScopedJavaLocalRef<jobject> counting_jstream = |
49 Java_InputStreamUnittest_getCountingStream(env_, stream_size); | 48 Java_InputStreamUnittest_getCountingStream(env_, stream_size); |
50 EXPECT_FALSE(counting_jstream.is_null()); | 49 EXPECT_FALSE(counting_jstream.is_null()); |
51 | 50 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 135 |
137 const int bytes_requested = 10; | 136 const int bytes_requested = 10; |
138 int bytes_read = 0; | 137 int bytes_read = 0; |
139 scoped_refptr<IOBuffer> buffer = new IOBuffer(bytes_requested); | 138 scoped_refptr<IOBuffer> buffer = new IOBuffer(bytes_requested); |
140 EXPECT_FALSE(input_stream->Read(buffer.get(), bytes_requested, &bytes_read)); | 139 EXPECT_FALSE(input_stream->Read(buffer.get(), bytes_requested, &bytes_read)); |
141 EXPECT_EQ(0, bytes_read); | 140 EXPECT_EQ(0, bytes_read); |
142 | 141 |
143 // This closes the stream. | 142 // This closes the stream. |
144 input_stream.reset(NULL); | 143 input_stream.reset(NULL); |
145 } | 144 } |
OLD | NEW |