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

Side by Side Diff: Source/modules/fetch/BodyStreamBufferTest.cpp

Issue 1233573002: [Fetch API] Remove DrainingBuffer. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "modules/fetch/BodyStreamBuffer.h" 6 #include "modules/fetch/BodyStreamBuffer.h"
7 7
8 #include "core/testing/DummyPageHolder.h"
8 #include "modules/fetch/DataConsumerHandleTestUtil.h" 9 #include "modules/fetch/DataConsumerHandleTestUtil.h"
9 #include "platform/testing/UnitTestHelpers.h" 10 #include "platform/testing/UnitTestHelpers.h"
11 #include "wtf/OwnPtr.h"
10 12
11 #include <gmock/gmock.h> 13 #include <gmock/gmock.h>
12 #include <gtest/gtest.h> 14 #include <gtest/gtest.h>
13 15
14 namespace blink { 16 namespace blink {
15 17
16 namespace { 18 namespace {
17 19
18 using ::testing::InSequence; 20 using ::testing::InSequence;
19 using ::testing::_; 21 using ::testing::_;
20 using ::testing::Return; 22 using ::testing::SaveArg;
21 using Checkpoint = ::testing::StrictMock<::testing::MockFunction<void(int)>>; 23 using Checkpoint = ::testing::StrictMock<::testing::MockFunction<void(int)>>;
22 using Command = DataConsumerHandleTestUtil::Command; 24 using Command = DataConsumerHandleTestUtil::Command;
23 using ReplayingHandle = DataConsumerHandleTestUtil::ReplayingHandle; 25 using ReplayingHandle = DataConsumerHandleTestUtil::ReplayingHandle;
24 using MockFetchDataConsumerHandle = DataConsumerHandleTestUtil::MockFetchDataCon sumerHandle;
25 using MockFetchDataConsumerReader = DataConsumerHandleTestUtil::MockFetchDataCon sumerReader;
26 using MockFetchDataLoaderClient = DataConsumerHandleTestUtil::MockFetchDataLoade rClient; 26 using MockFetchDataLoaderClient = DataConsumerHandleTestUtil::MockFetchDataLoade rClient;
27 27
28 const FetchDataConsumerHandle::Reader::BlobSizePolicy kAllowBlobWithInvalidSize = FetchDataConsumerHandle::Reader::AllowBlobWithInvalidSize; 28 using Result = WebDataConsumerHandle::Result;
29 29 const WebDataConsumerHandle::Flags kNone = WebDataConsumerHandle::FlagNone;
30 class MockDrainingStreamNotificationClient : public GarbageCollectedFinalized<Mo ckDrainingStreamNotificationClient>, public BodyStreamBuffer::DrainingStreamNoti ficationClient { 30 const Result kDone = WebDataConsumerHandle::Done;
31 USING_GARBAGE_COLLECTED_MIXIN(MockDrainingStreamNotificationClient); 31
32 class BodyStreamBufferTest : public ::testing::Test {
32 public: 33 public:
33 static ::testing::StrictMock<MockDrainingStreamNotificationClient>* create() { return new ::testing::StrictMock<MockDrainingStreamNotificationClient>; } 34 BodyStreamBufferTest()
34
35 DEFINE_INLINE_VIRTUAL_TRACE()
36 { 35 {
37 DrainingStreamNotificationClient::trace(visitor); 36 m_page = DummyPageHolder::create(IntSize(1, 1));
38 } 37 }
39 38 ~BodyStreamBufferTest() override {}
40 MOCK_METHOD0(didFetchDataLoadFinishedFromDrainingStream, void()); 39
40 protected:
41 ExecutionContext* executionContext() { return &m_page->document(); }
42
43 OwnPtr<DummyPageHolder> m_page;
41 }; 44 };
42 45
43 TEST(DrainingBodyStreamBufferTest, NotifyOnDestruction) 46 TEST_F(BodyStreamBufferTest, CreateNullBodyStreamBuffer)
44 { 47 {
45 Checkpoint checkpoint; 48 BodyStreamBuffer* buffer = new BodyStreamBuffer();
46 InSequence s; 49 EXPECT_FALSE(buffer->hasBody());
47 50 EXPECT_FALSE(buffer->isLocked());
48 MockDrainingStreamNotificationClient* client = MockDrainingStreamNotificatio nClient::create(); 51 EXPECT_FALSE(buffer->hasPendingActivity());
49 52 EXPECT_TRUE(buffer->stream());
50 EXPECT_CALL(checkpoint, Call(1)); 53 }
51 EXPECT_CALL(*client, didFetchDataLoadFinishedFromDrainingStream()); 54
52 EXPECT_CALL(checkpoint, Call(2)); 55 TEST_F(BodyStreamBufferTest, LockNullBodyStreamBuffer)
53 56 {
54 BodyStreamBuffer* buffer = BodyStreamBuffer::createEmpty(); 57 BodyStreamBuffer* buffer = new BodyStreamBuffer();
55 OwnPtr<DrainingBodyStreamBuffer> drainingBuffer = DrainingBodyStreamBuffer:: create(buffer, client); 58 size_t size;
56 checkpoint.Call(1); 59
57 drainingBuffer.clear(); 60 OwnPtr<FetchDataConsumerHandle> handle = buffer->lock(executionContext());
58 checkpoint.Call(2); 61
59 } 62 EXPECT_FALSE(buffer->hasBody());
60 63 EXPECT_FALSE(buffer->isLocked());
61 TEST(DrainingBodyStreamBufferTest, NotifyWhenBlobDataHandleIsDrained) 64 EXPECT_TRUE(buffer->hasPendingActivity());
62 { 65 ASSERT_TRUE(handle);
63 Checkpoint checkpoint; 66
64 InSequence s; 67 OwnPtr<FetchDataConsumerHandle::Reader> reader = handle->obtainReader(nullpt r);
65 68 ASSERT_TRUE(reader);
66 OwnPtr<MockFetchDataConsumerHandle> src(MockFetchDataConsumerHandle::create( )); 69 Result r =reader->read(nullptr, 0, kNone, &size);
67 OwnPtr<MockFetchDataConsumerReader> reader(MockFetchDataConsumerReader::crea te()); 70 EXPECT_EQ(kDone, r);
68 RefPtr<BlobDataHandle> blobDataHandle = BlobDataHandle::create(); 71 reader = nullptr;
69 72 buffer->unlock(handle.release());
70 MockDrainingStreamNotificationClient* client = MockDrainingStreamNotificatio nClient::create(); 73 EXPECT_FALSE(buffer->hasBody());
71 74 EXPECT_FALSE(buffer->isLocked());
72 EXPECT_CALL(checkpoint, Call(1)); 75 EXPECT_FALSE(buffer->hasPendingActivity());
73 EXPECT_CALL(checkpoint, Call(2)); 76 }
74 EXPECT_CALL(*src, obtainReaderInternal(_)).WillOnce(Return(reader.get())); 77
75 EXPECT_CALL(*reader, drainAsBlobDataHandle(kAllowBlobWithInvalidSize)).WillO nce(Return(blobDataHandle)); 78 TEST_F(BodyStreamBufferTest, LoadNullBodyStreamBuffer)
76 EXPECT_CALL(*client, didFetchDataLoadFinishedFromDrainingStream()); 79 {
77 EXPECT_CALL(checkpoint, Call(3)); 80 Checkpoint checkpoint;
78 EXPECT_CALL(checkpoint, Call(4)); 81 MockFetchDataLoaderClient* client = MockFetchDataLoaderClient::create();
79 82
80 // |reader| is adopted by |obtainReader|. 83 InSequence s;
81 ASSERT_TRUE(reader.leakPtr()); 84 EXPECT_CALL(checkpoint, Call(1));
82 85 EXPECT_CALL(*client, didFetchDataLoadedString(String("")));
83 BodyStreamBuffer* buffer = BodyStreamBuffer::create(src.release()); 86 EXPECT_CALL(checkpoint, Call(2));
84 checkpoint.Call(1); 87
85 OwnPtr<DrainingBodyStreamBuffer> drainingBuffer = DrainingBodyStreamBuffer:: create(buffer, client); 88 BodyStreamBuffer* buffer = new BodyStreamBuffer();
86 checkpoint.Call(2); 89 buffer->startLoading(executionContext(), FetchDataLoader::createLoaderAsStri ng(), client);
87 EXPECT_EQ(blobDataHandle, drainingBuffer->drainAsBlobDataHandle(kAllowBlobWi thInvalidSize)); 90
88 checkpoint.Call(3); 91 EXPECT_FALSE(buffer->hasBody());
89 drainingBuffer.clear(); 92 EXPECT_FALSE(buffer->isLocked());
90 checkpoint.Call(4); 93 EXPECT_TRUE(buffer->hasPendingActivity());
91 } 94
92 95 checkpoint.Call(1);
93 TEST(DrainingBodyStreamBufferTest, DoNotNotifyWhenNullBlobDataHandleIsDrained) 96 testing::runPendingTasks();
94 { 97 checkpoint.Call(2);
95 Checkpoint checkpoint; 98
96 InSequence s; 99 EXPECT_FALSE(buffer->hasBody());
97 100 EXPECT_FALSE(buffer->isLocked());
98 MockDrainingStreamNotificationClient* client = MockDrainingStreamNotificatio nClient::create(); 101 EXPECT_FALSE(buffer->hasPendingActivity());
99 102 }
100 EXPECT_CALL(checkpoint, Call(1)); 103
101 EXPECT_CALL(checkpoint, Call(2)); 104 TEST_F(BodyStreamBufferTest, LockBodyStreamBuffer)
102 EXPECT_CALL(*client, didFetchDataLoadFinishedFromDrainingStream()); 105 {
103 EXPECT_CALL(checkpoint, Call(3)); 106 OwnPtr<FetchDataConsumerHandle> handle = createFetchDataConsumerHandleFromWe bHandle(createWaitingDataConsumerHandle());
104 107 FetchDataConsumerHandle* rawHandle = handle.get();
105 BodyStreamBuffer* buffer = BodyStreamBuffer::createEmpty(); 108 BodyStreamBuffer* buffer = new BodyStreamBuffer(handle.release());
106 OwnPtr<DrainingBodyStreamBuffer> drainingBuffer = DrainingBodyStreamBuffer:: create(buffer, client); 109
107 checkpoint.Call(1); 110 EXPECT_TRUE(buffer->hasBody());
108 EXPECT_FALSE(drainingBuffer->drainAsBlobDataHandle(kAllowBlobWithInvalidSize )); 111 EXPECT_FALSE(buffer->isLocked());
109 checkpoint.Call(2); 112 EXPECT_FALSE(buffer->hasPendingActivity());
110 drainingBuffer.clear(); 113
111 checkpoint.Call(3); 114 handle = buffer->lock(executionContext());
112 } 115
113 116 ASSERT_EQ(rawHandle, handle.get());
114 TEST(DrainingBodyStreamBufferTest, DoNotNotifyWhenBufferIsLeaked) 117 EXPECT_TRUE(buffer->hasBody());
115 { 118 EXPECT_TRUE(buffer->isLocked());
116 Checkpoint checkpoint; 119 EXPECT_TRUE(buffer->hasPendingActivity());
117 InSequence s; 120
118 121 buffer->unlock(handle.release());
119 MockDrainingStreamNotificationClient* client = MockDrainingStreamNotificatio nClient::create(); 122
120 123 EXPECT_TRUE(buffer->hasBody());
121 EXPECT_CALL(checkpoint, Call(1)); 124 EXPECT_FALSE(buffer->isLocked());
122 EXPECT_CALL(checkpoint, Call(2)); 125 EXPECT_FALSE(buffer->hasPendingActivity());
123 EXPECT_CALL(checkpoint, Call(3)); 126
124 127 // Once again!
125 BodyStreamBuffer* buffer = BodyStreamBuffer::createEmpty(); 128 handle = buffer->lock(executionContext());
126 129
127 OwnPtr<DrainingBodyStreamBuffer> drainingBuffer = DrainingBodyStreamBuffer:: create(buffer, client); 130 ASSERT_EQ(rawHandle, handle.get());
128 checkpoint.Call(1); 131 EXPECT_TRUE(buffer->hasBody());
129 EXPECT_EQ(buffer, drainingBuffer->leakBuffer()); 132 EXPECT_TRUE(buffer->isLocked());
130 checkpoint.Call(2); 133 EXPECT_TRUE(buffer->hasPendingActivity());
131 drainingBuffer.clear(); 134 }
132 checkpoint.Call(3); 135
133 } 136 TEST_F(BodyStreamBufferTest, LoadBodyStreamBufferAsArrayBuffer)
134 137 {
135 TEST(DrainingBodyStreamBufferTest, NotifyOnStartLoading) 138 Checkpoint checkpoint;
136 { 139 MockFetchDataLoaderClient* client = MockFetchDataLoaderClient::create();
137 Checkpoint checkpoint; 140 RefPtr<DOMArrayBuffer> arrayBuffer;
138 InSequence s; 141
139 142 InSequence s;
140 OwnPtr<ReplayingHandle> src(ReplayingHandle::create()); 143 EXPECT_CALL(checkpoint, Call(1));
141 src->add(Command(Command::Data, "hello, world.")); 144 EXPECT_CALL(*client, didFetchDataLoadedArrayBufferMock(_)).WillOnce(SaveArg< 0>(&arrayBuffer));
142 src->add(Command(Command::Done)); 145 EXPECT_CALL(checkpoint, Call(2));
143 146
144 MockDrainingStreamNotificationClient* client = MockDrainingStreamNotificatio nClient::create(); 147 OwnPtr<ReplayingHandle> handle = ReplayingHandle::create();
145 MockFetchDataLoaderClient* fetchDataLoaderClient = MockFetchDataLoaderClient ::create(); 148 handle->add(Command(Command::Data, "hello"));
146 FetchDataLoader* fetchDataLoader = FetchDataLoader::createLoaderAsString(); 149 handle->add(Command(Command::Done));
147 150 BodyStreamBuffer* buffer = new BodyStreamBuffer(createFetchDataConsumerHandl eFromWebHandle(handle.release()));
148 EXPECT_CALL(checkpoint, Call(1)); 151 buffer->startLoading(executionContext(), FetchDataLoader::createLoaderAsArra yBuffer(), client);
149 EXPECT_CALL(checkpoint, Call(2)); 152
150 EXPECT_CALL(checkpoint, Call(3)); 153 EXPECT_TRUE(buffer->hasBody());
151 EXPECT_CALL(checkpoint, Call(4)); 154 EXPECT_TRUE(buffer->isLocked());
152 EXPECT_CALL(*fetchDataLoaderClient, didFetchDataLoadedString(String("hello, world."))); 155 EXPECT_TRUE(buffer->hasPendingActivity());
153 EXPECT_CALL(*client, didFetchDataLoadFinishedFromDrainingStream()); 156
154 EXPECT_CALL(checkpoint, Call(5)); 157 checkpoint.Call(1);
155 158 testing::runPendingTasks();
156 Persistent<BodyStreamBuffer> buffer = BodyStreamBuffer::create(createFetchDa taConsumerHandleFromWebHandle(src.release())); 159 checkpoint.Call(2);
157 OwnPtr<DrainingBodyStreamBuffer> drainingBuffer = DrainingBodyStreamBuffer:: create(buffer, client); 160
158 checkpoint.Call(1); 161 EXPECT_TRUE(buffer->hasBody());
159 drainingBuffer->startLoading(fetchDataLoader, fetchDataLoaderClient); 162 EXPECT_FALSE(buffer->isLocked());
160 checkpoint.Call(2); 163 EXPECT_FALSE(buffer->hasPendingActivity());
161 drainingBuffer.clear(); 164 EXPECT_EQ("hello", String(static_cast<const char*>(arrayBuffer->data()), arr ayBuffer->byteLength()));
162 checkpoint.Call(3); 165 }
163 // Loading continues as long as |buffer| is alive. 166
164 Heap::collectAllGarbage(); 167 TEST_F(BodyStreamBufferTest, LoadBodyStreamBufferAsBlob)
165 checkpoint.Call(4); 168 {
166 testing::runPendingTasks(); 169 Checkpoint checkpoint;
167 checkpoint.Call(5); 170 MockFetchDataLoaderClient* client = MockFetchDataLoaderClient::create();
171 RefPtr<BlobDataHandle> blobDataHandle;
172
173 InSequence s;
174 EXPECT_CALL(checkpoint, Call(1));
175 EXPECT_CALL(*client, didFetchDataLoadedBlobHandleMock(_)).WillOnce(SaveArg<0 >(&blobDataHandle));
176 EXPECT_CALL(checkpoint, Call(2));
177
178 OwnPtr<ReplayingHandle> handle = ReplayingHandle::create();
179 handle->add(Command(Command::Data, "hello"));
180 handle->add(Command(Command::Done));
181 BodyStreamBuffer* buffer = new BodyStreamBuffer(createFetchDataConsumerHandl eFromWebHandle(handle.release()));
182 buffer->startLoading(executionContext(), FetchDataLoader::createLoaderAsBlob Handle("text/plain"), client);
183
184 EXPECT_TRUE(buffer->hasBody());
185 EXPECT_TRUE(buffer->isLocked());
186 EXPECT_TRUE(buffer->hasPendingActivity());
187
188 checkpoint.Call(1);
189 testing::runPendingTasks();
190 checkpoint.Call(2);
191
192 EXPECT_TRUE(buffer->hasBody());
193 EXPECT_FALSE(buffer->isLocked());
194 EXPECT_FALSE(buffer->hasPendingActivity());
195 EXPECT_EQ(5u, blobDataHandle->size());
196 }
197
198 TEST_F(BodyStreamBufferTest, LoadBodyStreamBufferAsString)
199 {
200 Checkpoint checkpoint;
201 MockFetchDataLoaderClient* client = MockFetchDataLoaderClient::create();
202
203 InSequence s;
204 EXPECT_CALL(checkpoint, Call(1));
205 EXPECT_CALL(*client, didFetchDataLoadedString(String("hello")));
206 EXPECT_CALL(checkpoint, Call(2));
207
208 OwnPtr<ReplayingHandle> handle = ReplayingHandle::create();
209 handle->add(Command(Command::Data, "hello"));
210 handle->add(Command(Command::Done));
211 BodyStreamBuffer* buffer = new BodyStreamBuffer(createFetchDataConsumerHandl eFromWebHandle(handle.release()));
212 buffer->startLoading(executionContext(), FetchDataLoader::createLoaderAsStri ng(), client);
213
214 EXPECT_TRUE(buffer->hasBody());
215 EXPECT_TRUE(buffer->isLocked());
216 EXPECT_TRUE(buffer->hasPendingActivity());
217
218 checkpoint.Call(1);
219 testing::runPendingTasks();
220 checkpoint.Call(2);
221
222 EXPECT_TRUE(buffer->hasBody());
223 EXPECT_FALSE(buffer->isLocked());
224 EXPECT_FALSE(buffer->hasPendingActivity());
225 }
226
227 TEST_F(BodyStreamBufferTest, LockClosedHandle)
228 {
229 BodyStreamBuffer* buffer = new BodyStreamBuffer(createFetchDataConsumerHandl eFromWebHandle(createDoneDataConsumerHandle()));
230
231 EXPECT_EQ(ReadableStream::Readable, buffer->stream()->stateInternal());
232 testing::runPendingTasks();
233 EXPECT_EQ(ReadableStream::Closed, buffer->stream()->stateInternal());
234
235 EXPECT_FALSE(buffer->isLocked());
236 OwnPtr<FetchDataConsumerHandle> handle = buffer->lock(executionContext());
237 EXPECT_FALSE(buffer->isLocked());
238 OwnPtr<FetchDataConsumerHandle> handle2 = buffer->lock(executionContext());
239
240 EXPECT_TRUE(handle);
241 EXPECT_TRUE(handle2);
242 EXPECT_FALSE(buffer->isLocked());
243 EXPECT_TRUE(buffer->hasPendingActivity());
244 EXPECT_TRUE(buffer->hasBody());
245
246 buffer->unlock(handle.release());
247
248 EXPECT_FALSE(buffer->isLocked());
249 EXPECT_TRUE(buffer->hasPendingActivity());
250 EXPECT_TRUE(buffer->hasBody());
251
252 buffer->unlock(handle2.release());
253
254 EXPECT_FALSE(buffer->isLocked());
255 EXPECT_FALSE(buffer->hasPendingActivity());
256 EXPECT_TRUE(buffer->hasBody());
257 }
258
259 TEST_F(BodyStreamBufferTest, LoadClosedHandle)
260 {
261 Checkpoint checkpoint;
262 MockFetchDataLoaderClient* client1 = MockFetchDataLoaderClient::create();
263 MockFetchDataLoaderClient* client2 = MockFetchDataLoaderClient::create();
264
265 InSequence s;
266 EXPECT_CALL(checkpoint, Call(1));
267 EXPECT_CALL(*client1, didFetchDataLoadedString(String("")));
268 EXPECT_CALL(*client2, didFetchDataLoadedString(String("")));
269 EXPECT_CALL(checkpoint, Call(2));
270
271 BodyStreamBuffer* buffer = new BodyStreamBuffer(createFetchDataConsumerHandl eFromWebHandle(createDoneDataConsumerHandle()));
272
273 EXPECT_EQ(ReadableStream::Readable, buffer->stream()->stateInternal());
274 testing::runPendingTasks();
275 EXPECT_EQ(ReadableStream::Closed, buffer->stream()->stateInternal());
276
277 buffer->startLoading(executionContext(), FetchDataLoader::createLoaderAsStri ng(), client1);
278 EXPECT_FALSE(buffer->isLocked());
279 buffer->startLoading(executionContext(), FetchDataLoader::createLoaderAsStri ng(), client2);
280 EXPECT_FALSE(buffer->isLocked());
281 EXPECT_TRUE(buffer->hasPendingActivity());
282
283 checkpoint.Call(1);
284 testing::runPendingTasks();
285 checkpoint.Call(2);
286
287 EXPECT_FALSE(buffer->isLocked());
288 EXPECT_FALSE(buffer->hasPendingActivity());
289 }
290
291 TEST_F(BodyStreamBufferTest, LockErroredHandle)
292 {
293 BodyStreamBuffer* buffer = new BodyStreamBuffer(createFetchDataConsumerHandl eFromWebHandle(createUnexpectedErrorDataConsumerHandle()));
294
295 EXPECT_EQ(ReadableStream::Readable, buffer->stream()->stateInternal());
296 testing::runPendingTasks();
297 EXPECT_EQ(ReadableStream::Errored, buffer->stream()->stateInternal());
298
299 EXPECT_FALSE(buffer->isLocked());
300 OwnPtr<FetchDataConsumerHandle> handle = buffer->lock(executionContext());
301 EXPECT_FALSE(buffer->isLocked());
302 OwnPtr<FetchDataConsumerHandle> handle2 = buffer->lock(executionContext());
303
304 EXPECT_TRUE(handle);
305 EXPECT_TRUE(handle2);
306 EXPECT_FALSE(buffer->isLocked());
307 EXPECT_TRUE(buffer->hasPendingActivity());
308 EXPECT_TRUE(buffer->hasBody());
309
310 buffer->unlock(handle.release());
311
312 EXPECT_FALSE(buffer->isLocked());
313 EXPECT_TRUE(buffer->hasPendingActivity());
314 EXPECT_TRUE(buffer->hasBody());
315
316 buffer->unlock(handle2.release());
317
318 EXPECT_FALSE(buffer->isLocked());
319 EXPECT_FALSE(buffer->hasPendingActivity());
320 EXPECT_TRUE(buffer->hasBody());
321 }
322
323 TEST_F(BodyStreamBufferTest, LoadErroredHandle)
324 {
325 Checkpoint checkpoint;
326 MockFetchDataLoaderClient* client1 = MockFetchDataLoaderClient::create();
327 MockFetchDataLoaderClient* client2 = MockFetchDataLoaderClient::create();
328
329 InSequence s;
330 EXPECT_CALL(checkpoint, Call(1));
331 EXPECT_CALL(*client1, didFetchDataLoadFailed());
332 EXPECT_CALL(*client2, didFetchDataLoadFailed());
333 EXPECT_CALL(checkpoint, Call(2));
334
335 BodyStreamBuffer* buffer = new BodyStreamBuffer(createFetchDataConsumerHandl eFromWebHandle(createUnexpectedErrorDataConsumerHandle()));
336
337 EXPECT_EQ(ReadableStream::Readable, buffer->stream()->stateInternal());
338 testing::runPendingTasks();
339 EXPECT_EQ(ReadableStream::Errored, buffer->stream()->stateInternal());
340
341 buffer->startLoading(executionContext(), FetchDataLoader::createLoaderAsStri ng(), client1);
342 EXPECT_FALSE(buffer->isLocked());
343 buffer->startLoading(executionContext(), FetchDataLoader::createLoaderAsStri ng(), client2);
344 EXPECT_FALSE(buffer->isLocked());
345 EXPECT_TRUE(buffer->hasPendingActivity());
346
347 checkpoint.Call(1);
348 testing::runPendingTasks();
349 checkpoint.Call(2);
350
351 EXPECT_FALSE(buffer->isLocked());
352 EXPECT_FALSE(buffer->hasPendingActivity());
168 } 353 }
169 354
170 } // namespace 355 } // namespace
171 356
172 } // namespace blink 357 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698