summaryrefslogtreecommitdiff
path: root/test/XmlRpcMethodTest.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-12-21 15:17:34 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-12-21 15:17:34 +0000
commitdd98c64161d4a781978d154787fa756e5bbbc408 (patch)
tree9967f8c78e4786beff9d89def26bfff62a400fa0 /test/XmlRpcMethodTest.cc
parentd78b2721a5aed3500d4960547be3022945692ece (diff)
2009-12-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added changePosition XML-RPC method. It takes 3 parameters: gid, pos and how. This method changes the position of download denoted by gid. If how is POS_SET, it moves the download to a position relative to the beginning of the queue. If how is POS_CUR, it moves the download to a position relative to the current position. If how is POS_END, it moves the download to a position relative to the end of the queue. If the destination position is less than 0 or beyond the end of the queue, it moves the download to the beginning or the end of the queue respectively. Returns the destination position. * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/XmlRpcMethodFactory.cc * src/XmlRpcMethodImpl.cc * src/XmlRpcMethodImpl.h * test/RequestGroupManTest.cc * test/XmlRpcMethodTest.cc
Diffstat (limited to 'test/XmlRpcMethodTest.cc')
-rw-r--r--test/XmlRpcMethodTest.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/XmlRpcMethodTest.cc b/test/XmlRpcMethodTest.cc
index ab3051fd..79658061 100644
--- a/test/XmlRpcMethodTest.cc
+++ b/test/XmlRpcMethodTest.cc
@@ -67,6 +67,8 @@ class XmlRpcMethodTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testNoSuchMethod);
CPPUNIT_TEST(testGatherStoppedDownload);
CPPUNIT_TEST(testGatherProgressCommon);
+ CPPUNIT_TEST(testChangePosition);
+ CPPUNIT_TEST(testChangePosition_fail);
CPPUNIT_TEST_SUITE_END();
private:
SharedHandle<DownloadEngine> _e;
@@ -119,6 +121,8 @@ public:
void testNoSuchMethod();
void testGatherStoppedDownload();
void testGatherProgressCommon();
+ void testChangePosition();
+ void testChangePosition_fail();
};
@@ -676,6 +680,38 @@ void XmlRpcMethodTest::testGatherProgressCommon()
CPPUNIT_ASSERT_EQUAL(std::string("2"), entry["belongsTo"].s());
}
+void XmlRpcMethodTest::testChangePosition()
+{
+ _e->_requestGroupMan->addReservedGroup
+ (SharedHandle<RequestGroup>(new RequestGroup(_option)));
+ _e->_requestGroupMan->addReservedGroup
+ (SharedHandle<RequestGroup>(new RequestGroup(_option)));
+
+ ChangePositionXmlRpcMethod m;
+ XmlRpcRequest req("aria2.changePosition", BDE::list());
+ req._params << std::string("1");
+ req._params << BDE((int64_t)1);
+ req._params << std::string("POS_SET");
+ XmlRpcResponse res = m.execute(req, _e.get());
+ CPPUNIT_ASSERT_EQUAL(0, res._code);
+ CPPUNIT_ASSERT_EQUAL((int64_t)1, res._param.i());
+ CPPUNIT_ASSERT_EQUAL
+ ((int32_t)1, _e->_requestGroupMan->getReservedGroups()[1]->getGID());
+}
+
+void XmlRpcMethodTest::testChangePosition_fail()
+{
+ ChangePositionXmlRpcMethod m;
+ XmlRpcRequest req("aria2.changePosition", BDE::list());
+ XmlRpcResponse res = m.execute(req, _e.get());
+ CPPUNIT_ASSERT_EQUAL(1, res._code);
+
+ req._params << std::string("1");
+ req._params << BDE((int64_t)2);
+ req._params << std::string("bad keyword");
+ CPPUNIT_ASSERT_EQUAL(1, res._code);
+}
+
} // namespace xmlrpc
} // namespace aria2