| 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());
|
|
|
|
|