Skip to content

Commit a31191c

Browse files
authored
Merge pull request #49 from greygoo/cenity_handle_labels
Add cenity functionality to handle ok-label and cancel-label
2 parents ac5815b + fb96484 commit a31191c

12 files changed

+179
-27
lines changed

tests/cenity/d_function_test

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ cenity="../../usr/lib/tik/lib/cenity"
22
. $cenity
33

44
compare() {
5-
diff -y <(echo "$1") <(echo "$2") || RESULT=$((RESULT+1))
5+
if [ "$mode" = "output" ]; then
6+
echo "$1"
7+
elif [ "$mode" = "sidebyside" ]; then
8+
diff -y <(echo "$1") <(echo "$2") || RESULT=$((RESULT+1))
9+
else
10+
diff <(echo "$1") <(echo "$2") || RESULT=$((RESULT+1))
11+
fi
612
}
713

814
string_test() {
@@ -16,7 +22,7 @@ string_test() {
1622
echo "$i found - passed"
1723
else
1824
echo "$i not found - failed"
19-
RESULT=1
25+
RESULT=$((RESULT+1))
2026
fi
2127
done
2228
}
File renamed without changes.

tests/cenity/manual_progress.sh

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/sh
2+
3+
cenity="../../usr/lib/tik/lib/cenity"
4+
. $cenity
5+
6+
RESULT=1
7+
8+
z_result="$((
9+
echo "10" ; sleep 1
10+
echo "# Updating mail logs" ; sleep 1
11+
echo "20" ; sleep 1
12+
echo "# Resetting cron jobs" ; sleep 1
13+
echo "50" ; sleep 1
14+
echo "This line will just be ignored" ; sleep 1
15+
echo "75" ; sleep 1
16+
echo "# Rebooting system" ; sleep 1
17+
echo "100" ; sleep 1
18+
) |
19+
zenity --progress --title="Update System Logs" \
20+
--text="Scanning mail logs..." --percentage=0)" ; z_retval=$?
21+
22+
(
23+
echo "10" ; sleep 1
24+
echo "# Updating mail logs" ; sleep 1
25+
echo "20" ; sleep 1
26+
echo "# Resetting cron jobs" ; sleep 1
27+
echo "50" ; sleep 1
28+
echo "This line will just be ignored" ; sleep 1
29+
echo "75" ; sleep 1
30+
echo "# Rebooting system" ; sleep 1
31+
echo "100" ; sleep 1
32+
) |
33+
cenity c_result --progress --title="Update System Logs" \
34+
--text="Scanning mail logs..." --percentage=0 ; c_retval=$?
35+
36+
37+
echo "[cenity][${c_retval}][${c_result}]"
38+
echo "[zenity][${z_retval}][${z_result}]"
39+
40+
RESULT=1
41+
42+
z_result="$((
43+
echo "# Updating mail logs" ; sleep 1
44+
echo "# Resetting cron jobs" ; sleep 1
45+
echo "This line will just be ignored" ; sleep 1
46+
echo "# Rebooting system" ; sleep 1
47+
) |
48+
zenity --progress --title="Update System Logs" \
49+
--pulsate --auto-close --no-cancel)" ; z_retval=$?
50+
51+
(
52+
echo "# Updating mail logs" ; sleep 1
53+
echo "# Resetting cron jobs" ; sleep 1
54+
echo "This line will just be ignored" ; sleep 1
55+
echo "# Rebooting system" ; sleep 1
56+
) |
57+
cenity c_result --progress --title="Update System Logs" \
58+
--pulsate --auto-close --no-cancel ; c_retval=$?
59+
60+
61+
echo "[cenity][${c_retval}][${c_result}]"
62+
echo "[zenity][${z_retval}][${z_result}]"
63+
64+
65+
66+
if [[ ${c_retval} = ${z_retval} ]] && [[ ${c_result} = ${z_result} ]]; then
67+
RESULT=0
68+
fi
69+
70+
echo "Result: $RESULT"
71+

tests/cenity/run_tests.sh

+22-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,30 @@
33
PASSED=0
44
FAILED=0
55

