My favorites | Sign in
Logo
                
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# tagging_tests.rb
# Author:: Jamie Hardt
#
# This file is part of "agent-orange".
#
# "agent-orange" is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# "agent-orange" is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with "agent-orange"; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

require 'test/unit'
($:).unshift "lib/"
require 'pt/session'
require 'pt/track'
require 'pt/region'

require 'tag_interpreter'

# This TestCase tests some simple tagging operations. All of these tagging operations
# are *LAW* and any if your patches break any of these tests, you patch will not be
# applied.
#
# It is not recommended for you to add your own test cases to this TestCase; these
# are for foundational operations of tagging and if you find a particular tagging
# operation that doesn't come out the way you're expecting, contact Jamie and writeup
# a text import-export test for your full file. If your scenario is particularly
# compelling Jamie will add it.
class TaggingTest < Test::Unit::TestCase

def setup # :nodoc:
@session = PT::Session.new
@session.title = "TaggingTest"

@tag_interpreter = TagInterpreter.new do |ti|
ti.blender.blend_duration = 2.0
end

end

# Test for untagged regions.
#
# Any sequence made up of untagged regions should be made into one region, with the name
# of the first region.
def test_untagged
track = @session.add_track("Untagged")

track.add_region("test 1" , "90+0", "95+0")
track.add_region("test 2" , "95+0", "99+0")
track.add_region("test 3" , "99+0", "110+0")

track_result = @tag_interpreter.interpret_track(track)

assert_equal(track_result.regions.size , 1)
assert_equal(track_result.regions[0].clean_name , "test 1")
assert_equal(track_result.regions[0].start , 90 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[0].finish , 110 * PT::Region.divs_per_foot)
end

# Test for the closed-brace-tag *-}*.
#
# Definitively, a closed brace tag cause the region so tagged to start where it's
# containing sequence starts.
def test_brace_closed
track = @session.add_track("Simple -}")

track.add_region('test 1' ,"9+0" ,"12+0")
track.add_region('test 2-}',"12+0" , "18+0")

track_result = @tag_interpreter.interpret_track(track)

assert_equal(track_result.regions.size, 1)
assert_equal(track_result.regions[0].clean_name, "test 2")
assert_equal(track_result.regions[0].start, 9 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[0].finish , 18 * PT::Region.divs_per_foot)
end

# Test for the closed-bracket-tag "-]".
#
# Definitively, a closed bracket tag causes the sequence of regions leading up to
# a region so tagged to be omitted.
def test_bracket_closed
track = @session.add_track("Simple -]")

track.add_region('test 1', "100+0", "105+0")
track.add_region('test 2-]', "105+0", "120+0")

track_result = @tag_interpreter.interpret_track(track)

assert_equal(track_result.regions.size , 1)
assert_equal(track_result.regions[0].clean_name, "test 2")
assert_equal(track_result.regions[0].start, 105 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[0].finish, 120 * PT::Region.divs_per_foot)
end

# Test for the closed-angle-bracket-tag "->".
#
# Definitively, a closed angle bracket causes the sequence of regions leading up to the
# region so tagged to be labeled "Fill".
def test_angle_bracket_closed
track = @session.add_track("Simple ->")

track.add_region('test 1', "30+0", "35+0")
track.add_region('test 2->', "35+0", "40+0")

track_result = @tag_interpreter.interpret_track(track)

assert_equal(track_result.regions.size , 2)
assert_equal(track_result.regions[0].clean_name, "Fill")
assert_equal(track_result.regions[0].start, 30 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[0].finish, 35 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[1].clean_name , "test 2")
assert_equal(track_result.regions[1].start, 35 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[1].finish, 40 * PT::Region.divs_per_foot)
end

# Test the open bracket tag "-["
#
# A region tagged with an open-bracket will start at the time of the region,
# but will also *end* at the time of the *start* of the region, causing the
# resulting region to have zero duration
def test_bracket_open
track = @session.add_track("Simple -[")

track.add_region('test 1-[', "45+0" , "51+0")

track_result = @tag_interpreter.interpret_track(track)

assert_equal(track_result.regions.size , 1)
assert_equal(track_result.regions[0].clean_name, "test 1")
assert_equal(track_result.regions[0].start, 45 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[0].finish, 45 * PT::Region.divs_per_foot)
end

# Test the ampersand tag "-&"
#
# Within a sequence of regions, an ampersand causes the clean text of a second region
# to be concatenated with a space " " to the clean text of a first tagged region.
# The amperand-tagged region itself is omitted, and the first region is lengthened
# to cover the space occupied by her victim.
def test_ampersand
track = @session.add_track("Simple -&")

