~nick-dedekind/unity8/indicators.hint-interval

« back to all changes in this revision

Viewing changes to tests/qmltests/Components/tst_DragHandle.cpp

  • Committer: Nick Dedekind
  • Date: 2014-03-07 15:54:57 UTC
  • mfrom: (638.1.118 unity8)
  • Revision ID: nicholas.dedekind@gmail.com-20140307155457-f0s1zu5ll2czt3rq
merged with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    void cleanup(); // called right after each and every test function is executed
59
59
 
60
60
    void dragThreshold_horizontal();
 
61
    void dragThreshold_horizontal_data();
61
62
    void dragThreshold_vertical();
 
63
    void dragThreshold_vertical_data();
62
64
    void stretch_horizontal();
63
65
    void stretch_vertical();
64
66
    void hintingAnimation();
145
147
namespace {
146
148
QPointF calculateDirectionVector(DirectionalDragArea *edgeDragArea)
147
149
{
148
 
 
 
150
    QPointF localOrigin(0., 0.);
 
151
    QPointF localDirection;
149
152
    switch (edgeDragArea->direction()) {
150
153
        case Direction::Upwards:
151
 
            return QPointF(0, -1);
 
154
            localDirection.rx() = 0.;
 
155
            localDirection.ry() = -1.;
 
156
            break;
152
157
        case Direction::Downwards:
153
 
            return QPointF(0, 1);
 
158
            localDirection.rx() = 0.;
 
159
            localDirection.ry() = 1;
 
160
            break;
154
161
        case Direction::Leftwards:
155
 
            return QPointF(-1, 0);
 
162
            localDirection.rx() = -1.;
 
163
            localDirection.ry() = 0.;
 
164
            break;
156
165
        default: // Direction::Rightwards:
157
 
            return QPointF(1, 0);
 
166
            localDirection.rx() = 1.;
 
167
            localDirection.ry() = 0.;
 
168
            break;
158
169
    }
 
170
    QPointF sceneOrigin = edgeDragArea->mapToScene(localOrigin);
 
171
    QPointF sceneDirection = edgeDragArea->mapToScene(localDirection);
 
172
    return sceneDirection - sceneOrigin;
159
173
}
160
174
}
161
175
 
222
236
 */
223
237
void tst_DragHandle::dragThreshold_horizontal()
224
238
{
 
239
    QFETCH(qreal, rotation);
 
240
 
 
241
    QQuickItem *baseItem =  m_view->rootObject()->findChild<QQuickItem*>("baseItem");
 
242
    baseItem->setRotation(rotation);
 
243
 
225
244
    DirectionalDragArea *dragHandle = fetchAndSetupDragHandle("rightwardsDragHandle");
226
245
 
227
246
    qreal dragThreshold = fetchDragThreshold(dragHandle);
260
279
    QCOMPARE(parentItem->property("shown").toBool(), false);
261
280
}
262
281
 
 
282
void tst_DragHandle::dragThreshold_horizontal_data()
 
283
{
 
284
    QTest::addColumn<qreal>("rotation");
 
285
 
 
286
    QTest::newRow("not rotated") << 0.;
 
287
    QTest::newRow("rotated 90")  << 90.;
 
288
}
 
289
 
263
290
void tst_DragHandle::dragThreshold_vertical()
264
291
{
 
292
    QFETCH(qreal, rotation);
 
293
 
 
294
    QQuickItem *baseItem =  m_view->rootObject()->findChild<QQuickItem*>("baseItem");
 
295
    baseItem->setRotation(rotation);
 
296
 
265
297
    DirectionalDragArea *dragHandle = fetchAndSetupDragHandle("downwardsDragHandle");
266
298
 
267
299
    qreal dragThreshold = fetchDragThreshold(dragHandle);
300
332
    QCOMPARE(parentItem->property("shown").toBool(), false);
301
333
}
302
334
 
 
335
void tst_DragHandle::dragThreshold_vertical_data()
 
336
{
 
337
    QTest::addColumn<qreal>("rotation");
 
338
 
 
339
    QTest::newRow("not rotated") << 0.;
 
340
    QTest::newRow("rotated 90")  << 90.;
 
341
}
 
342
 
303
343
/*
304
344
  Checks that when the stretch property is true, dragging the DragHandle increases
305
345
  the width or height (depending on its direction) of its parent Showable