Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1517)

Unified Diff: mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java

Issue 514293002: Mojo: validate nullability in Java bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix line length in mojom_java_generator in a way that works. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java
diff --git a/mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java b/mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java
index 8944b82a82b0587255b3b13dea8c837080290873..d899834313b206ac0e087458f08d300a4b88865b 100644
--- a/mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java
+++ b/mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java
@@ -40,7 +40,7 @@ public class InterfacesTest extends MojoTestCase {
*/
public static class MockNamedObjectImpl extends CapturingErrorHandler implements NamedObject {
- private String mName;
+ private String mName = "";
/**
* @see org.chromium.mojo.bindings.Interface#close()
@@ -123,14 +123,16 @@ public class InterfacesTest extends MojoTestCase {
@Override
public void doStuff(Request request, MessagePipeHandle pipe) {
+ if (pipe != null) {
+ pipe.close();
+ }
+ Response response = new Response();
+ response.x = 42;
+ mFactoryClient.didStuff(response, "Hello");
}
@Override
public void doStuff2(ConsumerHandle pipe) {
- if (pipe != null) {
- pipe.close();
- }
- mFactoryClient.didStuff2("Hello");
}
@Override
@@ -157,14 +159,14 @@ public class InterfacesTest extends MojoTestCase {
public static class MockFactoryClientImpl implements FactoryClient {
private boolean mClosed = false;
- private boolean mDidStuff2Called = false;
+ private boolean mDidStuffCalled = false;
public boolean isClosed() {
return mClosed;
}
- public boolean wasDidStuff2Called() {
- return mDidStuff2Called;
+ public boolean wasDidStuffCalled() {
+ return mDidStuffCalled;
}
/**
@@ -187,6 +189,7 @@ public class InterfacesTest extends MojoTestCase {
*/
@Override
public void didStuff(Response response, String text) {
+ mDidStuffCalled = true;
}
/**
@@ -194,7 +197,6 @@ public class InterfacesTest extends MojoTestCase {
*/
@Override
public void didStuff2(String text) {
- mDidStuff2Called = true;
}
}
@@ -246,7 +248,7 @@ public class InterfacesTest extends MojoTestCase {
if (impl != null) {
assertNull(impl.getLastMojoException());
- assertNull(impl.getNameSynchronously());
+ assertEquals("", impl.getNameSynchronously());
}
proxy.getName(callback);
@@ -254,7 +256,7 @@ public class InterfacesTest extends MojoTestCase {
assertNull(errorHandler.getLastMojoException());
assertTrue(callback.wasCalled());
- assertNull(callback.getName());
+ assertEquals("", callback.getName());
callback.reset();
proxy.setName(NAME);
@@ -325,12 +327,14 @@ public class InterfacesTest extends MojoTestCase {
MockFactoryClientImpl client = new MockFactoryClientImpl();
Factory.Proxy proxy = newProxyOverPipeWithClient(
Factory.MANAGER, impl, client);
- proxy.doStuff2(null);
+ Request request = new Request();
+ request.x = 42;
+ proxy.doStuff(request, null);
- assertFalse(client.wasDidStuff2Called());
+ assertFalse(client.wasDidStuffCalled());
nativeRunLoop(RUN_LOOP_TIMEOUT_MS);
- assertTrue(client.wasDidStuff2Called());
+ assertTrue(client.wasDidStuffCalled());
}
}

Powered by Google App Engine
This is Rietveld 408576698