1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# This file is a Tcl script to test systray and sysnotify features in Tk.
# It is organized in the standard fashion for Tcl tests.
#
# Copyright © 2020 Kevin Walzer/WordTech Communications LLC.
# All rights reserved.
package require tcltest 2.2
namespace import ::tcltest::*
eval tcltest::configure $argv
tcltest::loadTestedCommands
test systray-1 {systray icon creation, all options} -setup {
image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
} -body {
tk systray create -image _book -text "Systray sample" \
-button1 {puts "button 1 click"} -button3 {puts "button 3 click"}
} -cleanup {
tk systray destroy
image delete _book
} -result {}
test systray-2 {systray create, argument checking} -body {
tk systray create
} -returnCodes {error} -result {missing required option "-image"}
test systray-3 {systray create, argument checking} -body {
tk systray create -text Hell
} -returnCodes {error} -result {missing required option "-image"}
test systray-4 {systray create, argument checking} -setup {
image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
} -body {
tk systray create -image _book -gorp invalidOption
} -returnCodes {error} -result {unknown option "-gorp": must be -image, -text, -button1 or -button3}
test systray-5 {systray icon creation, only required option present} -setup {
image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
} -body {
tk systray create -image _book
} -cleanup {
tk systray destroy
image delete _book
} -result {}
test systray-6 {systray icon creation, some options present} -setup {
image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
} -body {
tk systray create -image _book -button3 {puts b3}
} -cleanup {
tk systray destroy
image delete _book
} -result {}
test systray-7 {systray icon, all parameters modification, introspection} -setup {
image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
image create photo _page -data R0lGODlhCwAPAKIAAP//////AMDAwICAgAAA/wAAAAAAAAAAACwAAAAACwAPAAADMzi6CzAugiAgDGE68aB0RXgRJBFVX0SNpQlUWfahQOvSsgrX7eZJMlQMWBEYj8iQchlKAAA7
} -body {
tk systray create -image _book -text "Systray icon text"
tk systray configure -image _page
tk systray configure -text "Another text for my icon"
tk systray configure -button1 {set a 1}
tk systray configure -button3 {set b 2}
tk systray configure
} -cleanup {
tk systray destroy
image delete _book
image delete _page
} -result {-image _page -text {Another text for my icon} -button1 {set a 1} -button3 {set b 2}}
test systray-8 {systray icon, single parameter modification, introspection} -setup {
image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
} -body {
tk systray create -image _book -text "Systray icon text" -button1 {puts b1}
tk systray configure -button1 {set a 1}
tk systray configure -button1
} -cleanup {
tk systray destroy
image delete _book
} -result {set a 1}
test systray-9 {systray icon, several parameters modification at once, introspection} -setup {
image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
} -body {
tk systray create -image _book -text "Systray icon text" -button1 {puts b1}
tk systray configure -button1 {set a 1} -text NewText
list [tk systray configure -button1] [tk systray configure -text]
} -cleanup {
tk systray destroy
image delete _book
} -result {{set a 1} NewText}
test systray-10 {configure non-existing systray icon} -setup {
catch {tk systray destroy}
} -body {
tk systray configure
} -returnCodes {error} -result {systray not created}
test systray-11 {destroy non-existing systray icon} -setup {
catch {tk systray destroy}
} -body {
tk systray destroy
} -returnCodes {error} -result {systray not created}
test systray-12 {systray icon creation, attempt to create more than one in an interp} -setup {
image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
} -body {
tk systray create -image _book
tk systray create -image _book
} -cleanup {
tk systray destroy
image delete _book
} -returnCodes {error} -result {only one system tray icon supported per interpeter}
test systray-13 {systray icon creation, create one per interp} -setup {
image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
} -body {
tk systray create -image _book
interp create childInterp
childInterp eval {
package require Tk
image create photo _page -data R0lGODlhCwAPAKIAAP//////AMDAwICAgAAA/wAAAAAAAAAAACwAAAAACwAPAAADMzi6CzAugiAgDGE68aB0RXgRJBFVX0SNpQlUWfahQOvSsgrX7eZJMlQMWBEYj8iQchlKAAA7
tk systray create -image page
}
} -cleanup {
tk systray destroy
image delete _book
interp delete childInterp
} -result {}
test sysnotify-1 {system notification popup} -setup {
image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
tk systray create -image _book -text "Systray sample"
} -body {
tk sysnotify {Alert} {This is an alert}
} -cleanup {
tk systray destroy
image delete _book
} -result {}
test sysnotify-2.1 {system notification stems from a systray icon on Windows} -constraints {
win
} -setup {
catch {tk systray destroy}
} -body {
tk sysnotify {Alert} {This is an alert}
} -returnCodes {error} -result {must create a system tray icon with the "tk systray" command first}
test sysnotify-2.2 {system notification is not linked to any systray icon on X11 or aqua} -constraints {
nonwin
} -setup {
catch {tk systray destroy}
} -body {
tk sysnotify {Alert} {This is an alert}
} -result {}
cleanupTests
|