on xenial help sign in
Fix tests
5671037Michael Terry
qml/Greeter/GreeterPrompt.qml+13−9
@@ -33,18 +33,19 @@ FocusScope {
33 function reset() {
33 function reset() {
34 passwordInput.text = "";
34 passwordInput.text = "";
35 focus = false;
35 focus = false;
36− enabled = true;
36+ d.enabled = true;
37 }
37 }
38
38
39 StyledItem {
39 StyledItem {
40 id: d
40 id: d
41
41
42+ property bool enabled: true
42− property color color: root.enabled ? theme.palette.normal.backgroundText
43+ readonly property color color: root.enabled ? theme.palette.normal.backgroundText
43− : theme.palette.disabled.backgroundText
44+ : theme.palette.disabled.backgroundText
44− property color inverseColor: root.enabled ? theme.palette.normal.background
45+ readonly property color inverseColor: root.enabled ? theme.palette.normal.background
45− : theme.palette.disabled.background
46+ : theme.palette.disabled.background
46− property color errorColor: root.enabled ? theme.palette.normal.negative
47+ readonly property color errorColor: root.enabled ? theme.palette.normal.negative
47− : theme.palette.disabled.negative
48+ : theme.palette.disabled.negative
48 }
49 }
49
50
50 Rectangle {
51 Rectangle {
@@ -58,6 +59,7 @@ FocusScope {
58 AbstractButton {
59 AbstractButton {
59 anchors.fill: parent
60 anchors.fill: parent
60 visible: !root.isPrompt
61 visible: !root.isPrompt
62+ enabled: d.enabled
61
63
62 onClicked: root.clicked()
64 onClicked: root.clicked()
63
65
@@ -70,8 +72,10 @@ FocusScope {
70
72
71 TextField {
73 TextField {
72 id: passwordInput
74 id: passwordInput
75+ objectName: "promptField"
73 anchors.fill: parent
76 anchors.fill: parent
74 visible: root.isPrompt
77 visible: root.isPrompt
78+ enabled: d.enabled
75
79
76 inputMethodHints: root.isAlphanumeric ? Qt.ImhNone : Qt.ImhDigitsOnly
80 inputMethodHints: root.isAlphanumeric ? Qt.ImhNone : Qt.ImhDigitsOnly
77 echoMode: root.isSecret ? TextInput.Password : TextInput.Normal
81 echoMode: root.isSecret ? TextInput.Password : TextInput.Normal
@@ -111,10 +115,10 @@ FocusScope {
111 }
115 }
112
116
113 onAccepted: {
117 onAccepted: {
114− if (!root.enabled)
118+ if (!enabled)
115 return;
119 return;
116 root.focus = true; // so that it can handle Escape presses for us
120 root.focus = true; // so that it can handle Escape presses for us
117− root.enabled = false;
121+ d.enabled = false;
118 root.responded(text);
122 root.responded(text);
119 }
123 }
120
124
tests/qmltests/Greeter/tst_WideView.qml+16−25
@@ -394,8 +394,8 @@ StyledItem {
394 view.locked = true;
394 view.locked = true;
395 view.showPrompt("Prompt", true, true);
395 view.showPrompt("Prompt", true, true);
396 var passwordInput = findChild(view, "passwordInput");
396 var passwordInput = findChild(view, "passwordInput");
397− compare(passwordInput.placeholderText, "Prompt");
397+ compare(passwordInput.text, "Prompt");
398− compare(passwordInput.echoMode, TextInput.Password);
398+ verify(passwordInput.isSecret);
399 tap(passwordInput);
399 tap(passwordInput);
400 typeString("password");
400 typeString("password");
401 keyClick(Qt.Key_Enter);
401 keyClick(Qt.Key_Enter);
@@ -407,8 +407,8 @@ StyledItem {
407 view.locked = true;
407 view.locked = true;
408 view.showPrompt("otp", false, false);
408 view.showPrompt("otp", false, false);
409 var passwordInput = findChild(view, "passwordInput");
409 var passwordInput = findChild(view, "passwordInput");
410− compare(passwordInput.placeholderText, "otp");
410+ compare(passwordInput.text, "otp");
411− compare(passwordInput.echoMode, TextInput.Normal);
411+ verify(!passwordInput.isSecret);
412 tap(passwordInput);
412 tap(passwordInput);
413 typeString("foo");
413 typeString("foo");
414 keyClick(Qt.Key_Enter);
414 keyClick(Qt.Key_Enter);
@@ -441,7 +441,6 @@ StyledItem {
441 var infoLabel = findChild(view, "infoLabel");
441 var infoLabel = findChild(view, "infoLabel");
442 compare(infoLabel.text, "Welcome to Unity Greeter<br><font color=\"#df382c\">This is an error</font><br>You should have seen three messages and this is a really long message too. wow so long much length");
442 compare(infoLabel.text, "Welcome to Unity Greeter<br><font color=\"#df382c\">This is an error</font><br>You should have seen three messages and this is a really long message too. wow so long much length");
443 compare(infoLabel.textFormat, Text.StyledText);
443 compare(infoLabel.textFormat, Text.StyledText);
444− compare(infoLabel.clip, true);
445 verify(infoLabel.contentWidth > infoLabel.width);
444 verify(infoLabel.contentWidth > infoLabel.width);
446 verify(infoLabel.opacity < 1);
445 verify(infoLabel.opacity < 1);
447 tryCompare(infoLabel, "opacity", 1);
446 tryCompare(infoLabel, "opacity", 1);
@@ -453,15 +452,15 @@ StyledItem {
453 selectedSpy.clear();
452 selectedSpy.clear();
454 view.locked = true;
453 view.locked = true;
455 view.showPrompt("Prompt", true, true);
454 view.showPrompt("Prompt", true, true);
456− var passwordInput = findChild(view, "passwordInput");
455+ var promptField = findChild(view, "promptField");
457− tap(passwordInput);
456+ tap(promptField);
458− compare(passwordInput.focus, true);
457+ compare(promptField.focus, true);
459− compare(passwordInput.enabled, true);
458+ compare(promptField.enabled, true);
460
459
461 typeString("password");
460 typeString("password");
462 keyClick(Qt.Key_Enter);
461 keyClick(Qt.Key_Enter);
463− compare(passwordInput.focus, false);
462+ compare(promptField.focus, true);
464− compare(passwordInput.enabled, false);
463+ compare(promptField.enabled, false);
465
464
466 compare(selectedSpy.count, 0);
465 compare(selectedSpy.count, 0);
467 keyClick(Qt.Key_Escape);
466 keyClick(Qt.Key_Escape);
@@ -469,8 +468,8 @@ StyledItem {
469 compare(selectedSpy.signalArguments[0][0], 1);
468 compare(selectedSpy.signalArguments[0][0], 1);
470
469
471 view.reset();
470 view.reset();
472− compare(passwordInput.focus, false);
471+ compare(promptField.focus, false);
473− compare(passwordInput.enabled, true);
472+ compare(promptField.enabled, true);
474 }
473 }
475
474
476 function test_unicode() {
475 function test_unicode() {
@@ -479,17 +478,11 @@ StyledItem {
479 tryCompare(label, "text", "가나다라마");
478 tryCompare(label, "text", "가나다라마");
480 }
479 }
481
480
482− function test_longName() {
483− var index = selectUser("long-name");
484− var label = findChild(view, "username" + index);
485− tryCompare(label, "truncated", true);
486− }
487−
488 function test_promptless() {
481 function test_promptless() {
489 var passwordInput = findChild(view, "passwordInput");
482 var passwordInput = findChild(view, "passwordInput");
490
483
491 view.locked = true;
484 view.locked = true;
492− compare(passwordInput.placeholderText, "Retry");
485+ compare(passwordInput.text, "Retry");
493 tap(passwordInput);
486 tap(passwordInput);
494 compare(respondedSpy.count, 0);
487 compare(respondedSpy.count, 0);
495 compare(selectedSpy.count, 1);
488 compare(selectedSpy.count, 1);
@@ -497,7 +490,7 @@ StyledItem {
497 selectedSpy.clear();
490 selectedSpy.clear();
498
491
499 view.locked = false;
492 view.locked = false;
500− compare(passwordInput.placeholderText, "Tap to unlock");
493+ compare(passwordInput.text, "Log In");
501 tap(passwordInput);
494 tap(passwordInput);
502 compare(selectedSpy.count, 0);
495 compare(selectedSpy.count, 0);
503 compare(respondedSpy.count, 1);
496 compare(respondedSpy.count, 1);
@@ -529,11 +522,9 @@ StyledItem {
529 var passwordInput = findChild(view, "passwordInput");
522 var passwordInput = findChild(view, "passwordInput");
530
523
531 verify(view.alphanumeric);
524 verify(view.alphanumeric);
532− compare(passwordInput.inputMethodHints, Qt.ImhNone);
525+ verify(passwordInput.isAlphanumeric);
533 view.alphanumeric = false;
526 view.alphanumeric = false;
534− compare(passwordInput.inputMethodHints, Qt.ImhDigitsOnly);
527+ verify(!passwordInput.isAlphanumeric);
535− view.alphanumeric = true;
536− compare(passwordInput.inputMethodHints, Qt.ImhNone);
537 }
528 }
538 }
529 }
539}
530}