1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#define BOOST_TEST_MODULE Maintenance
#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 <si.h>
#include <linux/dvb/frontend.h>
#define XSTR(s) STR(s)
#define STR(s) #s
const auto bindir = boost::filesystem::canonical("/proc/self/exe").parent_path();
const auto componentdir = bindir.parent_path() / "component";
const boost::filesystem::path root(XSTR(ROOT));
class MockDevices : public P2PVR::Devices {
public:
P2PVR::TunerPrx GetTunerSpecific(const DVBSI::DeliveryPtr&, const Ice::Current & ice) override
{
return P2PVR::PrivateTunerPrx::checkedCast(ice.adapter->addWithUUID(new MockTuner()));
}
P2PVR::TunerPrx GetTunerAny(Ice::Short, const DVBSI::DeliveryPtr&, const Ice::Current & ice) override
{
return P2PVR::PrivateTunerPrx::checkedCast(ice.adapter->addWithUUID(new MockTuner()));
}
P2PVR::PrivateTunerPrx GetPrivateTuner(Ice::Short, const Ice::Current & ice) override
{
return P2PVR::PrivateTunerPrx::checkedCast(ice.adapter->addWithUUID(new MockTuner()));
}
void ReleaseTuner(const P2PVR::TunerPrx & tuner, const Ice::Current & ice) override
{
ice.adapter->remove(tuner->ice_getIdentity());
}
Ice::Int TunerCount(const Ice::Current&) override
{
return 1;
}
};
class MockScheduler : public P2PVR::Schedules {
public:
void DoReschedule(const ::Ice::Current&) { }
void DeleteSchedule(Ice::Int, const Ice::Current&) { }
P2PVR::SchedulePtr GetSchedule(::Ice::Int, const ::Ice::Current&) { return P2PVR::SchedulePtr(); }
P2PVR::ScheduleList GetSchedules(const ::Ice::Current&) { return P2PVR::ScheduleList(); }
P2PVR::ScheduledToRecordList GetScheduledToRecord(const ::Ice::Current&) { return P2PVR::ScheduledToRecordList(); }
Ice::Int UpdateSchedule(const ::P2PVR::SchedulePtr&, const ::Ice::Current&) { return 0; }
};
static
Ice::CommunicatorPtr
standardConfig()
{
int paramCount = 0;
Ice::CommunicatorPtr ic = Ice::initialize(paramCount, NULL);
auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12000");
TestOptionsSource::LoadTestOptions({
{ "common.datasourceRoot", (root / "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 Maintenance(adapter, NULL), ic->stringToIdentity("Maintenance"));
adapter->activate();
return ic;
}
BOOST_AUTO_TEST_CASE( update_network )
{
auto ic = standardConfig();
ScopeObject _([&ic]{ ic->destroy(); });
auto m = P2PVR::MaintenancePrx::checkedCast(ic->stringToProxy("Maintenance"));
BOOST_REQUIRE(m);
m->ice_ping();
m->UpdateNetwork(FE_OFDM);
}
BOOST_AUTO_TEST_CASE( update_services )
{
auto ic = standardConfig();
ScopeObject _([&ic]{ ic->destroy(); });
auto m = P2PVR::MaintenancePrx::checkedCast(ic->stringToProxy("Maintenance"));
BOOST_REQUIRE(m);
m->ice_ping();
m->UpdateServices(FE_OFDM);
}
BOOST_AUTO_TEST_CASE( update_events )
{
auto ic = standardConfig();
ScopeObject _([&ic]{ ic->destroy(); });
auto m = P2PVR::MaintenancePrx::checkedCast(ic->stringToProxy("Maintenance"));
BOOST_REQUIRE(m);
m->ice_ping();
m->UpdateEvents(FE_OFDM);
}
|