summaryrefslogtreecommitdiff
path: root/p2pvr/daemon
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-08-07 00:08:54 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2017-08-07 00:08:54 +0100
commit3e50a4e08541435dfb647be15173cd35ed52cd6c (patch)
tree3c72e4ed623897b3dc89577443cd19d286b2e7c1 /p2pvr/daemon
parentAdd ice_print to device error (diff)
downloadp2pvr-3e50a4e08541435dfb647be15173cd35ed52cd6c.tar.bz2
p2pvr-3e50a4e08541435dfb647be15173cd35ed52cd6c.tar.xz
p2pvr-3e50a4e08541435dfb647be15173cd35ed52cd6c.zip
Have MockDevices extend DevicesI and simply intercept tuner creation with MockTuner
Diffstat (limited to 'p2pvr/daemon')
-rw-r--r--p2pvr/daemon/unittests/Jamfile.jam1
-rw-r--r--p2pvr/daemon/unittests/mockDevices.cpp90
-rw-r--r--p2pvr/daemon/unittests/mockDevices.h22
-rw-r--r--p2pvr/daemon/unittests/testErrorHandling.cpp2
-rw-r--r--p2pvr/daemon/unittests/testMaint.cpp2
-rw-r--r--p2pvr/daemon/unittests/testRecording.cpp2
-rw-r--r--p2pvr/daemon/unittests/testSched.cpp2
7 files changed, 16 insertions, 105 deletions
diff --git a/p2pvr/daemon/unittests/Jamfile.jam b/p2pvr/daemon/unittests/Jamfile.jam
index bb39bbb..eb4bf2e 100644
--- a/p2pvr/daemon/unittests/Jamfile.jam
+++ b/p2pvr/daemon/unittests/Jamfile.jam
@@ -39,6 +39,7 @@ lib testCommon :
<library>dbppcore
<library>dbpp-postgresql
<library>../../devices//p2pvrMockTuner
+ <library>../../devices//p2pvrdevices
<library>boost_system
<library>boost_filesystem
<implicit-dependency>../../ice
diff --git a/p2pvr/daemon/unittests/mockDevices.cpp b/p2pvr/daemon/unittests/mockDevices.cpp
index 3e04c85..12203b0 100644
--- a/p2pvr/daemon/unittests/mockDevices.cpp
+++ b/p2pvr/daemon/unittests/mockDevices.cpp
@@ -4,94 +4,16 @@
namespace P2PVR {
namespace Testing {
- void MockDevices::ScanAndSendNetworkInformation(const RawDataClientPrx & target, const ::Ice::Current & ice)
+ MockDevices::MockDevices(Ice::CommunicatorPtr c) :
+ ic(c)
{
- MockTuner mt(ice.adapter->getCommunicator());
- mt.ScanAndSendNetworkInformation(target);
+ devices.push_back("/dev/dvb/dummy");
}
- void MockDevices::SendNetworkInformation(const ::DVBSI::DeliveryPtr & del, const RawDataClientPrx & target, const ::Ice::Current & ice)
+ TunerPtr
+ MockDevices::openTuner(const boost::filesystem::path &) const
{
- BOOST_ASSERT(del);
- MockTuner mt(ice.adapter->getCommunicator());
- mt.SendNetworkInformation(target);
- }
-
- void MockDevices::SendBouquetAssociations(const ::DVBSI::DeliveryPtr & del, const RawDataClientPrx & target, const ::Ice::Current & ice)
- {
- BOOST_ASSERT(del);
- MockTuner mt(ice.adapter->getCommunicator());
- mt.SendBouquetAssociations(target);
- }
-
- void MockDevices::SendServiceDescriptions(const ::DVBSI::DeliveryPtr & del, const RawDataClientPrx & target, const ::Ice::Current & ice)
- {
- BOOST_ASSERT(del);
- MockTuner mt(ice.adapter->getCommunicator());
- mt.SendServiceDescriptions(target);
- }
-
- void MockDevices::SendProgramAssociationTable(const ::DVBSI::DeliveryPtr & del, const RawDataClientPrx & target, const ::Ice::Current & ice)
- {
- BOOST_ASSERT(del);
- MockTuner mt(ice.adapter->getCommunicator());
- mt.SendProgramAssociationTable(target);
- }
-
- void MockDevices::SendProgramMap(const ::DVBSI::DeliveryPtr & del, ::Ice::Int pid, const RawDataClientPrx & target, const ::Ice::Current & ice)
- {
- BOOST_ASSERT(del);
- MockTuner mt(ice.adapter->getCommunicator());
- mt.SendProgramMap(pid, target);
- }
-
- void MockDevices::SendEventInformation(const ::DVBSI::DeliveryPtr & del, const RawDataClientPrx & target, const ::Ice::Current & ice)
- {
- BOOST_ASSERT(del);
- MockTuner mt(ice.adapter->getCommunicator());
- mt.SendEventInformation(target);
- }
-
- ::Ice::Int MockDevices::StartSendingTS(const ::DVBSI::DeliveryPtr & del, const PacketIds & pids, const RawDataClientPrx & target, const ::Ice::Current & ice)
- {
- BOOST_ASSERT(del);
- TunerPtr tuner = new MockTuner(ice.adapter->getCommunicator());
- return bgOps.insert({ tuner->StartSendingTS(pids, target), tuner }).first->first;
- }
-
- ::Ice::Int MockDevices::StartSendingSection(const ::DVBSI::DeliveryPtr & del, ::Ice::Int sid, const RawDataClientPrx & target, const ::Ice::Current & ice)
- {
- BOOST_ASSERT(del);
- TunerPtr tuner = new MockTuner(ice.adapter->getCommunicator());
- return bgOps.insert({ tuner->StartSendingSection(sid, target), tuner }).first->first;
- }
-
- void MockDevices::StopSending(::Ice::Int handle, const ::Ice::Current &)
- {
- BOOST_ASSERT(handle);
- auto itr = bgOps.find(handle);
- BOOST_ASSERT(itr != bgOps.end());
- BOOST_ASSERT(itr->second);
- itr->second->StopSending(handle);
- bgOps.erase(itr);
- }
-
-
- void MockDevices::Scan(const std::string &, const Ice::Current &)
- {
- }
-
- void MockDevices::Add(const std::string &, const Ice::Current &)
- {
- }
-
- void MockDevices::Remove(const std::string &, const Ice::Current &)
- {
- }
-
- ::Ice::Int MockDevices::TunerCount(const Ice::Current &)
- {
- return 1;
+ return new MockTuner(ic);
}
}
}
diff --git a/p2pvr/daemon/unittests/mockDevices.h b/p2pvr/daemon/unittests/mockDevices.h
index bc0a22a..a9ed170 100644
--- a/p2pvr/daemon/unittests/mockDevices.h
+++ b/p2pvr/daemon/unittests/mockDevices.h
@@ -3,30 +3,18 @@
#include <dvb.h>
#include <visibility.h>
+#include <devices.h>
namespace P2PVR {
namespace Testing {
- class DLL_PUBLIC MockDevices : public Tuners {
+ class DLL_PUBLIC MockDevices : public DevicesI {
public:
- virtual void ScanAndSendNetworkInformation(const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual void SendNetworkInformation(const ::DVBSI::DeliveryPtr&, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual void SendBouquetAssociations(const ::DVBSI::DeliveryPtr&, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual void SendServiceDescriptions(const ::DVBSI::DeliveryPtr&, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual void SendProgramAssociationTable(const ::DVBSI::DeliveryPtr&, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual void SendProgramMap(const ::DVBSI::DeliveryPtr&, ::Ice::Int, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual void SendEventInformation(const ::DVBSI::DeliveryPtr&, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual ::Ice::Int StartSendingTS(const ::DVBSI::DeliveryPtr&, const PacketIds&, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual ::Ice::Int StartSendingSection(const ::DVBSI::DeliveryPtr&, ::Ice::Int, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual void StopSending(::Ice::Int, const ::Ice::Current&) override;
+ MockDevices(Ice::CommunicatorPtr ic);
- void Scan(const std::string & path, const Ice::Current &) override;
- void Add(const std::string & frontend, const Ice::Current &) override;
- void Remove(const std::string & frontend, const Ice::Current &) override;
- ::Ice::Int TunerCount(const Ice::Current &) override;
+ TunerPtr openTuner(const boost::filesystem::path &) const override;
private:
- typedef std::map<::Ice::Int, TunerPtr> BackgroundOperations;
- BackgroundOperations bgOps;
+ Ice::CommunicatorPtr ic;
};
}
}
diff --git a/p2pvr/daemon/unittests/testErrorHandling.cpp b/p2pvr/daemon/unittests/testErrorHandling.cpp
index 2ec1941..80af051 100644
--- a/p2pvr/daemon/unittests/testErrorHandling.cpp
+++ b/p2pvr/daemon/unittests/testErrorHandling.cpp
@@ -26,7 +26,7 @@ class Core : public StandardMockDatabase {
public:
Core()
{
- replace("Devices", new MockDevices());
+ replace("Devices", new MockDevices(ic));
}
};
diff --git a/p2pvr/daemon/unittests/testMaint.cpp b/p2pvr/daemon/unittests/testMaint.cpp
index a1fc6fd..e918d74 100644
--- a/p2pvr/daemon/unittests/testMaint.cpp
+++ b/p2pvr/daemon/unittests/testMaint.cpp
@@ -27,7 +27,7 @@ class TestService : public SchemaOnlyMockDatabase {
public:
TestService()
{
- replace("Devices", new MockDevices());
+ replace("Devices", new MockDevices(ic));
replace("Schedules", new MockScheduler());
}
};
diff --git a/p2pvr/daemon/unittests/testRecording.cpp b/p2pvr/daemon/unittests/testRecording.cpp
index fe81b7d..ae3a3a3 100644
--- a/p2pvr/daemon/unittests/testRecording.cpp
+++ b/p2pvr/daemon/unittests/testRecording.cpp
@@ -28,7 +28,7 @@ class TestService : public StandardMockDatabase {
public:
TestService()
{
- replace("Devices", new MockDevices());
+ replace("Devices", new MockDevices(ic));
replace("Schedules", new MockScheduler());
}
};
diff --git a/p2pvr/daemon/unittests/testSched.cpp b/p2pvr/daemon/unittests/testSched.cpp
index 9f6881a..18e375c 100644
--- a/p2pvr/daemon/unittests/testSched.cpp
+++ b/p2pvr/daemon/unittests/testSched.cpp
@@ -26,7 +26,7 @@ class TestService : public StandardMockDatabasePlusOffset {
public:
TestService()
{
- replace("Devices", new MockDevices());
+ replace("Devices", new MockDevices(ic));
replace("Recorder", new MockRecorder());
}
};