Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /** |
---|---|
2 | * This file is part of the KDE project |
3 | * |
4 | * Copyright (C) 2001,2003 Peter Kelly (pmk@post.com) |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Library General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2 of the License, or (at your option) any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Library General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Library General Public License |
17 | * along with this library; see the file COPYING.LIB. If not, write to |
18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | * Boston, MA 02110-1301, USA. |
20 | * |
21 | */ |
22 | |
23 | #ifndef TEST_REGRESSION_H |
24 | #define TEST_REGRESSION_H |
25 | |
26 | #include <khtml_part.h> |
27 | #include <kurl.h> |
28 | #include <QtCore/QObject> |
29 | #include <QtCore/QStack> |
30 | #include <kjs/ustring.h> |
31 | #include <kjs/object.h> |
32 | #include <kjs/interpreter.h> |
33 | #include "ecma/kjs_binding.h" |
34 | |
35 | class RegressionTest; |
36 | class QTimer; |
37 | class QEventLoop; |
38 | |
39 | /** |
40 | * @internal |
41 | */ |
42 | class PartMonitor : public QObject |
43 | { |
44 | Q_OBJECT |
45 | public: |
46 | PartMonitor(KHTMLPart *_part); |
47 | ~PartMonitor(); |
48 | void waitForCompletion(); |
49 | void enterLoop(); |
50 | void exitLoop(); |
51 | static PartMonitor* sm_highestMonitor; |
52 | QStack<QEventLoop*> m_eventLoopStack; |
53 | bool m_completed; |
54 | KHTMLPart *m_part; |
55 | int m_timer_waits; |
56 | QTimer *m_timeout_timer; |
57 | public Q_SLOTS: |
58 | void partCompleted(); |
59 | void timeout(); |
60 | void finishTimers(); |
61 | }; |
62 | |
63 | /** |
64 | * @internal |
65 | */ |
66 | class RegTestObject : public KJS::JSObject |
67 | { |
68 | public: |
69 | RegTestObject(KJS::ExecState *exec, RegressionTest *_regTest); |
70 | |
71 | private: |
72 | RegressionTest *m_regTest; |
73 | }; |
74 | |
75 | /** |
76 | * @internal |
77 | */ |
78 | class RegTestFunction : public KJS::JSObject |
79 | { |
80 | public: |
81 | RegTestFunction(KJS::ExecState *exec, RegressionTest *_regTest, int _id, int length); |
82 | |
83 | bool implementsCall() const; |
84 | KJS::JSValue* callAsFunction(KJS::ExecState *exec, KJS::JSObject* thisObj, const KJS::List &args); |
85 | |
86 | enum { Print, ReportResult, CheckOutput, Quit }; |
87 | |
88 | private: |
89 | RegressionTest *m_regTest; |
90 | int id; |
91 | }; |
92 | |
93 | /** |
94 | * @internal |
95 | */ |
96 | class KHTMLPartObject : public KJS::JSObject |
97 | { |
98 | public: |
99 | KHTMLPartObject(KJS::ExecState *exec, KHTMLPart *_part); |
100 | |
101 | virtual bool getOwnPropertySlot(KJS::ExecState *exec, const KJS::Identifier& propertyName, KJS::PropertySlot& slot); |
102 | private: |
103 | static KJS::JSValue *winGetter(KJS::ExecState *, KJS::JSObject*, const KJS::Identifier&, const KJS::PropertySlot&); |
104 | static KJS::JSValue *docGetter(KJS::ExecState *, KJS::JSObject*, const KJS::Identifier&, const KJS::PropertySlot&); |
105 | KHTMLPart *m_part; |
106 | }; |
107 | |
108 | /** |
109 | * @internal |
110 | */ |
111 | class KHTMLPartFunction : public KJS::JSObject |
112 | { |
113 | public: |
114 | KHTMLPartFunction(KJS::ExecState *exec, KHTMLPart *_part, int _id, int length); |
115 | |
116 | bool implementsCall() const; |
117 | KJS::JSValue* callAsFunction(KJS::ExecState *exec, KJS::JSObject* thisObj, const KJS::List &args); |
118 | |
119 | enum { OpenPage, OpenPageAsUrl, Begin, Write, End, ExecuteScript, ProcessEvents }; |
120 | private: |
121 | KHTMLPart *m_part; |
122 | int id; |
123 | }; |
124 | |
125 | namespace KJS { |
126 | class ScriptInterpreter; |
127 | } |
128 | |
129 | /** |
130 | * @internal |
131 | */ |
132 | class RegressionTest : public QObject |
133 | { |
134 | Q_OBJECT |
135 | public: |
136 | |
137 | RegressionTest(KHTMLPart *part, const QString &baseDir, const QString &outputDir, const QString &baselineDir, |
138 | bool _genOutput, bool runJS, bool runHTML); |
139 | ~RegressionTest(); |
140 | |
141 | enum OutputType { DOMTree, RenderTree }; |
142 | QString getPartOutput( OutputType type ); |
143 | void getPartDOMOutput( QTextStream &outputStream, KHTMLPart* part, uint indent ); |
144 | void dumpRenderTree( QTextStream &outputStream, KHTMLPart* part ); |
145 | void testStaticFile(const QString& filename); |
146 | void testJSFile(const QString& filename); |
147 | enum CheckResult { Failure = 0, Success = 1, Ignored = 2 }; |
148 | CheckResult checkOutput(const QString& againstFilename); |
149 | CheckResult checkPaintdump( const QString& againstFilename); |
150 | enum FailureType { NoFailure = 0, AllFailure = 1, RenderFailure = 2, DomFailure = 4, PaintFailure = 8, JSFailure = 16}; |
151 | bool runTests(QString relPath = QString(), bool mustExist = false, QStringList failureFileList = QStringList()); |
152 | bool reportResult( bool passed, const QString & description = QString() ); |
153 | bool reportResult(CheckResult result, const QString & description = QString() ); |
154 | void createMissingDirs(const QString &path); |
155 | |
156 | QImage renderToImage(); |
157 | bool imageEqual( const QImage &lhs, const QImage &rhs ); |
158 | void createLink( const QString& test, int failures ); |
159 | void doJavascriptReport( const QString &test ); |
160 | void doFailureReport( const QString& test, int failures ); |
161 | |
162 | KHTMLPart *m_part; |
163 | QString m_baseDir; |
164 | QString m_outputDir; |
165 | QString m_baselineDir; |
166 | bool m_genOutput; |
167 | QString m_currentBase; |
168 | |
169 | QString m_currentOutput; |
170 | QString m_currentCategory; |
171 | QString m_currentTest; |
172 | QPixmap* m_paintBuffer; |
173 | |
174 | bool m_getOutput; |
175 | bool m_runJS; |
176 | bool m_runHTML; |
177 | int m_passes_work; |
178 | int m_passes_fail; |
179 | int m_failures_work; |
180 | int m_failures_fail; |
181 | int m_errors; |
182 | bool saw_failure; |
183 | bool ignore_errors; |
184 | int m_known_failures; |
185 | |
186 | static RegressionTest *curr; |
187 | |
188 | private: |
189 | void printDescription(const QString& description); |
190 | |
191 | static bool svnIgnored( const QString &filename ); |
192 | |
193 | private: |
194 | void evalJS( KJS::ScriptInterpreter &interp, const QString &filename, bool report ); // used by testJS |
195 | |
196 | private Q_SLOTS: |
197 | void slotOpenURL(const KUrl &url, const KParts::OpenUrlArguments& args, const KParts::BrowserArguments& browserArgs); |
198 | void resizeTopLevelWidget( int, int ); |
199 | |
200 | }; |
201 | |
202 | #endif |
203 |
Warning: That file was not part of the compilation database. It may have many parsing errors.