summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2010-02-12 14:19:27 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2010-02-15 12:41:03 (GMT)
commit57e94c1b1bf68fde430cecc138f395decf35e917 (patch)
treed3bc163d1bd58b23f687ddf26d43b22784f41786 /tests/benchmarks
parent7fc8fdc43e8f898908f2e8fc60f3c22b0cd47db7 (diff)
downloadQt-57e94c1b1bf68fde430cecc138f395decf35e917.zip
Qt-57e94c1b1bf68fde430cecc138f395decf35e917.tar.gz
Qt-57e94c1b1bf68fde430cecc138f395decf35e917.tar.bz2
Add support for running the GraphicsViewBenchmark application manually.
Also add support for the command line options that were supported in the old benchmark (see 2f389a95f5b9e4c7130aa333586d803b639bf259).
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/main.cpp92
-rw-r--r--tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.cpp134
-rw-r--r--tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp14
-rw-r--r--tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/settings.h7
4 files changed, 151 insertions, 96 deletions
diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/main.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/main.cpp
index 4b589e3..e84b879 100644
--- a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/main.cpp
+++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/main.cpp
@@ -50,6 +50,7 @@
#include "itemrecyclinglist.h"
#include "simplelist.h"
#include "theme.h"
+#include "commandline.h"
class tst_GraphicsViewBenchmark : public QObject
{
@@ -67,8 +68,8 @@ public:
Fast = 64
};
- tst_GraphicsViewBenchmark()
- : mMainView(0), currentListSize(-1), currentListType(None) {}
+ tst_GraphicsViewBenchmark(Settings *settings)
+ : mSettings(settings), mMainView(0), currentListSize(-1), currentListType(None) {}
~tst_GraphicsViewBenchmark() {}
public slots:
@@ -94,6 +95,7 @@ private slots:
void scroll();
private:
+ Settings *mSettings;
MainView *mMainView;
DummyDataGenerator mDataGenerator;
int currentListSize;
@@ -312,19 +314,20 @@ void tst_GraphicsViewBenchmark::insertListData()
void tst_GraphicsViewBenchmark::initTestCase()
{
- // ### Add support for:
- // 1) OpenGL
- // 2) FPS
- // 3) Running the test manually
- // Everything we need is already in widgets/[settings.cpp, commandline.cpp]
- mMainView = new MainView(/*enableOpenGL=*/false, /*outputFPS=*/false);
+ mMainView = new MainView(mSettings->options() & Settings::UseOpenGL,
+ mSettings->options() & Settings::OutputFps);
+ if (mSettings->size().width() > 0 && mSettings->size().height() > 0) {
+ mMainView->resize(mSettings->size().width(), mSettings->size().height());
+ mMainView->show();
+ } else {
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
- mMainView->showFullScreen();
+ mMainView->showFullScreen();
#else
- mMainView->resize(360, 640);
- mMainView->show();
+ mMainView->resize(360, 640);
+ mMainView->show();
#endif
+ }
mDataGenerator.Reset();
SimpleList *list = new SimpleList;
@@ -724,5 +727,70 @@ void tst_GraphicsViewBenchmark::scroll()
}
}
-QTEST_MAIN(tst_GraphicsViewBenchmark)
+int main(int argc, char *argv[])
+{
+ Settings settings;
+ if (!readSettingsFromCommandLine(argc, argv, settings))
+ return 1;
+
+ // Eat command line arguments.
+ int aargc = 0;
+ for (int i = 0; i < argc; ++i) {
+ if (argv[i])
+ ++aargc;
+ }
+ char **aargv = new char*[aargc];
+ aargc = 0;
+ for (int i = 0; i < argc; ++i) {
+ if (argv[i])
+ aargv[aargc++] = argv[i];
+ }
+
+ QApplication app(argc, argv);
+
+ int returnValue = 0;
+ if (settings.options() & Settings::ManualTest) {
+ MainView view(settings.options() & Settings::UseOpenGL, settings.options() & Settings::OutputFps);
+
+ DummyDataGenerator dataGenerator;
+ dataGenerator.Reset();
+
+ SimpleList *list = new SimpleList;
+ if (settings.options() & Settings::UseListItemCache)
+ list->setListItemCaching(true);
+ else
+ list->setListItemCaching(false);
+
+ if (settings.listItemCount())
+ fillList(dataGenerator, settings.listItemCount(), list);
+ else
+ fillList(dataGenerator, 500, list);
+
+ view.setTestWidget(list);
+
+ if ((settings.angle() % 360) != 0)
+ view.rotateContent(settings.angle());
+
+ if (settings.size().width() > 0 && settings.size().height() > 0) {
+ view.resize(settings.size().width(), settings.size().height());
+ view.show();
+ } else {
+#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
+ view.showFullScreen();
+#else
+ view.resize(360, 640);
+ view.show();
+#endif
+ }
+ returnValue = app.exec();
+ } else {
+ QTEST_DISABLE_KEYPAD_NAVIGATION
+ tst_GraphicsViewBenchmark tc(&settings);
+ returnValue = QTest::qExec(&tc, aargc, aargv);
+ }
+
+ delete [] aargv;
+ return returnValue;
+}
+
#include "main.moc"
diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.cpp
index c913fe9..cdfa941 100644
--- a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.cpp
+++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.cpp
@@ -45,76 +45,62 @@
static void usage(const char *appname)
{
- printf("%s [options]\n", appname);
- printf("Options:\n");
- printf("\t -h,-help : This help\n");
-#ifdef AUTO_TESTS
- printf("\t -o file : Write output to file\n");
- printf("\t -xml : Outputs results as XML document\n");
- printf("\t -lightxml : Outputs results as stream of XML tags\n");
- printf("\t -script-name file : Use this script instead of internal script file\n");
-#endif
- printf("\t -resolution : UI resolution in format WxH where width and height are positive values\n");
- printf("\t -rotation : UI rotation in degrees\n");
- printf("\t -subtree-cache : Enables usage of subtree caching method\n");
- printf("\t -noresusage : Disables CPU and Memory usage measurement\n");
-#ifndef AUTO_TESTS
- printf("\t -fps : Output FPS count to stdout during application execution\n");
- printf("\t -items : Count of items created to the list\n");
-#endif
-#if ENABLE_OPENGL
-#ifndef QT_NO_OPENGL
- printf("\t -opengl : Enables OpenGL usage. Building PRECONDITIONS: ENABLE_OPENGL is on. QT_NO_OPENGL is off.\n");
-#endif
-#endif
+ Q_UNUSED(appname);
+ printf(" GraphicsViewBenchmark related options:\n");
+ printf(" -h,-help,--help: This help\n");
+ printf(" -resolution : UI resolution in format WxH where width and height are positive values\n");
+ printf(" -opengl : Enables OpenGL usage. Building PRECONDITIONS: QT_NO_OPENGL is off.\n");
+ printf(" -manual : Run test manually \n");
+ printf("\n The following options are available in manual mode:\n");
+ printf(" -rotation : UI rotation in degrees\n");
+ printf(" -subtree-cache : Enables usage of subtree caching method\n");
+ printf(" -fps : Output FPS count to stdout during application execution\n");
+ printf(" -items : Count of items created to the list\n");
printf("\n");
}
+static inline bool argumentOnlyAvailableInManualMode(const char *arg)
+{
+ return (strcmp(arg, "-rotation") == 0)
+ || (strcmp(arg, "-subtree-cache") == 0)
+ || (strcmp(arg, "-fps") == 0)
+ || (strcmp(arg, "-items") == 0);
+}
+
bool readSettingsFromCommandLine(int argc, char *argv[],
Settings& config)
{
bool builtWithOpenGL = false;
Settings::Options options;
-#if ENABLE_OPENGL
#ifndef QT_NO_OPENGL
builtWithOpenGL = true;
#endif
-#endif
- for (int i=0; i<argc; ++i) {
- if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) {
+ for (int i = 1; i < argc; ++i) {
+ if (strcmp(argv[i], "-manual") == 0) {
+ options |= Settings::ManualTest;
+ argv[i] = 0;
+ break;
+ }
+ }
+
+ for (int i = 1; i < argc; ++i) {
+ if (!argv[i])
+ continue;
+ if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "--help") == 0) {
usage(argv[0]);
- return false;
+ return true;
}
-#ifdef AUTO_TESTS
- if (strcmp(argv[i], "-o") == 0) {
- if (i + 1 >= argc) {
- printf("-o needs an extra parameter specifying the filename\n");
- usage(argv[0]);
- return false;
+ if (strcmp(argv[i], "-opengl") == 0) {
+ if (builtWithOpenGL) {
+ options |= Settings::UseOpenGL;
+ argv[i] = 0;
} else {
- config.setOutputFileName(QString(argv[i+1]));
- i++;
- }
- }
- if (strcmp(argv[i], "-xml") == 0) {
- config.setResultFormat(1); // See FileLogger::ResultFormat
- }
- if (strcmp(argv[i], "-lightxml") == 0) {
- config.setResultFormat(2); // See FileLogger::ResultFormat
- }
- if (strcmp(argv[i], "-script-name") == 0) {
- if (i + 1 >= argc) {
- printf("-script-name needs an extra parameter specifying the filename\n");
+ printf("-opengl parameter can be used only with building PRECONDITIONS: QT_NO_OPENGL is off.\n");
usage(argv[0]);
return false;
- } else {
- config.setScriptName(QString(argv[i+1]));
- i++;
}
- }
-#endif
- if (strcmp(argv[i], "-resolution") == 0) {
+ } else if (strcmp(argv[i], "-resolution") == 0) {
if (i + 1 >= argc) {
printf("-resolution needs an extra parameter specifying the application UI resolution\n");
usage(argv[0]);
@@ -137,9 +123,24 @@ bool readSettingsFromCommandLine(int argc, char *argv[],
usage(argv[0]);
return false;
}
+ argv[i] = 0;
i++;
+ argv[i] = 0;
}
}
+
+ if (!argv[i])
+ continue;
+
+ if (!(options & Settings::ManualTest)) {
+ if (argumentOnlyAvailableInManualMode(argv[i])) {
+ printf("\nWrong option: '%s' is only available in manual mode\n\n", argv[i]);
+ usage(argv[0]);
+ return false;
+ }
+ continue;
+ }
+
if (strcmp(argv[i], "-rotation") == 0) {
if (i + 1 >= argc) {
printf("-rotation needs an extra parameter specifying the application UI rotation in degrees\n");
@@ -155,29 +156,17 @@ bool readSettingsFromCommandLine(int argc, char *argv[],
return false;
}
config.setAngle(angle);
+ argv[i] = 0;
i++;
+ argv[i] = 0;
}
- }
- if (strcmp(argv[i], "-subtree-cache") == 0) {
+ } else if (strcmp(argv[i], "-subtree-cache") == 0) {
options |= Settings::UseListItemCache;
- }
- if (strcmp(argv[i], "-opengl") == 0) {
- if (builtWithOpenGL)
- options |= Settings::UseOpenGL;
- else {
- printf("-opengl parameter can be used only with building PRECONDITIONS: ENABLE_OPENGL is on. QT_NO_OPENGL is off.\n");
- usage(argv[0]);
- return false;
- }
- }
- if (strcmp(argv[i], "-noresusage") == 0) {
- options |= Settings::NoResourceUsage;
- }
-#ifndef AUTO_TESTS
- if (strcmp(argv[i], "-fps") == 0) {
+ argv[i] = 0;
+ } else if (strcmp(argv[i], "-fps") == 0) {
options |= Settings::OutputFps;
- }
- if (strcmp(argv[i], "-items") == 0) {
+ argv[i] = 0;
+ } else if (strcmp(argv[i], "-items") == 0) {
if (i + 1 >= argc) {
printf("-items needs an extra parameter specifying amount of list items\n");
usage(argv[0]);
@@ -192,10 +181,11 @@ bool readSettingsFromCommandLine(int argc, char *argv[],
return false;
}
config.setListItemCount(amount);
+ argv[i] = 0;
i++;
+ argv[i] = 0;
}
}
-#endif
}
config.setOptions(options);
diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp
index a9cf3ac..07a154b 100644
--- a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp
+++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp
@@ -41,11 +41,9 @@
#include <QDebug>
#include <QApplication>
#include <QGraphicsLinearLayout>
-#if ENABLE_OPENGL
#ifndef QT_NO_OPENGL
#include <QGLWidget>
#endif
-#endif
#include <QObject>
#include "button.h"
@@ -210,7 +208,9 @@ void MainView::paintEvent (QPaintEvent *event)
else {
QGraphicsView::paintEvent(event);
}
- emit repainted();
+
+ if (!m_OutputFps)
+ emit repainted();
m_frameCount++;
m_fpsLatestTs.start();
@@ -261,7 +261,6 @@ void MainView::construct()
{
m_scene = new QGraphicsScene;
-#ifdef ENABLE_OPENGL
#ifndef QT_NO_OPENGL
if (m_enableOpenGL) {
qDebug() << "OpenGL enabled";
@@ -271,14 +270,11 @@ void MainView::construct()
// Qt doc says: This is the preferred update mode for
// viewports that do not support partial updates, such as QGLWidget...
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
- }
-#endif
+ } else
#endif
+ setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
setScene(m_scene);
-
- if (!m_enableOpenGL)
- setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
m_scene->setItemIndexMethod(QGraphicsScene::NoIndex);
//setCacheMode(QGraphicsView::CacheBackground);
diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/settings.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/settings.h
index 8473bf5..57ad970 100644
--- a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/settings.h
+++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/settings.h
@@ -51,11 +51,12 @@ class Settings : public QObject {
public:
enum Option {
- NoOptions = 0x0,
+ NoOptions = 0x1,
UseListItemCache = 0x2,
UseOpenGL = 0x4,
- OutputFps = 0x5,
- NoResourceUsage = 0x6,
+ OutputFps = 0x8,
+ NoResourceUsage = 0x10,
+ ManualTest = 0x20
};
Q_DECLARE_FLAGS(Options, Option)