unimidi 0.3.5 → 0.4.4

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.
@@ -1,36 +0,0 @@
1
- require 'helper'
2
-
3
- class CongruousApiAdapterTest < UniMIDI::TestCase
4
-
5
- def test_input_type
6
- input = $test_device[:input]
7
- assert_equal(:input, input.type)
8
- end
9
-
10
- def test_output_type
11
- output = $test_device[:output]
12
- assert_equal(:output, output.type)
13
- end
14
-
15
- def test_count
16
- count = 0
17
- Input.all.each do |input|
18
- count += 1
19
- end
20
-
21
- assert_equal count, Input.count
22
- end
23
-
24
- def test_find_by_name
25
- index = rand(0..(Input.count-1))
26
- input = Input.all[index]
27
- selected_input = Input.find_by_name(input.name)
28
- assert_equal input, selected_input
29
-
30
- output = rand(0..(Output.count-1))
31
- output = Output.all[index]
32
- selected_input = Input.find_by_name(input.name)
33
- assert_equal input, selected_input
34
- end
35
-
36
- end
@@ -1,40 +0,0 @@
1
- require 'helper'
2
-
3
- class InputBufferTest < UniMIDI::TestCase
4
-
5
- def test_input_buffer
6
- sleep(1)
7
-
8
- messages = VariousMIDIMessages
9
- bytes = []
10
-
11
- $test_device[:output].open do |output|
12
- $test_device[:input].open do |input|
13
-
14
- input.buffer.clear
15
-
16
- messages.each do |msg|
17
-
18
- $>.puts "sending: " + msg.inspect
19
-
20
- output.puts(msg)
21
-
22
- bytes += msg
23
-
24
- sleep(0.5)
25
-
26
- buffer = input.buffer.map { |m| m[:data] }.flatten
27
-
28
- $>.puts "received: " + buffer.to_s
29
-
30
- assert_equal(bytes, buffer)
31
-
32
- end
33
-
34
- assert_equal(bytes.length, input.buffer.map { |m| m[:data] }.flatten.length)
35
-
36
- end
37
- end
38
- end
39
-
40
- end
@@ -1,115 +0,0 @@
1
- require 'helper'
2
-
3
- class IoTest < UniMIDI::TestCase
4
-
5
- # ** this test assumes that TestOutput is connected to TestInput
6
- def test_full_io
7
- sleep(1)
8
- messages = VariousMIDIMessages
9
- messages_arr = messages.inject { |a,b| a+b }.flatten
10
- received_arr = []
11
- pointer = 0
12
- $test_device[:output].open do |output|
13
- $test_device[:input].open do |input|
14
-
15
- input.buffer.clear
16
-
17
- messages.each do |msg|
18
-
19
- $>.puts "sending: " + msg.inspect
20
-
21
- output.puts(msg)
22
- sleep(1)
23
- received = input.gets.map { |m| m[:data] }.flatten
24
-
25
-
26
- $>.puts "received: " + received.inspect
27
-
28
- assert_equal(messages_arr.slice(pointer, received.length), received)
29
-
30
- pointer += received.length
31
-
32
- received_arr += received
33
-
34
- end
35
-
36
- assert_equal(messages_arr.length, received_arr.length)
37
-
38
- end
39
- end
40
- end
41
-
42
- # ** this test assumes that TestOutput is connected to TestInput
43
- def test_full_io_bytestr
44
- sleep(1) # pause between tests
45
-
46
- messages = VariousMIDIByteStrMessages
47
- messages_str = messages.join
48
- received_str = ""
49
- pointer = 0
50
-
51
- $test_device[:output].open do |output|
52
- $test_device[:input].open do |input|
53
-
54
- messages.each do |msg|
55
-
56
- $>.puts "sending: " + msg.inspect
57
-
58
- output.puts(msg)
59
- sleep(1)
60
- received = input.gets_bytestr.map { |m| m[:data] }.flatten.join
61
- $>.puts "received: " + received.inspect
62
-
63
- assert_equal(messages_str.slice(pointer, received.length), received)
64
-
65
- pointer += received.length
66
-
67
- received_str += received
68
-
69
- end
70
-
71
- assert_equal(messages_str, received_str)
72
-
73
- end
74
- end
75
-
76
- end
77
-
78
- # ** this test assumes that TestOutput is connected to TestInput
79
- def test_full_io_objects
80
- sleep(1)
81
- messages = VariousMIDIObjects
82
- messages_arr = messages.map { |m| m.to_bytes }.flatten
83
- received_arr = []
84
- pointer = 0
85
- $test_device[:output].open do |output|
86
- $test_device[:input].open do |input|
87
-
88
- #input.buffer.clear
89
-
90
- messages.each do |msg|
91
-
92
- $>.puts "sending: " + msg.inspect
93
-
94
- output.puts(msg)
95
- sleep(1)
96
- received = input.gets.map { |m| m[:data] }.flatten
97
-
98
-
99
- $>.puts "received: " + received.inspect
100
-
101
- assert_equal(messages_arr.slice(pointer, received.length), received)
102
-
103
- pointer += received.length
104
-
105
- received_arr += received
106
-
107
- end
108
-
109
- assert_equal(messages_arr.length, received_arr.length)
110
-
111
- end
112
- end
113
- end
114
-
115
- end
@@ -1,59 +0,0 @@
1
- require 'helper'
2
-
3
- class SelectorTest < UniMIDI::TestCase
4
-
5
- def test_first
6
- i = Input.first
7
- assert_equal(Input.all.first, i)
8
- end
9
-
10
- def test_last
11
- i = Input.last
12
- assert_equal(Input.all.last, i)
13
- end
14
-
15
- def test_first_with_block
16
- sleep(1)
17
- i = Input.first do |i|
18
- assert_equal(true, i.enabled?)
19
- end
20
- assert_equal(Input.all.first, i)
21
- end
22
-
23
- def test_last_with_block
24
- sleep(1)
25
- i = Input.last do |i|
26
- assert_equal(true, i.enabled?)
27
- end
28
- assert_equal(Input.all.last, i)
29
- end
30
-
31
- def test_brackets
32
- i = Input[0]
33
- assert_equal(Input.first, i)
34
- assert_equal(Input.all.first, i)
35
- end
36
-
37
- def test_use_with_block
38
- sleep(1)
39
- i = Input.use(0) do |i|
40
- assert_equal(true, i.enabled?)
41
- end
42
- assert_equal(Input.first, i)
43
- assert_equal(Input.all.first, i)
44
- end
45
-
46
- def test_use_with_symbol
47
- sleep(1)
48
- i = Input.use(:first)
49
- assert_equal(true, i.enabled?)
50
- assert_equal(Input.first, i)
51
- assert_equal(Input.all.first, i)
52
- end
53
-
54
- def test_all
55
- i = Input.all
56
- assert_equal(Device.all_by_type[:input], Input.all)
57
- end
58
-
59
- end