@@ -24,6 +24,7 @@ import Unity.Test 0.1 as UT
25StyledItem {
25StyledItem {
27 width: units.gu(120)
28 width: units.gu(120)
28 height: units.gu(80)
29 height: units.gu(80)
29 focus: true
30 focus: true
@@ -111,11 +112,9 @@ StyledItem {
111 color: theme.palette.normal.background
112 color: theme.palette.normal.background
112 width: units.gu(40)
113 width: units.gu(40)
113 height: parent.height
114 height: parent.height
116 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
116 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
117 spacing: units.gu(1)
117 spacing: units.gu(1)
121 text: "Show Last Chance"
120 text: "Show Last Chance"
@@ -266,6 +265,51 @@ StyledItem {
266 text: "emergency: " + emergencySpy.count
265 text: "emergency: " + emergencySpy.count
269+ id: multipleSessions
271+ id: multipleSessionsCheckbox
274+ LightDM.Sessions.testScenario = "multipleSessions"
276+ LightDM.Sessions.testScenario = "singleSession"
280+ target: LightDM.Sessions
281+ onTestScenarioChanged: {
282+ if (LightDM.Sessions.testScenario === "multipleSessions") {
283+ multipleSessionsCheckbox.checked = true;
285+ multipleSessionsCheckbox.checked = false;
291+ text: "Multiple Sessions"
296+ id: numSessionsSlider
300+ maximumValue: LightDM.Sessions.numAvailableSessions
301+ value: LightDM.Sessions.numSessions
302+ visible: LightDM.Sessions.testScenario === "multipleSessions"
304+ target: LightDM.Sessions
305+ property: "numSessions"
306+ value: numSessionsSlider.value
310+ text: "Available Sessions"
271 text: "Reload View"
315 text: "Reload View"
@@ -316,6 +360,7 @@ StyledItem {
316 when: windowShown
360 when: windowShown
318 property Item view: loader.status === Loader.Ready ? loader.item : null
362 property Item view: loader.status === Loader.Ready ? loader.item : null
363+ property url testIconDirectory: Qt.resolvedUrl("../../../qml/Greeter/graphics/session_icons")
320 function init() {
365 function init() {
321 selectIndex(0); // break binding with text field
366 selectIndex(0); // break binding with text field
@@ -323,6 +368,7 @@ StyledItem {
323 respondedSpy.clear();
368 respondedSpy.clear();
324 teaseSpy.clear();
369 teaseSpy.clear();
325 emergencySpy.clear();
370 emergencySpy.clear();
371+ LightDM.Sessions.testScenario = "multipleSessions"
328 function cleanup() {
374 function cleanup() {
@@ -378,6 +424,76 @@ StyledItem {
378 {tag: "right", x: view.width, offset: 0, count: 1, locked: false},
424 {tag: "right", x: view.width, offset: 0, count: 1, locked: false},
428+ function test_sessionIconsAreValid() {
429+ LightDM.Sessions.testScenario = "multipleSessions"
430+ var originalDirectories = LightDM.Sessions.iconSearchDirectories
431+ LightDM.Sessions.iconSearchDirectories = [testIconDirectory]
433+ // Test the login list icon is valid
434+ var sessionChooserButton = findChild(view, "sessionChooserButton");
435+ compare(sessionChooserButton.visible, true);
437+ var session = String(view.sessionToStart).toLowerCase();
438+ var icon = String(sessionChooserButton.icon);
439+ compare(icon.indexOf(session) > -1, true);
441+ // Test the session list icons are valid
442+ var coverPage = findChild(view, "coverPage");
443+ coverPage.state = "SessionsList"
444+ var sessionsList = findChild(view, "sessionsList");
445+ tryCompare(sessionsList, "visible", true);
448+ function test_choosingNewSessionChangesLoginListIcon() {
449+ // Ensure the default session is selected (Ubuntu)
450+ loader.active = false;
451+ loader.active = true;
453+ LightDM.Sessions.testScenario = "multipleSessions";
454+ var sessionChooserButton = findChild(view, "sessionChooserButton");
455+ var icon = String(sessionChooserButton.icon);
456+ compare(icon.indexOf("ubuntu") > -1, true);
458+ tap(sessionChooserButton)
459+ for(var i = 0; i < LightDM.Sessions.count; i++) {
460+ var delegateName = "sessionDelegate" + String(i);
461+ var currentDelegate = findChild(view, delegateName);
462+ var sessionKey = LightDM.Sessions.data(i,LightDM.SessionRoles.KeyRole);
463+ if (sessionKey === "gnome-classic") {
464+ tap(currentDelegate);
465+ var sessionChooserButton = findChild(view, "sessionChooserButton");
466+ waitForRendering(sessionChooserButton);
467+ var icon = String(sessionChooserButton.icon);
472+ compare(icon.indexOf("gnome") > -1, true,
473+ "Expected icon to contain gnome but it was " + icon);
476+ function test_noSessionsDoesntBreakView() {
477+ LightDM.Sessions.testScenario = "noSessions"
478+ compare(LightDM.Sessions.count, 0)
481+ function test_sessionIconNotShownWithOneSession() {
482+ LightDM.Sessions.testScenario = "singleSession"
483+ compare(LightDM.Sessions.count, 1);
485+ var sessionChooserButton = findChild(view, "sessionChooserButton");
486+ tryCompare(sessionChooserButton, "visible", false);
489+ function test_sessionIconShownWithMultipleSessions() {
490+ LightDM.Sessions.testScenario = "multipleSessions"
491+ compare(LightDM.Sessions.count > 1, true);
493+ var sessionChooserButton = findChild(view, "sessionChooserButton");
494+ tryCompare(sessionChooserButton, "visible", true);
381 function test_tease(data) {
497 function test_tease(data) {
382 view.locked = data.locked;
498 view.locked = data.locked;
383 view.dragHandleLeftMargin = data.offset;
499 view.dragHandleLeftMargin = data.offset;