Tests: fixup license headers, code style
This commit is contained in:
parent
41b835ba46
commit
12ee62d393
|
@ -1,3 +1,22 @@
|
|||
/*************************************************************************
|
||||
* Copyright 2017 by Adriaan de Groot <groot@kde.org> *
|
||||
* *
|
||||
* This program 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. *
|
||||
* *
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||
*************************************************************************/
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
|
||||
#include "helpers.h"
|
||||
|
||||
#include "backend/corebackendmanager.h"
|
||||
|
@ -5,43 +24,35 @@
|
|||
#include <QDebug>
|
||||
#include <QString>
|
||||
|
||||
static bool s_KPMcoreInited = false;
|
||||
static bool s_initialized = false;
|
||||
|
||||
KPMCoreInitializer::KPMCoreInitializer() :
|
||||
m_isValid( s_KPMcoreInited )
|
||||
m_isValid( s_initialized )
|
||||
{
|
||||
if ( !s_KPMcoreInited )
|
||||
if ( !s_initialized )
|
||||
{
|
||||
QByteArray env = qgetenv( "KPMCORE_BACKEND" );
|
||||
auto backendName = env.isEmpty() ? CoreBackendManager::defaultBackendName() : QString::fromLatin1(env);
|
||||
auto backendName = env.isEmpty() ? CoreBackendManager::defaultBackendName() : QString::fromLatin1( env );
|
||||
|
||||
if ( !CoreBackendManager::self()->load( backendName ) )
|
||||
{
|
||||
qWarning() << "Failed to load backend plugin" << backendName;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isValid = s_KPMcoreInited = true;
|
||||
}
|
||||
m_isValid = s_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
KPMCoreInitializer::KPMCoreInitializer(const QString& backendName) :
|
||||
m_isValid( s_KPMcoreInited )
|
||||
KPMCoreInitializer::KPMCoreInitializer( const QString& backendName ) :
|
||||
m_isValid( s_initialized )
|
||||
{
|
||||
if (!s_KPMcoreInited)
|
||||
if ( !s_initialized )
|
||||
{
|
||||
if ( !CoreBackendManager::self()->load( backendName ) )
|
||||
{
|
||||
qWarning() << "Failed to load backend plugin" << backendName;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isValid = s_KPMcoreInited = true;
|
||||
}
|
||||
m_isValid = s_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
KPMCoreInitializer::KPMCoreInitializer(const char *backend) : KPMCoreInitializer( QString::fromLatin1(backend) )
|
||||
KPMCoreInitializer::KPMCoreInitializer( const char* backend ) : KPMCoreInitializer( QString::fromLatin1( backend ) )
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,16 +1,42 @@
|
|||
/*************************************************************************
|
||||
* Copyright 2017 by Adriaan de Groot <groot@kde.org> *
|
||||
* *
|
||||
* This program 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. *
|
||||
* *
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||
*************************************************************************/
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
|
||||
#ifndef TEST_KPMHELPERS_H
|
||||
#define TEST_KPMHELPERS_H
|
||||
|
||||
class QString;
|
||||
|
||||
/**
|
||||
* Use RAII to initialize the KPMcore library. Just instantiatie one
|
||||
* object of this class to do "normal" initialization.
|
||||
*/
|
||||
class KPMCoreInitializer
|
||||
{
|
||||
public:
|
||||
KPMCoreInitializer();
|
||||
KPMCoreInitializer(const QString& backend);
|
||||
KPMCoreInitializer(const char *backend);
|
||||
KPMCoreInitializer(); /// Default backend
|
||||
KPMCoreInitializer( const QString& backend ); /// Use named backend
|
||||
KPMCoreInitializer( const char* backend ); /// Use named backend
|
||||
|
||||
bool isValid() const { return m_isValid; }
|
||||
bool isValid() const
|
||||
{
|
||||
return m_isValid;
|
||||
}
|
||||
private:
|
||||
bool m_isValid;
|
||||
} ;
|
||||
|
|
|
@ -1,15 +1,38 @@
|
|||
/*************************************************************************
|
||||
* Copyright 2017 by Adriaan de Groot <groot@kde.org> *
|
||||
* *
|
||||
* This program 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. *
|
||||
* *
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||
*************************************************************************/
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
|
||||
// Initializes KPMcore, and either loads the default backend for
|
||||
// the current platform, or if one is named on the command line,
|
||||
// loads that one. Returns 0 on success.
|
||||
|
||||
#include "helpers.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
if (argc != 2)
|
||||
if ( argc != 2 )
|
||||
{
|
||||
KPMCoreInitializer i;
|
||||
return i.isValid() ? 0 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
KPMCoreInitializer i(argv[1]);
|
||||
KPMCoreInitializer i( argv[1] );
|
||||
return i.isValid() ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue