summaryrefslogtreecommitdiff
path: root/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/SdlConnection/SdlSessionTests.java
blob: d00d946d56f4bdccf5e9db1d5f75818c43c62799 (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
package com.smartdevicelink.test.SdlConnection;

import com.smartdevicelink.SdlConnection.SdlSession;
import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.proxy.interfaces.ISdlServiceListener;
import com.smartdevicelink.test.streaming.MockInterfaceBroker;
import com.smartdevicelink.transport.MultiplexTransportConfig;

import junit.framework.TestCase;

import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;

/**
 * This is a unit test class for the SmartDeviceLink library project class : 
 * {@link com.smartdevicelink.SdlConnection.SdlSession}
 */
public class SdlSessionTests extends TestCase {

	public void testServiceListeners(){
		SdlSession session = new SdlSession(new MockInterfaceBroker(),  new MultiplexTransportConfig(getInstrumentation().getTargetContext(),"19216801"));
		ISdlServiceListener test = new ISdlServiceListener() {
			@Override
			public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted) {

			}

			@Override
			public void onServiceEnded(SdlSession session, SessionType type) {

			}

			@Override
			public void onServiceError(SdlSession session, SessionType type, String reason) {

			}
		};

		session.addServiceListener(SessionType.RPC, test);
		assertNotNull(session.getServiceListeners());

		assertTrue(session.removeServiceListener(SessionType.RPC, test));

		assertFalse(session.removeServiceListener(SessionType.RPC, test));

	}


}