on xenial help sign in
Coding style
692ed7eDaniel d'Andrada
tests/qmltests/Components/tst_DragHandle.cpp+32−32
@@ -49,7 +49,7 @@ class tst_DragHandle: public QObject
49{
49{
50 Q_OBJECT
50 Q_OBJECT
51public:
51public:
52− tst_DragHandle() : device(0) { }
52+ tst_DragHandle() : m_device(0) { }
53private Q_SLOTS:
53private Q_SLOTS:
54 void initTestCase(); // will be called before the first test function is executed
54 void initTestCase(); // will be called before the first test function is executed
55 void cleanupTestCase(); // will be called after the last test function was executed.
55 void cleanupTestCase(); // will be called after the last test function was executed.
@@ -67,22 +67,22 @@ private:
67 void tryCompare(std::function<qreal ()> actualFunc, qreal expectedValue);
67 void tryCompare(std::function<qreal ()> actualFunc, qreal expectedValue);
68
68
69 QQuickView *createView();
69 QQuickView *createView();
70− QQuickView *view;
70+ QQuickView *m_view;
71− QTouchDevice *device;
71+ QTouchDevice *m_device;
72− FakeTimer *fakeTimer;
72+ FakeTimer *m_fakeTimer;
73− FakeTimeSource *fakeTimeSource;
73+ FakeTimeSource *m_fakeTimeSource;
74};
74};
75
75
76
76
77void tst_DragHandle::initTestCase()
77void tst_DragHandle::initTestCase()
78{
78{
79− if (!device) {
79+ if (!m_device) {
80− device = new QTouchDevice;
80+ m_device = new QTouchDevice;
81− device->setType(QTouchDevice::TouchScreen);
81+ m_device->setType(QTouchDevice::TouchScreen);
82− QWindowSystemInterface::registerTouchDevice(device);
82+ QWindowSystemInterface::registerTouchDevice(m_device);
83 }
83 }
84
84
85− view = 0;
85+ m_view = 0;
86}
86}
87
87
88void tst_DragHandle::cleanupTestCase()
88void tst_DragHandle::cleanupTestCase()
@@ -91,27 +91,27 @@ void tst_DragHandle::cleanupTestCase()
91
91
92void tst_DragHandle::init()
92void tst_DragHandle::init()
93{
93{
94− view = createView();
94+ m_view = createView();
95− view->setSource(QUrl::fromLocalFile(TEST_DIR"/tst_DragHandle.qml"));
95+ m_view->setSource(QUrl::fromLocalFile(TEST_DIR"/tst_DragHandle.qml"));
96− view->show();
96+ m_view->show();
97− QVERIFY(QTest::qWaitForWindowExposed(view));
97+ QVERIFY(QTest::qWaitForWindowExposed(m_view));
98− QVERIFY(view->rootObject() != 0);
98+ QVERIFY(m_view->rootObject() != 0);
99 qApp->processEvents();
99 qApp->processEvents();
100
100
101− fakeTimer = new FakeTimer;
101+ m_fakeTimer = new FakeTimer;
102− fakeTimeSource = new FakeTimeSource;
102+ m_fakeTimeSource = new FakeTimeSource;
103}
103}
104
104
105void tst_DragHandle::cleanup()
105void tst_DragHandle::cleanup()
106{
106{
107− delete view;
107+ delete m_view;
108− view = 0;
108+ m_view = 0;
109
109
110− delete fakeTimer;
110+ delete m_fakeTimer;
111− fakeTimer = 0;
111+ m_fakeTimer = 0;
112
112
113− delete fakeTimeSource;
113+ delete m_fakeTimeSource;
114− fakeTimeSource = 0;
114+ m_fakeTimeSource = 0;
115}
115}
116
116
117QQuickView *tst_DragHandle::createView()
117QQuickView *tst_DragHandle::createView()
@@ -166,32 +166,32 @@ void tst_DragHandle::flickAndHold(DirectionalDragArea *dragHandle,
166 QPointF dragDirectionVector = calculateDirectionVector(dragHandle);
166 QPointF dragDirectionVector = calculateDirectionVector(dragHandle);
167 QPointF touchMovement = dragDirectionVector * (distance / (qreal)numSteps);
167 QPointF touchMovement = dragDirectionVector * (distance / (qreal)numSteps);
168
168
169− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
169+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
170
170
171 for (int i = 0; i < numSteps; ++i) {
171 for (int i = 0; i < numSteps; ++i) {
172 touchPoint += touchMovement;
172 touchPoint += touchMovement;
173− fakeTimeSource->m_msecsSinceReference += timeStep;
173+ m_fakeTimeSource->m_msecsSinceReference += timeStep;
174− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
174+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
175 }
175 }
176
176
177 // Wait for quite a bit before finally releasing to make a very low flick/release
177 // Wait for quite a bit before finally releasing to make a very low flick/release
178 // speed.
178 // speed.
179− fakeTimeSource->m_msecsSinceReference += 5000;
179+ m_fakeTimeSource->m_msecsSinceReference += 5000;
180− QTest::touchEvent(view, device).release(0, touchPoint.toPoint());
180+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
181}
181}
182
182
183DirectionalDragArea *tst_DragHandle::fetchAndSetupDragHandle(const char *objectName)
183DirectionalDragArea *tst_DragHandle::fetchAndSetupDragHandle(const char *objectName)
184{
184{
185 DirectionalDragArea *dragHandle =
185 DirectionalDragArea *dragHandle =
186− view->rootObject()->findChild<DirectionalDragArea*>(objectName);
186+ m_view->rootObject()->findChild<DirectionalDragArea*>(objectName);
187 Q_ASSERT(dragHandle != 0);
187 Q_ASSERT(dragHandle != 0);
188− dragHandle->setRecognitionTimer(fakeTimer);
188+ dragHandle->setRecognitionTimer(m_fakeTimer);
189− dragHandle->setTimeSource(fakeTimeSource);
189+ dragHandle->setTimeSource(m_fakeTimeSource);
190
190
191 AxisVelocityCalculator *edgeDragEvaluator =
191 AxisVelocityCalculator *edgeDragEvaluator =
192 dragHandle->findChild<AxisVelocityCalculator*>("edgeDragEvaluator");
192 dragHandle->findChild<AxisVelocityCalculator*>("edgeDragEvaluator");
193 Q_ASSERT(edgeDragEvaluator != 0);
193 Q_ASSERT(edgeDragEvaluator != 0);
194− edgeDragEvaluator->setTimeSource(fakeTimeSource);
194+ edgeDragEvaluator->setTimeSource(m_fakeTimeSource);
195
195
196 return dragHandle;
196 return dragHandle;
197}
197}
tests/qmltests/Components/tst_DragHandle.qml+5−4
@@ -52,10 +52,11 @@ Item {
52
52
53 x: {
53 x: {
54 if (dragHandle) {
54 if (dragHandle) {
55− if (dragHandle.direction === Direction.Rightwards)
55+ if (dragHandle.direction === Direction.Rightwards) {
56− dragHandle.edgeDragEvaluator.dragThreshold
56+ dragHandle.edgeDragEvaluator.dragThreshold;
57− else
57+ } else {
58− parent.width - dragHandle.edgeDragEvaluator.dragThreshold
58+ parent.width - dragHandle.edgeDragEvaluator.dragThreshold;
59+ }
59 } else {
60 } else {
60 0
61 0
61 }
62 }
tests/qmltests/Components/tst_DragHandle/HorizontalShowable.qml+4−2
@@ -46,8 +46,9 @@ Showable {
46 direction: Direction.Leftwards
46 direction: Direction.Leftwards
47
47
48 onStatusChanged: {
48 onStatusChanged: {
49− if (status === DirectionalDragArea.Recognized)
49+ if (status === DirectionalDragArea.Recognized) {
50 dragHandleRecognizedGesture(leftwardsDragHandle);
50 dragHandleRecognizedGesture(leftwardsDragHandle);
51+ }
51 }
52 }
52
53
53 Rectangle { color: "red"; anchors.fill: parent }
54 Rectangle { color: "red"; anchors.fill: parent }
@@ -65,8 +66,9 @@ Showable {
65 direction: Direction.Rightwards
66 direction: Direction.Rightwards
66
67
67 onStatusChanged: {
68 onStatusChanged: {
68− if (status === DirectionalDragArea.Recognized)
69+ if (status === DirectionalDragArea.Recognized) {
69 dragHandleRecognizedGesture(rightwardsDragHandle);
70 dragHandleRecognizedGesture(rightwardsDragHandle);
71+ }
70 }
72 }
71
73
72 Rectangle { color: "green"; anchors.fill: parent }
74 Rectangle { color: "green"; anchors.fill: parent }
tests/qmltests/Components/tst_DragHandle/VerticalShowable.qml+4−2
@@ -46,8 +46,9 @@ Showable {
46 direction: Direction.Upwards
46 direction: Direction.Upwards
47
47
48 onStatusChanged: {
48 onStatusChanged: {
49− if (status === DirectionalDragArea.Recognized)
49+ if (status === DirectionalDragArea.Recognized) {
50 dragHandleRecognizedGesture(upwardsDragHandle);
50 dragHandleRecognizedGesture(upwardsDragHandle);
51+ }
51 }
52 }
52
53
53 Rectangle { color: "red"; anchors.fill: parent }
54 Rectangle { color: "red"; anchors.fill: parent }
@@ -65,8 +66,9 @@ Showable {
65 direction: Direction.Downwards
66 direction: Direction.Downwards
66
67
67 onStatusChanged: {
68 onStatusChanged: {
68− if (status === DirectionalDragArea.Recognized)
69+ if (status === DirectionalDragArea.Recognized) {
69 dragHandleRecognizedGesture(downwardsDragHandle);
70 dragHandleRecognizedGesture(downwardsDragHandle);
71+ }
70 }
72 }
71
73
72 Rectangle { color: "green"; anchors.fill: parent }
74 Rectangle { color: "green"; anchors.fill: parent }