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

Unified Diff: content/browser/streams/stream_unittest.cc

Issue 2146773002: [Stream] Notify ReadObserver of Stream abortion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/streams/stream_unittest.cc
diff --git a/content/browser/streams/stream_unittest.cc b/content/browser/streams/stream_unittest.cc
index f57e678c1f55052f8c405f8c47ae8cb39d2013f4..314f56b714fed169617d2f5b1ed68d770fce2f6d 100644
--- a/content/browser/streams/stream_unittest.cc
+++ b/content/browser/streams/stream_unittest.cc
@@ -43,8 +43,7 @@ class StreamTest : public testing::Test {
class TestStreamReader : public StreamReadObserver {
public:
- TestStreamReader() : buffer_(new net::GrowableIOBuffer()), completed_(false) {
- }
+ TestStreamReader() : buffer_(new net::GrowableIOBuffer()) {}
~TestStreamReader() override {}
void Read(Stream* stream) {
@@ -68,6 +67,7 @@ class TestStreamReader : public StreamReadObserver {
EXPECT_FALSE(completed_);
return;
case Stream::STREAM_ABORTED:
+ aborted_ = true;
EXPECT_FALSE(completed_);
return;
}
@@ -82,13 +82,13 @@ class TestStreamReader : public StreamReadObserver {
scoped_refptr<net::GrowableIOBuffer> buffer() { return buffer_; }
- bool completed() const {
- return completed_;
- }
+ bool completed() const { return completed_; }
+ bool aborted() const { return aborted_; }
private:
scoped_refptr<net::GrowableIOBuffer> buffer_;
- bool completed_;
+ bool completed_ = false;
+ bool aborted_ = false;
};
class TestStreamWriter : public StreamWriteObserver {
@@ -204,6 +204,20 @@ TEST_F(StreamTest, Stream) {
EXPECT_EQ(buffer->data()[i], reader.buffer()->data()[i]);
}
+TEST_F(StreamTest, Abort) {
+ TestStreamReader reader;
+ TestStreamWriter writer;
+
+ GURL url("blob://stream");
+ scoped_refptr<Stream> stream(new Stream(registry_.get(), &writer, url));
+ EXPECT_TRUE(stream->SetReadObserver(&reader));
+
+ stream->Abort();
+ base::RunLoop().RunUntilIdle();
+ EXPECT_FALSE(reader.completed());
+ EXPECT_TRUE(reader.aborted());
+}
+
// Test that even if a reader receives an empty buffer, once TransferData()
// method is called on it with |source_complete| = true, following Read() calls
// on it never returns STREAM_EMPTY. Together with StreamTest.Stream above, this

Powered by Google App Engine
This is Rietveld 408576698