880
888
bottomEdge->setEnabled(!bottomEdge->isEnabled());
881
889
QCOMPARE(bottomEdge->isEnabled(), bottomEdge->hint()->isEnabled());
892
void test_preload_content()
894
QScopedPointer<BottomEdgeTestCase> test(new BottomEdgeTestCase("PreloadedContent.qml"));
895
UCBottomEdge *bottomEdge = test->testItem();
897
QPoint from(bottomEdge->width() / 2.0f, bottomEdge->height() - 5);
898
QPoint to = from + QPoint(0, -(bottomEdge->parentItem()->height() - 1));
899
QSignalSpy spy(bottomEdge, SIGNAL(activeRegionChanged(UCBottomEdgeRegion*)));
901
connect(bottomEdge, &UCBottomEdge::contentItemChanged, [=]() {
902
regionObjects.append(bottomEdge->contentItem()
903
? bottomEdge->contentItem()->objectName()
907
UCTestExtras::touchPress(0, bottomEdge, from);
908
QPoint movePos(from);
909
while (movePos.y() > to.y()) {
911
UCTestExtras::touchMove(0, bottomEdge, movePos);
912
movePos += QPoint(0, -10);
915
UCTestExtras::touchRelease(0, bottomEdge, movePos);
916
// we should have had 3 active region changes by now
917
// null -> region #0 -> region #1 -> null
918
QCOMPARE(spy.count(), 3);
919
QCOMPARE(regionObjects.size(), 5);
921
QCOMPARE(regionObjects[i++], QString("default"));
922
QCOMPARE(regionObjects[i++], QString("region1"));
923
QCOMPARE(regionObjects[i++], QString("default"));
924
QCOMPARE(regionObjects[i++], QString("region2"));
925
QCOMPARE(regionObjects[i++], QString("default"));
928
void test_reset_preload_content()
930
QScopedPointer<BottomEdgeTestCase> test(new BottomEdgeTestCase("PreloadedContent.qml"));
931
UCBottomEdge *bottomEdge = test->testItem();
933
UCBottomEdgePrivate *d = UCBottomEdgePrivate::get(bottomEdge);
934
for (int i = 0; i < d->regions.size(); i++) {
935
QVERIFY(d->regions[i]->regionContent());
938
// set preloadContent: false
939
bottomEdge->setPreloadContent(false);
940
for (int i = 0; i < d->regions.size(); i++) {
941
QVERIFY(!d->regions[i]->regionContent());
945
void test_disabled_content_unloads()
947
QScopedPointer<BottomEdgeTestCase> test(new BottomEdgeTestCase("PreloadedContent.qml"));
948
UCBottomEdge *bottomEdge = test->testItem();
950
UCBottomEdgePrivate *d = UCBottomEdgePrivate::get(bottomEdge);
952
d->regions[0]->setEnabled(false);
953
QVERIFY(!d->regions[0]->regionContent());
956
d->regions[0]->setEnabled(true);
957
QTRY_VERIFY_WITH_TIMEOUT(d->regions[0]->regionContent() != nullptr, 1000);
885
961
QTEST_MAIN(tst_BottomEdge)