proxygen
proxygen::RFC1867Base Class Reference
Inheritance diagram for proxygen::RFC1867Base:
proxygen::RFC1867CR proxygen::RFC1867Test

Public Member Functions

void SetUp ()
 
void parse (unique_ptr< IOBuf > input, size_t chunkSize=0)
 

Protected Member Functions

void testSimple (unique_ptr< IOBuf > data, size_t fileSize, size_t splitSize, size_t parts)
 

Protected Attributes

StrictMock< Mock1867Callbackcallback_
 
RFC1867Codec codec_ {kTestBoundary}
 

Detailed Description

Definition at line 119 of file RFC1867Test.cpp.

Member Function Documentation

void proxygen::RFC1867Base::parse ( unique_ptr< IOBuf input,
size_t  chunkSize = 0 
)
inline

Definition at line 126 of file RFC1867Test.cpp.

References folly::IOBufQueue::append(), codec_, data, min, folly::gen::move, folly::IOBuf::prependChain(), and testSimple().

126  {
127  IOBufQueue ibuf{IOBufQueue::cacheChainLength()};
128  ibuf.append(std::move(input));
129  if (chunkSize == 0) {
130  chunkSize = ibuf.chainLength();
131  }
132  unique_ptr<IOBuf> rem;
133  while (!ibuf.empty()) {
134  auto chunk = ibuf.split(std::min(chunkSize, ibuf.chainLength()));
135  if (rem) {
136  rem->prependChain(std::move(chunk));
137  chunk = std::move(rem);
138  }
139  rem = codec_.onIngress(std::move(chunk));
140  }
142  }
void append(std::unique_ptr< folly::IOBuf > &&buf, bool pack=false)
Definition: IOBufQueue.cpp:143
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
LogLevel min
Definition: LogLevel.cpp:30
void prependChain(std::unique_ptr< IOBuf > &&iobuf)
Definition: IOBuf.cpp:509
std::unique_ptr< folly::IOBuf > onIngress(std::unique_ptr< folly::IOBuf > data)
Definition: RFC1867.cpp:61
void proxygen::RFC1867Base::SetUp ( )
inline

Definition at line 122 of file RFC1867Test.cpp.

References callback_, and codec_.

122  {
124  }
StrictMock< Mock1867Callback > callback_
void setCallback(Callback *callback)
Definition: RFC1867.h:54
void proxygen::RFC1867Base::testSimple ( unique_ptr< IOBuf data,
size_t  fileSize,
size_t  splitSize,
size_t  parts 
)
protected
Parameters
datafull multipart content
filesizesum of all parts
partsnumber of parts

Definition at line 167 of file RFC1867Test.cpp.

References testing::_, callback_, EXPECT_CALL, testing::Invoke(), parse(), testing::Return(), and uint64_t.

170  {
171  size_t fileLength = 0;
172  IOBufQueue parsedData{IOBufQueue::cacheChainLength()};
173  EXPECT_CALL(callback_, onFieldStartImpl(_, _, _, _))
174  .Times(parts)
175  .WillRepeatedly(Return(0));
176  EXPECT_CALL(callback_, onFieldData(_, _))
177  .WillRepeatedly(Invoke([&] (std::shared_ptr<IOBuf> data, uint64_t) {
178  fileLength += data->computeChainDataLength();
179  parsedData.append(data->clone());
180  return 0;
181  }));
182  EXPECT_CALL(callback_, onFieldEnd(true, _))
183  .Times(parts)
184  .WillRepeatedly(Return());
185  parse(data->clone(), splitSize);
186  auto parsedDataBuf = parsedData.move();
187  if (fileLength > 0) {
188  // isChained() called from coalesce below asserts if no data has
189  // been added
190  parsedDataBuf->coalesce();
191  }
192  CHECK_EQ(fileLength, fileSize);
193 }
void parse(unique_ptr< IOBuf > input, size_t chunkSize=0)
StrictMock< Mock1867Callback > callback_
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
internal::ReturnAction< R > Return(R value)

Member Data Documentation

StrictMock<Mock1867Callback> proxygen::RFC1867Base::callback_
protected

Definition at line 150 of file RFC1867Test.cpp.

RFC1867Codec proxygen::RFC1867Base::codec_ {kTestBoundary}
protected

Definition at line 151 of file RFC1867Test.cpp.


The documentation for this class was generated from the following file: