From: Jason Monk Date: Fri, 28 Apr 2017 19:53:59 +0000 (-0400) Subject: Fix flaky test? X-Git-Tag: android-x86-9.0-r1~1044^2~1201^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1660a27b5d682cbb0bd9e2ce66e5ca39d6ab7816;p=android-x86%2Fframeworks-base.git Fix flaky test? - Fix testAttachDetach, process more messages so it actually does attach and detach - Don't inflate Clocks in QSFragmentTest because they are doing something weird... Test: runtest systemui Change-Id: I05360630ee8d96158b6ab36660f20588ad158a28 Fixes: 37773362 --- diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java index 673ffc5d0fbf..d81224e8507d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java @@ -32,6 +32,7 @@ import android.testing.AndroidTestingRunner; import com.android.systemui.SysuiBaseFragmentTest; import com.android.systemui.statusbar.phone.StatusBarIconController; +import com.android.systemui.statusbar.policy.Clock; import com.android.systemui.statusbar.policy.UserSwitcherController; import android.testing.LayoutInflaterBuilder; import android.testing.TestableLooper; @@ -64,6 +65,7 @@ public class QSFragmentTest extends SysuiBaseFragmentTest { FrameLayout.class) .replace("TextClock", View.class) .replace(CarrierText.class, View.class) + .replace(Clock.class, View.class) .build()); mDependency.injectTestDependency(Dependency.BG_LOOPER, diff --git a/tests/testables/src/android/testing/BaseFragmentTest.java b/tests/testables/src/android/testing/BaseFragmentTest.java index b09bcde897d7..32ee091a46c9 100644 --- a/tests/testables/src/android/testing/BaseFragmentTest.java +++ b/tests/testables/src/android/testing/BaseFragmentTest.java @@ -161,12 +161,12 @@ public abstract class BaseFragmentTest { protected void attachFragmentToWindow() { ViewUtils.attachView(mView); - TestableLooper.get(this).processMessages(1); + TestableLooper.get(this).processAllMessages(); } protected void detachFragmentToWindow() { ViewUtils.detachView(mView); - TestableLooper.get(this).processMessages(1); + TestableLooper.get(this).processAllMessages(); } protected void destroyFragments() {