mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-19 07:22:32 +02:00
Add test for Servent
This commit is contained in:
parent
96fc4c6d0c
commit
0c63b9db71
@ -6,3 +6,4 @@ include(tomahawk_add_test.cmake)
|
||||
tomahawk_add_test(Result)
|
||||
tomahawk_add_test(Query)
|
||||
tomahawk_add_test(Database)
|
||||
tomahawk_add_test(Servent)
|
||||
|
77
src/tests/TestServent.h
Normal file
77
src/tests/TestServent.h
Normal file
@ -0,0 +1,77 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, Dominik Schmidt <domme@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TOMAHAWK_TESTDATABASE_H
|
||||
#define TOMAHAWK_TESTDATABASE_H
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "network/Servent.h"
|
||||
#include "sip/SipInfo.h"
|
||||
|
||||
class TestServent : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
|
||||
bool plainIPAddress( const QString& address )
|
||||
{
|
||||
// TODO: Add real checks
|
||||
return true;
|
||||
}
|
||||
|
||||
private slots:
|
||||
void testListenAll()
|
||||
{
|
||||
// Instatiante a new instance for each test so we have a sane state.
|
||||
Servent* servent = new Servent();
|
||||
QVERIFY( servent != NULL );
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
QHostAddress anyAddress = QHostAddress::Any;
|
||||
#else
|
||||
QHostAddress anyAddress = QHostAddress::AnyIPv6;
|
||||
#endif
|
||||
|
||||
// TODO: Use a random free port for tests
|
||||
// With (upnp == false) and (mode ==
|
||||
// Tomahawk::Network::ExternalAddress::Upnp) we should not do
|
||||
// any external address detection.
|
||||
bool ok = servent->startListening( anyAddress, false, 52222,
|
||||
Tomahawk::Network::ExternalAddress::Upnp, 52222);
|
||||
QVERIFY( ok );
|
||||
|
||||
// Verify that computed external addresses are ok
|
||||
QList<QHostAddress> externalAddresses = servent->addresses();
|
||||
foreach ( QHostAddress addr, externalAddresses )
|
||||
{
|
||||
QVERIFY( plainIPAddress( addr.toString() ) );
|
||||
}
|
||||
|
||||
// Verify that the local SipInfos contain valid addresses
|
||||
QList<SipInfo> sipInfos = servent->getLocalSipInfos( uuid(), uuid() );
|
||||
foreach ( SipInfo sipInfo, sipInfos )
|
||||
{
|
||||
QVERIFY( plainIPAddress( sipInfo.host() ) );
|
||||
}
|
||||
|
||||
delete servent;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // TOMAHAWK_TESTDATABASE_H
|
Loading…
x
Reference in New Issue
Block a user