6+
mode=diff
7+
8+
for p in "$@"; do
9+
case "$p" in
10+
--mode*)
11+
mode=$(sed 's/^--mode=//' <<< $p)
12+
;;
13+
*)
14+
echo "Unknown parameter"
15+
exit 1
16+
;;
17+
esac
18+
done
19+
20+
if ! [[ "$mode" =~ ^(diff|output|sidebyside)$ ]]; then
21+
echo "Unknown mode: $mode"
22+
exit 1
23+
fi
24+
625
for test in tik_*; do
726
RESULT=0
8-
echo "Running: ${test}"
9-
./${test} || RESULT=1
27+
echo
28+
echo "############## Running: ${test} ##############"
29+
mode="$mode" ./${test} || RESULT=1
1030
echo "Test result for ${test}: $RESULT"
1131
if [ $RESULT == 1 ]; then
1232
FAILED=$((FAILED+1))

tests/cenity/tik_entry.sh

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ RESULT=0
77
#######################################
88
asserted_output="$(echo -e '--ENTRY----- This is a ENTRY ----------------
99
10+
Press CTRL+C to cancel
1011
[cenity][][Test entry] --entry --text=This is a entry text --title=This is a ENTRY')"
1112
output="$(c_test --entry --text="This is a entry text" --title="This is a ENTRY" <<< "Test entry" 2>&1)"
1213
compare "$output" "$asserted_output"

