on xenial help sign in
add a test
commit63c582f8ea217b62e6ccbc41259129f8bcc10003 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 7 Dec 2016, 17:38 (10 years ago) parenta506dbd
3 files changed+34−1
qml/Launcher/Drawer.qml+1 tests/mocks/Unity/Launcher/MockAppDrawerModel.cpp−1 tests/qmltests/Launcher/tst_Launcher.qml+33
qml/Launcher/Drawer.qml+1
@@ -84,6 +84,7 @@ FocusScope {
8484
8585 TextField {
8686 id: searchField
87+ objectName: "searchField"
8788 anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
8889 placeholderText: i18n.tr("Search…")
8990 focus: true
tests/mocks/Unity/Launcher/MockAppDrawerModel.cpp−1
@@ -48,7 +48,6 @@ MockAppDrawerModel::MockAppDrawerModel(QObject *parent):
4848 m_list.append(item);
4949 item = new MockLauncherItem("libreoffice", "/usr/share/applications/libreoffice.desktop","Libre Office", "libreoffice", this);
5050 m_list.append(item);
51− qDebug() << "mock model created";
5251
5352 qsrand(QDateTime::currentMSecsSinceEpoch() / 1000);
5453}
tests/qmltests/Launcher/tst_Launcher.qml+33
@@ -1478,5 +1478,38 @@ Rectangle {
14781478
14791479 launcher.available = true;
14801480 }
1481+
1482+ function dragDrawerIntoView() {
1483+ var startX = launcher.dragAreaWidth/2;
1484+ var startY = launcher.height/2;
1485+ touchFlick(launcher,
1486+ startX, startY,
1487+ startX+units.gu(35), startY);
1488+
1489+ var drawer = findChild(launcher, "drawer");
1490+ verify(!!drawer);
1491+
1492+ // wait until it gets fully extended
1493+ // a tryCompare doesn't work since
1494+ // compare(-0.000005917593600024418, 0);
1495+ // is true and in this case we want exactly 0 or will have pain later on
1496+ tryCompareFunction( function(){ return drawer.x === 0; }, true );
1497+ tryCompare(launcher, "state", "drawer");
1498+ tryCompare(launcher, "drawerShown", true);
1499+
1500+ return drawer;
1501+ }
1502+
1503+ function test_directSearch() {
1504+ var drawer = dragDrawerIntoView();
1505+ verify(!!drawer);
1506+
1507+ tryCompare(drawer, "focus", true);
1508+
1509+ var searchField = findChild(drawer, "searchField");
1510+ verify(searchField);
1511+ typeString("cam");
1512+ tryCompare(searchField, "displayText", "cam");
1513+ }
14811514 }
14821515}