Merge "[AWARE] CTS for failure mode of send message API" am: f138c95d1f
am: 3ceb23d6ca
Change-Id: I32956bbfd809dd92a1062b868dbb66377210ef02
This commit is contained in:
@@ -75,7 +75,7 @@ public class SingleDeviceTest extends AndroidTestCase {
|
|||||||
boolean waitForStateChange() throws InterruptedException {
|
boolean waitForStateChange() throws InterruptedException {
|
||||||
return mBlocker.await(WAIT_FOR_AWARE_CHANGE_SECS, TimeUnit.SECONDS);
|
return mBlocker.await(WAIT_FOR_AWARE_CHANGE_SECS, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
private class AttachCallbackTest extends AttachCallback {
|
private class AttachCallbackTest extends AttachCallback {
|
||||||
static final int ATTACHED = 0;
|
static final int ATTACHED = 0;
|
||||||
@@ -289,7 +289,6 @@ public class SingleDeviceTest extends AndroidTestCase {
|
|||||||
mSubscribeDiscoverySession = null;
|
mSubscribeDiscoverySession = null;
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -528,9 +527,43 @@ public class SingleDeviceTest extends AndroidTestCase {
|
|||||||
session.destroy();
|
session.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the send message flow. Since testing single device cannot send to a real peer -
|
||||||
|
* validate that sending to a bogus peer fails.
|
||||||
|
*/
|
||||||
|
public void testSendMessageFail() {
|
||||||
|
if (!TestUtils.shouldTestWifiAware(getContext())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WifiAwareSession session = attachAndGetSession();
|
||||||
|
|
||||||
|
PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(
|
||||||
|
"ValidName").build();
|
||||||
|
DiscoverySessionCallbackTest discoveryCb = new DiscoverySessionCallbackTest();
|
||||||
|
|
||||||
|
// 1. publish
|
||||||
|
session.publish(publishConfig, discoveryCb, null);
|
||||||
|
assertTrue("Publish started",
|
||||||
|
discoveryCb.waitForCallback(DiscoverySessionCallbackTest.ON_PUBLISH_STARTED));
|
||||||
|
PublishDiscoverySession discoverySession = discoveryCb.getPublishDiscoverySession();
|
||||||
|
assertNotNull("Publish session", discoverySession);
|
||||||
|
|
||||||
|
// 2. send a message with a null peer-handle - expect exception
|
||||||
|
try {
|
||||||
|
discoverySession.sendMessage(null, -1290, "some message".getBytes());
|
||||||
|
fail("Expected IllegalArgumentException");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
discoverySession.destroy();
|
||||||
|
session.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
// local utilities
|
// local utilities
|
||||||
|
|
||||||
WifiAwareSession attachAndGetSession() {
|
private WifiAwareSession attachAndGetSession() {
|
||||||
AttachCallbackTest attachCb = new AttachCallbackTest();
|
AttachCallbackTest attachCb = new AttachCallbackTest();
|
||||||
mWifiAwareManager.attach(attachCb, null);
|
mWifiAwareManager.attach(attachCb, null);
|
||||||
int cbCalled = attachCb.waitForAnyCallback();
|
int cbCalled = attachCb.waitForAnyCallback();
|
||||||
|
|||||||
Reference in New Issue
Block a user