summaryrefslogtreecommitdiff
path: root/p2pvr/daemon/unittests/testSi.cpp
blob: a8941557f504fe433d485ab82d262141bd2a917f (plain)
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
#define BOOST_TEST_MODULE SI
#include <boost/test/unit_test.hpp>
#include <boost/filesystem/operations.hpp>
#include <options.h>
#include <Ice/ObjectAdapter.h>
#include <Ice/Service.h>
#include <maintenance.h>
#include <mockTuner.h>
#include <si.h>
#include <linux/dvb/frontend.h>
#include <definedDirs.h>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/lexical_cast.hpp>
#include "mockDefs.h"
#include "icetraySupport.h"

using namespace P2PVR;
using namespace P2PVR::Testing;
using namespace std::literals;

BOOST_GLOBAL_FIXTURE( StandardMockDatabase );

BOOST_FIXTURE_TEST_SUITE( SiCore, TestClient )

BOOST_AUTO_TEST_CASE ( si_getEvents )
{
	// Get an event known to exist so we can use its uid
	auto event = si->GetEvent(23968, 4378);
	BOOST_REQUIRE(event);

	auto events = si->GetEvents({ event->EventUid });
	BOOST_REQUIRE_EQUAL(events.size(), 1);
	BOOST_REQUIRE_EQUAL(events.front()->ServiceId, 23968);
	BOOST_REQUIRE_EQUAL(events.front()->EventId, 4378);
}

BOOST_AUTO_TEST_CASE ( si_getEvents_missing )
{
	BOOST_REQUIRE_THROW(si->GetEvents({ 0 }), P2PVR::NotFound);
}

BOOST_AUTO_TEST_CASE( si_getEvent )
{
	auto event = si->GetEvent(23968, 4378);
	BOOST_REQUIRE(event);
	BOOST_REQUIRE_EQUAL(event->Title, "Timothy Goes to School");
	BOOST_REQUIRE_EQUAL(event->Current, true);
}

BOOST_AUTO_TEST_CASE( si_getEvent_missing )
{
	BOOST_REQUIRE_THROW(si->GetEvent(0, 0), P2PVR::NotFound);
}

BOOST_AUTO_TEST_CASE( si_getEventsOnNow )
{
	si->EventsOnNow();
}

BOOST_AUTO_TEST_CASE( si_getEventsInSched )
{
	si->EventsInSchedule(0);
}

BOOST_AUTO_TEST_CASE( si_getEventsInScheds )
{
	si->EventsInSchedules();
}

BOOST_AUTO_TEST_CASE( si_getEventsInRange )
{
	si->EventsInRange(Chrono::DateTime {2014, 12, 19, 3, 0}, Chrono::DateTime {2014, 12, 20, 3, 0});
}

BOOST_AUTO_TEST_CASE( si_getEventSearch )
{
	si->EventSearch("Top Gear"s, Ice::optional< ::Ice::Int >(),
			Ice::optional<Chrono::DateTime>(), Ice::optional<Chrono::DateTime>());
	si->EventSearch("Top Gear"s, 22272,
			Ice::optional<Chrono::DateTime>(), Ice::optional<Chrono::DateTime>());
	si->EventSearch("Top Gear"s, 22272,
			Chrono::DateTime {2014, 12, 19, 3, 0}, Ice::optional<Chrono::DateTime>());
	si->EventSearch("Top Gear"s, 22272,
			Chrono::DateTime {2014, 12, 19, 3, 0}, Chrono::DateTime {2014, 12, 20, 3, 0});
}

BOOST_AUTO_TEST_CASE( si_getAllDeliveries )
{
	auto dels = si->GetAllDeliveries();
	BOOST_REQUIRE_EQUAL(dels.size(), 6);
}

BOOST_AUTO_TEST_CASE( si_getDeliveryForTransport )
{
	auto del = si->GetDeliveryForTransport(4170);
	BOOST_REQUIRE(del);
	auto dvbt = std::dynamic_pointer_cast<DVBSI::TerrestrialDelivery>(del);
	BOOST_REQUIRE(dvbt);
	BOOST_REQUIRE_EQUAL(dvbt->TransportStreamId, 4170);
}

BOOST_AUTO_TEST_CASE( si_getDeliveryForSI )
{
	auto del = si->GetDeliveryForSi();
	BOOST_REQUIRE(del);
	auto dvbt = std::dynamic_pointer_cast<DVBSI::TerrestrialDelivery>(del);
	BOOST_REQUIRE(dvbt);
}

BOOST_AUTO_TEST_CASE( si_getDeliveryForService )
{
	auto del = si->GetDeliveryForService(4170);
	BOOST_REQUIRE(del);
	auto dvbt = std::dynamic_pointer_cast<DVBSI::TerrestrialDelivery>(del);
	BOOST_REQUIRE(dvbt);
	BOOST_REQUIRE_EQUAL(dvbt->TransportStreamId, 4170);
}

BOOST_AUTO_TEST_CASE( si_getServices )
{
	auto services = si->GetServices();
	BOOST_REQUIRE_EQUAL(services.size(), 145);
	BOOST_REQUIRE(services[0]->Name);
	BOOST_REQUIRE_EQUAL(*services[0]->Name, "BBC ONE Yorks");
	BOOST_REQUIRE(services[0]->DefaultAuthority);
	BOOST_REQUIRE_EQUAL(*services[0]->DefaultAuthority, "fp.bbc.co.uk");
	BOOST_REQUIRE_EQUAL(services[0]->EitSchedule, true);
	BOOST_REQUIRE_EQUAL(services[0]->EitPresentFollowing, true);
}

BOOST_AUTO_TEST_CASE( si_getService )
{
	auto service = si->GetService(4170);
	BOOST_REQUIRE(service->Name);
	BOOST_REQUIRE_EQUAL(*service->Name, "BBC ONE Yorks");
	BOOST_REQUIRE(service->DefaultAuthority);
	BOOST_REQUIRE_EQUAL(*service->DefaultAuthority, "fp.bbc.co.uk");
	BOOST_REQUIRE_EQUAL(service->EitSchedule, true);
	BOOST_REQUIRE_EQUAL(service->EitPresentFollowing, true);
}

BOOST_AUTO_TEST_CASE( si_getServiceMissing )
{
	BOOST_REQUIRE_THROW(si->GetService(0), P2PVR::NotFound);
}

BOOST_AUTO_TEST_SUITE_END()