From 732becfd664b243dea7507d568654b97efd211a6 Mon Sep 17 00:00:00 2001 From: vadimt Date: Fri, 10 May 2019 12:12:44 -0700 Subject: Tests: attempt to wait until navigation mode settles after switching Change-Id: If2d14a062275a6cfbc81d1cb7d7ca38da302b51c --- .../launcher3/tapl/LauncherInstrumentation.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'tests/tapl') diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 4d8ff1bb2..0d8d92c88 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -176,17 +176,19 @@ public final class LauncherInstrumentation { // Workaround, use constructed context because both the instrumentation context and the // app context are not constructed with resources that take overlays into account final Context ctx = baseContext.createPackageContext("android", 0); - log("Interaction mode = " + getCurrentInteractionMode(ctx)); - if (isGesturalMode(ctx)) { - return NavigationModel.ZERO_BUTTON; - } else if (isSwipeUpMode(ctx)) { - return NavigationModel.TWO_BUTTON; - } else if (isLegacyMode(ctx)) { - return NavigationModel.THREE_BUTTON; - } else { - fail("Can't detect navigation mode"); + for (int i = 0; i < 100; ++i) { + log("Interaction mode = " + getCurrentInteractionMode(ctx)); + if (isGesturalMode(ctx)) { + return NavigationModel.ZERO_BUTTON; + } else if (isSwipeUpMode(ctx)) { + return NavigationModel.TWO_BUTTON; + } else if (isLegacyMode(ctx)) { + return NavigationModel.THREE_BUTTON; + } + Thread.sleep(100); } - } catch (PackageManager.NameNotFoundException e) { + fail("Can't detect navigation mode"); + } catch (Exception e) { fail(e.toString()); } return NavigationModel.THREE_BUTTON; -- cgit v1.2.3