1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
#include "macrowindow.h"
#include <QDomElement>
MacroWindow *createMacroWindow();
QDomElement getWidgetElement(QString type = "",
QString name = "",
QString value = "");
//
// Predefined tests
//
#define TEST_CREATION(W) \
QDomElement n = getWidgetElement(#W, "mywidget"); \
MacroWindow *wnd = createMacroWindow(); \
W wgd(n, wnd);
#define TEST_DISABLE(W) \
QDomElement n = getWidgetElement(#W, "mywidget"); \
MacroWindow *wnd = createMacroWindow(); \
W wdg(n, wnd); \
wdg.setEnabled(false); \
QCOMPARE(wdg.enabled(), false); \
wdg.setEnabled(true); \
QCOMPARE(wdg.enabled(), true);
#define TEST_VALUE(W) \
QDomElement n = getWidgetElement(#W, "mywidget"); \
MacroWindow *wnd = createMacroWindow(); \
W wdg(n, wnd); \
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); \
}
|