source: trunk/CHDK/SCRIPTS/TEST/ubtest.bas @ 2791

Revision 1225, 3.6 KB checked in by reyalp, 23 months ago (diff)

add preliminary ubasic test script, see http://chdk.setepontos.com/index.php?topic=6592.0

Line 
1@title ubasic functionality test
2@param a interactive
3@default a 1
4@param b sleep between tests sec/10
5@default b 5
6rem test various ubasic commands
7
8b=b*100
9
10rem fail flag
11f=0
12
13rem output to CHDK/LOGS/LOG_0001.TXT
14print_screen 1
15print "test plat", get_platform_id, "pset",get_propset
16
17print "sleep/tick test"
18s=get_tick_count
19sleep 500
20t=get_tick_count
21r=t-s
22print "start",s,"end",t,"dif",r
23rem per line yield means we might not be exactly 500
24if r < 500 or r > 550 then
25        gosub "set_fail"
26        print "failed"
27endif
28
29rem key input test
30if a <> 1 then goto "keyin_done"
31
32rem note not all keys are valid on all cameras
33print "key test - set to end"
34do
35        wait_click 1000
36    if is_key "up"    then print "up"
37    if is_key "down"    then print "down"
38    if is_key "left"    then print "left"
39    if is_key "right"    then print "right"
40    if is_key "remote"  then print "remote"
41    if is_key "display"  then print "disp"
42    if is_key "menu"  then print "menu"
43    if is_key "set"  then print "set"
44    if is_key "erase"  then print "erase"
45until is_key "set"
46
47sleep b
48
49:keyin_done
50print "key press test"
51rem opening menu and moving up and down should be safe and work everywhere
52press "menu"
53sleep 50
54release "menu"
55sleep 1000
56click "down"
57sleep 1000
58click "up"
59sleep 1000
60click "menu"
61sleep b
62
63rem mode switch test
64if get_mode=1 then
65        print "try to switch to rec"
66        c=0
67        set_record 1
68        while get_mode=1 and c < 20
69                sleep 100
70                c = c  + 1
71        wend
72        if c = 20 then
73                print "switching to rec failed"
74rem can't continue if not rec
75                gosub "set_fail"
76                goto "the_end"
77        endif
78else
79        print "already in rec"
80endif
81
82rem TODO some cameras need additional sleep between play->rec and mode switch (g12, ?)
83sleep 1000
84
85c = get_capture_mode
86print "current mode ",c
87
88if c <> 2 then
89rem I think all cameras have P (might be called manual)
90        print "try switch to P"
91        set_capture_mode 2
92        print "new mode", get_capture_mode
93        if get_capture_mode <> 2 then
94                gosub "set_fail"
95        endif
96endif
97rem TODO should switch to A (1) and back to P to test mode switching
98
99n=get_exp_count
100print "exp_count", n
101rem half shot and read exposure values
102c = 0
103press "shoot_half"
104while get_shooting <> 1 and c < 30
105        sleep 100
106        c = c + 1
107wend
108if c = 30 then
109        print "halfshoot failed"
110        gosub "set_fail"
111endif
112p=get_av96
113s=get_sv96
114t=get_tv96
115print "Av", p, "Sv", s, "Tv", t
116print "shot - default",get_exp_count + 1
117press "shoot_full"
118sleep 50
119release "shoot_full"
120release "shoot_half"
121
122while get_shooting <> 0
123        sleep 100
124wend
125
126rem a little more to make sure shooting is really done
127sleep 500
128
129print "exp_count", get_exp_count
130n=n+1
131if n <> get_exp_count then
132        print "exp count or shot fail"
133        gosub "set_fail"
134endif
135
136rem if auto Tv > 1/250, use -2 stop otherwise +2
137if t > 768 then
138        print "shoot Tv-2",get_exp_count + 1
139        set_tv96_direct t-192
140else
141        print "shoot Tv+2",get_exp_count + 1
142        set_tv96_direct t+192
143endif
144shoot
145
146sleep b
147
148rem if out Sv > 200, use -2 stop, otherwise +2
149if s > 576 then
150        print "shoot Sv-2",get_exp_count + 1
151
152        set_sv96 s-192
153else
154        print "shoot Sv+2",get_exp_count + 1
155        set_sv96 s+192
156endif
157shoot
158
159sleep b
160
161rem get nd filter - 0=no ND, iris assumed; 1=nd, no iris; 2=both
162if get_nd_present = 0 or get_nd_present = 2 then
163rem TODO valid ranges depend on zoom hard to tell what to use
164        print "cam has iris"
165endif
166
167if get_nd_present > 0 then
168        print "shoot ND in",get_exp_count + 1
169        set_nd_filter 1
170        shoot
171
172        sleep b
173
174        print "shoot ND out",get_exp_count + 1
175        set_nd_filter 2
176        shoot
177
178        sleep b
179endif
180
181goto "the_end"
182
183rem subs
184:set_fail
185        f=f+1
186        return
187
188rem final cleanup
189:the_end
190if f > 0 then
191        print "failed ",f
192else
193        print "ok"
194endif
195print_screen 0
196rem this should not appear in the log
197
198print "done"
199
Note: See TracBrowser for help on using the repository browser.