on xenial help sign in
Fix tests
commit5671037a60f04bf7be0702447a44a71636e879af authorMichael Terry <michael.terry@canonical.com> dateThu 19 May 2016, 16:23 (10 years ago) parent0e2758d
2 files changed+29−34
qml/Greeter/GreeterPrompt.qml+13−9 tests/qmltests/Greeter/tst_WideView.qml+16−25
qml/Greeter/GreeterPrompt.qml+13−9
@@ -33,18 +33,19 @@ FocusScope {
3333 function reset() {
3434 passwordInput.text = "";
3535 focus = false;
36− enabled = true;
36+ d.enabled = true;
3737 }
3838
3939 StyledItem {
4040 id: d
4141
42− property color color: root.enabled ? theme.palette.normal.backgroundText
43− : theme.palette.disabled.backgroundText
44− property color inverseColor: root.enabled ? theme.palette.normal.background
45− : theme.palette.disabled.background
46− property color errorColor: root.enabled ? theme.palette.normal.negative
47− : theme.palette.disabled.negative
42+ property bool enabled: true
43+ readonly property color color: root.enabled ? theme.palette.normal.backgroundText
44+ : theme.palette.disabled.backgroundText
45+ readonly property color inverseColor: root.enabled ? theme.palette.normal.background
46+ : theme.palette.disabled.background
47+ readonly property color errorColor: root.enabled ? theme.palette.normal.negative
48+ : theme.palette.disabled.negative
4849 }
4950
5051 Rectangle {
@@ -58,6 +59,7 @@ FocusScope {
5859 AbstractButton {
5960 anchors.fill: parent
6061 visible: !root.isPrompt
62+ enabled: d.enabled
6163
6264 onClicked: root.clicked()
6365
@@ -70,8 +72,10 @@ FocusScope {
7072
7173 TextField {
7274 id: passwordInput
75+ objectName: "promptField"
7376 anchors.fill: parent
7477 visible: root.isPrompt
78+ enabled: d.enabled
7579
7680 inputMethodHints: root.isAlphanumeric ? Qt.ImhNone : Qt.ImhDigitsOnly
7781 echoMode: root.isSecret ? TextInput.Password : TextInput.Normal
@@ -111,10 +115,10 @@ FocusScope {
111115 }
112116
113117 onAccepted: {
114− if (!root.enabled)
118+ if (!enabled)
115119 return;
116120 root.focus = true; // so that it can handle Escape presses for us
117− root.enabled = false;
121+ d.enabled = false;
118122 root.responded(text);
119123 }
120124
tests/qmltests/Greeter/tst_WideView.qml+16−25
@@ -394,8 +394,8 @@ StyledItem {
394394 view.locked = true;
395395 view.showPrompt("Prompt", true, true);
396396 var passwordInput = findChild(view, "passwordInput");
397− compare(passwordInput.placeholderText, "Prompt");
398− compare(passwordInput.echoMode, TextInput.Password);
397+ compare(passwordInput.text, "Prompt");
398+ verify(passwordInput.isSecret);
399399 tap(passwordInput);
400400 typeString("password");
401401 keyClick(Qt.Key_Enter);
@@ -407,8 +407,8 @@ StyledItem {
407407 view.locked = true;
408408 view.showPrompt("otp", false, false);
409409 var passwordInput = findChild(view, "passwordInput");
410− compare(passwordInput.placeholderText, "otp");
411− compare(passwordInput.echoMode, TextInput.Normal);
410+ compare(passwordInput.text, "otp");
411+ verify(!passwordInput.isSecret);
412412 tap(passwordInput);
413413 typeString("foo");
414414 keyClick(Qt.Key_Enter);
@@ -441,7 +441,6 @@ StyledItem {
441441 var infoLabel = findChild(view, "infoLabel");
442442 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");
443443 compare(infoLabel.textFormat, Text.StyledText);
444− compare(infoLabel.clip, true);
445444 verify(infoLabel.contentWidth > infoLabel.width);
446445 verify(infoLabel.opacity < 1);
447446 tryCompare(infoLabel, "opacity", 1);
@@ -453,15 +452,15 @@ StyledItem {
453452 selectedSpy.clear();
454453 view.locked = true;
455454 view.showPrompt("Prompt", true, true);
456− var passwordInput = findChild(view, "passwordInput");
457− tap(passwordInput);
458− compare(passwordInput.focus, true);
459− compare(passwordInput.enabled, true);
455+ var promptField = findChild(view, "promptField");
456+ tap(promptField);
457+ compare(promptField.focus, true);
458+ compare(promptField.enabled, true);
460459
461460 typeString("password");
462461 keyClick(Qt.Key_Enter);
463− compare(passwordInput.focus, false);
464− compare(passwordInput.enabled, false);
462+ compare(promptField.focus, true);
463+ compare(promptField.enabled, false);
465464
466465 compare(selectedSpy.count, 0);
467466 keyClick(Qt.Key_Escape);
@@ -469,8 +468,8 @@ StyledItem {
469468 compare(selectedSpy.signalArguments[0][0], 1);
470469
471470 view.reset();
472− compare(passwordInput.focus, false);
473− compare(passwordInput.enabled, true);
471+ compare(promptField.focus, false);
472+ compare(promptField.enabled, true);
474473 }
475474
476475 function test_unicode() {
@@ -479,17 +478,11 @@ StyledItem {
479478 tryCompare(label, "text", "가나다라마");
480479 }
481480
482− function test_longName() {
483− var index = selectUser("long-name");
484− var label = findChild(view, "username" + index);
485− tryCompare(label, "truncated", true);
486− }
487−
488481 function test_promptless() {
489482 var passwordInput = findChild(view, "passwordInput");
490483
491484 view.locked = true;
492− compare(passwordInput.placeholderText, "Retry");
485+ compare(passwordInput.text, "Retry");
493486 tap(passwordInput);
494487 compare(respondedSpy.count, 0);
495488 compare(selectedSpy.count, 1);
@@ -497,7 +490,7 @@ StyledItem {
497490 selectedSpy.clear();
498491
499492 view.locked = false;
500− compare(passwordInput.placeholderText, "Tap to unlock");
493+ compare(passwordInput.text, "Log In");
501494 tap(passwordInput);
502495 compare(selectedSpy.count, 0);
503496 compare(respondedSpy.count, 1);
@@ -529,11 +522,9 @@ StyledItem {
529522 var passwordInput = findChild(view, "passwordInput");
530523
531524 verify(view.alphanumeric);
532− compare(passwordInput.inputMethodHints, Qt.ImhNone);
525+ verify(passwordInput.isAlphanumeric);
533526 view.alphanumeric = false;
534− compare(passwordInput.inputMethodHints, Qt.ImhDigitsOnly);
535− view.alphanumeric = true;
536− compare(passwordInput.inputMethodHints, Qt.ImhNone);
527+ verify(!passwordInput.isAlphanumeric);
537528 }
538529 }
539530}