From 0b7033abb7ebf7a82b699d03cbb6f5f1566346b6 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 3 Nov 2008 12:06:39 +0000 Subject: [PATCH] 2008-11-03 Tatsuhiro Tsujikawa Added testcase for BtNotInterestedMessage from unchoked peer. * test/BtNotInterestedMessageTest.cc --- ChangeLog | 5 +++++ test/BtNotInterestedMessageTest.cc | 18 +++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7301ea8..d7a06f67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-11-03 Tatsuhiro Tsujikawa + + Added testcase for BtNotInterestedMessage from unchoked peer. + * test/BtNotInterestedMessageTest.cc + 2008-11-03 Tatsuhiro Tsujikawa Execute choking algorithm when BtInterestedMessage arrives from diff --git a/test/BtNotInterestedMessageTest.cc b/test/BtNotInterestedMessageTest.cc index d57d8d89..b23c0fec 100644 --- a/test/BtNotInterestedMessageTest.cc +++ b/test/BtNotInterestedMessageTest.cc @@ -6,7 +6,7 @@ #include "PeerMessageUtil.h" #include "Peer.h" -#include "PeerStorage.h" +#include "MockPeerStorage.h" namespace aria2 { @@ -19,13 +19,7 @@ class BtNotInterestedMessageTest:public CppUnit::TestFixture { CPPUNIT_TEST(testOnSendComplete); CPPUNIT_TEST(testToString); CPPUNIT_TEST_SUITE_END(); -private: - public: - void setUp() { - // TODO add peer storage here - } - void testCreate(); void testGetMessage(); void testDoReceivedAction(); @@ -71,11 +65,21 @@ void BtNotInterestedMessageTest::testDoReceivedAction() { SharedHandle peer(new Peer("host", 6969)); peer->allocateSessionResource(1024, 1024*1024); peer->peerInterested(true); + + SharedHandle peerStorage(new MockPeerStorage()); + BtNotInterestedMessage msg; msg.setPeer(peer); + msg.setPeerStorage(peerStorage); + CPPUNIT_ASSERT(peer->peerInterested()); msg.doReceivedAction(); CPPUNIT_ASSERT(!peer->peerInterested()); + CPPUNIT_ASSERT_EQUAL(0, peerStorage->getNumChokeExecuted()); + + peer->amChoking(false); + msg.doReceivedAction(); + CPPUNIT_ASSERT_EQUAL(1, peerStorage->getNumChokeExecuted()); } void BtNotInterestedMessageTest::testOnSendComplete() {