diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-02-03 21:06:10 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-06-13 17:29:50 +0100 |
commit | 40a57d1dda631b191a6a2614a99322577e0fc620 (patch) | |
tree | 7aa3207d3526cbfe5721d71528117ea187cb7e03 | |
parent | Don't use the local adapter reference before it's initialized (diff) | |
download | p2pvr-40a57d1dda631b191a6a2614a99322577e0fc620.tar.bz2 p2pvr-40a57d1dda631b191a6a2614a99322577e0fc620.tar.xz p2pvr-40a57d1dda631b191a6a2614a99322577e0fc620.zip |
Add basics for tests over streaming and recording
-rw-r--r-- | p2pvr/daemon/Jamfile.jam | 1 | ||||
-rw-r--r-- | p2pvr/daemon/unittests/Jamfile.jam | 23 | ||||
-rw-r--r-- | p2pvr/daemon/unittests/testRecording.cpp | 107 |
3 files changed, 131 insertions, 0 deletions
diff --git a/p2pvr/daemon/Jamfile.jam b/p2pvr/daemon/Jamfile.jam index e1b8386..a2a20c0 100644 --- a/p2pvr/daemon/Jamfile.jam +++ b/p2pvr/daemon/Jamfile.jam @@ -28,6 +28,7 @@ lib p2pvrdaemon : : : <include>. <library>../ice//p2pvrice + <library>../lib//p2pvrlib <library>slicer ; diff --git a/p2pvr/daemon/unittests/Jamfile.jam b/p2pvr/daemon/unittests/Jamfile.jam index 28d4fbd..0f0094c 100644 --- a/p2pvr/daemon/unittests/Jamfile.jam +++ b/p2pvr/daemon/unittests/Jamfile.jam @@ -70,6 +70,29 @@ run : testMaint ; run + testRecording.cpp mockDevices.cpp mockScheduler.cpp + : : + ../../datasources/schema.sql + datasources/data.sql + : + <define>BOOST_TEST_DYN_LINK + <library>../..//p2common + <library>../..//p2basics + <library>../..//p2lib + <library>../..//p2xml + <library>../..//p2ut + <library>..//p2pvrdaemon + <library>../../devices//p2pvrMockTuner + <library>IceUtil + <library>Ice + <library>boost_system + <library>boost_filesystem + <library>testCommon + <library>../..//boost_utf + <define>ROOT=\"$(me)\" + : testRecording ; + +run testErrorHandling.cpp mockDevices.cpp mockScheduler.cpp : : ../../datasources/schema.sql diff --git a/p2pvr/daemon/unittests/testRecording.cpp b/p2pvr/daemon/unittests/testRecording.cpp new file mode 100644 index 0000000..48b0990 --- /dev/null +++ b/p2pvr/daemon/unittests/testRecording.cpp @@ -0,0 +1,107 @@ +#define BOOST_TEST_MODULE Recording +#include <boost/test/unit_test.hpp> +#include <boost/filesystem/operations.hpp> +#include <testOptionsSource.h> +#include <Ice/ObjectAdapter.h> +#include <Ice/Service.h> +#include <scopeObject.h> +#include <maintenance.h> +#include <mockTuner.h> +#include "mockDevices.h" +#include "mockScheduler.h" +#include <si.h> +#include <recordings.h> +#include <linux/dvb/frontend.h> +#include <definedDirs.h> +#include "mockDefs.h" +#include "sqlSelectDeserializer.h" +#include "commonHelpers.h" +#include "serviceStreamer.h" +#include "temporaryIceAdapterObject.h" +#include <slicer/slicer.h> + + +class Core : public CommonObjects { + public: + Core() + { + int paramCount = 0; + ic = Ice::initialize(paramCount, NULL); + adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12005"); + TestOptionsSource::LoadTestOptions({ + { "common.datasourceRoot", (RootDir / "datasources").string() }, + }); + adapter->add(new MockDevices(), ic->stringToIdentity("GlobalDevices")); + adapter->add(new MockScheduler(), ic->stringToIdentity("Schedules")); + adapter->add(new SI(), ic->stringToIdentity("SI")); + adapter->add(new Recordings(), ic->stringToIdentity("Recordings")); + adapter->add(new Maintenance(adapter, NULL), ic->stringToIdentity("Maintenance")); + adapter->activate(); + + r = P2PVR::RecordingsPrx::checkedCast(ic->stringToProxy("Recordings")); + BOOST_REQUIRE(r); + r->ice_ping(); + + s = P2PVR::SIPrx::checkedCast(ic->stringToProxy("SI")); + BOOST_REQUIRE(s); + s->ice_ping(); + + m = P2PVR::MaintenancePrx::checkedCast(ic->stringToProxy("Maintenance")); + BOOST_REQUIRE(m); + m->ice_ping(); + } + + ~Core() + { + ic->destroy(); + } + + P2PVR::MaintenancePrx m; + P2PVR::RecordingsPrx r; + P2PVR::SIPrx s; + + protected: + Ice::CommunicatorPtr ic; + Ice::ObjectAdapterPtr adapter; +}; + +class MockTarget : public P2PVR::RawDataClient { + public: + MockTarget() : bytesReceived(0) { } + + bool NewData(const P2PVR::Data & data, const Ice::Current &) override + { + bytesReceived += data.size(); + return false; + } + + unsigned int bytesReceived; +}; + +BOOST_GLOBAL_FIXTURE( StandardMockDatabase ); + +BOOST_FIXTURE_TEST_SUITE( RecordingCore, Core ); + +BOOST_AUTO_TEST_CASE( streamServiceToTarget ) +{ + BOOST_CHECKPOINT("Create mock target"); + IceUtil::Handle<MockTarget> target = new MockTarget(); + TemporaryIceAdapterObject<P2PVR::RawDataClient> targetPrx(adapter, target); + + BOOST_CHECKPOINT("Create service streamer"); + auto ss = ServiceStreamerPtr(new ServiceStreamer(4170, targetPrx, ic, adapter)); + + BOOST_CHECKPOINT("Start"); + ss->Start(); + sleep(1); + + BOOST_CHECKPOINT("Stop"); + ss->Stop(); + + BOOST_MESSAGE("Received bytes: " << target->bytesReceived); + BOOST_REQUIRE(target->bytesReceived > 150000); +} + +BOOST_AUTO_TEST_SUITE_END(); + + |