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(RegisterNativesImpl(env_)); | |
42 } | 41 } |
43 | 42 |
44 scoped_refptr<IOBuffer> DoReadCountedStreamTest(int stream_size, | 43 scoped_refptr<IOBuffer> DoReadCountedStreamTest(int stream_size, |
45 int bytes_requested, | 44 int bytes_requested, |
46 int* bytes_read) { | 45 int* bytes_read) { |
47 ScopedJavaLocalRef<jobject> counting_jstream = | 46 ScopedJavaLocalRef<jobject> counting_jstream = |
48 Java_InputStreamUnittest_getCountingStream(env_, stream_size); | 47 Java_InputStreamUnittest_getCountingStream(env_, stream_size); |
49 EXPECT_FALSE(counting_jstream.is_null()); | 48 EXPECT_FALSE(counting_jstream.is_null()); |
50 | 49 |
51 std::unique_ptr<InputStream> input_stream( | 50 std::unique_ptr<InputStream> input_stream( |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 134 |
136 const int bytes_requested = 10; | 135 const int bytes_requested = 10; |
137 int bytes_read = 0; | 136 int bytes_read = 0; |
138 scoped_refptr<IOBuffer> buffer = new IOBuffer(bytes_requested); | 137 scoped_refptr<IOBuffer> buffer = new IOBuffer(bytes_requested); |
139 EXPECT_FALSE(input_stream->Read(buffer.get(), bytes_requested, &bytes_read)); | 138 EXPECT_FALSE(input_stream->Read(buffer.get(), bytes_requested, &bytes_read)); |
140 EXPECT_EQ(0, bytes_read); | 139 EXPECT_EQ(0, bytes_read); |
141 | 140 |
142 // This closes the stream. | 141 // This closes the stream. |
143 input_stream.reset(NULL); | 142 input_stream.reset(NULL); |
144 } | 143 } |
OLD | NEW |