Loading apct-tests/perftests/contentcapture/src/android/view/contentcapture/AbstractContentCapturePerfTestCase.java +5 −0 Original line number Diff line number Diff line Loading @@ -248,6 +248,11 @@ public abstract class AbstractContentCapturePerfTestCase { return mServiceWatcher.waitOnCreate(); } /** Wait for session paused. */ public void waitForSessionPaused() throws InterruptedException { mServiceWatcher.waitSessionPaused(); } @NonNull protected ActivityWatcher startWatcher() { return mActivitiesWatcher.watch(CustomTestActivity.class); Loading apct-tests/perftests/contentcapture/src/android/view/contentcapture/LoginTest.java +60 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,34 @@ public class LoginTest extends AbstractContentCapturePerfTestCase { testActivityLaunchTime(R.layout.test_container_activity, 500); } @Test public void testSendEventsLatency() throws Throwable { enableService(); testSendEventLatency(R.layout.test_container_activity, 0); } @Test public void testSendEventsLatency_contains100Views() throws Throwable { enableService(); testSendEventLatency(R.layout.test_container_activity, 100); } @Test public void testSendEventsLatency_contains300Views() throws Throwable { enableService(); testSendEventLatency(R.layout.test_container_activity, 300); } @Test public void testSendEventsLatency_contains500Views() throws Throwable { enableService(); testSendEventLatency(R.layout.test_container_activity, 500); } private void testActivityLaunchTime(int layoutId, int numViews) throws Throwable { final Object drawNotifier = new Object(); final Intent intent = getLaunchIntent(layoutId, numViews); Loading Loading @@ -111,6 +139,38 @@ public class LoginTest extends AbstractContentCapturePerfTestCase { } } private void testSendEventLatency(int layoutId, int numViews) throws Throwable { final Object drawNotifier = new Object(); final Intent intent = getLaunchIntent(layoutId, numViews); intent.putExtra(CustomTestActivity.INTENT_EXTRA_FINISH_ON_IDLE, true); intent.putExtra(CustomTestActivity.INTENT_EXTRA_DRAW_CALLBACK, new RemoteCallback(result -> { synchronized (drawNotifier) { drawNotifier.notifyAll(); } })); final ActivityWatcher watcher = startWatcher(); final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { mEntryActivity.startActivity(intent); synchronized (drawNotifier) { try { drawNotifier.wait(GENERIC_TIMEOUT_MS); } catch (InterruptedException e) { throw new RuntimeException(e); } } waitForSessionPaused(); // Ignore the time to finish the activity state.pauseTiming(); watcher.waitFor(DESTROYED); sInstrumentation.waitForIdleSync(); state.resumeTiming(); } } @Test public void testOnVisibilityAggregated_visibleChanged() throws Throwable { enableService(); Loading apct-tests/perftests/contentcapture/src/android/view/contentcapture/MyContentCaptureService.java +10 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,10 @@ public class MyContentCaptureService extends ContentCaptureService { public void onContentCaptureEvent(ContentCaptureSessionId sessionId, ContentCaptureEvent event) { Log.i(TAG, "onContentCaptureEventsRequest(session=" + sessionId + "): " + event); if (sServiceWatcher != null && event.getType() == ContentCaptureEvent.TYPE_SESSION_PAUSED) { sServiceWatcher.mSessionPaused.countDown(); } } @Override Loading @@ -126,6 +130,7 @@ public class MyContentCaptureService extends ContentCaptureService { private static final long GENERIC_TIMEOUT_MS = 10_000; private final CountDownLatch mCreated = new CountDownLatch(1); private final CountDownLatch mDestroyed = new CountDownLatch(1); private final CountDownLatch mSessionPaused = new CountDownLatch(1); private boolean mReadyToClear = true; private Pair<Set<String>, Set<ComponentName>> mAllowList; Loading @@ -151,6 +156,11 @@ public class MyContentCaptureService extends ContentCaptureService { await(mDestroyed, "not destroyed"); } /** Wait for session paused. */ public void waitSessionPaused() throws InterruptedException { await(mSessionPaused, "no Paused"); } /** * Allow just this package. */ Loading Loading
apct-tests/perftests/contentcapture/src/android/view/contentcapture/AbstractContentCapturePerfTestCase.java +5 −0 Original line number Diff line number Diff line Loading @@ -248,6 +248,11 @@ public abstract class AbstractContentCapturePerfTestCase { return mServiceWatcher.waitOnCreate(); } /** Wait for session paused. */ public void waitForSessionPaused() throws InterruptedException { mServiceWatcher.waitSessionPaused(); } @NonNull protected ActivityWatcher startWatcher() { return mActivitiesWatcher.watch(CustomTestActivity.class); Loading
apct-tests/perftests/contentcapture/src/android/view/contentcapture/LoginTest.java +60 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,34 @@ public class LoginTest extends AbstractContentCapturePerfTestCase { testActivityLaunchTime(R.layout.test_container_activity, 500); } @Test public void testSendEventsLatency() throws Throwable { enableService(); testSendEventLatency(R.layout.test_container_activity, 0); } @Test public void testSendEventsLatency_contains100Views() throws Throwable { enableService(); testSendEventLatency(R.layout.test_container_activity, 100); } @Test public void testSendEventsLatency_contains300Views() throws Throwable { enableService(); testSendEventLatency(R.layout.test_container_activity, 300); } @Test public void testSendEventsLatency_contains500Views() throws Throwable { enableService(); testSendEventLatency(R.layout.test_container_activity, 500); } private void testActivityLaunchTime(int layoutId, int numViews) throws Throwable { final Object drawNotifier = new Object(); final Intent intent = getLaunchIntent(layoutId, numViews); Loading Loading @@ -111,6 +139,38 @@ public class LoginTest extends AbstractContentCapturePerfTestCase { } } private void testSendEventLatency(int layoutId, int numViews) throws Throwable { final Object drawNotifier = new Object(); final Intent intent = getLaunchIntent(layoutId, numViews); intent.putExtra(CustomTestActivity.INTENT_EXTRA_FINISH_ON_IDLE, true); intent.putExtra(CustomTestActivity.INTENT_EXTRA_DRAW_CALLBACK, new RemoteCallback(result -> { synchronized (drawNotifier) { drawNotifier.notifyAll(); } })); final ActivityWatcher watcher = startWatcher(); final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { mEntryActivity.startActivity(intent); synchronized (drawNotifier) { try { drawNotifier.wait(GENERIC_TIMEOUT_MS); } catch (InterruptedException e) { throw new RuntimeException(e); } } waitForSessionPaused(); // Ignore the time to finish the activity state.pauseTiming(); watcher.waitFor(DESTROYED); sInstrumentation.waitForIdleSync(); state.resumeTiming(); } } @Test public void testOnVisibilityAggregated_visibleChanged() throws Throwable { enableService(); Loading
apct-tests/perftests/contentcapture/src/android/view/contentcapture/MyContentCaptureService.java +10 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,10 @@ public class MyContentCaptureService extends ContentCaptureService { public void onContentCaptureEvent(ContentCaptureSessionId sessionId, ContentCaptureEvent event) { Log.i(TAG, "onContentCaptureEventsRequest(session=" + sessionId + "): " + event); if (sServiceWatcher != null && event.getType() == ContentCaptureEvent.TYPE_SESSION_PAUSED) { sServiceWatcher.mSessionPaused.countDown(); } } @Override Loading @@ -126,6 +130,7 @@ public class MyContentCaptureService extends ContentCaptureService { private static final long GENERIC_TIMEOUT_MS = 10_000; private final CountDownLatch mCreated = new CountDownLatch(1); private final CountDownLatch mDestroyed = new CountDownLatch(1); private final CountDownLatch mSessionPaused = new CountDownLatch(1); private boolean mReadyToClear = true; private Pair<Set<String>, Set<ComponentName>> mAllowList; Loading @@ -151,6 +156,11 @@ public class MyContentCaptureService extends ContentCaptureService { await(mDestroyed, "not destroyed"); } /** Wait for session paused. */ public void waitSessionPaused() throws InterruptedException { await(mSessionPaused, "no Paused"); } /** * Allow just this package. */ Loading