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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
#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 "mockDevices.h"
#include "mockScheduler.h"
#include <si.h>
#include <recordings.h>
#include <linux/dvb/frontend.h>
#include <definedDirs.h>
#include "mockDefs.h"
class Core {
public:
Core()
{
int paramCount = 0;
ic = Ice::initialize(paramCount, NULL);
auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12000");
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;
private:
Ice::CommunicatorPtr ic;
};
BOOST_GLOBAL_FIXTURE( SchemaOnlyMockDatabase );
BOOST_FIXTURE_TEST_SUITE( MaintCore, Core );
const int serviceId = 4170;
const int transportId = 20544;
const int eventId1 = 31;
const int eventId2 = 915;
//
// Run all these tests when there's no data
// This tests behaviour from clean startup/fresh install
//
BOOST_AUTO_TEST_CASE( GetNetworks_emptySet )
{
BOOST_REQUIRE(s->GetNetworks().empty());
}
BOOST_AUTO_TEST_CASE( GetAllDeliveries_emptySet )
{
BOOST_REQUIRE(s->GetAllDeliveries().empty());
}
BOOST_AUTO_TEST_CASE( GetDeliveryForService_notFound )
{
BOOST_REQUIRE_THROW(s->GetDeliveryForService(serviceId), P2PVR::NotFound);
}
BOOST_AUTO_TEST_CASE( GetDeliveryForTransport_notFound )
{
BOOST_REQUIRE_THROW(s->GetDeliveryForTransport(transportId), P2PVR::NotFound);
}
BOOST_AUTO_TEST_CASE( GetDeliveryForSi_null )
{
BOOST_REQUIRE_EQUAL(s->GetDeliveryForSi(), DVBSI::DeliveryPtr());
}
BOOST_AUTO_TEST_CASE( GetServices_emptySet )
{
BOOST_REQUIRE(s->GetServices().empty());
}
BOOST_AUTO_TEST_CASE( GetService_notFound )
{
BOOST_REQUIRE_THROW(s->GetService(serviceId), P2PVR::NotFound);
}
BOOST_AUTO_TEST_CASE( GetSpecificEvents_notFound )
{
BOOST_REQUIRE_THROW(s->GetEvents({ eventId1, eventId2 }), P2PVR::NotFound);
}
//
// Now scan for and configure a network
//
BOOST_AUTO_TEST_CASE( update_network )
{
m->UpdateNetwork(FE_OFDM);
}
BOOST_AUTO_TEST_CASE( GetNetworks )
{
auto ns = s->GetNetworks();
BOOST_REQUIRE_EQUAL(ns.size(), 1);
BOOST_REQUIRE_EQUAL(ns[0]->NetworkId, 12333);
BOOST_REQUIRE_EQUAL(ns[0]->Name, "Yorkshire");
}
BOOST_AUTO_TEST_CASE( GetDeliveryForService )
{
auto del = s->GetDeliveryForService(serviceId);
BOOST_REQUIRE(del);
BOOST_REQUIRE_EQUAL(del->ice_id(), "::DVBSI::TerrestrialDelivery");
BOOST_REQUIRE_EQUAL(del->Frequency, 682000000);
}
BOOST_AUTO_TEST_CASE( GetDeliveryForTransport )
{
auto del = s->GetDeliveryForTransport(transportId);
BOOST_REQUIRE(del);
BOOST_REQUIRE_EQUAL(del->ice_id(), "::DVBSI::TerrestrialDelivery");
BOOST_REQUIRE_EQUAL(del->Frequency, 722000000);
}
BOOST_AUTO_TEST_CASE( GetServices_stubs )
{
auto services = s->GetServices();
BOOST_REQUIRE_EQUAL(services.size(), 145);
BOOST_REQUIRE_EQUAL(services[0]->ServiceId, 4170);
BOOST_REQUIRE_EQUAL(services[0]->TransportStreamId, 4170);
// Definitely a stub
BOOST_REQUIRE(!services[0]->Name);
}
BOOST_AUTO_TEST_CASE( GetService_stubs )
{
auto service = s->GetService(serviceId);
BOOST_REQUIRE_EQUAL(service->ServiceId, serviceId);
// Definitely a stub
BOOST_REQUIRE(!service->Name);
}
BOOST_AUTO_TEST_CASE( GetDeliveryForSi_any )
{
auto del = s->GetDeliveryForSi();
BOOST_REQUIRE(del);
// Any yes, but is our case it should be DVB-T
BOOST_REQUIRE_EQUAL(del->ice_id(), "::DVBSI::TerrestrialDelivery");
}
BOOST_AUTO_TEST_CASE( UpdateNetwork_prepopulated )
{
// This should now run using existing transport data (although this test doesn't prove that)
m->UpdateNetwork(FE_OFDM);
}
//
// Load in the service details
// Should give things names etc, but not add/remove
//
BOOST_AUTO_TEST_CASE( update_services )
{
m->UpdateServices(FE_OFDM);
}
BOOST_AUTO_TEST_CASE( GetServices )
{
auto services = s->GetServices();
BOOST_REQUIRE_EQUAL(services.size(), 145);
BOOST_REQUIRE_EQUAL(services[0]->ServiceId, 4170);
BOOST_REQUIRE_EQUAL(services[0]->TransportStreamId, 4170);
BOOST_REQUIRE_EQUAL(services[0]->Name, "BBC ONE Yorks");
BOOST_REQUIRE_EQUAL(services[0]->DefaultAuthority, "fp.bbc.co.uk");
}
BOOST_AUTO_TEST_CASE( GetService )
{
auto service = s->GetService(serviceId);
BOOST_REQUIRE_EQUAL(service->ServiceId, serviceId);
BOOST_REQUIRE_EQUAL(service->TransportStreamId, 4170);
BOOST_REQUIRE_EQUAL(service->Name, "BBC ONE Yorks");
BOOST_REQUIRE_EQUAL(service->DefaultAuthority, "fp.bbc.co.uk");
}
BOOST_AUTO_TEST_CASE( update_events )
{
BOOST_CHECKPOINT("Write first events");
MockTuner::SetEventsSet(0);
m->UpdateEvents(FE_OFDM);
BOOST_REQUIRE(s->GetEvent(14448, 27052));
BOOST_REQUIRE_THROW(s->GetEvent(15856, 3591), P2PVR::NotFound);
BOOST_CHECKPOINT("Write second events");
MockTuner::SetEventsSet(1);
m->UpdateEvents(FE_OFDM);
BOOST_REQUIRE_THROW(s->GetEvent(14448, 27052), P2PVR::NotFound);
BOOST_REQUIRE(s->GetEvent(15856, 3591));
}
BOOST_AUTO_TEST_SUITE_END()
|