on xenial help sign in
A test for departments
commit8d1fce8f0a78bb7fa2fb90797a75a7f7ad68263b authorAlbert Astals <albert.astals@canonical.com> dateThu 29 May 2014, 12:08 (12 years ago) parentb3088f8
3 files changed+103
qml/Dash/DashDepartments.qml+3 qml/Dash/DashDepartmentsList.qml+3 tests/qmltests/Dash/tst_DashContent.qml+97
qml/Dash/DashDepartments.qml+3
@@ -19,6 +19,7 @@ import Ubuntu.Components 0.1
1919
2020AbstractButton {
2121 id: root
22+ objectName: "dashDepartments"
2223
2324 property int windowHeight: 0
2425
@@ -91,6 +92,7 @@ AbstractButton {
9192 // departmentListView is outside root
9293 ListView {
9394 id: departmentListView
95+ objectName: "departmentListView"
9496 orientation: ListView.Horizontal
9597 interactive: false
9698 model: ListModel {
@@ -107,6 +109,7 @@ AbstractButton {
107109 onHeightChanged: prevHeight = height;
108110 anchors.top: root.bottom
109111 delegate: DashDepartmentsList {
112+ objectName: "department" + index
110113 visible: height != 0
111114 width: departmentListView.width
112115 height: !root.showList ? 0 : department && department.loaded ? Math.min(implicitHeight, departmentListView.maxHeight) : departmentListView.prevHeight
qml/Dash/DashDepartmentsList.qml+3
@@ -59,6 +59,7 @@ Item {
5959
6060 AbstractButton {
6161 id: backButton
62+ objectName: "backButton"
6263 width: parent.width
6364 visible: department && !department.isRoot
6465 height: visible ? itemHeight : 0
@@ -97,6 +98,7 @@ Item {
9798
9899 AbstractButton {
99100 id: allButton
101+ objectName: "allButton"
100102 anchors.top: backButton.bottom
101103 width: parent.width
102104 visible: department && (!department.isRoot || (root.currentDepartment && !root.currentDepartment.isRoot && root.currentDepartment.parentId == department.departmentId))
@@ -129,6 +131,7 @@ Item {
129131 model: department && department.loaded ? department : null
130132 clip: true
131133 delegate: AbstractButton {
134+ objectName: root.objectName + "child" + index
132135 height: root.itemHeight
133136 width: root.width
134137 y: (flickable.nTopButtonsVisible + index) * root.itemHeight
tests/qmltests/Dash/tst_DashContent.qml+97
@@ -392,5 +392,102 @@ Item {
392392 }
393393 closePreview();
394394 }
395+
396+ function test_departments() {
397+ var dashDepartments = findChild(dashContent, "dashDepartments");
398+ compare(dashDepartments.visible, true);
399+ compare(dashDepartments.showList, false);
400+ waitForRendering(dashDepartments);
401+ mouseClick(dashDepartments, 0, 0);
402+ compare(dashDepartments.showList, true);
403+
404+ var departmentListView = findChild(dashDepartments, "departmentListView");
405+ compare(departmentListView.count, 1);
406+ tryCompare(departmentListView.currentItem.department, "loaded", true);
407+
408+ waitForRendering(departmentListView);
409+ waitForRendering(departmentListView.currentItem);
410+
411+ var allButton = findChild(dashDepartments, "allButton");
412+ compare(allButton.visible, false);
413+
414+ var department = findChild(dashDepartments, "department0child3");
415+ mouseClick(department, 0, 0);
416+ compare(dashDepartments.showList, false);
417+ tryCompare(dashDepartments.currentDepartment, "departmentId", "middle3");
418+ tryCompare(departmentListView.currentItem.department, "departmentId", "root");
419+
420+ mouseClick(dashDepartments, 0, 0);
421+ compare(dashDepartments.showList, true);
422+ waitForRendering(departmentListView);
423+ waitForRendering(departmentListView.currentItem);
424+ compare(allButton.visible, true);
425+
426+ mouseClick(allButton, 0, 0);
427+ compare(dashDepartments.showList, false);
428+ tryCompare(dashDepartments.currentDepartment, "departmentId", "root");
429+ tryCompare(departmentListView.currentItem.department, "departmentId", "root");
430+
431+ mouseClick(dashDepartments, 0, 0);
432+ compare(dashDepartments.showList, true);
433+ waitForRendering(departmentListView);
434+ waitForRendering(departmentListView.currentItem);
435+ compare(allButton.visible, false);
436+
437+ department = findChild(dashDepartments, "department0child2");
438+ mouseClick(department, 0, 0);
439+ compare(dashDepartments.showList, true);
440+ tryCompare(dashDepartments.currentDepartment, "departmentId", "middle2");
441+ tryCompare(departmentListView.currentItem.department, "departmentId", "middle2");
442+
443+ var departmentList1 = findChild(dashDepartments, "department1");
444+ allButton = findChild(departmentList1, "allButton");
445+ var backButton = findChild(findChild(departmentList1, "department1"), "backButton");
446+ compare(allButton.visible, true);
447+ compare(backButton.visible, true);
448+
449+ mouseClick(allButton, 0, 0);
450+ compare(dashDepartments.showList, false);
451+ tryCompare(dashDepartments.currentDepartment, "departmentId", "middle2");
452+ tryCompare(departmentListView.currentItem.department, "departmentId", "middle2");
453+
454+ mouseClick(dashDepartments, 0, 0);
455+ compare(dashDepartments.showList, true);
456+ waitForRendering(departmentListView);
457+ waitForRendering(departmentListView.currentItem);
458+ compare(allButton.visible, true);
459+ compare(backButton.visible, true);
460+
461+ tryCompare(departmentList1.department, "loaded", true);
462+ department = findChild(dashDepartments, "department1child2");
463+ mouseClick(department, 0, 0);
464+ compare(dashDepartments.showList, false);
465+ tryCompare(dashDepartments.currentDepartment, "departmentId", "childmiddle22");
466+ tryCompare(departmentListView.currentItem.department, "departmentId", "middle2");
467+
468+ mouseClick(dashDepartments, 0, 0);
469+ compare(dashDepartments.showList, true);
470+ waitForRendering(departmentListView);
471+ waitForRendering(departmentListView.currentItem);
472+
473+ tryCompare(departmentList1.department, "loaded", true);
474+ department = findChild(dashDepartments, "department1child3");
475+ mouseClick(department, 0, 0);
476+ compare(dashDepartments.showList, false);
477+ tryCompare(dashDepartments.currentDepartment, "departmentId", "childmiddle23");
478+ tryCompare(departmentListView.currentItem.department, "departmentId", "middle2");
479+
480+ mouseClick(dashDepartments, 0, 0);
481+ compare(dashDepartments.showList, true);
482+ waitForRendering(departmentListView);
483+ waitForRendering(departmentListView.currentItem);
484+ mouseClick(backButton, 0, 0);
485+
486+ tryCompare(dashDepartments.currentDepartment, "departmentId", "root");
487+ tryCompare(departmentListView.currentItem.department, "departmentId", "root");
488+ compare(dashDepartments.showList, true);
489+ mouseClick(dashDepartments, 0, 0);
490+ compare(dashDepartments.showList, false);
491+ }
395492 }
396493}