| 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 17 matching lines...) Expand all Loading... |
| 28 using testing::Return; | 28 using testing::Return; |
| 29 using testing::SetArgPointee; | 29 using testing::SetArgPointee; |
| 30 using testing::Test; | 30 using testing::Test; |
| 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 virtual void SetUp() { | 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_)); | 41 ASSERT_TRUE(android_webview::RegisterInputStream(env_)); |
| 42 ASSERT_TRUE(RegisterNativesImpl(env_)); | 42 ASSERT_TRUE(RegisterNativesImpl(env_)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 scoped_refptr<IOBuffer> DoReadCountedStreamTest(int stream_size, | 45 scoped_refptr<IOBuffer> DoReadCountedStreamTest(int stream_size, |
| 46 int bytes_requested, | 46 int bytes_requested, |
| 47 int* bytes_read) { | 47 int* bytes_read) { |
| 48 ScopedJavaLocalRef<jobject> counting_jstream = | 48 ScopedJavaLocalRef<jobject> counting_jstream = |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 const int bytes_requested = 10; | 137 const int bytes_requested = 10; |
| 138 int bytes_read = 0; | 138 int bytes_read = 0; |
| 139 scoped_refptr<IOBuffer> buffer = new IOBuffer(bytes_requested); | 139 scoped_refptr<IOBuffer> buffer = new IOBuffer(bytes_requested); |
| 140 EXPECT_FALSE(input_stream->Read(buffer.get(), bytes_requested, &bytes_read)); | 140 EXPECT_FALSE(input_stream->Read(buffer.get(), bytes_requested, &bytes_read)); |
| 141 EXPECT_EQ(0, bytes_read); | 141 EXPECT_EQ(0, bytes_read); |
| 142 | 142 |
| 143 // This closes the stream. | 143 // This closes the stream. |
| 144 input_stream.reset(NULL); | 144 input_stream.reset(NULL); |
| 145 } | 145 } |
| OLD | NEW |