@Test public void testReceiveString() throws Exception { Pig pig = PigTestUtils.getMockedPiggie(); PigTestUtils.addMockHandler(pig, new MockWebViewWrapper.Handler(pig) { public void handle(String data) { send("A String"); } }); stringReceived = false; stringReceivedError = null; stringReceivedResponse = null; final CountDownLatch lock = new CountDownLatch(1); pig.execute("event", new Pig.Callback<String>() { @Override public void onSuccess(String response) { stringReceived = true; stringReceivedError = null; stringReceivedResponse = response; lock.countDown(); } @Override public void onError(String code, String name, String message) { stringReceived = true; stringReceivedError = message; stringReceivedResponse = null; lock.countDown(); } }); lock.await(2000, TimeUnit.MILLISECONDS); assertTrue(stringReceived); assertTrue(stringReceivedError == null); assertTrue(stringReceivedResponse.equals("A String")); }
public void execute(String path) { execute(path, (String) null, (Type) null, (Callback) null); }
Pig { public void execute(String path) { execute(path, (String) null, (Type) null, (Callback) null); } }
Pig { public void execute(String path) { execute(path, (String) null, (Type) null, (Callback) null); } private  Pig(Context context);   Pig(Context context, WebViewWrapper webViewWrapper); }
Pig { public void execute(String path) { execute(path, (String) null, (Type) null, (Callback) null); } private  Pig(Context context);   Pig(Context context, WebViewWrapper webViewWrapper); static Pig get(Context context); void execute(String path); void execute(String path, Callback<R> callback); void execute(String path, Object data, Callback<R> callback); @SuppressWarnings("unchecked") // We are checking the type before casting void execute(String path, Type dataClass, D data, Callback<R> callback); void execute(String path, Type responseType, Callback<R> callback); void execute(String path, D data, Type responseType, Callback<R> callback); void execute(String path, Type dataType, D data, Type responseType, Callback<R> callback); void execute(String path, String json, Type responseType, Callback<R> callback); synchronized void addListener(String event, EventListener listener); synchronized void removeListener(String event, EventListener listener); void emit(String event); void emit(String event, String data); }
Pig { public void execute(String path) { execute(path, (String) null, (Type) null, (Callback) null); } private  Pig(Context context);   Pig(Context context, WebViewWrapper webViewWrapper); static Pig get(Context context); void execute(String path); void execute(String path, Callback<R> callback); void execute(String path, Object data, Callback<R> callback); @SuppressWarnings("unchecked") // We are checking the type before casting void execute(String path, Type dataClass, D data, Callback<R> callback); void execute(String path, Type responseType, Callback<R> callback); void execute(String path, D data, Type responseType, Callback<R> callback); void execute(String path, Type dataType, D data, Type responseType, Callback<R> callback); void execute(String path, String json, Type responseType, Callback<R> callback); synchronized void addListener(String event, EventListener listener); synchronized void removeListener(String event, EventListener listener); void emit(String event); void emit(String event, String data);  }