File: record.test

package info (click to toggle)
snack 2.2.10-dfsg1-12.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 3,024 kB
  • sloc: ansic: 35,473; sh: 8,557; tcl: 1,065; python: 701; makefile: 565
file content (97 lines) | stat: -rw-r--r-- 2,014 bytes parent folder | download | duplicates (9)
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
# Commands covered: sound record/stop
#

package require -exact snack 2.2

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import ::tcltest::*
}

test record-1.1 {record command} {
  set s [snack::sound snd]
  $s record
  set flag 0
  after 2000 {set flag 1}
  while {$flag == 0} update
  $s stop
  set len [$s length]
  $s destroy
  expr $len > 0
} 1

test record-1.2 {record command, with -append} {
  set s [snack::sound snd]
  $s record
  set flag 0
  after 2000 {set flag 1}
  while {$flag == 0} update
  $s stop
  set len1 [$s length]

  $s record -append 1
  set flag 0
  after 2000 {set flag 1}
  while {$flag == 0} update
  $s stop
  set len2 [$s length]
  $s destroy
  expr $len2 > $len1
} 1

test record-2.1 {record command, using default sound device} {
  set s [snack::sound snd]
  $s record -device ""
  set flag 0
  after 2000 {set flag 1}
  while {$flag == 0} update
  $s stop
  set len [$s length]
  $s destroy
  expr $len > 0
} 1

test record-2.2 {record command, using first sound device} {
  set s [snack::sound snd]
  set dev [lindex [snack::audio inputDevices] 0]
  $s record -device $dev
  set flag 0
  after 2000 {set flag 1}
  while {$flag == 0} update
  $s stop
  set len [$s length]
  $s destroy
  expr $len > 0
} 1

test record-3.1 {record command, using unknown sound device} {
  set s [snack::sound snd]
  catch {$s record -device junk} msg
  $s destroy
  set msg
} {No such device: junk}

test record-3.2 {record command, missing argument to -device option} {
  set s [snack::sound snd]
  catch {$s record -device} msg
  $s destroy
  set msg
} {No argument given for -device option}

test record-3.1 {record command, -file} {
  set s [snack::sound snd -file snackTest.au]
  $s record
  set flag 0
  after 2000 {set flag 1}
  while {$flag == 0} update
  $s stop
  $s configure -load snackTest.au
  set len [$s length]
  $s destroy
  expr $len > 0
} 1

# cleanup
catch {::tcltest::removeFile snackTest.au}
::tcltest::cleanupTests
return