~dandrader/unity8/childWindows

« back to all changes in this revision

Viewing changes to tests/qmltests/Greeter/tst_WideView.qml

  • Committer: Bileto Bot
  • Author(s): Michael Terry
  • Date: 2017-01-24 07:39:14 UTC
  • mfrom: (2743.4.8 simple-lightdm-mock)
  • Revision ID: ci-train-bot@canonical.com-20170124073914-imw1y4dae2ivqqtb
Simplify the lightdm mock to make future greeter improvements easier to test.

I simplified the mock liblightdm to avoid separate files for the Private classes. That can all go into the main files. The separation isn't worth wading through the files to find what you want.

And I dropped the mock LightDM plugin entirely. (opting instead for a tiny "mock()" API call on the real plugin that returns an object that can be used to manipulate our mock liblightdm, if we're in testing mode)

Approved by: Albert Astals Cid, Unity8 CI Bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import QtTest 1.0
19
19
import ".."
20
20
import "../../../qml/Greeter"
21
 
import LightDM.IntegratedLightDM 0.1 as LightDM
 
21
import LightDMController 0.1
 
22
import LightDM.FullLightDM 0.1 as LightDM
22
23
import Ubuntu.Components 1.3
23
24
import Unity.Test 0.1 as UT
24
25
 
31
32
 
32
33
    theme.name: "Ubuntu.Components.Themes.SuruDark"
33
34
 
34
 
    Binding {
35
 
        target: LightDM.Users
36
 
        property: "mockMode"
37
 
        value: "full"
38
 
    }
39
 
 
40
35
    Row {
41
36
        anchors.fill: parent
42
37
        Loader {
271
266
                        id: multipleSessionsCheckbox
272
267
                        onClicked: {
273
268
                            if (checked) {
274
 
                                LightDM.Sessions.testScenario = "multipleSessions"
 
269
                                LightDMController.sessionMode = "full";
275
270
                            } else {
276
 
                                LightDM.Sessions.testScenario = "singleSession"
 
271
                                LightDMController.sessionMode = "single";
277
272
                            }
278
273
                        }
279
274
                        Connections {
280
 
                            target: LightDM.Sessions
281
 
                            onTestScenarioChanged: {
282
 
                                if (LightDM.Sessions.testScenario === "multipleSessions") {
 
275
                            target: LightDMController
 
276
                            onSessionModeChanged: {
 
277
                                if (LightDMController.sessionMode === "full") {
283
278
                                    multipleSessionsCheckbox.checked = true;
284
279
                                } else {
285
280
                                    multipleSessionsCheckbox.checked = false;
297
292
 
298
293
                        width: units.gu(10)
299
294
                        minimumValue: 0
300
 
                        maximumValue: LightDM.Sessions.numAvailableSessions
301
 
                        value: LightDM.Sessions.numSessions
302
 
                        visible: LightDM.Sessions.testScenario === "multipleSessions"
 
295
                        maximumValue: LightDMController.numAvailableSessions
 
296
                        value: LightDMController.numSessions
 
297
                        visible: LightDMController.sessionMode === "full"
303
298
                        Binding {
304
 
                            target: LightDM.Sessions
 
299
                            target: LightDMController
305
300
                            property: "numSessions"
306
301
                            value: numSessionsSlider.value
307
302
                        }
368
363
            respondedSpy.clear();
369
364
            teaseSpy.clear();
370
365
            emergencySpy.clear();
371
 
            LightDM.Sessions.testScenario = "multipleSessions"
 
366
            LightDMController.sessionMode = "full";
 
367
            LightDM.Sessions.iconSearchDirectories = [testIconDirectory];
372
368
        }
373
369
 
374
370
        function cleanup() {
426
422
        }
427
423
 
428
424
        function test_sessionIconsAreValid() {
429
 
            LightDM.Sessions.testScenario = "multipleSessions"
430
 
            var originalDirectories = LightDM.Sessions.iconSearchDirectories
431
 
            LightDM.Sessions.iconSearchDirectories = [testIconDirectory]
432
 
 
433
425
            selectUser("has-password");
434
426
 
435
427
            // Test the login list icon is valid
449
441
 
450
442
        function test_choosingNewSessionChangesLoginListIcon() {
451
443
            // Ensure the default session is selected (Ubuntu)
452
 
            loader.active = false;
453
 
            loader.active = true;
 
444
            cleanup();
454
445
 
455
446
            selectUser("has-password");
456
447
 
457
 
            LightDM.Sessions.testScenario = "multipleSessions";
458
448
            var sessionChooserButton = findChild(view, "sessionChooserButton");
459
449
            var icon = String(sessionChooserButton.icon);
460
450
            compare(icon.indexOf("ubuntu") > -1, true);
465
455
                var currentDelegate = findChild(view, delegateName);
466
456
                var sessionKey = LightDM.Sessions.data(i,LightDM.SessionRoles.KeyRole);
467
457
                if (sessionKey === "gnome-classic") {
 
458
                    waitForRendering(currentDelegate);
468
459
                    tap(currentDelegate);
469
 
                    var sessionChooserButton = findChild(view, "sessionChooserButton");
470
460
                    waitForRendering(sessionChooserButton);
471
 
                    var icon = String(sessionChooserButton.icon);
472
461
                    break;
473
462
                }
474
463
            }
475
464
 
 
465
            icon = String(sessionChooserButton.icon);
476
466
            compare(icon.indexOf("gnome") > -1, true,
477
467
                "Expected icon to contain gnome but it was " + icon);
478
468
        }
479
469
 
480
470
        function test_noSessionsDoesntBreakView() {
481
 
            LightDM.Sessions.testScenario = "noSessions"
 
471
            LightDMController.sessionMode = "none";
482
472
            compare(LightDM.Sessions.count, 0)
483
473
        }
484
474
 
485
475
        function test_sessionIconNotShownWithOneSession() {
486
 
            LightDM.Sessions.testScenario = "singleSession"
 
476
            LightDMController.sessionMode = "single";
487
477
            compare(LightDM.Sessions.count, 1);
488
478
 
489
479
            var sessionChooserButton = findChild(view, "sessionChooserButton");
491
481
        }
492
482
 
493
483
        function test_sessionIconNotShownWithActiveUser() {
494
 
            LightDM.Sessions.testScenario = "multipleSessions";
 
484
            LightDMController.sessionMode = "full";
495
485
            compare(LightDM.Sessions.count > 1, true);
496
486
 
497
487
            selectUser("active");
501
491
        }
502
492
 
503
493
        function test_sessionIconShownWithMultipleSessions() {
504
 
            LightDM.Sessions.testScenario = "multipleSessions"
 
494
            LightDMController.sessionMode = "full";
505
495
            compare(LightDM.Sessions.count > 1, true);
506
496
 
507
497
            selectUser("has-password");