summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-02-27 11:32:15 +0100
committerJohan Helsing <johan.helsing@qt.io>2018-02-27 17:03:41 +0000
commitc4bd9198b4a0fac809903dd2c09276c2c3c1b22e (patch)
tree83325fe11d258c922ede480e0ad3de3df45032fa /tests
parent72999738489b5251d025c954a77c93e8e1fdfd9d (diff)
Init variables where they are declared when possible (clang-tidy)
clang-tidy -p compile_commands.json $file \ -checks='-*,modernize-use-default-member-init,readability-redundant-member-init' \ -config='{CheckOptions: [{key: modernize-use-default-member-init.UseAssignment, value: "1"}]}' \ -header-filter='qtwayland' \ -fix Afterwards I ran search and replace on the diff to clean up some whitespace errors: - Replaced '(\n\+[^:\n]*)(:\s+\+\s+)' with '$1: ' - Replaced '(\n\+[^,\n]*)(,\s+\+\s+)' with '$1, ' - Replaced '\n\+\s*\n' with '\n' I also had to do some manual edits, because for some reason, this particular clang-tidy check doesn't trigger for some files. Change-Id: I3b3909bac4bf20108bbe8ad1e01bcc54236dae1b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/client/client/tst_client.cpp27
-rw-r--r--tests/auto/client/shared/mockcompositor.cpp3
-rw-r--r--tests/auto/client/shared/mockcompositor.h6
-rw-r--r--tests/auto/client/shared/mockinput.cpp15
-rw-r--r--tests/auto/client/shared/mockinput.h12
-rw-r--r--tests/auto/client/shared/mocksurface.cpp2
-rw-r--r--tests/auto/client/shared/mocksurface.h4
-rw-r--r--tests/auto/compositor/compositor/mockclient.cpp9
-rw-r--r--tests/auto/compositor/compositor/mockclient.h22
-rw-r--r--tests/auto/compositor/compositor/testcompositor.cpp3
10 files changed, 35 insertions, 68 deletions
diff --git a/tests/auto/client/client/tst_client.cpp b/tests/auto/client/client/tst_client.cpp
index eb99b2e2f..8ee52d736 100644
--- a/tests/auto/client/client/tst_client.cpp
+++ b/tests/auto/client/client/tst_client.cpp
@@ -48,14 +48,6 @@ class TestWindow : public QWindow
{
public:
TestWindow()
- : focusInEventCount(0)
- , focusOutEventCount(0)
- , keyPressEventCount(0)
- , keyReleaseEventCount(0)
- , mousePressEventCount(0)
- , mouseReleaseEventCount(0)
- , touchEventCount(0)
- , keyCode(0)
{
setSurfaceType(QSurface::RasterSurface);
setGeometry(0, 0, 32, 32);
@@ -103,15 +95,15 @@ public:
QPoint frameOffset() const { return QPoint(frameMargins().left(), frameMargins().top()); }
- int focusInEventCount;
- int focusOutEventCount;
- int keyPressEventCount;
- int keyReleaseEventCount;
- int mousePressEventCount;
- int mouseReleaseEventCount;
- int touchEventCount;
+ int focusInEventCount = 0;
+ int focusOutEventCount = 0;
+ int keyPressEventCount = 0;
+ int keyReleaseEventCount = 0;
+ int mousePressEventCount = 0;
+ int mouseReleaseEventCount = 0;
+ int touchEventCount = 0;
- uint keyCode;
+ uint keyCode = 0;
QPoint mousePressPos;
};
@@ -404,7 +396,6 @@ class DndWindow : public QWindow
public:
DndWindow(QWindow *parent = nullptr)
: QWindow(parent)
- , dragStarted(false)
{
QImage cursorImage(64,64,QImage::Format_ARGB32);
cursorImage.fill(Qt::blue);
@@ -412,7 +403,7 @@ public:
}
~DndWindow(){}
QPoint frameOffset() const { return QPoint(frameMargins().left(), frameMargins().top()); }
- bool dragStarted;
+ bool dragStarted = false;
protected:
void mousePressEvent(QMouseEvent *event) override
diff --git a/tests/auto/client/shared/mockcompositor.cpp b/tests/auto/client/shared/mockcompositor.cpp
index 2f1d68b01..1d76cec12 100644
--- a/tests/auto/client/shared/mockcompositor.cpp
+++ b/tests/auto/client/shared/mockcompositor.cpp
@@ -37,9 +37,6 @@
#include <stdio.h>
MockCompositor::MockCompositor()
- : m_alive(true)
- , m_ready(false)
- , m_compositor(0)
{
pthread_create(&m_thread, 0, run, this);
diff --git a/tests/auto/client/shared/mockcompositor.h b/tests/auto/client/shared/mockcompositor.h
index 747da38fa..c6de12376 100644
--- a/tests/auto/client/shared/mockcompositor.h
+++ b/tests/auto/client/shared/mockcompositor.h
@@ -212,13 +212,13 @@ private:
static void *run(void *data);
- bool m_alive;
- bool m_ready;
+ bool m_alive = true;
+ bool m_ready = false;
pthread_t m_thread;
QMutex m_mutex;
QWaitCondition m_waitCondition;
- Impl::Compositor *m_compositor;
+ Impl::Compositor *m_compositor = nullptr;
QList<Command> m_commandQueue;
};
diff --git a/tests/auto/client/shared/mockinput.cpp b/tests/auto/client/shared/mockinput.cpp
index 9cea85b6d..8b7592824 100644
--- a/tests/auto/client/shared/mockinput.cpp
+++ b/tests/auto/client/shared/mockinput.cpp
@@ -232,10 +232,7 @@ void Seat::seat_get_touch(Resource *resource, uint32_t id)
}
Keyboard::Keyboard(Compositor *compositor)
- : wl_keyboard()
- , m_compositor(compositor)
- , m_focusResource(nullptr)
- , m_focus(nullptr)
+ : m_compositor(compositor)
{
}
@@ -286,10 +283,7 @@ void Keyboard::keyboard_destroy_resource(wl_keyboard::Resource *resource)
}
Pointer::Pointer(Compositor *compositor)
- : wl_pointer()
- , m_compositor(compositor)
- , m_focusResource(nullptr)
- , m_focus(nullptr)
+ : m_compositor(compositor)
{
}
@@ -393,10 +387,7 @@ DataOffer::DataOffer()
}
DataDevice::DataDevice(Compositor *compositor)
- : wl_data_device()
- , m_compositor(compositor)
- , m_dataOffer(nullptr)
- , m_focus(nullptr)
+ : m_compositor(compositor)
{
}
diff --git a/tests/auto/client/shared/mockinput.h b/tests/auto/client/shared/mockinput.h
index 9c217b6ac..5760ab40c 100644
--- a/tests/auto/client/shared/mockinput.h
+++ b/tests/auto/client/shared/mockinput.h
@@ -85,8 +85,8 @@ protected:
private:
Compositor *m_compositor;
- Resource *m_focusResource;
- Surface *m_focus;
+ Resource *m_focusResource = nullptr;
+ Surface *m_focus = nullptr;
};
class Pointer : public QtWaylandServer::wl_pointer
@@ -108,8 +108,8 @@ protected:
private:
Compositor *m_compositor;
- Resource *m_focusResource;
- Surface *m_focus;
+ Resource *m_focusResource = nullptr;
+ Surface *m_focus = nullptr;
};
class Touch : public QtWaylandServer::wl_touch
@@ -146,8 +146,8 @@ protected:
private:
Compositor *m_compositor;
- QtWaylandServer::wl_data_offer *m_dataOffer;
- Surface* m_focus;
+ QtWaylandServer::wl_data_offer *m_dataOffer = nullptr;
+ Surface* m_focus = nullptr;
};
class DataDeviceManager : public QtWaylandServer::wl_data_device_manager
diff --git a/tests/auto/client/shared/mocksurface.cpp b/tests/auto/client/shared/mocksurface.cpp
index 7aa2a00b2..98a9615a6 100644
--- a/tests/auto/client/shared/mocksurface.cpp
+++ b/tests/auto/client/shared/mocksurface.cpp
@@ -62,10 +62,8 @@ void Compositor::sendSurfaceLeave(void *data, const QList<QVariant> &parameters)
Surface::Surface(wl_client *client, uint32_t id, int v, Compositor *compositor)
: QtWaylandServer::wl_surface(client, id, v)
- , m_buffer(nullptr)
, m_compositor(compositor)
, m_mockSurface(new MockSurface(this))
- , m_mapped(false)
{
}
diff --git a/tests/auto/client/shared/mocksurface.h b/tests/auto/client/shared/mocksurface.h
index 5155599bb..8bf6eb755 100644
--- a/tests/auto/client/shared/mocksurface.h
+++ b/tests/auto/client/shared/mocksurface.h
@@ -63,12 +63,12 @@ protected:
uint32_t callback) override;
void surface_commit(Resource *resource) override;
private:
- wl_resource *m_buffer;
+ wl_resource *m_buffer = nullptr;
Compositor *m_compositor;
QSharedPointer<MockSurface> m_mockSurface;
QList<wl_resource *> m_frameCallbackList;
- bool m_mapped;
+ bool m_mapped = false;
};
}
diff --git a/tests/auto/compositor/compositor/mockclient.cpp b/tests/auto/compositor/compositor/mockclient.cpp
index 4720b0d9f..e6eac1553 100644
--- a/tests/auto/compositor/compositor/mockclient.cpp
+++ b/tests/auto/compositor/compositor/mockclient.cpp
@@ -47,14 +47,6 @@ const struct wl_registry_listener MockClient::registryListener = {
MockClient::MockClient()
: display(wl_display_connect("wayland-qt-test-0"))
- , compositor(nullptr)
- , registry(nullptr)
- , wlshell(nullptr)
- , xdgShell(nullptr)
- , iviApplication(nullptr)
- , refreshRate(-1)
- , error(0 /* means no error according to spec */)
- , protocolError({0, 0, nullptr})
{
if (!display)
qFatal("MockClient(): wl_display_connect() failed");
@@ -223,7 +215,6 @@ ivi_surface *MockClient::createIviSurface(wl_surface *surface, uint iviId)
}
ShmBuffer::ShmBuffer(const QSize &size, wl_shm *shm)
- : handle(nullptr)
{
int stride = size.width() * 4;
int alloc = stride * size.height();
diff --git a/tests/auto/compositor/compositor/mockclient.h b/tests/auto/compositor/compositor/mockclient.h
index dd50f9a28..8933f8327 100644
--- a/tests/auto/compositor/compositor/mockclient.h
+++ b/tests/auto/compositor/compositor/mockclient.h
@@ -44,7 +44,7 @@ public:
ShmBuffer(const QSize &size, wl_shm *shm);
~ShmBuffer();
- struct wl_buffer *handle;
+ struct wl_buffer *handle = nullptr;
struct wl_shm_pool *shm_pool;
QImage image;
};
@@ -63,29 +63,29 @@ public:
ivi_surface *createIviSurface(wl_surface *surface, uint iviId);
wl_display *display;
- wl_compositor *compositor;
+ wl_compositor *compositor = nullptr;
QMap<uint, wl_output *> m_outputs;
wl_shm *shm;
- wl_registry *registry;
- wl_shell *wlshell;
- xdg_shell *xdgShell;
- ivi_application *iviApplication;
+ wl_registry *registry = nullptr;
+ wl_shell *wlshell = nullptr;
+ xdg_shell *xdgShell = nullptr;
+ ivi_application *iviApplication = nullptr;
QList<MockSeat *> m_seats;
QRect geometry;
QSize resolution;
- int refreshRate;
+ int refreshRate = -1;
QWaylandOutputMode currentMode;
QWaylandOutputMode preferredMode;
QList<QWaylandOutputMode> modes;
int fd;
- int error;
+ int error = 0 /* means no error according to spec */;
struct {
- uint id;
- uint code;
- const wl_interface *interface;
+ uint id = 0;
+ uint code = 0;
+ const wl_interface *interface = nullptr;
} protocolError;
private slots:
diff --git a/tests/auto/compositor/compositor/testcompositor.cpp b/tests/auto/compositor/compositor/testcompositor.cpp
index f91d0d3f1..710bb7b3a 100644
--- a/tests/auto/compositor/compositor/testcompositor.cpp
+++ b/tests/auto/compositor/compositor/testcompositor.cpp
@@ -33,8 +33,7 @@
#include <wayland-server.h>
TestCompositor::TestCompositor(bool createInputDev)
- : QWaylandCompositor()
- , shell(new QWaylandWlShell(this))
+ : shell(new QWaylandWlShell(this))
, m_createSeat(createInputDev)
{
setSocketName("wayland-qt-test-0");