File indexing completed on 2024-04-28 15:25:14

0001 /**
0002  * This file is part of the KDE project
0003  *
0004  * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Library General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Library General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Library General Public License
0017  * along with this library; see the file COPYING.LIB.  If not, write to
0018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020  *
0021  */
0022 
0023 #ifndef TEST_REGRESSION_WINDOW_H
0024 #define TEST_REGRESSION_WINDOW_H
0025 
0026 #include <kio/job.h>
0027 
0028 #include <QQueue>
0029 #include <QProcess>
0030 #include <QUrl>
0031 
0032 #include "khtml_part.h"
0033 #include "ui_test_regression_gui.h"
0034 
0035 class TestRegressionWindow : public QMainWindow
0036 {
0037     Q_OBJECT
0038 
0039 public:
0040     TestRegressionWindow(QWidget *parent = 0);
0041     virtual ~TestRegressionWindow();
0042 
0043 private Q_SLOTS:
0044     void toggleJSTests(bool checked);
0045     void toggleHTMLTests(bool checked);
0046     void toggleDebugOutput(bool checked);
0047     void toggleNoXvfbUse(bool checked);
0048 
0049     void setTestsDirectory();
0050     void setKHTMLDirectory();
0051     void setOutputDirectory();
0052 
0053     void directoryListingResult(KIO::Job *job, const KIO::UDSEntryList &list);
0054     void directoryListingFinished(KJob *job);
0055 
0056     void pauseContinueButtonClicked();
0057     void saveLogButtonClicked();
0058 
0059     void treeWidgetContextMenuRequested(const QPoint &pos);
0060 
0061     void runTests();
0062     void runSingleTest();
0063 
0064     void processQueue();
0065 
0066     void testerExited(int exitCode, QProcess::ExitStatus exitStatus);
0067     void testerReceivedData();
0068 
0069     void addToIgnores();
0070     void removeFromIgnores();
0071 
0072 private: // Helpers
0073     enum TestResult {
0074         Unknown         = 0,
0075         Crash           = 1,
0076         Pass            = 2,
0077         PassUnexpected  = 3,
0078         Fail            = 4,
0079         FailKnown       = 5
0080     };
0081 
0082     void initLegend();
0083     void initOutputBrowser();
0084     void initTestsDirectory();
0085     void initRegressionTesting(const QString &testFileName);
0086     void updateItemStatus(TestResult result, QTreeWidgetItem *item, const QString &testFileName);
0087     void updateLogOutput(const QString &data);
0088     void updateProgressBarRange() const;
0089     void parseRegressionTestingOutput(QString data, TestResult result, const QString &cacheName);
0090 
0091     unsigned long countLogLines() const;
0092 
0093     QString extractTestNameFromData(QString &data, TestResult &result) const;
0094     QStringList readListFile(const QString &fileName) const;
0095     void writeListFile(const QString &fileName, const QStringList &content) const;
0096     void loadOutputHTML() const;
0097 
0098     QString pathFromItem(const QTreeWidgetItem *item) const;
0099 
0100 public:
0101     // Flags
0102     enum ProcessArgument {
0103         None        = 0x0,
0104         JSTests     = 0x1,
0105         HTMLTests   = 0x2,
0106         DebugOutput = 0x4,
0107         NoXvfbUse   = 0x8
0108     };
0109 
0110     Q_DECLARE_FLAGS(ProcessArguments, ProcessArgument)
0111 
0112 private:
0113     Ui::MainWindow m_ui;
0114 
0115     ProcessArguments m_flags;
0116 
0117     long m_runCounter;
0118     long m_testCounter;
0119 
0120     unsigned long m_totalTests;
0121     unsigned long m_totalTestsJS;
0122     unsigned long m_totalTestsDOMTS;
0123 
0124     QUrl m_khtmlUrl;
0125     QUrl m_testsUrl;
0126     QUrl m_outputUrl;
0127     QUrl m_saveLogUrl;
0128 
0129     // Temporary variables
0130     TestResult m_lastResult;
0131     QString m_lastName;
0132 
0133     // Status pixmaps
0134     QPixmap m_failPixmap;
0135     QPixmap m_failKnownPixmap;
0136     QPixmap m_passPixmap;
0137     QPixmap m_passUnexpectedPixmap;
0138     QPixmap m_crashPixmap;
0139     QPixmap m_ignorePixmap;
0140     QPixmap m_noBaselinePixmap;
0141 
0142     KHTMLPart *m_browserPart;
0143     QProcess *m_activeProcess;
0144     QTreeWidgetItem *m_activeTreeItem;
0145 
0146     // Caches
0147     QMap<QString, QTreeWidgetItem *> m_itemMap;
0148 
0149     QMap<QString, QStringList> m_ignoreMap;
0150     QMap<QString, QStringList> m_failureMap;
0151     QMap<QString, QStringList> m_directoryMap;
0152 
0153     bool m_suspended;
0154 
0155     // Processing queue
0156     bool m_justProcessingQueue;
0157     QQueue<QString> m_processingQueue;
0158 };
0159 
0160 Q_DECLARE_OPERATORS_FOR_FLAGS(TestRegressionWindow::ProcessArguments)
0161 
0162 #endif
0163