I am using eclipse for writing JUnit test case for my project. My project contains a bound service based on AIDL. After executing the project i get an autogenerated java file for the AIDL, in the gen folder.
This file contains a Stub class which has methods like
public android.os.IBinder asBinder()
public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
and a Proxy class which has methods
public android.os.IBinder asBinder()
public java.lang.String getInterfaceDescriptor()
and also some methods created by me . I want to test the above methods using JUint Test . Is it possible to test these methods using ServiceTestCase or can i test this using some other method.
I managed to test the methods of my Stub Class using the following code in my testProject
IBinder service = this.bindService(new Intent(MyService.class.getName()));
MyFile iTestServiceCall = MyFile.Stub.asInterface(service);
b=service.transact(0, data, null, 0);
assertTrue("Value is still false", b);
assertNotNull("Value is null",iTestServiceCall.asBinder());
Here MyService is the service i created and MyFile is the Aidl.