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

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

Issue 2432883002: Replaced PassRefPtr copies with moves in unit tests. (Closed)
Patch Set: Created 4 years, 2 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/BytesConsumerTestUtil.h" 5 #include "modules/fetch/BytesConsumerTestUtil.h"
6 6
7 #include "core/dom/ExecutionContext.h" 7 #include "core/dom/ExecutionContext.h"
8 #include "core/dom/TaskRunnerHelper.h" 8 #include "core/dom/TaskRunnerHelper.h"
9 #include "platform/testing/UnitTestHelpers.h" 9 #include "platform/testing/UnitTestHelpers.h"
10 #include "public/platform/WebTaskRunner.h" 10 #include "public/platform/WebTaskRunner.h"
11 #include "wtf/Assertions.h" 11 #include "wtf/Assertions.h"
12 #include "wtf/Functional.h" 12 #include "wtf/Functional.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 using Result = BytesConsumer::Result; 16 using Result = BytesConsumer::Result;
17 using ::testing::_; 17 using ::testing::_;
18 using ::testing::ByMove;
18 using ::testing::DoAll; 19 using ::testing::DoAll;
19 using ::testing::Return; 20 using ::testing::Return;
20 using ::testing::SetArgPointee; 21 using ::testing::SetArgPointee;
21 22
22 BytesConsumerTestUtil::MockBytesConsumer::MockBytesConsumer() { 23 BytesConsumerTestUtil::MockBytesConsumer::MockBytesConsumer() {
23 ON_CALL(*this, beginRead(_, _)) 24 ON_CALL(*this, beginRead(_, _))
24 .WillByDefault(DoAll(SetArgPointee<0>(nullptr), SetArgPointee<1>(0), 25 .WillByDefault(DoAll(SetArgPointee<0>(nullptr), SetArgPointee<1>(0),
25 Return(Result::Error))); 26 Return(Result::Error)));
26 ON_CALL(*this, endRead(_)).WillByDefault(Return(Result::Error)); 27 ON_CALL(*this, endRead(_)).WillByDefault(Return(Result::Error));
27 ON_CALL(*this, getPublicState()).WillByDefault(Return(PublicState::Errored)); 28 ON_CALL(*this, getPublicState()).WillByDefault(Return(PublicState::Errored));
28 ON_CALL(*this, drainAsBlobDataHandle(_)).WillByDefault(Return(nullptr)); 29 ON_CALL(*this, drainAsBlobDataHandle(_))
29 ON_CALL(*this, drainAsFormData()).WillByDefault(Return(nullptr)); 30 .WillByDefault(Return(ByMove(nullptr)));
31 ON_CALL(*this, drainAsFormData()).WillByDefault(Return(ByMove(nullptr)));
30 } 32 }
31 33
32 BytesConsumerTestUtil::ReplayingBytesConsumer::ReplayingBytesConsumer( 34 BytesConsumerTestUtil::ReplayingBytesConsumer::ReplayingBytesConsumer(
33 ExecutionContext* executionContext) 35 ExecutionContext* executionContext)
34 : m_executionContext(executionContext) {} 36 : m_executionContext(executionContext) {}
35 37
36 BytesConsumerTestUtil::ReplayingBytesConsumer::~ReplayingBytesConsumer() {} 38 BytesConsumerTestUtil::ReplayingBytesConsumer::~ReplayingBytesConsumer() {}
37 39
38 Result BytesConsumerTestUtil::ReplayingBytesConsumer::beginRead( 40 Result BytesConsumerTestUtil::ReplayingBytesConsumer::beginRead(
39 const char** buffer, 41 const char** buffer,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 BytesConsumerTestUtil::TwoPhaseReader::run() { 189 BytesConsumerTestUtil::TwoPhaseReader::run() {
188 onStateChange(); 190 onStateChange();
189 while (m_result != BytesConsumer::Result::Done && 191 while (m_result != BytesConsumer::Result::Done &&
190 m_result != BytesConsumer::Result::Error) 192 m_result != BytesConsumer::Result::Error)
191 testing::runPendingTasks(); 193 testing::runPendingTasks();
192 testing::runPendingTasks(); 194 testing::runPendingTasks();
193 return std::make_pair(m_result, std::move(m_data)); 195 return std::make_pair(m_result, std::move(m_data));
194 } 196 }
195 197
196 } // namespace blink 198 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698