tests/cenity/tik_error.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ It can be found on the IGNITION partition on this USB Stick
1414
1515
\033[1mSystem is shutting down\033[0m
1616
17-
Press key to continue
17+
Press CTRL+C to cancel
18+
Press any key to continue
1819
[cenity][][] --error --no-wrap --title=Installation Failed --text=Please file a bug report at <tt>TEST URL</tt>\\n\\nPlease include the <tt>tik.log</tt> file\\nIt can be found on the IGNITION partition on this USB Stick\\n\\n<b>System is shutting down</b>')"
1920
output="$(c_test --error --no-wrap --title="Installation Failed" --text="Please file a bug report at <tt>TEST URL</tt>\n\nPlease include the <tt>tik.log</tt> file\nIt can be found on the IGNITION partition on this USB Stick\n\n<b>System is shutting down</b>" <<< "\n" 2>&1)"
2021
compare "$output" "$asserted_output"

tests/cenity/tik_info.sh

+22-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ asserted_output="$(echo -e '--INFO------ ----------------
1111
1212
Have a nice day!
1313
14-
Press key to continue
14+
Press CTRL+C to cancel
15+
Press any key to continue
1516
[cenity][][] --timeout 5 --info --no-wrap --text=<b>Test Succeeded:</b>\\n\\nHave a nice day!')"
1617
output="$(c_test --timeout 5 --info --no-wrap --text="<b>Test Succeeded:</b>\n\nHave a nice day!" <<< "\n" 2>&1)"
1718
compare "$output" "$asserted_output"
@@ -24,7 +25,8 @@ TIK_OS_NAME has been installed.
2425
2526
\033[1mSystem is rebooting\033[0m
2627
27-
Press key to continue
28+
Press CTRL+C to cancel
29+
Press any key to continue
2830
[cenity][][] --timeout 5 --info --no-wrap --title=Installation Complete! --text=TIK_OS_NAME has been installed.\\n\\n<b>System is rebooting</b>')"
2931
output="$(c_test --timeout 5 --info --no-wrap --title="Installation Complete!" --text="TIK_OS_NAME has been installed.\n\n<b>System is rebooting</b>" <<< "\n" 2>&1)"
3032
compare "$output" "$asserted_output"
@@ -51,7 +53,8 @@ You may optionally scan the recovery key off screen:
5153
5254
For more information please visit \033[1mhttps://aeondesktop.org/encrypt\033[0m
5355
54-
Press key to continue
56+
Press CTRL+C to cancel
57+
Press any key to continue
5558
[cenity][][] --width=500 --height=500 --no-wrap --warning --icon=security-high-symbolic --title=Encryption Recovery Key --text=You may optionally scan the recovery key off screen:\\n<span face='\''monospace'\''>
5659
5760
█▀▀▀▀▀█ ▀ █ █▀▀▀▀▀█
@@ -80,7 +83,8 @@ You will be prompted to set the Passphrase on the next screen
8083
8184
For more information please visit \033[1mhttps://aeondesktop.org/encrypt\033[0m
8285
83-
Press key to continue
86+
Press CTRL+C to cancel
87+
Press any key to continue
8488
[cenity][][] --width=500 --height=300 --no-wrap --warning --icon=security-high-symbolic --title=Set Encryption Passphrase --text=This system is encrypted and will require a Passphrase on every boot\\n\\nYou will be prompted to set the Passphrase on the next screen\\n\\nFor more information please visit <tt>https://aeondesktop.org/encrypt</tt>')"
8589
output="$(c_test --width=500 --height=300 --no-wrap --warning --icon=security-high-symbolic --title="Set Encryption Passphrase" --text="This ${TIK_OS_NAME} system is encrypted and will require a Passphrase on every boot\n\nYou will be prompted to set the Passphrase on the next screen\n\nFor more information please visit <tt>https://aeondesktop.org/encrypt</tt>" <<< "\n" 2>&1)"
8690
compare "$output" "$asserted_output"
@@ -97,14 +101,25 @@ We are sorry that you need to reinstall your system
97101
Thank you so much for your support.
98102
We hope you enjoy the new look openSUSE Aeon
99103
100-
Press key to continue
104+
Press CTRL+C to cancel
105+
Press any key to continue
101106
[cenity][][] --info --width=300 --height=300 --icon=distributor-logo-Aeon-symbolic --no-wrap --title=Message from the Aeon Team --text=We'\''d like to thank you for adopting openSUSE Aeon so early in it'\''s development,\\nbefore we fully understood what we were building or how we wanted it to look\\n\\nWe are sorry that you need to reinstall your system\\n\\nThank you so much for your support.\\nWe hope you enjoy the new look openSUSE Aeon')"
102107
output="$(c_test --info --width=300 --height=300 --icon=distributor-logo-Aeon-symbolic --no-wrap --title="Message from the Aeon Team" --text="We'd like to thank you for adopting openSUSE Aeon so early in it's development,\nbefore we fully understood what we were building or how we wanted it to look\n\nWe are sorry that you need to reinstall your system\n\nThank you so much for your support.\nWe hope you enjoy the new look openSUSE Aeon" <<< "\n" 2>&1)"
103108
compare "$output" "$asserted_output"
104109

105110

106-
# TODO: handle ok label
107-
#output=$(c_test --info --ok-label="Install Now" --no-wrap --width=300 --height=300 --icon=distributor-logo-Aeon-symbolic --title="" --text="<big>Welcome to ${TIK_OS_NAME}</big>\n\nPlease press <b>Install Now</b> to continue")
111+
#######################################
112+
asserted_output="$(echo -e '--INFO------ ----------------
113+
114+
\033[1mWelcome to \033[0m
115+
116+
Please press \033[1mInstall Now\033[0m to continue
117+
118+
Press CTRL+C to cancel
119+
Press any key to Install Now
120+
[cenity][][] --info --ok-label=Install Now --no-wrap --width=300 --height=300 --icon=distributor-logo-Aeon-symbolic --title= --text=<big>Welcome to </big>\\n\\nPlease press <b>Install Now</b> to continue')"
121+
output="$(c_test --info --ok-label="Install Now" --no-wrap --width=300 --height=300 --icon=distributor-logo-Aeon-symbolic --title="" --text="<big>Welcome to ${TIK_OS_NAME}</big>\n\nPlease press <b>Install Now</b> to continue" <<< "\n" 2>&1)"
122+
compare "$output" "$asserted_output"
108123

109124
tput sgr0
110125
check_result

tests/cenity/tik_list.sh

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ list_items=' virtio-0987654321 20G 3 unknown(2M),vfat(20M),btrfs(4.3G) virtio-te
88
#######################################
99
asserted_output="$(echo -e '--LIST------ Select A Disk ----------------
1010
11+
Press CTRL+C to cancel
1112
Select the disk to install the operating system to.
1213
1314
\033[1mMake sure any important documents and files have been backed up.\033[0m
@@ -26,6 +27,7 @@ compare "$output" "$asserted_output"
2627
#######################################
2728
asserted_output="$(echo -e '--LIST------ Select A Disk ----------------
2829
30+
Press CTRL+C to cancel
2931
Select the disk to install the operating system to.
3032
3133
\033[1mMake sure any important documents and files have been backed up.\033[0m
@@ -45,6 +47,7 @@ list_items='tik-osimage-Aeon.20240731.raw.xz 1501130408 tik-osimage-Aeon.test2.r
4547
#######################################
4648
asserted_output="$(echo -e '--LIST------ Select A Image ----------------
4749
50+
Press CTRL+C to cancel
4851
Select the operating system image to install.
4952
5053
Item Image Size
@@ -61,6 +64,7 @@ compare "$output" "$asserted_output"
6164
#######################################
6265
asserted_output="$(echo -e '--LIST------ Select A Image ----------------
6366
67+
Press CTRL+C to cancel
6468
Select the operating system image to install.
6569
6670
Item Image Size

tests/cenity/tik_password.sh

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ RESULT=0
77
#######################################
88
asserted_output="$(echo -e '--PASSWORD-- Set Encryption Passphrase ----------------
99
10+
Press CTRL+C to cancel
1011
[cenity][][test] --password --title=Set Encryption Passphrase')"
1112
output="$(c_test --password --title='Set Encryption Passphrase' <<< "test" 2>&1)"
1213
compare "$output" "$asserted_output"

tests/cenity/tik_question.sh

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ asserted_output="\
1010
1111
Do you really want to quit?
1212
13+
Press CTRL+C to cancel
1314
1) Yes
1415
2) No
1516
#? Selected: 1) yes
@@ -24,6 +25,7 @@ asserted_output="\
2425
2526
Do you really want to quit?
2627
28+
Press CTRL+C to cancel
2729
1) Yes
2830
2) No
2931
#? Selected: 2) No
@@ -39,6 +41,7 @@ asserted_output="\
3941
4042
These users will be restored to the new installation.
4143
44+
Press CTRL+C to cancel
4245
1) Yes
4346
2) No
4447
#? Selected: 1) yes
@@ -53,6 +56,7 @@ asserted_output="\
5356
5457
These users will be restored to the new installation.
5558
59+
Press CTRL+C to cancel
5660
1) Yes
5761
2) No
5862
#? Selected: 2) No

tests/cenity/tik_warning.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Runnning on battery power detected
1212
1313
It is recommended to connect the system to AC power during the install
1414
15-
Press key to continue
15+
Press CTRL+C to cancel
16+
Press any key to continue
1617
[cenity][][] --warning --no-wrap --title=AC Power Recommended --text=Runnning on battery power detected\n\nIt is recommended to connect the system to AC power during the install"
1718
output=$(c_test --warning --no-wrap --title="AC Power Recommended" --text="Runnning on battery power detected\n\nIt is recommended to connect the system to AC power during the install" <<< "\n" 2>&1)
1819
compare "$output" "$asserted_output"
@@ -23,7 +24,8 @@ asserted_output="$(echo -e '--WARNING--- -------------security-low--
2324
2425
postamble
2526
26-
Press key to continue
27+
Press CTRL+C to cancel
28+
Press any key to continue
2729
[cenity][][] --width=600 --warning --icon=security-low-symbolic --text=postamble')"
2830
output=$(c_test --width=600 --warning --icon=security-low-symbolic --text="postamble" <<< "\n" 2>&1)
2931
compare "$output" "$asserted_output"
@@ -38,7 +40,8 @@ Reason: reason
3840
3941
postamble
4042
41-
Press key to continue
43+
Press CTRL+C to cancel
44+
Press any key to continue
4245
[cenity][][] --width=600 --warning --icon=security-medium-symbolic --text=preamble\\n\\nReason: reason\\n\\npostamble')"
4346
output=$(c_test --width=600 --warning --icon=security-medium-symbolic --text="preamble\n\nReason: reason\n\npostamble" <<< "\n" 2>&1)
4447
compare "$output" "$asserted_output"

0 commit comments

Comments
 (0)