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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp

Issue 2307003002: Move collectGarbage* methods to ThreadState (Closed)
Patch Set: fix Created 4 years, 3 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
OLDNEW
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
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 testing::runPendingTasks(); 186 testing::runPendingTasks();
187 187
188 size_t size = 0; 188 size_t size = 0;
189 reader->read(nullptr, 0, kNone, &size); 189 reader->read(nullptr, 0, kNone, &size);
190 checkpoint.Call(1); 190 checkpoint.Call(1);
191 testing::runPendingTasks(); 191 testing::runPendingTasks();
192 checkpoint.Call(2); 192 checkpoint.Call(2);
193 handle = nullptr; 193 handle = nullptr;
194 reader = nullptr; 194 reader = nullptr;
195 checkpoint.Call(3); 195 checkpoint.Call(3);
196 ThreadHeap::collectAllGarbage(); 196 ThreadState::current()-> collectAllGarbage();
197 checkpoint.Call(4); 197 checkpoint.Call(4);
198 } 198 }
199 199
200 TEST_F(FetchBlobDataConsumerHandleTest, ReadTest) 200 TEST_F(FetchBlobDataConsumerHandleTest, ReadTest)
201 { 201 {
202 auto factory = new StrictMock<MockLoaderFactory>; 202 auto factory = new StrictMock<MockLoaderFactory>;
203 Checkpoint checkpoint; 203 Checkpoint checkpoint;
204 204
205 Persistent<MockThreadableLoader> loader = MockThreadableLoader::create(); 205 Persistent<MockThreadableLoader> loader = MockThreadableLoader::create();
206 ThreadableLoaderClient* client = nullptr; 206 ThreadableLoaderClient* client = nullptr;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 std::unique_ptr<FetchDataConsumerHandle::Reader> reader = handle->obtainFetc hDataReader(nullptr); 412 std::unique_ptr<FetchDataConsumerHandle::Reader> reader = handle->obtainFetc hDataReader(nullptr);
413 413
414 const void* buffer; 414 const void* buffer;
415 size_t available; 415 size_t available;
416 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available)); 416 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available));
417 EXPECT_FALSE(reader->drainAsBlobDataHandle()); 417 EXPECT_FALSE(reader->drainAsBlobDataHandle());
418 } 418 }
419 419
420 } // namespace 420 } // namespace
421 } // namespace blink 421 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698