on xenial help sign in
Coding style
commit692ed7e2424ea3c88768e0084c01f11d3b756a66 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateThu 27 Jun 2013, 10:16 (13 years ago) parent648e4f2
4 files changed+45−40
tests/qmltests/Components/tst_DragHandle.cpp+32−32 tests/qmltests/Components/tst_DragHandle.qml+5−4 tests/qmltests/Components/tst_DragHandle/HorizontalShowable.qml+4−2 tests/qmltests/Components/tst_DragHandle/VerticalShowable.qml+4−2
tests/qmltests/Components/tst_DragHandle.cpp+32−32
@@ -49,7 +49,7 @@ class tst_DragHandle: public QObject
4949{
5050 Q_OBJECT
5151public:
52− tst_DragHandle() : device(0) { }
52+ tst_DragHandle() : m_device(0) { }
5353private Q_SLOTS:
5454 void initTestCase(); // will be called before the first test function is executed
5555 void cleanupTestCase(); // will be called after the last test function was executed.
@@ -67,22 +67,22 @@ private:
6767 void tryCompare(std::function<qreal ()> actualFunc, qreal expectedValue);
6868
6969 QQuickView *createView();
70− QQuickView *view;
71− QTouchDevice *device;
72− FakeTimer *fakeTimer;
73− FakeTimeSource *fakeTimeSource;
70+ QQuickView *m_view;
71+ QTouchDevice *m_device;
72+ FakeTimer *m_fakeTimer;
73+ FakeTimeSource *m_fakeTimeSource;
7474};
7575
7676
7777void tst_DragHandle::initTestCase()
7878{
79− if (!device) {
80− device = new QTouchDevice;
81− device->setType(QTouchDevice::TouchScreen);
82− QWindowSystemInterface::registerTouchDevice(device);
79+ if (!m_device) {
80+ m_device = new QTouchDevice;
81+ m_device->setType(QTouchDevice::TouchScreen);
82+ QWindowSystemInterface::registerTouchDevice(m_device);
8383 }
8484
85− view = 0;
85+ m_view = 0;
8686}
8787
8888void tst_DragHandle::cleanupTestCase()
@@ -91,27 +91,27 @@ void tst_DragHandle::cleanupTestCase()
9191
9292void tst_DragHandle::init()
9393{
94− view = createView();
95− view->setSource(QUrl::fromLocalFile(TEST_DIR"/tst_DragHandle.qml"));
96− view->show();
97− QVERIFY(QTest::qWaitForWindowExposed(view));
98− QVERIFY(view->rootObject() != 0);
94+ m_view = createView();
95+ m_view->setSource(QUrl::fromLocalFile(TEST_DIR"/tst_DragHandle.qml"));
96+ m_view->show();
97+ QVERIFY(QTest::qWaitForWindowExposed(m_view));
98+ QVERIFY(m_view->rootObject() != 0);
9999 qApp->processEvents();
100100
101− fakeTimer = new FakeTimer;
102− fakeTimeSource = new FakeTimeSource;
101+ m_fakeTimer = new FakeTimer;
102+ m_fakeTimeSource = new FakeTimeSource;
103103}
104104
105105void tst_DragHandle::cleanup()
106106{
107− delete view;
108− view = 0;
107+ delete m_view;
108+ m_view = 0;
109109
110− delete fakeTimer;
111− fakeTimer = 0;
110+ delete m_fakeTimer;
111+ m_fakeTimer = 0;
112112
113− delete fakeTimeSource;
114− fakeTimeSource = 0;
113+ delete m_fakeTimeSource;
114+ m_fakeTimeSource = 0;
115115}
116116
117117QQuickView *tst_DragHandle::createView()
@@ -166,32 +166,32 @@ void tst_DragHandle::flickAndHold(DirectionalDragArea *dragHandle,
166166 QPointF dragDirectionVector = calculateDirectionVector(dragHandle);
167167 QPointF touchMovement = dragDirectionVector * (distance / (qreal)numSteps);
168168
169− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
169+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
170170
171171 for (int i = 0; i < numSteps; ++i) {
172172 touchPoint += touchMovement;
173− fakeTimeSource->m_msecsSinceReference += timeStep;
174− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
173+ m_fakeTimeSource->m_msecsSinceReference += timeStep;
174+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
175175 }
176176
177177 // Wait for quite a bit before finally releasing to make a very low flick/release
178178 // speed.
179− fakeTimeSource->m_msecsSinceReference += 5000;
180− QTest::touchEvent(view, device).release(0, touchPoint.toPoint());
179+ m_fakeTimeSource->m_msecsSinceReference += 5000;
180+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
181181}
182182
183183DirectionalDragArea *tst_DragHandle::fetchAndSetupDragHandle(const char *objectName)
184184{
185185 DirectionalDragArea *dragHandle =
186− view->rootObject()->findChild<DirectionalDragArea*>(objectName);
186+ m_view->rootObject()->findChild<DirectionalDragArea*>(objectName);
187187 Q_ASSERT(dragHandle != 0);
188− dragHandle->setRecognitionTimer(fakeTimer);
189− dragHandle->setTimeSource(fakeTimeSource);
188+ dragHandle->setRecognitionTimer(m_fakeTimer);
189+ dragHandle->setTimeSource(m_fakeTimeSource);
190190
191191 AxisVelocityCalculator *edgeDragEvaluator =
192192 dragHandle->findChild<AxisVelocityCalculator*>("edgeDragEvaluator");
193193 Q_ASSERT(edgeDragEvaluator != 0);
194− edgeDragEvaluator->setTimeSource(fakeTimeSource);
194+ edgeDragEvaluator->setTimeSource(m_fakeTimeSource);
195195
196196 return dragHandle;
197197}
tests/qmltests/Components/tst_DragHandle.qml+5−4
@@ -52,10 +52,11 @@ Item {
5252
5353 x: {
5454 if (dragHandle) {
55− if (dragHandle.direction === Direction.Rightwards)
56− dragHandle.edgeDragEvaluator.dragThreshold
57− else
58− parent.width - dragHandle.edgeDragEvaluator.dragThreshold
55+ if (dragHandle.direction === Direction.Rightwards) {
56+ dragHandle.edgeDragEvaluator.dragThreshold;
57+ } else {
58+ parent.width - dragHandle.edgeDragEvaluator.dragThreshold;
59+ }
5960 } else {
6061 0
6162 }
tests/qmltests/Components/tst_DragHandle/HorizontalShowable.qml+4−2
@@ -46,8 +46,9 @@ Showable {
4646 direction: Direction.Leftwards
4747
4848 onStatusChanged: {
49− if (status === DirectionalDragArea.Recognized)
49+ if (status === DirectionalDragArea.Recognized) {
5050 dragHandleRecognizedGesture(leftwardsDragHandle);
51+ }
5152 }
5253
5354 Rectangle { color: "red"; anchors.fill: parent }
@@ -65,8 +66,9 @@ Showable {
6566 direction: Direction.Rightwards
6667
6768 onStatusChanged: {
68− if (status === DirectionalDragArea.Recognized)
69+ if (status === DirectionalDragArea.Recognized) {
6970 dragHandleRecognizedGesture(rightwardsDragHandle);
71+ }
7072 }
7173
7274 Rectangle { color: "green"; anchors.fill: parent }
tests/qmltests/Components/tst_DragHandle/VerticalShowable.qml+4−2
@@ -46,8 +46,9 @@ Showable {
4646 direction: Direction.Upwards
4747
4848 onStatusChanged: {
49− if (status === DirectionalDragArea.Recognized)
49+ if (status === DirectionalDragArea.Recognized) {
5050 dragHandleRecognizedGesture(upwardsDragHandle);
51+ }
5152 }
5253
5354 Rectangle { color: "red"; anchors.fill: parent }
@@ -65,8 +66,9 @@ Showable {
6566 direction: Direction.Downwards
6667
6768 onStatusChanged: {
68− if (status === DirectionalDragArea.Recognized)
69+ if (status === DirectionalDragArea.Recognized) {
6970 dragHandleRecognizedGesture(downwardsDragHandle);
71+ }
7072 }
7173
7274 Rectangle { color: "green"; anchors.fill: parent }