OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "modules/fetch/FetchBlobDataConsumerHandle.h" | 5 #include "modules/fetch/FetchBlobDataConsumerHandle.h" |
6 | 6 |
7 #include "core/dom/ExecutionContext.h" | 7 #include "core/dom/ExecutionContext.h" |
8 #include "core/fetch/ResourceLoaderOptions.h" | 8 #include "core/fetch/ResourceLoaderOptions.h" |
9 #include "core/loader/MockThreadableLoader.h" | 9 #include "core/loader/MockThreadableLoader.h" |
10 #include "core/loader/ThreadableLoaderClient.h" | 10 #include "core/loader/ThreadableLoaderClient.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 | 71 |
72 class FetchBlobDataConsumerHandleTest : public ::testing::Test { | 72 class FetchBlobDataConsumerHandleTest : public ::testing::Test { |
73 public: | 73 public: |
74 FetchBlobDataConsumerHandleTest() | 74 FetchBlobDataConsumerHandleTest() |
75 : m_dummyPageHolder(DummyPageHolder::create(IntSize(1, 1))) {} | 75 : m_dummyPageHolder(DummyPageHolder::create(IntSize(1, 1))) {} |
76 ~FetchBlobDataConsumerHandleTest() override | 76 ~FetchBlobDataConsumerHandleTest() override |
77 { | 77 { |
78 m_dummyPageHolder = nullptr; | 78 m_dummyPageHolder = nullptr; |
79 // We need this to collect garbage-collected mocks. | 79 // We need this to collect garbage-collected mocks. |
80 ThreadHeap::collectAllGarbage(); | 80 ThreadState::current()-> collectAllGarbage(); |
81 } | 81 } |
82 | 82 |
83 Document& document() { return m_dummyPageHolder->document(); } | 83 Document& document() { return m_dummyPageHolder->document(); } |
84 | 84 |
85 private: | 85 private: |
86 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; | 86 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
87 }; | 87 }; |
88 | 88 |
89 TEST_F(FetchBlobDataConsumerHandleTest, CreateLoader) | 89 TEST_F(FetchBlobDataConsumerHandleTest, CreateLoader) |
90 { | 90 { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 char buffer[1]; | 211 char buffer[1]; |
212 size_t size = 0; | 212 size_t size = 0; |
213 ASSERT_EQ(kShouldWait, reader->read(buffer, sizeof(buffer), kNone, &size)); | 213 ASSERT_EQ(kShouldWait, reader->read(buffer, sizeof(buffer), kNone, &size)); |
214 checkpoint.Call(1); | 214 checkpoint.Call(1); |
215 testing::runPendingTasks(); | 215 testing::runPendingTasks(); |
216 checkpoint.Call(2); | 216 checkpoint.Call(2); |
217 handle = nullptr; | 217 handle = nullptr; |
218 reader = nullptr; | 218 reader = nullptr; |
219 checkpoint.Call(3); | 219 checkpoint.Call(3); |
220 ThreadHeap::collectAllGarbage(); | 220 ThreadState::current()-> collectAllGarbage(); |
221 checkpoint.Call(4); | 221 checkpoint.Call(4); |
222 } | 222 } |
223 | 223 |
224 TEST_F(FetchBlobDataConsumerHandleTest, ReadTest) | 224 TEST_F(FetchBlobDataConsumerHandleTest, ReadTest) |
225 { | 225 { |
226 auto factory = new StrictMock<MockLoaderFactory>; | 226 auto factory = new StrictMock<MockLoaderFactory>; |
227 Checkpoint checkpoint; | 227 Checkpoint checkpoint; |
228 | 228 |
229 Persistent<MockThreadableLoader> loader = MockThreadableLoader::create(); | 229 Persistent<MockThreadableLoader> loader = MockThreadableLoader::create(); |
230 ThreadableLoaderClient* client = nullptr; | 230 ThreadableLoaderClient* client = nullptr; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 std::unique_ptr<FetchDataConsumerHandle::Reader> reader = handle->obtainFetc
hDataReader(nullptr); | 440 std::unique_ptr<FetchDataConsumerHandle::Reader> reader = handle->obtainFetc
hDataReader(nullptr); |
441 | 441 |
442 const void* buffer; | 442 const void* buffer; |
443 size_t available; | 443 size_t available; |
444 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available)); | 444 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available)); |
445 EXPECT_FALSE(reader->drainAsBlobDataHandle()); | 445 EXPECT_FALSE(reader->drainAsBlobDataHandle()); |
446 } | 446 } |
447 | 447 |
448 } // namespace | 448 } // namespace |
449 } // namespace blink | 449 } // namespace blink |
OLD | NEW |