Skip to content

Commit 3a2dfd9

Browse files
Restarted from scratch; turns out we needed lots of this code for the browser testing still.
1 parent a227b6f commit 3a2dfd9

File tree

2 files changed

+6
-86
lines changed

2 files changed

+6
-86
lines changed

java/test/android/controller/src/main/java/com/zeroc/testcontroller/ControllerApp.java

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
import android.os.Build;
1010
import android.util.Log;
1111

12-
import Test.Common.ProcessControllerPrx;
13-
import Test.Common.ProcessControllerRegistryPrx;
14-
1512
import com.zeroc.Ice.Communicator;
1613
import com.zeroc.Ice.Logger;
1714
import com.zeroc.Ice.Time;
@@ -195,77 +192,8 @@ public ControllerI(boolean bluetooth) {
195192

196193
_communicator = new com.zeroc.Ice.Communicator(initData);
197194
com.zeroc.Ice.ObjectAdapter adapter = _communicator.createObjectAdapter("ControllerAdapter");
198-
ProcessControllerPrx processController =
199-
ProcessControllerPrx.uncheckedCast(
200-
adapter.add(
201-
new ProcessControllerI(),
202-
com.zeroc.Ice.Util.stringToIdentity("Android/ProcessController")));
195+
adapter.add(new ProcessControllerI(), new com.zeroc.Ice.Identity("ProcessController", "Android"));
203196
adapter.activate();
204-
205-
if (!isEmulator())
206-
{
207-
// Use IceDiscovery to find a process controller registry
208-
ProcessControllerRegistryPrx registry =
209-
ProcessControllerRegistryPrx.createProxy(_communicator, "Util/ProcessControllerRegistry");
210-
registerProcessController(adapter, registry, processController);
211-
}
212-
}
213-
214-
public void registerProcessController(
215-
final com.zeroc.Ice.ObjectAdapter adapter,
216-
final ProcessControllerRegistryPrx registry,
217-
final ProcessControllerPrx processController) {
218-
registry.ice_pingAsync()
219-
.whenCompleteAsync(
220-
(r1, e1) -> {
221-
if (e1 != null) {
222-
handleException(e1, adapter, registry, processController);
223-
} else {
224-
com.zeroc.Ice.Connection connection = registry.ice_getConnection();
225-
connection.setAdapter(adapter);
226-
connection.setCloseCallback(
227-
con -> {
228-
println("connection with process controller registry closed");
229-
while (true) {
230-
try {
231-
Thread.sleep(500);
232-
break;
233-
} catch (InterruptedException e) {
234-
// Ignore and try again.
235-
}
236-
}
237-
registerProcessController(adapter, registry, processController);
238-
});
239-
240-
registry.setProcessControllerAsync(processController)
241-
.whenCompleteAsync(
242-
(r2, e2) -> {
243-
if (e2 != null) {
244-
handleException(e2, adapter, registry, processController);
245-
}
246-
});
247-
}
248-
});
249-
}
250-
251-
public void handleException(
252-
Throwable ex,
253-
final com.zeroc.Ice.ObjectAdapter adapter,
254-
final ProcessControllerRegistryPrx registry,
255-
final ProcessControllerPrx processController) {
256-
if (ex instanceof com.zeroc.Ice.ConnectFailedException || ex instanceof com.zeroc.Ice.TimeoutException) {
257-
while (true) {
258-
try {
259-
Thread.sleep(500);
260-
break;
261-
} catch (InterruptedException e) {
262-
// Ignore and try again.
263-
}
264-
}
265-
registerProcessController(adapter, registry, processController);
266-
} else {
267-
println(ex.toString());
268-
}
269197
}
270198

271199
public void destroy() {

scripts/Util.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,7 +2378,6 @@ def getController(self, current):
23782378

23792379
if controllerEndpoints is not None:
23802380
proxy = Test.Common.ProcessControllerPrx(comm, f"{comm.identityToString(ident)}:{controllerEndpoints}")
2381-
23822381
else:
23832382
# Use well-known proxy and IceDiscovery to discover the process controller object from the app.
23842383
proxy = Test.Common.ProcessControllerPrx(comm, comm.identityToString(ident))
@@ -2402,10 +2401,8 @@ def callback(future):
24022401
while nRetry < 120:
24032402
nRetry += 1
24042403

2405-
# If the process controller supports discovery or if we have a direct endpoint to it, try to
2406-
# ping it. This can take a few tries as the controller app might still be starting.
2407-
if self.supportsDiscovery() or controllerEndpoints is not None:
2408-
proxy.ice_pingAsync().add_done_callback(callback)
2404+
# try to ping the controller. This can take a few tries as the controller app might still be starting.
2405+
proxy.ice_pingAsync().add_done_callback(callback)
24092406

24102407
with self.cond:
24112408
if ident not in self.processControllerProxies:
@@ -2498,13 +2495,8 @@ def destroy(self, driver):
24982495

24992496
class AndroidProcessController(RemoteProcessController):
25002497
def __init__(self, current):
2501-
endpoint = None
2502-
self.forwardPort = None
2503-
if current.config.device:
2504-
endpoint = "tcp -h 0.0.0.0 -p 15001"
2505-
elif current.config.avd or not current.config.device:
2506-
self.forwardPort = "15001"
2507-
RemoteProcessController.__init__(self, current, endpoint)
2498+
RemoteProcessController.__init__(self, current, "")
2499+
self.forwardPort = "15001" if not current.config.device and current.config.avd else None
25082500
self.device = current.config.device if current.config.device != "" else None
25092501
self.avd = current.config.avd
25102502
self.emulator = None # Keep a reference to the android emulator process
@@ -2544,7 +2536,7 @@ def startEmulator(self, avd):
25442536
raise RuntimeError("couldn't find AVD `{}'".format(avd))
25452537

25462538
#
2547-
# Find and unused port to run android emulator, between 5554 and 5584
2539+
# Find an unused port to run android emulator, between 5554 and 5584
25482540
#
25492541
port = -1
25502542
out = run("adb devices -l")

0 commit comments

Comments
 (0)