This source file includes following definitions.
- SetUp
- TEST_F
- TEST_F
- TEST_F
#include "net/quic/quic_ack_notifier.h"
#include "net/quic/test_tools/quic_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using testing::_;
namespace net {
namespace test {
namespace {
class QuicAckNotifierTest : public ::testing::Test {
protected:
virtual void SetUp() {
delegate_ = new MockAckNotifierDelegate;
notifier_.reset(new QuicAckNotifier(delegate_));
notifier_->AddSequenceNumber(26, 100);
notifier_->AddSequenceNumber(99, 20);
notifier_->AddSequenceNumber(1234, 3);
}
MockAckNotifierDelegate* delegate_;
scoped_ptr<QuicAckNotifier> notifier_;
};
TEST_F(QuicAckNotifierTest, TriggerCallback) {
EXPECT_CALL(*delegate_, OnAckNotification(3, 123, 0, 0)).Times(1);
EXPECT_FALSE(notifier_->OnAck(26));
EXPECT_FALSE(notifier_->OnAck(99));
EXPECT_TRUE(notifier_->OnAck(1234));
}
TEST_F(QuicAckNotifierTest, DoesNotTrigger) {
EXPECT_CALL(*delegate_, OnAckNotification(_, _, _, _)).Times(0);
EXPECT_FALSE(notifier_->OnAck(26));
EXPECT_FALSE(notifier_->OnAck(99));
}
TEST_F(QuicAckNotifierTest, UpdateSeqNums) {
notifier_->UpdateSequenceNumber(99, 3000);
notifier_->UpdateSequenceNumber(1234, 3001);
EXPECT_CALL(*delegate_, OnAckNotification(3, 123, 2, 20 + 3)).Times(1);
EXPECT_FALSE(notifier_->OnAck(26));
EXPECT_FALSE(notifier_->OnAck(3000));
EXPECT_TRUE(notifier_->OnAck(3001));
}
}
}
}