proxygen
ByteEventTrackerTest.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
12 
16 
17 #include <chrono>
18 
19 using namespace testing;
20 using namespace proxygen;
21 
24  public:
25  GMOCK_METHOD1_(, noexcept,, onPingReplyLatency, void(int64_t));
26  GMOCK_METHOD3_(, noexcept,, onLastByteEvent, void(HTTPTransaction*,
27  uint64_t, bool));
28  GMOCK_METHOD0_(, noexcept,, onDeleteAckEvent, void());
29 };
30 
31 class ByteEventTrackerTest : public Test {
32  public:
33 
34  void SetUp() override {
35  txn_.setTransportCallback(&transportCallback_);
36  }
37 
38  protected:
40  WheelTimerInstance transactionTimeouts_{std::chrono::milliseconds(500),
41  &eventBase_};
46  TransportDirection::DOWNSTREAM,
48  txnEgressQueue_, transactionTimeouts_.getWheelTimer(),
49  transactionTimeouts_.getDefaultTimeout()};
52  std::shared_ptr<ByteEventTracker> byteEventTracker_{
53  new ByteEventTracker(&callback_)};
54 };
55 
57  byteEventTracker_->addPingByteEvent(10, proxygen::getCurrentTime(), 0);
58  EXPECT_CALL(callback_, onPingReplyLatency(_));
59  byteEventTracker_->processByteEvents(byteEventTracker_, 10);
60 }
61 
63  byteEventTracker_->addLastByteEvent(&txn_, 10);
64  EXPECT_CALL(transportCallback_, headerBytesGenerated(_)); // sendAbort calls?
65  txn_.sendAbort(); // put it in a state for detach
66  EXPECT_CALL(transportCallback_, lastByteFlushed());
67  EXPECT_CALL(callback_, onLastByteEvent(_, _, _));
68  EXPECT_CALL(transport_, detach(_));
69  byteEventTracker_->processByteEvents(byteEventTracker_, 10);
70 }
#define GMOCK_METHOD0_(tn, constness, ct, Method,...)
HTTP2PriorityQueue txnEgressQueue_
#define GMOCK_METHOD1_(tn, constness, ct, Method,...)
TEST_F(TestInfoTest, Names)
requires E e noexcept(noexcept(s.error(std::move(e))))
NiceMock< MockHTTPTransactionTransport > transport_
StrictMock< MockHTTPHandler > handler_
AsyncFizzClient::UniquePtr transport_
std::chrono::time_point< ClockType > getCurrentTime()
Definition: Time.h:41
#define EXPECT_CALL(obj, call)
uint64_t StreamID
Definition: HTTPCodec.h:49
const internal::AnythingMatcher _
MockByteEventTrackerCallback callback_
folly::Function< void()> callback_
#define GMOCK_METHOD3_(tn, constness, ct, Method,...)
MockHTTPTransactionTransportCallback transportCallback_