Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/VSyncMonitorTest.java

Issue 1166223003: [Android] Use the UI thread for VSyncMonitorTest vsync requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/javatests/src/org/chromium/content/browser/VSyncMonitorTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/VSyncMonitorTest.java b/content/public/android/javatests/src/org/chromium/content/browser/VSyncMonitorTest.java
index 61b9dfeaa6694e663f8a14dc97751505aa31285f..610ba0b716bc29417e946b72b860f43156aca042 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/VSyncMonitorTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/VSyncMonitorTest.java
@@ -43,6 +43,7 @@ public class VSyncMonitorTest extends InstrumentationTestCase {
@Override
public void onVSync(VSyncMonitor monitor, long vsyncTimeMicros) {
+ ThreadUtils.assertOnUiThread();
mLastVSyncCpuTimeMillis = SystemClock.uptimeMillis();
if (mPreviousVSyncTimeMicros == 0) {
mPreviousVSyncTimeMicros = vsyncTimeMicros;
@@ -81,6 +82,17 @@ public class VSyncMonitorTest extends InstrumentationTestCase {
});
}
+ // Vsync requests should be made on the same thread as that used to create the VSyncMonitor (the
+ // UI thread).
+ private void requestVSyncMonitorUpdate(final VSyncMonitor monitor) {
+ ThreadUtils.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ monitor.requestUpdate();
+ }
+ });
+ }
+
// Check that the vsync period roughly matches the timestamps that the monitor generates.
@MediumTest
public void testVSyncPeriod() throws InterruptedException {
@@ -92,7 +104,7 @@ public class VSyncMonitorTest extends InstrumentationTestCase {
assertTrue(reportedFramePeriod > 0);
assertFalse(collector.isDone());
- monitor.requestUpdate();
+ requestVSyncMonitorUpdate(monitor);
collector.waitTillDone();
assertTrue(collector.isDone());
@@ -122,7 +134,7 @@ public class VSyncMonitorTest extends InstrumentationTestCase {
VSyncDataCollector collector = new VSyncDataCollector(1);
VSyncMonitor monitor = createVSyncMonitor(collector);
- monitor.requestUpdate();
+ requestVSyncMonitorUpdate(monitor);
collector.waitTillDone();
assertTrue(collector.isDone());

Powered by Google App Engine
This is Rietveld 408576698