Loading InCallUI/src/com/android/incallui/async/PausableExecutor.java +8 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,14 @@ public interface PausableExecutor extends Executor { @NeededForTesting void ackMilestoneForTesting(); /** * Method called from the test code to inform this executor that the tests are finished with all * milestones. Future calls to {@link #milestone()} or {@link #awaitMilestoneForTesting()} * should return immediately. */ @NeededForTesting void ackAllMilestonesForTesting(); /** * Method called from the test code to block until a milestone has been reached in the * production code. Loading InCallUI/src/com/android/incallui/async/PausableExecutorImpl.java +3 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,9 @@ public class PausableExecutorImpl implements PausableExecutor { @Override public void ackMilestoneForTesting() {} @Override public void ackAllMilestonesForTesting() {} @Override public void awaitMilestoneForTesting() {} Loading InCallUI/tests/src/com/android/incallui/async/SingleProdThreadExecutor.java +9 −2 Original line number Diff line number Diff line Loading @@ -30,12 +30,13 @@ public final class SingleProdThreadExecutor implements PausableExecutor { private int mMilestonesReached; private int mMilestonesAcked; private boolean mHasAckedAllMilestones; @Override public synchronized void milestone() { ++mMilestonesReached; notify(); while (mMilestonesReached > mMilestonesAcked) { while (!mHasAckedAllMilestones && mMilestonesReached > mMilestonesAcked) { try { wait(); } catch (InterruptedException e) {} Loading @@ -48,9 +49,15 @@ public final class SingleProdThreadExecutor implements PausableExecutor { notify(); } @Override public synchronized void ackAllMilestonesForTesting() { mHasAckedAllMilestones = true; notify(); } @Override public synchronized void awaitMilestoneForTesting() throws InterruptedException { while (mMilestonesReached <= mMilestonesAcked) { while (!mHasAckedAllMilestones && mMilestonesReached <= mMilestonesAcked) { wait(); } } Loading InCallUI/tests/src/com/android/incallui/ringtone/InCallTonePlayerTest.java +2 −5 Original line number Diff line number Diff line Loading @@ -61,11 +61,8 @@ public class InCallTonePlayerTest extends AndroidTestCase { super.tearDown(); // Stop any playing so the InCallTonePlayer isn't stuck waiting for the tone to complete mInCallTonePlayer.stop(); // 3 milestones in InCallTonePlayer, ack them to ensure that the prod thread doesn't block // forever. It's fine to ack for more milestones than are hit mExecutor.ackMilestoneForTesting(); mExecutor.ackMilestoneForTesting(); mExecutor.ackMilestoneForTesting(); // Ack all milestones to ensure that the prod thread doesn't block forever mExecutor.ackAllMilestonesForTesting(); } public void testIsPlayingTone_False() { Loading Loading
InCallUI/src/com/android/incallui/async/PausableExecutor.java +8 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,14 @@ public interface PausableExecutor extends Executor { @NeededForTesting void ackMilestoneForTesting(); /** * Method called from the test code to inform this executor that the tests are finished with all * milestones. Future calls to {@link #milestone()} or {@link #awaitMilestoneForTesting()} * should return immediately. */ @NeededForTesting void ackAllMilestonesForTesting(); /** * Method called from the test code to block until a milestone has been reached in the * production code. Loading
InCallUI/src/com/android/incallui/async/PausableExecutorImpl.java +3 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,9 @@ public class PausableExecutorImpl implements PausableExecutor { @Override public void ackMilestoneForTesting() {} @Override public void ackAllMilestonesForTesting() {} @Override public void awaitMilestoneForTesting() {} Loading
InCallUI/tests/src/com/android/incallui/async/SingleProdThreadExecutor.java +9 −2 Original line number Diff line number Diff line Loading @@ -30,12 +30,13 @@ public final class SingleProdThreadExecutor implements PausableExecutor { private int mMilestonesReached; private int mMilestonesAcked; private boolean mHasAckedAllMilestones; @Override public synchronized void milestone() { ++mMilestonesReached; notify(); while (mMilestonesReached > mMilestonesAcked) { while (!mHasAckedAllMilestones && mMilestonesReached > mMilestonesAcked) { try { wait(); } catch (InterruptedException e) {} Loading @@ -48,9 +49,15 @@ public final class SingleProdThreadExecutor implements PausableExecutor { notify(); } @Override public synchronized void ackAllMilestonesForTesting() { mHasAckedAllMilestones = true; notify(); } @Override public synchronized void awaitMilestoneForTesting() throws InterruptedException { while (mMilestonesReached <= mMilestonesAcked) { while (!mHasAckedAllMilestones && mMilestonesReached <= mMilestonesAcked) { wait(); } } Loading
InCallUI/tests/src/com/android/incallui/ringtone/InCallTonePlayerTest.java +2 −5 Original line number Diff line number Diff line Loading @@ -61,11 +61,8 @@ public class InCallTonePlayerTest extends AndroidTestCase { super.tearDown(); // Stop any playing so the InCallTonePlayer isn't stuck waiting for the tone to complete mInCallTonePlayer.stop(); // 3 milestones in InCallTonePlayer, ack them to ensure that the prod thread doesn't block // forever. It's fine to ack for more milestones than are hit mExecutor.ackMilestoneForTesting(); mExecutor.ackMilestoneForTesting(); mExecutor.ackMilestoneForTesting(); // Ack all milestones to ensure that the prod thread doesn't block forever mExecutor.ackAllMilestonesForTesting(); } public void testIsPlayingTone_False() { Loading