on xenial help sign in
A test for departments
8d1fce8Albert Astals
qml/Dash/DashDepartments.qml+3
@@ -19,6 +19,7 @@ import Ubuntu.Components 0.1
19
19
20AbstractButton {
20AbstractButton {
21 id: root
21 id: root
22+ objectName: "dashDepartments"
22
23
23 property int windowHeight: 0
24 property int windowHeight: 0
24
25
@@ -91,6 +92,7 @@ AbstractButton {
91 // departmentListView is outside root
92 // departmentListView is outside root
92 ListView {
93 ListView {
93 id: departmentListView
94 id: departmentListView
95+ objectName: "departmentListView"
94 orientation: ListView.Horizontal
96 orientation: ListView.Horizontal
95 interactive: false
97 interactive: false
96 model: ListModel {
98 model: ListModel {
@@ -107,6 +109,7 @@ AbstractButton {
107 onHeightChanged: prevHeight = height;
109 onHeightChanged: prevHeight = height;
108 anchors.top: root.bottom
110 anchors.top: root.bottom
109 delegate: DashDepartmentsList {
111 delegate: DashDepartmentsList {
112+ objectName: "department" + index
110 visible: height != 0
113 visible: height != 0
111 width: departmentListView.width
114 width: departmentListView.width
112 height: !root.showList ? 0 : department && department.loaded ? Math.min(implicitHeight, departmentListView.maxHeight) : departmentListView.prevHeight
115 height: !root.showList ? 0 : department && department.loaded ? Math.min(implicitHeight, departmentListView.maxHeight) : departmentListView.prevHeight
qml/Dash/DashDepartmentsList.qml+3
@@ -59,6 +59,7 @@ Item {
59
59
60 AbstractButton {
60 AbstractButton {
61 id: backButton
61 id: backButton
62+ objectName: "backButton"
62 width: parent.width
63 width: parent.width
63 visible: department && !department.isRoot
64 visible: department && !department.isRoot
64 height: visible ? itemHeight : 0
65 height: visible ? itemHeight : 0
@@ -97,6 +98,7 @@ Item {
97
98
98 AbstractButton {
99 AbstractButton {
99 id: allButton
100 id: allButton
101+ objectName: "allButton"
100 anchors.top: backButton.bottom
102 anchors.top: backButton.bottom
101 width: parent.width
103 width: parent.width
102 visible: department && (!department.isRoot || (root.currentDepartment && !root.currentDepartment.isRoot && root.currentDepartment.parentId == department.departmentId))
104 visible: department && (!department.isRoot || (root.currentDepartment && !root.currentDepartment.isRoot && root.currentDepartment.parentId == department.departmentId))
@@ -129,6 +131,7 @@ Item {
129 model: department && department.loaded ? department : null
131 model: department && department.loaded ? department : null
130 clip: true
132 clip: true
131 delegate: AbstractButton {
133 delegate: AbstractButton {
134+ objectName: root.objectName + "child" + index
132 height: root.itemHeight
135 height: root.itemHeight
133 width: root.width
136 width: root.width
134 y: (flickable.nTopButtonsVisible + index) * root.itemHeight
137 y: (flickable.nTopButtonsVisible + index) * root.itemHeight
tests/qmltests/Dash/tst_DashContent.qml+97
@@ -392,5 +392,102 @@ Item {
392 }
392 }
393 closePreview();
393 closePreview();
394 }
394 }
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+ }
395 }
492 }
396}
493}