Repository navigation
Expand file tree
/
Copy pathSSIPClientTest.java
More file actions
145 lines (134 loc) · 3.88 KB
/
Copy pathSSIPClientTest.java
File metadata and controls
145 lines (134 loc) · 3.88 KB
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
/*
* SSIPClientTest.java
*
* Copyright (C) 2008, 2010 Rui Batista <rui.batista@ist.utl.pt>
*
* This 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.1, or (at your option)
* any later version.
*
* This software 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 this package; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
package speechd.tests;
import java.util.List;
import speechd.ssip.SSIPClient;
import speechd.ssip.SSIPCommandException;
import speechd.ssip.SSIPException;
import speechd.ssip.SSIPPriority;
import speechd.ssip.SSIPSynthesisVoice;
import junit.framework.TestCase;
/**
*
*
* @author ragb
*
*/
public class SSIPClientTest extends TestCase {
SSIPClient _client;
/**
* @param arg0
*/
public SSIPClientTest (String arg0) {
super(arg0);
}
/**
* @see junit.framework.TestCase#setUp()
*/
protected void setUp () throws Exception {
super.setUp();
_client = new SSIPClient("junit", null, null);
}
/**
* @see junit.framework.TestCase#tearDown()
*/
protected void tearDown () throws Exception {
super.tearDown();
_client.close();
}
/**
*
*/
public void testSay () {
try {
_client.say(SSIPPriority.TEXT,
"this is the client say method test. this one should not be spoken");
_client.say(SSIPPriority.IMPORTANT, "this is important");
_client.say(SSIPPriority.MESSAGE, "this is a message");
_client.say(SSIPPriority.TEXT, "a litle text to say...");
} catch (SSIPException e) {
fail();
}
}
public void testSayFormated () {
try {
_client.sayFormated(SSIPPriority.TEXT, "this thing is testing with %s",
"junit");
} catch (SSIPException e) {
fail("say formated");
}
}
public void testGetClientId () {
int id = _client.getClientId();
assertTrue(id > 0);
}
public void testStop () {
try {
_client.stop();
_client.setTarget(SSIPClient.Target.ALL);
_client.stop();
_client.setTarget(_client.getClientId());
_client.stop();
_client.setTarget(SSIPClient.Target.SELF);
} catch (SSIPException e) {
fail("stop test.");
}
}
public void testSetParameters () {
try {
_client.setVolume(0);
_client.say(SSIPPriority.MESSAGE, "this is in a lower volume");
_client.setVolume(100);
_client.say(SSIPPriority.MESSAGE, "this is the highest");
_client.setRate(100);
_client.say(SSIPPriority.MESSAGE, "this is fast");
_client.setRate(0);
_client.setPitch(50);
_client.say(SSIPPriority.MESSAGE, "this is like girls");
} catch (SSIPCommandException e) {
fail("" + e.getResponse().getCode());
} catch (SSIPException e) {
fail();
}
}
public void testListings () {
try {
List<String> data;
data = _client.getOutputModules();
for (String s : data) {
if(s == "dummy") continue; //Not for this one...:)
_client.setOutputModule(s);
_client.sayFormated(SSIPPriority.MESSAGE, "speaking from module %s", s);
}
data = _client.getVoices();
for (String s : data) {
_client.setVoice(s);
_client.sayFormated(SSIPPriority.MESSAGE, "this voice %s", s);
}
for (SSIPSynthesisVoice v : _client.getSynthesisVoices()) {
_client.sayFormated(SSIPPriority.MESSAGE, "Synth voice %s", v
.toString());
}
} catch (SSIPException e) {
fail();
}
}
}