track.add_region('test 1-]', "45+0" , "51+0")
track.add_region('test 2-&', "51+0" , "58+0")

track_result = @tag_interpreter.interpret_track(track)

assert_equal(track_result.regions.size , 1)
assert_equal(track_result.regions[0].clean_name, "test 1 test 2")
assert_equal(track_result.regions[0].start, 45 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[0].finish, 58 * PT::Region.divs_per_foot)
end

# Test of simple cue insertion with "-]"
#
# Using the "-]" in the middle of an audio sequence, when a host region precedes
# it, will cause the first host region to end and a second to commence in the middle
# of the sequence.
def test_insert_cue
track = @session.add_track("Insert cue with -]")

track.add_region('test 1-]', "100+0" , "105+0")
track.add_region('test 2-]', "105+0" , "110+0")

track_result = @tag_interpreter.interpret_track(track)

assert_equal(track_result.regions.size , 2)
assert_equal(track_result.regions[0].clean_name , "test 1")
assert_equal(track_result.regions[0].start , 100 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[0].finish , 105 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[1].clean_name , "test 2")
assert_equal(track_result.regions[1].start , 105 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[1].finish , 110 * PT::Region.divs_per_foot)
end

# Test blend stop with "-!"
#
# A region tagged with "-!" will cause a region sequence to end at the leading edge of
# the region. The region tagged with the "-!" is omitted, and blending is not premitted
# to occur across the gap.
def test_blend_stop
track = @session.add_track("Blend stop with -!")

track.add_region('test 1-}', "100+0" , "105+0")
track.add_region('test 2-!', "105+5" , "106+0")
track.add_region('test 2-]', "106+0" , "110+0")

track_result = @tag_interpreter.interpret_track(track)

assert_equal(track_result.regions.size , 2)
assert_equal(track_result.regions[0].clean_name , "test 1")
assert_equal(track_result.regions[0].start , 100 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[0].finish , 105 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[1].clean_name , "test 2")
assert_equal(track_result.regions[1].start , 106 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[1].finish , 110 * PT::Region.divs_per_foot)
end

# Test of forced continued cue "-}}"
#
# A region tagged with a "-}}" will form an audio sequence with all regions following
# it without regard for the distance between them, until a "-!!" or "-!" region is
# encountered.
def test_forced_continued_cue
track = @session.add_track("Forced cue with -}}")

track.add_region('test 1-}}', "100+0" , "105+0")
track.add_region('test 2-!!', "130+0" , "180+0")

track_result = @tag_interpreter.interpret_track(track)

assert_equal(track_result.regions.size , 1)
assert_equal(track_result.regions[0].clean_name , "test 1")
assert_equal(track_result.regions[0].start , 100 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[0].finish , 180 * PT::Region.divs_per_foot)
end

# Test of forced continued cue "-}}" with inserted cues
#
def test_forced_continued_cue_insertion
track = @session.add_track("-}} with inserted cues")

track.add_region('test 1-}}', "100+0" , "105+0")
track.add_region('test 2-]', "120+0" , "180+0")
track.add_region('test 3', "300+0" , "320+0")
track.add_region('test 4-]', "360+0" , "400+0")
track.add_region('test 5-!!', "480+0" , "490+0")

track_result = @tag_interpreter.interpret_track(track)

assert_equal(track_result.regions.size , 3)
assert_equal(track_result.regions[0].clean_name , "test 1")
assert_equal(track_result.regions[0].start , 100 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[0].finish , 120 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[1].clean_name , "test 2")
assert_equal(track_result.regions[1].start , 120 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[1].finish , 360 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[2].clean_name , "test 4")
assert_equal(track_result.regions[2].start , 360 * PT::Region.divs_per_foot)
assert_equal(track_result.regions[2].finish , 490 * PT::Region.divs_per_foot)
end


end #class
Show details Hide details

Change log

r109 by jhardt on Sep 23, 2007   Diff
moved tests
Go to: 
Project members, sign in to write a code review

Older revisions

r94 by jhardt on Oct 24, 2006   Diff
Fixed an issue with adding the local
lib directory to $: .  We now unshift
lib/ onto the load path, so it comes
first and we don't accidently install
a pt gem
r76 by jhardt on Jul 06, 2006   Diff
Renamed a duplicate-named test case in
the tagging_tests.rb
r63 by jhardt on Jun 27, 2006   Diff
Moving branch_1 into trunk.
All revisions of this file

File info

Size: 10474 bytes, 253 lines
Hosted by Google Code