Skip to content

Commit df0b824

Browse files
committed
order test for readability
1 parent 295d537 commit df0b824

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

binder/src/test/java/io/grpc/binder/internal/RobolectricBinderTransportTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,13 @@ protected String testAuthority(InternalServer server) {
199199

200200
@Test
201201
public void clientAuthorizesServerUidsInOrder() throws Exception {
202-
serverAppInfo.uid = 11111;
202+
// TODO(jdcormie): In real Android, Binder#getCallingUid is thread-local but Robolectric only
203+
// lets us fake value this *globally*. So the ShadowBinder#setCallingUid() here unrealistically
204+
// affects the server's view of the client's uid too. For now this doesn't matter because this
205+
// test never exercises server SecurityPolicy.
206+
ShadowBinder.setCallingUid(11111); // UID of the server *process*.
207+
208+
serverPkgInfo.applicationInfo.uid = 22222; // UID of the server *app*, which can be different.
203209
shadowOf(application.getPackageManager()).installPackage(serverPkgInfo);
204210
shadowOf(application.getPackageManager()).addOrUpdateService(serviceInfo);
205211
server = newServer(Collections.emptyList());
@@ -213,23 +219,17 @@ public void clientAuthorizesServerUidsInOrder() throws Exception {
213219
.setSecurityPolicy(securityPolicy)
214220
.buildClientTransportFactory())
215221
.build();
216-
217-
// TODO(jdcormie): In real Android, Binder#getCallingUid is thread-local but Robolectric only
218-
// lets us fake value this *globally*. So the ShadowBinder#setCallingUid() here unrealistically
219-
// affects the server's view of the client's uid too. For now this doesn't matter because this
220-
// test never exercises server SecurityPolicy.
221-
ShadowBinder.setCallingUid(22222); // UID of the server *process* which != serverAppInfo.uid.
222222
runIfNotNull(client.start(mockClientTransportListener));
223223

224224
if (preAuthServersParam) {
225225
AuthRequest preAuthRequest = securityPolicy.takeNextAuthRequest(TIMEOUT_MS, MILLISECONDS);
226-
assertThat(preAuthRequest.uid).isEqualTo(serverAppInfo.uid);
226+
assertThat(preAuthRequest.uid).isEqualTo(22222);
227227
verify(mockClientTransportListener, never()).transportReady();
228228
preAuthRequest.setResult(Status.OK);
229229
}
230230

231231
AuthRequest authRequest = securityPolicy.takeNextAuthRequest(TIMEOUT_MS, MILLISECONDS);
232-
assertThat(authRequest.uid).isEqualTo(22222);
232+
assertThat(authRequest.uid).isEqualTo(11111);
233233
verify(mockClientTransportListener, never()).transportReady();
234234
authRequest.setResult(Status.OK);
235235

0 commit comments

Comments
 (0)