summaryrefslogtreecommitdiff
path: root/client/test
diff options
context:
space:
mode:
authordeva <deva>2010-08-17 07:24:27 +0000
committerdeva <deva>2010-08-17 07:24:27 +0000
commit57c5ca5b7fc3db3ab16d9a1cf2760d114e5685ca (patch)
tree42a23e13f97b3d2d3eb65217312327a634608fad /client/test
parent16fa999ed01f3f98e42e2b1248c7021d75b3ef75 (diff)
More tests
Diffstat (limited to 'client/test')
-rw-r--r--client/test/.cvsignore1
-rw-r--r--client/test/testlineedit.cc9
-rw-r--r--client/test/testmacrowindow.cc30
-rw-r--r--client/test/testmultilist.cc35
-rw-r--r--client/test/testresumewidget.cc17
-rw-r--r--client/test/testwindow.cc33
-rw-r--r--client/test/util.h13
7 files changed, 138 insertions, 0 deletions
diff --git a/client/test/.cvsignore b/client/test/.cvsignore
index 868255a..dcb34bb 100644
--- a/client/test/.cvsignore
+++ b/client/test/.cvsignore
@@ -1 +1,2 @@
test*.log
+test*.bin \ No newline at end of file
diff --git a/client/test/testlineedit.cc b/client/test/testlineedit.cc
index 0cf70fd..577e0da 100644
--- a/client/test/testlineedit.cc
+++ b/client/test/testlineedit.cc
@@ -10,6 +10,15 @@ class TestLineEdit: public QObject
Q_OBJECT
private slots:
void creation() { TEST_CREATION(LineEdit); }
+
+ void memleak() {
+ QDomDocument doc; doc.setContent(xml);
+ QDomElement e = doc.documentElement();
+ MacroWindow *w = createMacroWindow();
+ TEST_MEMLEAK(LineEdit le(e, w));
+ delete w;
+ }
+
void disable() { TEST_DISABLE(LineEdit); }
void value() { TEST_VALUE(LineEdit); }
void edit()
diff --git a/client/test/testmacrowindow.cc b/client/test/testmacrowindow.cc
new file mode 100644
index 0000000..6c90445
--- /dev/null
+++ b/client/test/testmacrowindow.cc
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+#include <QtTest/QtTest>
+#include "util.h"
+#include "macrowindow.h"
+
+static QString xml = "<macro name=\"foo\">\n"
+ "<widgets caption=\"bleh\"/>\n"
+ "</widgets>\n"
+ "</macro>";
+
+class TestMacroWindow: public QObject
+{
+Q_OBJECT
+private slots:
+ void memleak() {
+ /*
+ MacroWindow(NetCom &netcom, QDomNode &xml_doc, QString templ,
+ bool collapsed = true, bool compact = false);
+ */
+ QDomDocument doc;// doc.setContent(xml);
+ NetCom netcom("nohost", 42);
+
+ // MacroWindow w(netcom, doc, "test");
+
+ TEST_MEMLEAK(MacroWindow w(netcom, doc, "test"));
+ }
+};
+
+QTEST_MAIN(TestMacroWindow)
+#include "testmacrowindow.moc"
diff --git a/client/test/testmultilist.cc b/client/test/testmultilist.cc
new file mode 100644
index 0000000..65c14d7
--- /dev/null
+++ b/client/test/testmultilist.cc
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+#include <QtTest/QtTest>
+#include "util.h"
+#include "widgets/multilist.h"
+#include <QPixmap>
+#include <QIcon>
+
+static QString xml =
+ "<multilist name=\"foo\" value=\"bar\"/>";
+static QString xml2 =
+ "<multilist name=\"foo\" value=\"bar\" innerwidget=\"bar\">"
+ " <lineedit name=\"bar\" value=\"bleh\"/>"
+ "</multilist>";
+
+class TestMultiList: public QObject
+{
+Q_OBJECT
+private slots:
+ void memleak() {
+ QDomDocument doc; doc.setContent(xml2);
+ QDomElement e = doc.documentElement();
+ MacroWindow *w = createMacroWindow();
+
+ // FIXME: this is used to make sure all resources (icons and pixmaps)
+ // are loaded.
+ MultiList ml(e, w);
+
+ TEST_MEMLEAK(MultiList ml(e, w));
+
+ delete w;
+ }
+};
+
+QTEST_MAIN(TestMultiList)
+#include "testmultilist.moc"
diff --git a/client/test/testresumewidget.cc b/client/test/testresumewidget.cc
new file mode 100644
index 0000000..299d597
--- /dev/null
+++ b/client/test/testresumewidget.cc
@@ -0,0 +1,17 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+#include <QtTest/QtTest>
+#include "util.h"
+#include "resumewidget.h"
+
+class TestResumeWidget: public QObject
+{
+Q_OBJECT
+private slots:
+ void memleak() {
+
+ TEST_MEMLEAK(ResumeWidget r(false));
+ }
+};
+
+QTEST_MAIN(TestResumeWidget)
+#include "testresumewidget.moc"
diff --git a/client/test/testwindow.cc b/client/test/testwindow.cc
new file mode 100644
index 0000000..72f5533
--- /dev/null
+++ b/client/test/testwindow.cc
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+#include <QtTest/QtTest>
+#include "util.h"
+#include "widgets/window.h"
+
+static QString xml = "<widgets name=\"foo\">\n</widgets>";
+static QString xml2 = "<widgets name=\"foo\">\n"
+ "<lineedit name=\"foo\" value=\"bar\"/>\n"
+ "</widgets>";
+
+class TestWindow: public QObject
+{
+Q_OBJECT
+private slots:
+ void memleak() {
+ QDomDocument doc; doc.setContent(xml);
+ QDomElement e = doc.documentElement();
+ MacroWindow *w = createMacroWindow();
+ TEST_MEMLEAK(Window le(e, w));
+ delete w;
+ }
+
+ void memleak2() {
+ QDomDocument doc; doc.setContent(xml2);
+ QDomElement e = doc.documentElement();
+ MacroWindow *w = createMacroWindow();
+ TEST_MEMLEAK(Window le(e, w));
+ delete w;
+ }
+};
+
+QTEST_MAIN(TestWindow)
+#include "testwindow.moc"
diff --git a/client/test/util.h b/client/test/util.h
index abf7df5..03b3e8a 100644
--- a/client/test/util.h
+++ b/client/test/util.h
@@ -31,3 +31,16 @@ QDomElement getWidgetElement(QString type = "",
QCOMPARE(wdg.value(), QString("")); \
wdg.setValue("hello", "source"); \
QCOMPARE(wdg.value(), QString("hello"));
+
+#define TEST_MEMLEAK(C) { \
+ FILE *memlk_fp = fopen("/proc/self/statm", "r"); \
+ int memlk_before; \
+ int memlk_after; \
+ fscanf(memlk_fp, "%d", &memlk_before); \
+ { C; } \
+ rewind(memlk_fp); \
+ fscanf(memlk_fp, "%d", &memlk_after); \
+ fclose(memlk_fp); \
+ QCOMPARE(memlk_before, memlk_after); \
+ }
+