*bump* I'm sure I'm just doing something stupid wrong but I really would love to get this working right so I can write good automated tests for my project! Please help if you can...
On Aug 25, 4:01 pm, Josh Guilfoyle <[EMAIL PROTECTED]> wrote: > I am trying to add unit tests to a service of mine that utilizes > remote callbacks (managed by the service with RemoteCallbackList). I > know that this service functions properly already, I am just trying to > formalize with a unit test as I have recently discovered how to make > instrumentation work. The service otherwise works fine except that it > seems that the service callbacks never fire on the observing side. My > simple test case looks similar to the following sample: > > -- begin paste -- > > public void testMyService() throws RemoteException { > IMyService svc = IMyService.Stub.asInterface(bindService(new > Intent(this, MyService.class))); > > svc.registerObserver(new IMyServiceObserver.Stub() { > public void onFoo() > { > Log.d(TAG, "Here I am !"); > synchronized(MyServiceTest.this) { mDone = true; > MyServiceTest.this.notify(); } > } > }); > > svc.doStuffThatWillEventuallyCallBack(); > > synchronized(this) { > while (mDone == false) { > try { wait(); } catch (InterruptException e) {} > } > } > > } > > -- end paste -- > > "Here I am" is never logged, in this case and the call to adb shell am > never returns. I have verified that > doStuffThatWillEventuallyCallback() does actually return, and the test > thread enters the synchronized wait loop correctly. My suspicion is > that the binder's normal transaction thread loop is somehow not the > same in the context of an instrumented test, however I have no way to > validate this. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new Android 0.9 SDK beta! http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---