summaryrefslogtreecommitdiff
path: root/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/TTSChunkFactoryTests.java
blob: ad1976cb19d20ff22f06fd0d24f113a0fe0c96ea (plain)
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
package com.smartdevicelink.test.proxy;

import com.smartdevicelink.proxy.TTSChunkFactory;
import com.smartdevicelink.proxy.rpc.TTSChunk;
import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
import com.smartdevicelink.test.TestValues;

import junit.framework.TestCase;

import java.util.Vector;

/**
 * This is a unit test class for the SmartDeviceLink library project class : 
 * {@link com.smartdevicelink.proxy.TTSChunkFactory}
 */
public class TTSChunkFactoryTests extends TestCase {
	
	private TTSChunk testChunk;
	
	/**
	 * This is a unit test for the following methods : 
	 * {@link com.smartdevicelink.proxy.TTSChunkFactory#createChunk(SpeechCapabilities, String)}
	 */
	public void testCreateChunk () {
		// Valid Tests
		SpeechCapabilities testType = SpeechCapabilities.TEXT;
		testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING);
		assertNotNull(TestValues.NOT_NULL, testChunk);
		assertEquals(TestValues.MATCH, testType, testChunk.getType());
		assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText());
		
		testType = SpeechCapabilities.SILENCE;
		testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING);
		assertNotNull(TestValues.NOT_NULL, testChunk);
		assertEquals(TestValues.MATCH, testType, testChunk.getType());
		assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText());
				
		testType = SpeechCapabilities.SAPI_PHONEMES;
		testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING);
		assertNotNull(TestValues.NOT_NULL, testChunk);
		assertEquals(TestValues.MATCH, testType, testChunk.getType());
		assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText());
		
		testType = SpeechCapabilities.PRE_RECORDED;
		testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING);
		assertNotNull(TestValues.NOT_NULL, testChunk);
		assertEquals(TestValues.MATCH, testType, testChunk.getType());
		assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText());
		
		testType = SpeechCapabilities.LHPLUS_PHONEMES;
		testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING);
		assertNotNull(TestValues.NOT_NULL, testChunk);
		assertEquals(TestValues.MATCH, testType, testChunk.getType());
		assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText());
		
		// Invalid/Null Tests
		testChunk = TTSChunkFactory.createChunk(null, null);
		assertNotNull(TestValues.NOT_NULL, testChunk);
		assertNull(TestValues.NULL, testChunk.getType());
		assertNull(TestValues.NULL, testChunk.getText());
	}
	
	/**
	 * This is a unit test for the following methods : 
	 * {@link com.smartdevicelink.proxy.TTSChunkFactory#createSimpleTTSChunks(String)}
	 */
	public void testCreateSimpleTTSChunks () {
		// Test Values
		Vector<TTSChunk> testChunks;
		testChunks = TTSChunkFactory.createSimpleTTSChunks(TestValues.GENERAL_STRING);
		
		// Valid Tests
		assertNotNull(TestValues.NOT_NULL, testChunks);
		assertEquals(TestValues.MATCH, SpeechCapabilities.TEXT, testChunks.get(0).getType());
		assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunks.get(0).getText());
		
		// Invalid/Null Tests
		testChunks = TTSChunkFactory.createSimpleTTSChunks(null);
		assertNull(TestValues.NULL, testChunks);
	}

	/**
	 * This is a unit test for the following methods : 
	 * {@link com.smartdevicelink.proxy.TTSChunkFactory#createPrerecordedTTSChunks(String)}
	 */
	public void testCreatePrerecordedTTSChunks () {
		// Test Values
		Vector<TTSChunk> testChunks;
		testChunks = TTSChunkFactory.createPrerecordedTTSChunks(TestValues.GENERAL_STRING);
		
		// Valid Tests
		assertNotNull(TestValues.NOT_NULL, testChunks);
		assertEquals(TestValues.MATCH, SpeechCapabilities.PRE_RECORDED, testChunks.get(0).getType());
		assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunks.get(0).getText());
		
		// Invalid/Null Tests
		testChunks = TTSChunkFactory.createPrerecordedTTSChunks(null);
		assertNull(TestValues.NULL, testChunks);
	}
}