summaryrefslogtreecommitdiff
path: root/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/TurnTests.java
blob: 6b4b719885ddc222056510e8cccf892b18edb74d (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
package com.smartdevicelink.test.rpc.datatypes;

import com.smartdevicelink.proxy.rpc.Image;
import com.smartdevicelink.proxy.rpc.Turn;
import com.smartdevicelink.test.TestValues;
import com.smartdevicelink.test.Validator;

import junit.framework.TestCase;

import org.json.JSONException;
import org.json.JSONObject;

public class TurnTests extends TestCase {
	
	private Turn msg;

	@Override
    public void setUp(){
        msg = new Turn();
        assertNotNull(TestValues.NOT_NULL, msg);
        
        msg.setTurnIcon(TestValues.GENERAL_IMAGE);
        msg.setNavigationText(TestValues.GENERAL_STRING);
	}

    /**
	 * Tests the expected values of the RPC message.
	 */
    public void testRpcValues () {
    	// Test Values
		Image icon = msg.getTurnIcon();
		String text = msg.getNavigationText();
		
		// Valid Tests
		assertTrue(TestValues.MATCH, Validator.validateImage(TestValues.GENERAL_IMAGE, icon));
		assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, text);
		
		// Invalid/Null Tests
		Turn msg = new Turn();
		assertNotNull(TestValues.NOT_NULL, msg);
		
		assertNull(TestValues.NULL, msg.getNavigationText());
		assertNull(TestValues.NULL, msg.getTurnIcon());
	}
	
	public void testJson(){
        JSONObject reference = new JSONObject();

        try{
        	reference.put(Turn.KEY_NAVIGATION_TEXT, TestValues.GENERAL_STRING);
        	reference.put(Turn.KEY_TURN_IMAGE, TestValues.JSON_IMAGE);
        } catch(JSONException e){
        	fail(TestValues.JSON_FAIL);
        }
	}
}