Loading services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java +128 −135 File changed.Preview size limit exceeded, changes collapsed. Show changes services/tests/servicestests/utils/com/android/server/testutils/TestUtils.java +23 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.server.testutils; import android.os.Message; import android.os.TestLooperManager; import android.test.MoreAsserts; import junit.framework.Assert; Loading Loading @@ -60,4 +62,25 @@ public class TestUtils { throw new AssertionError("Unexpected invocation: " + invocation); }); } /** * Dispatch all the ready looper messages. The loopers might depend on each other and send * messages to each other, so this method loops through all of them until there are no ready * messages left in any of them. * @param tlms The test looper managers */ public static void flushLoopers(TestLooperManager... tlms) { boolean noMoreMessages; do { noMoreMessages = true; for (TestLooperManager tlm : tlms) { Message m = tlm.poll(); if (m != null) { tlm.execute(m); tlm.recycle(m); noMoreMessages = false; } } } while(!noMoreMessages); } } Loading
services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java +128 −135 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/tests/servicestests/utils/com/android/server/testutils/TestUtils.java +23 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.server.testutils; import android.os.Message; import android.os.TestLooperManager; import android.test.MoreAsserts; import junit.framework.Assert; Loading Loading @@ -60,4 +62,25 @@ public class TestUtils { throw new AssertionError("Unexpected invocation: " + invocation); }); } /** * Dispatch all the ready looper messages. The loopers might depend on each other and send * messages to each other, so this method loops through all of them until there are no ready * messages left in any of them. * @param tlms The test looper managers */ public static void flushLoopers(TestLooperManager... tlms) { boolean noMoreMessages; do { noMoreMessages = true; for (TestLooperManager tlm : tlms) { Message m = tlm.poll(); if (m != null) { tlm.execute(m); tlm.recycle(m); noMoreMessages = false; } } } while(!noMoreMessages); } }