2011-04-27 10:05:43 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2012-01-05 04:03:39 +00:00
|
|
|
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2012-01-20 03:06:31 +00:00
|
|
|
** Contact: http://www.qt-project.org/
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** This file is part of the test suite of the Qt Toolkit.
|
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
|
|
|
** GNU Lesser General Public License Usage
|
2011-05-24 09:34:08 +00:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this
|
|
|
|
** file. Please review the following information to ensure the GNU Lesser
|
|
|
|
** General Public License version 2.1 requirements will be met:
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-05-24 09:34:08 +00:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2011-04-27 10:05:43 +00:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
2011-05-24 09:34:08 +00:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU General
|
|
|
|
** Public License version 3.0 as published by the Free Software Foundation
|
|
|
|
** and appearing in the file LICENSE.GPL included in the packaging of this
|
|
|
|
** file. Please review the following information to ensure the GNU General
|
|
|
|
** Public License version 3.0 requirements will be met:
|
|
|
|
** http://www.gnu.org/copyleft/gpl.html.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
2011-05-24 09:34:08 +00:00
|
|
|
** Other Usage
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
**
|
|
|
|
**
|
|
|
|
**
|
|
|
|
**
|
2012-01-24 06:17:24 +00:00
|
|
|
**
|
2011-04-27 10:05:43 +00:00
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef BASELINESERVER_H
|
|
|
|
#define BASELINESERVER_H
|
|
|
|
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QTcpServer>
|
|
|
|
#include <QThread>
|
|
|
|
#include <QTcpSocket>
|
|
|
|
#include <QScopedPointer>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QDateTime>
|
2011-04-27 10:37:19 +00:00
|
|
|
#include <QSettings>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#include "baselineprotocol.h"
|
|
|
|
#include "report.h"
|
|
|
|
|
|
|
|
// #seconds between update checks
|
|
|
|
#define HEARTBEAT 10
|
|
|
|
#define MetadataFileExt "metadata"
|
|
|
|
|
|
|
|
class BaselineServer : public QTcpServer
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
BaselineServer(QObject *parent = 0);
|
|
|
|
|
|
|
|
static QString storagePath();
|
|
|
|
static QString baseUrl();
|
2011-04-27 10:37:19 +00:00
|
|
|
static QString settingsFilePath();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
protected:
|
2012-01-11 15:06:14 +00:00
|
|
|
void incomingConnection(qintptr socketDescriptor);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void heartbeat();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QTimer *heartbeatTimer;
|
|
|
|
QDateTime meLastMod;
|
|
|
|
QString lastRunId;
|
|
|
|
int lastRunIdIdx;
|
|
|
|
static QString storage;
|
|
|
|
static QString url;
|
2011-04-27 10:37:19 +00:00
|
|
|
static QString settingsFile;
|
2011-04-27 10:05:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BaselineThread : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
BaselineThread(const QString &runId, int socketDescriptor, QObject *parent);
|
|
|
|
void run();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString runId;
|
|
|
|
int socketDescriptor;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class BaselineHandler : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
BaselineHandler(const QString &runId, int socketDescriptor = -1);
|
|
|
|
void testPathMapping();
|
|
|
|
QString pathForItem(const ImageItem &item, bool isBaseline = true, bool absolute = true) const;
|
|
|
|
|
|
|
|
// CGI callbacks:
|
|
|
|
static QString view(const QString &baseline, const QString &rendered, const QString &compared);
|
|
|
|
static QString clearAllBaselines(const QString &context);
|
|
|
|
static QString updateBaselines(const QString &context, const QString &mismatchContext, const QString &itemFile);
|
|
|
|
static QString blacklistTest(const QString &context, const QString &itemId, bool removeFromBlacklist = false);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void receiveRequest();
|
|
|
|
void receiveDisconnect();
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool establishConnection();
|
|
|
|
void provideBaselineChecksums(const QByteArray &itemListBlock);
|
|
|
|
void storeImage(const QByteArray &itemBlock, bool isBaseline);
|
|
|
|
void storeItemMetadata(const PlatformInfo &metadata, const QString &path);
|
|
|
|
PlatformInfo fetchItemMetadata(const QString &path);
|
2011-09-01 12:50:59 +00:00
|
|
|
PlatformInfo mapPlatformInfo(const PlatformInfo& orig) const;
|
2011-04-27 10:05:43 +00:00
|
|
|
const char *logtime();
|
|
|
|
QString computeMismatchScore(const QImage& baseline, const QImage& rendered);
|
|
|
|
|
|
|
|
BaselineProtocol proto;
|
2011-09-01 12:50:59 +00:00
|
|
|
PlatformInfo clientInfo;
|
|
|
|
mutable PlatformInfo mappedClientInfo;
|
|
|
|
mutable PlatformInfo overriddenMappedClientInfo;
|
2011-04-27 10:05:43 +00:00
|
|
|
QString runId;
|
|
|
|
bool connectionEstablished;
|
|
|
|
Report report;
|
2011-04-27 10:37:19 +00:00
|
|
|
QSettings *settings;
|
2011-04-27 10:05:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BASELINESERVER_H
|