taglib-ruby 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +33 -0
- data/.yardopts +1 -1
- data/{CHANGES.md → CHANGELOG.md} +35 -14
- data/Gemfile +2 -0
- data/Guardfile +4 -2
- data/README.md +56 -38
- data/Rakefile +8 -8
- data/docs/taglib/aiff.rb +0 -3
- data/docs/taglib/base.rb +0 -4
- data/docs/taglib/flac.rb +1 -3
- data/docs/taglib/id3v2.rb +1 -1
- data/docs/taglib/mp4.rb +2 -4
- data/docs/taglib/mpeg.rb +0 -1
- data/docs/taglib/ogg.rb +0 -4
- data/docs/taglib/vorbis.rb +0 -1
- data/docs/taglib/wav.rb +0 -4
- data/ext/extconf_common.rb +24 -28
- data/ext/taglib_aiff/extconf.rb +2 -0
- data/ext/taglib_aiff/taglib_aiff_wrap.cxx +217 -178
- data/ext/taglib_base/extconf.rb +2 -0
- data/ext/taglib_base/includes.i +25 -0
- data/ext/taglib_base/taglib_base.i +18 -0
- data/ext/taglib_base/taglib_base_wrap.cxx +233 -191
- data/ext/taglib_flac/extconf.rb +2 -0
- data/ext/taglib_flac/taglib_flac.i +7 -0
- data/ext/taglib_flac/taglib_flac_wrap.cxx +235 -189
- data/ext/taglib_flac_picture/extconf.rb +2 -0
- data/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx +210 -168
- data/ext/taglib_id3v1/extconf.rb +2 -0
- data/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +223 -182
- data/ext/taglib_id3v2/extconf.rb +2 -0
- data/ext/taglib_id3v2/taglib_id3v2.i +17 -0
- data/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +2922 -993
- data/ext/taglib_mp4/extconf.rb +2 -0
- data/ext/taglib_mp4/taglib_mp4_wrap.cxx +295 -260
- data/ext/taglib_mpeg/extconf.rb +2 -0
- data/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +243 -206
- data/ext/taglib_ogg/extconf.rb +2 -0
- data/ext/taglib_ogg/taglib_ogg_wrap.cxx +214 -171
- data/ext/taglib_vorbis/extconf.rb +2 -0
- data/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +217 -178
- data/ext/taglib_wav/extconf.rb +2 -0
- data/ext/taglib_wav/taglib_wav_wrap.cxx +217 -178
- data/lib/taglib/aiff.rb +2 -0
- data/lib/taglib/base.rb +3 -1
- data/lib/taglib/flac.rb +2 -0
- data/lib/taglib/id3v1.rb +2 -0
- data/lib/taglib/id3v2.rb +2 -0
- data/lib/taglib/mp4.rb +10 -13
- data/lib/taglib/mpeg.rb +2 -0
- data/lib/taglib/ogg.rb +2 -0
- data/lib/taglib/version.rb +4 -2
- data/lib/taglib/vorbis.rb +2 -0
- data/lib/taglib/wav.rb +2 -1
- data/lib/taglib.rb +4 -3
- data/taglib-ruby.gemspec +165 -162
- data/tasks/docs_coverage.rake +10 -8
- data/tasks/ext.rake +26 -25
- data/tasks/gemspec_check.rake +7 -5
- data/tasks/swig.rake +10 -11
- data/test/aiff_examples_test.rb +8 -13
- data/test/aiff_file_test.rb +29 -29
- data/test/aiff_file_write_test.rb +19 -20
- data/test/base_test.rb +4 -2
- data/test/data/add-relative-volume.cpp +7 -3
- data/test/data/flac-create.cpp +15 -5
- data/test/data/flac_nopic.flac +0 -0
- data/test/data/get_picture_data.cpp +5 -1
- data/test/data/id3v1-create.cpp +6 -3
- data/test/data/mp4-create.cpp +12 -4
- data/test/data/vorbis-create.cpp +12 -5
- data/test/data/wav-create.cpp +18 -3
- data/test/file_test.rb +7 -5
- data/test/fileref_open_test.rb +12 -10
- data/test/fileref_properties_test.rb +6 -4
- data/test/fileref_write_test.rb +14 -13
- data/test/flac_file_test.rb +32 -27
- data/test/flac_file_write_test.rb +17 -18
- data/test/flac_picture_memory_test.rb +39 -0
- data/test/helper.rb +3 -1
- data/test/id3v1_genres_test.rb +14 -12
- data/test/id3v1_tag_test.rb +7 -5
- data/test/id3v2_frames_test.rb +98 -34
- data/test/id3v2_header_test.rb +14 -13
- data/test/id3v2_memory_test.rb +21 -20
- data/test/id3v2_relative_volume_test.rb +11 -9
- data/test/id3v2_tag_test.rb +16 -14
- data/test/id3v2_unicode_test.rb +12 -10
- data/test/id3v2_unknown_frames_test.rb +7 -5
- data/test/id3v2_write_test.rb +28 -29
- data/test/mp4_file_test.rb +27 -26
- data/test/mp4_file_write_test.rb +12 -13
- data/test/mp4_items_test.rb +78 -79
- data/test/mpeg_file_test.rb +32 -30
- data/test/tag_test.rb +5 -3
- data/test/unicode_filename_test.rb +7 -7
- data/test/vorbis_file_test.rb +14 -12
- data/test/vorbis_tag_test.rb +46 -44
- data/test/wav_examples_test.rb +8 -16
- data/test/wav_file_test.rb +29 -29
- data/test/wav_file_write_test.rb +22 -23
- metadata +26 -23
data/test/id3v2_frames_test.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
require File.join(File.dirname(__FILE__), 'helper')
|
2
4
|
|
3
5
|
class TestID3v2Frames < Test::Unit::TestCase
|
@@ -9,28 +11,28 @@ class TestID3v2Frames < Test::Unit::TestCase
|
|
9
11
|
# itself would still be reachable. The reason is because
|
10
12
|
# TagLib::MPEG::File owns the TagLib::ID3v2::Tag and automatically
|
11
13
|
# deletes it in its destructor.
|
12
|
-
@file = TagLib::MPEG::File.new(
|
13
|
-
|
14
|
+
@file = TagLib::MPEG::File.new('test/data/sample.mp3', read_properties)
|
15
|
+
_picture_file = File.open('test/data/globe_east_540.jpg', 'rb') do |f|
|
14
16
|
@picture_data = f.read
|
15
17
|
end
|
16
18
|
@tag = @file.id3v2_tag
|
17
19
|
@frames = @tag.frame_list
|
18
20
|
end
|
19
21
|
|
20
|
-
should
|
22
|
+
should 'be complete' do
|
21
23
|
assert_not_nil @frames
|
22
24
|
assert_equal 11, @frames.size
|
23
25
|
frame = @frames.first
|
24
|
-
assert_equal
|
26
|
+
assert_equal 'Dummy Title', frame.to_string
|
25
27
|
end
|
26
28
|
|
27
|
-
should
|
28
|
-
ids = @frames.collect
|
29
|
-
assert_equal [
|
30
|
-
|
29
|
+
should 'be enumerable' do
|
30
|
+
ids = @frames.collect(&:frame_id)
|
31
|
+
assert_equal %w[TIT2 TPE1 TALB TRCK TDRC
|
32
|
+
COMM COMM TCON TXXX COMM APIC], ids
|
31
33
|
end
|
32
34
|
|
33
|
-
should
|
35
|
+
should 'be automatically converted' do
|
34
36
|
apic = @tag.frame_list('APIC').first
|
35
37
|
comm = @tag.frame_list('COMM').first
|
36
38
|
tit2 = @tag.frame_list('TIT2').first
|
@@ -41,73 +43,135 @@ class TestID3v2Frames < Test::Unit::TestCase
|
|
41
43
|
assert_equal TagLib::ID3v2::UserTextIdentificationFrame, txxx.class
|
42
44
|
end
|
43
45
|
|
44
|
-
should
|
46
|
+
should 'not fail for nil String' do
|
45
47
|
assert_equal [], @tag.frame_list(nil)
|
46
48
|
end
|
47
49
|
|
48
|
-
should
|
50
|
+
should 'be removable' do
|
49
51
|
assert_equal 11, @tag.frame_list.size
|
50
52
|
tit2 = @tag.frame_list('TIT2').first
|
51
53
|
@tag.remove_frame(tit2)
|
52
54
|
assert_equal 10, @tag.frame_list.size
|
53
55
|
begin
|
54
56
|
tit2.to_string
|
55
|
-
flunk(
|
56
|
-
rescue => e
|
57
|
-
assert_equal
|
57
|
+
flunk('Should have raised ObjectPreviouslyDeleted.')
|
58
|
+
rescue StandardError => e
|
59
|
+
assert_equal 'ObjectPreviouslyDeleted', e.class.to_s
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
|
-
should
|
63
|
+
should 'be removable by ID' do
|
62
64
|
frames = @tag.frame_list
|
63
65
|
@tag.remove_frames('COMM')
|
64
66
|
tit2 = frames.find { |f| f.frame_id == 'TIT2' }
|
65
67
|
# Other frames should still be accessible
|
66
|
-
assert_equal
|
68
|
+
assert_equal 'Dummy Title', tit2.to_s
|
67
69
|
end
|
68
70
|
|
69
|
-
context
|
71
|
+
context 'APIC frame' do
|
70
72
|
setup do
|
71
73
|
@apic = @tag.frame_list('APIC').first
|
72
74
|
end
|
73
75
|
|
74
|
-
should
|
76
|
+
should 'have a type' do
|
75
77
|
assert_equal TagLib::ID3v2::AttachedPictureFrame::FrontCover, @apic.type
|
76
78
|
end
|
77
79
|
|
78
|
-
should
|
79
|
-
assert_equal
|
80
|
+
should 'have a description' do
|
81
|
+
assert_equal 'Blue Marble', @apic.description
|
80
82
|
end
|
81
83
|
|
82
|
-
should
|
83
|
-
assert_equal
|
84
|
+
should 'have a mime type' do
|
85
|
+
assert_equal 'image/jpeg', @apic.mime_type
|
84
86
|
end
|
85
87
|
|
86
|
-
should
|
87
|
-
assert_equal
|
88
|
-
if HAVE_ENCODING
|
89
|
-
assert_equal @picture_data.encoding, @apic.picture.encoding
|
90
|
-
end
|
88
|
+
should 'have picture bytes' do
|
89
|
+
assert_equal 61_649, @apic.picture.size
|
90
|
+
assert_equal @picture_data.encoding, @apic.picture.encoding if HAVE_ENCODING
|
91
91
|
assert_equal @picture_data, @apic.picture
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
context
|
95
|
+
context 'CTOC and CHAP frames' do
|
96
|
+
setup do
|
97
|
+
@chapters = [
|
98
|
+
{ id: 'CH1', start_time: 100, end_time: 200 },
|
99
|
+
{ id: 'CH2', start_time: 201, end_time: 300 },
|
100
|
+
{ id: 'CH3', start_time: 301, end_time: 400 }
|
101
|
+
]
|
102
|
+
|
103
|
+
@default_ctoc = TagLib::ID3v2::TableOfContentsFrame.new('Test')
|
104
|
+
@default_chap = TagLib::ID3v2::ChapterFrame.new('Test', 0, 1, 0xFFFFFFFF, 0xFFFFFFFF)
|
105
|
+
end
|
106
|
+
|
107
|
+
should 'not have a CTOC frame' do
|
108
|
+
assert_equal [], @tag.frame_list('CTOC')
|
109
|
+
end
|
110
|
+
|
111
|
+
should 'not have a CHAP frame' do
|
112
|
+
assert_equal [], @tag.frame_list('CHAP')
|
113
|
+
end
|
114
|
+
|
115
|
+
should 'have one CTOC frame (only one Table of Contents)' do
|
116
|
+
toc = TagLib::ID3v2::TableOfContentsFrame.new('TOC')
|
117
|
+
toc.is_top_level = true
|
118
|
+
toc.is_ordered = true
|
119
|
+
|
120
|
+
@chapters.each do |chapter|
|
121
|
+
toc.add_child_element(chapter[:id])
|
122
|
+
end
|
123
|
+
|
124
|
+
@tag.add_frame(toc)
|
125
|
+
|
126
|
+
ctoc_frame_list = @tag.frame_list('CTOC')
|
127
|
+
assert_equal @default_ctoc.class, ctoc_frame_list.first.class
|
128
|
+
assert_equal 1, ctoc_frame_list.size
|
129
|
+
assert_equal 'TOC', ctoc_frame_list.first.element_id
|
130
|
+
assert_equal 3, ctoc_frame_list.first.child_elements.size
|
131
|
+
assert_equal %w[CH1 CH2 CH3], ctoc_frame_list.first.child_elements
|
132
|
+
end
|
133
|
+
|
134
|
+
should 'have CHAP frames (multiple chapters)' do
|
135
|
+
start_offset = 0xFFFFFFFF
|
136
|
+
end_offset = 0xFFFFFFFF
|
137
|
+
|
138
|
+
@chapters.each do |chapter|
|
139
|
+
chapter_frame = TagLib::ID3v2::ChapterFrame.new(
|
140
|
+
chapter[:id],
|
141
|
+
chapter[:start_time].to_i,
|
142
|
+
chapter[:end_time].to_i,
|
143
|
+
start_offset,
|
144
|
+
end_offset
|
145
|
+
)
|
146
|
+
|
147
|
+
@tag.add_frame(chapter_frame)
|
148
|
+
end
|
149
|
+
|
150
|
+
chap_frame_list = @tag.frame_list('CHAP')
|
151
|
+
assert_equal @default_chap.class, chap_frame_list.first.class
|
152
|
+
assert_equal 3, chap_frame_list.size
|
153
|
+
assert_equal 'CH1', chap_frame_list[0].element_id
|
154
|
+
assert_equal 'CH2', chap_frame_list[1].element_id
|
155
|
+
assert_equal 'CH3', chap_frame_list[2].element_id
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'TXXX frame' do
|
96
160
|
setup do
|
97
161
|
@txxx_frame = @tag.frame_list('TXXX').first
|
98
162
|
end
|
99
163
|
|
100
|
-
should
|
164
|
+
should 'exist' do
|
101
165
|
assert_not_nil @txxx_frame
|
102
166
|
end
|
103
167
|
|
104
|
-
should
|
105
|
-
expected =
|
106
|
-
|
168
|
+
should 'have to_s' do
|
169
|
+
expected = /\[MusicBrainz Album Id\].* 992dc19a-5631-40f5-b252-fbfedbc328a9/
|
170
|
+
assert_match expected, @txxx_frame.to_string
|
107
171
|
end
|
108
172
|
|
109
|
-
should
|
110
|
-
assert_equal [
|
173
|
+
should 'have field_list' do
|
174
|
+
assert_equal ['MusicBrainz Album Id', '992dc19a-5631-40f5-b252-fbfedbc328a9'], @txxx_frame.field_list
|
111
175
|
end
|
112
176
|
end
|
113
177
|
|
data/test/id3v2_header_test.rb
CHANGED
@@ -1,49 +1,50 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
require File.join(File.dirname(__FILE__), 'helper')
|
2
4
|
|
3
5
|
class TestID3v2Header < Test::Unit::TestCase
|
4
|
-
context
|
6
|
+
context 'The sample.mp3 file' do
|
5
7
|
setup do
|
6
8
|
read_properties = false
|
7
|
-
@file = TagLib::MPEG::File.new(
|
9
|
+
@file = TagLib::MPEG::File.new('test/data/sample.mp3', read_properties)
|
8
10
|
@tag = @file.id3v2_tag
|
9
11
|
end
|
10
12
|
|
11
|
-
should
|
13
|
+
should 'have a ID3v2 header' do
|
12
14
|
assert_not_nil @tag.header
|
13
15
|
end
|
14
16
|
|
15
|
-
context
|
17
|
+
context 'header' do
|
16
18
|
setup do
|
17
19
|
@header = @tag.header
|
18
20
|
end
|
19
21
|
|
20
|
-
should
|
22
|
+
should 'have a major version' do
|
21
23
|
assert_equal 3, @header.major_version
|
22
24
|
end
|
23
25
|
|
24
|
-
should
|
26
|
+
should 'have a revision number' do
|
25
27
|
assert_equal 0, @header.revision_number
|
26
28
|
end
|
27
29
|
|
28
|
-
should
|
29
|
-
assert_equal
|
30
|
+
should 'have a tag size' do
|
31
|
+
assert_equal 63_478, @header.tag_size
|
30
32
|
end
|
31
33
|
|
32
|
-
should
|
34
|
+
should 'not have a footer' do
|
33
35
|
assert_equal false, @header.footer_present
|
34
36
|
end
|
35
37
|
|
36
|
-
should
|
38
|
+
should 'not have an extended header' do
|
37
39
|
assert_equal false, @header.extended_header
|
38
40
|
end
|
39
41
|
|
40
|
-
context
|
41
|
-
|
42
|
+
context 'changing the major version' do
|
42
43
|
setup do
|
43
44
|
@header.major_version = 4
|
44
45
|
end
|
45
46
|
|
46
|
-
should
|
47
|
+
should 'have a different major verson' do
|
47
48
|
assert_equal 4, @header.major_version
|
48
49
|
end
|
49
50
|
|
data/test/id3v2_memory_test.rb
CHANGED
@@ -1,23 +1,24 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
require File.join(File.dirname(__FILE__), 'helper')
|
2
4
|
|
3
5
|
class TestID3v2Memory < Test::Unit::TestCase
|
4
|
-
|
5
6
|
N = 1000
|
6
7
|
|
7
|
-
context
|
8
|
+
context 'TagLib::ID3v2' do
|
8
9
|
setup do
|
9
|
-
@file = TagLib::MPEG::File.new(
|
10
|
+
@file = TagLib::MPEG::File.new('test/data/sample.mp3', false)
|
10
11
|
@tag = @file.id3v2_tag
|
11
|
-
@apic = @tag.frame_list(
|
12
|
+
@apic = @tag.frame_list('APIC').first
|
12
13
|
end
|
13
14
|
|
14
|
-
should
|
15
|
+
should 'not corrupt memory with FrameList' do
|
15
16
|
N.times do
|
16
17
|
@tag.frame_list
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
20
|
-
should
|
21
|
+
should 'not corrupt memory with ByteVector' do
|
21
22
|
data = nil
|
22
23
|
N.times do
|
23
24
|
data = @apic.picture
|
@@ -27,32 +28,32 @@ class TestID3v2Memory < Test::Unit::TestCase
|
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
|
-
should
|
31
|
+
should 'not corrupt memory with StringList' do
|
31
32
|
txxx = @tag.frame_list('TXXX').first
|
32
33
|
N.times do
|
33
34
|
txxx.field_list
|
34
35
|
end
|
35
36
|
N.times do
|
36
|
-
txxx.field_list = [
|
37
|
+
txxx.field_list = %w[one two three]
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
should
|
41
|
+
should 'not segfault when tag is deleted along with file' do
|
41
42
|
@file = nil
|
42
43
|
begin
|
43
44
|
N.times do
|
44
45
|
GC.start
|
45
46
|
@tag.title
|
46
47
|
end
|
47
|
-
rescue => e
|
48
|
-
assert_equal
|
48
|
+
rescue StandardError => e
|
49
|
+
assert_equal 'ObjectPreviouslyDeleted', e.class.to_s
|
49
50
|
else
|
50
|
-
raise
|
51
|
+
raise 'GC did not delete file, unsure if test was successful.'
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
54
|
-
should
|
55
|
-
file = TagLib::MPEG::File.new(
|
55
|
+
should 'not segfault when audio properties are deleted along with file' do
|
56
|
+
file = TagLib::MPEG::File.new('test/data/crash.mp3', true)
|
56
57
|
properties = file.audio_properties
|
57
58
|
file.close
|
58
59
|
begin
|
@@ -60,20 +61,20 @@ class TestID3v2Memory < Test::Unit::TestCase
|
|
60
61
|
GC.start
|
61
62
|
properties.bitrate
|
62
63
|
end
|
63
|
-
rescue => e
|
64
|
-
assert_equal
|
64
|
+
rescue StandardError => e
|
65
|
+
assert_equal 'ObjectPreviouslyDeleted', e.class.to_s
|
65
66
|
else
|
66
|
-
raise
|
67
|
+
raise 'GC did not delete file, unsure if test was successful.'
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
70
|
-
should
|
71
|
+
should 'not throw when adding frame via Tag.add_frame' do
|
71
72
|
tcom = TagLib::ID3v2::TextIdentificationFrame.new('TCOM', TagLib::String::Latin1)
|
72
|
-
tcom.text =
|
73
|
+
tcom.text = 'Some composer'
|
73
74
|
@tag.add_frame tcom
|
74
75
|
# the following leads to an ObjectPreviouslyDeleted error (see Issue #8)
|
75
76
|
assert_nothing_raised do
|
76
|
-
@tag.frame_list.find { |fr| 'TCOM'
|
77
|
+
@tag.frame_list.find { |fr| fr.frame_id == 'TCOM' }
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
@@ -1,30 +1,32 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
require File.join(File.dirname(__FILE__), 'helper')
|
2
4
|
|
3
5
|
class TestID3v2RelativeVolumeFrame < Test::Unit::TestCase
|
4
|
-
context
|
6
|
+
context 'The relative-volume.mp3 RVA2 frame' do
|
5
7
|
setup do
|
6
|
-
@file = TagLib::MPEG::File.new(
|
8
|
+
@file = TagLib::MPEG::File.new('test/data/relative-volume.mp3')
|
7
9
|
@tag = @file.id3v2_tag
|
8
10
|
@rv = @tag.frame_list('RVA2').first
|
9
11
|
end
|
10
12
|
|
11
|
-
should
|
13
|
+
should 'exist' do
|
12
14
|
assert_not_nil @rv
|
13
15
|
end
|
14
16
|
|
15
|
-
should
|
17
|
+
should 'have channels' do
|
16
18
|
expected = [TagLib::ID3v2::RelativeVolumeFrame::MasterVolume, TagLib::ID3v2::RelativeVolumeFrame::Subwoofer]
|
17
19
|
assert_equal expected, @rv.channels
|
18
20
|
end
|
19
21
|
|
20
|
-
should
|
22
|
+
should 'have volume adjustments' do
|
21
23
|
assert_equal 512, @rv.volume_adjustment_index
|
22
24
|
assert_equal 1.0, @rv.volume_adjustment
|
23
25
|
assert_equal 1024, @rv.volume_adjustment_index(TagLib::ID3v2::RelativeVolumeFrame::Subwoofer)
|
24
26
|
assert_equal 2.0, @rv.volume_adjustment(TagLib::ID3v2::RelativeVolumeFrame::Subwoofer)
|
25
27
|
end
|
26
28
|
|
27
|
-
should
|
29
|
+
should 'have peak volumes' do
|
28
30
|
master_pv = @rv.peak_volume
|
29
31
|
assert_equal 8, master_pv.bits_representing_peak
|
30
32
|
assert_equal 0b01000001.chr, master_pv.peak_volume
|
@@ -34,17 +36,17 @@ class TestID3v2RelativeVolumeFrame < Test::Unit::TestCase
|
|
34
36
|
assert_equal 0b00111111.chr, subwoofer_pv.peak_volume
|
35
37
|
end
|
36
38
|
|
37
|
-
should
|
39
|
+
should 'accept new volume adjustments' do
|
38
40
|
@rv.set_volume_adjustment_index(2048, TagLib::ID3v2::RelativeVolumeFrame::FrontCentre)
|
39
41
|
assert_equal 2048, @rv.volume_adjustment_index(TagLib::ID3v2::RelativeVolumeFrame::FrontCentre)
|
40
42
|
@rv.set_volume_adjustment(4.0, TagLib::ID3v2::RelativeVolumeFrame::FrontLeft)
|
41
43
|
assert_equal 4.0, @rv.volume_adjustment(TagLib::ID3v2::RelativeVolumeFrame::FrontLeft)
|
42
44
|
end
|
43
45
|
|
44
|
-
should
|
46
|
+
should 'accept new peak volumes' do
|
45
47
|
pv = TagLib::ID3v2::PeakVolume.new
|
46
48
|
assert_equal 0, pv.bits_representing_peak
|
47
|
-
assert_equal
|
49
|
+
assert_equal '', pv.peak_volume
|
48
50
|
pv.bits_representing_peak = 6
|
49
51
|
pv.peak_volume = 0b110111.chr
|
50
52
|
@rv.set_peak_volume(pv, TagLib::ID3v2::RelativeVolumeFrame::BackLeft)
|
data/test/id3v2_tag_test.rb
CHANGED
@@ -1,22 +1,24 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
require File.join(File.dirname(__FILE__), 'helper')
|
2
4
|
|
3
5
|
class TestID3v2Tag < Test::Unit::TestCase
|
4
|
-
context
|
6
|
+
context 'The sample.mp3 file' do
|
5
7
|
setup do
|
6
8
|
read_properties = false
|
7
|
-
@file = TagLib::MPEG::File.new(
|
9
|
+
@file = TagLib::MPEG::File.new('test/data/sample.mp3', read_properties)
|
8
10
|
end
|
9
11
|
|
10
|
-
should
|
12
|
+
should 'have an ID3v2 tag' do
|
11
13
|
assert_not_nil @file.id3v2_tag
|
12
14
|
end
|
13
15
|
|
14
|
-
context
|
16
|
+
context 'tag' do
|
15
17
|
setup do
|
16
18
|
@tag = @file.id3v2_tag
|
17
19
|
end
|
18
20
|
|
19
|
-
should
|
21
|
+
should 'have basic properties' do
|
20
22
|
assert_equal 'Dummy Title', @tag.title
|
21
23
|
assert_equal 'Dummy Artist', @tag.artist
|
22
24
|
assert_equal 'Dummy Album', @tag.album
|
@@ -34,24 +36,24 @@ class TestID3v2Tag < Test::Unit::TestCase
|
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
37
|
-
context
|
39
|
+
context 'A new ID3v2::Tag' do
|
38
40
|
setup do
|
39
41
|
@tag = TagLib::ID3v2::Tag.new
|
40
42
|
end
|
41
43
|
|
42
|
-
should
|
44
|
+
should 'be empty' do
|
43
45
|
assert @tag.empty?
|
44
46
|
end
|
45
47
|
|
46
|
-
should
|
47
|
-
assert_equal
|
48
|
-
assert_equal
|
49
|
-
assert_equal
|
50
|
-
assert_equal
|
51
|
-
assert_equal
|
48
|
+
should 'have empty string attributes' do
|
49
|
+
assert_equal '', @tag.title
|
50
|
+
assert_equal '', @tag.artist
|
51
|
+
assert_equal '', @tag.album
|
52
|
+
assert_equal '', @tag.comment
|
53
|
+
assert_equal '', @tag.genre
|
52
54
|
end
|
53
55
|
|
54
|
-
should
|
56
|
+
should 'have 0 for numeric attributes' do
|
55
57
|
assert_equal 0, @tag.track
|
56
58
|
assert_equal 0, @tag.year
|
57
59
|
end
|
data/test/id3v2_unicode_test.rb
CHANGED
@@ -1,30 +1,32 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
require File.join(File.dirname(__FILE__), 'helper')
|
2
4
|
|
3
5
|
class TestID3v2Unicode < Test::Unit::TestCase
|
4
|
-
context
|
6
|
+
context 'The unicode.mp3 file' do
|
5
7
|
setup do
|
6
8
|
read_properties = false
|
7
|
-
@file = TagLib::MPEG::File.new(
|
9
|
+
@file = TagLib::MPEG::File.new('test/data/unicode.mp3', read_properties)
|
8
10
|
end
|
9
11
|
|
10
|
-
should
|
12
|
+
should 'have an ID3v2 tag' do
|
11
13
|
assert_not_nil @file.id3v2_tag
|
12
14
|
end
|
13
15
|
|
14
16
|
if HAVE_ENCODING
|
15
|
-
context
|
17
|
+
context 'tag' do
|
16
18
|
setup do
|
17
19
|
@tag = @file.id3v2_tag
|
18
20
|
end
|
19
21
|
|
20
|
-
should
|
21
|
-
assert_equal
|
22
|
+
should 'return strings in the right encoding' do
|
23
|
+
assert_equal 'UTF-8', @tag.title.encoding.to_s
|
22
24
|
end
|
23
25
|
|
24
|
-
should
|
26
|
+
should 'convert strings to the right encoding' do
|
25
27
|
# Unicode Snowman in UTF-16
|
26
|
-
utf16_encoded = "\x26\x03"
|
27
|
-
utf16_encoded.force_encoding(
|
28
|
+
utf16_encoded = "\x26\x03".dup # mutable
|
29
|
+
utf16_encoded.force_encoding('UTF-16BE')
|
28
30
|
|
29
31
|
# It should be converted here
|
30
32
|
@tag.title = utf16_encoded
|
@@ -33,7 +35,7 @@ class TestID3v2Unicode < Test::Unit::TestCase
|
|
33
35
|
|
34
36
|
# In order for == to work, they have to be in the same
|
35
37
|
# encoding
|
36
|
-
utf8_encoded = utf16_encoded.encode(
|
38
|
+
utf8_encoded = utf16_encoded.encode('UTF-8')
|
37
39
|
assert_equal utf8_encoded, result
|
38
40
|
end
|
39
41
|
end
|
@@ -1,18 +1,20 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
require File.join(File.dirname(__FILE__), 'helper')
|
2
4
|
|
3
5
|
class TestID3v2UnknownFrames < Test::Unit::TestCase
|
4
|
-
context
|
6
|
+
context 'UnknownFrame' do
|
5
7
|
setup do
|
6
8
|
read_properties = false
|
7
|
-
@file = TagLib::MPEG::File.new(
|
9
|
+
@file = TagLib::MPEG::File.new('test/data/sample.mp3', read_properties)
|
8
10
|
@tag = @file.id3v2_tag
|
9
11
|
end
|
10
12
|
|
11
|
-
should
|
12
|
-
f = TagLib::ID3v2::UnknownFrame.new(
|
13
|
+
should 'should be returned with correct class' do
|
14
|
+
f = TagLib::ID3v2::UnknownFrame.new('TDAT')
|
13
15
|
assert_not_nil f
|
14
16
|
@tag.add_frame(f)
|
15
|
-
frames = @tag.frame_list(
|
17
|
+
frames = @tag.frame_list('TDAT')
|
16
18
|
tdat = frames.first
|
17
19
|
assert_not_nil tdat
|
18
20
|
# By looking at ID alone, it would have returned a
|