| 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 16c37f7831f53d62d1a71398e4f05bf80abedb1b..abb3976822a4c4d39aadc96b0760e751e364871d 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
|
| @@ -1,15 +1,20 @@
|
| -// Copyright 2012 The Chromium Authors. All rights reserved.
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| package org.chromium.content.browser;
|
|
|
| import android.content.Context;
|
| +import android.support.test.InstrumentationRegistry;
|
| import android.support.test.filters.MediumTest;
|
| -import android.test.InstrumentationTestCase;
|
| import android.view.WindowManager;
|
|
|
| +import org.junit.Assert;
|
| +import org.junit.Test;
|
| +import org.junit.runner.RunWith;
|
| +
|
| import org.chromium.base.ThreadUtils;
|
| +import org.chromium.base.test.BaseJUnit4ClassRunner;
|
| import org.chromium.base.test.util.DisabledTest;
|
| import org.chromium.ui.VSyncMonitor;
|
|
|
| @@ -19,7 +24,8 @@ import java.util.concurrent.Callable;
|
| /**
|
| * Tests VSyncMonitor to make sure it generates correct VSync timestamps.
|
| */
|
| -public class VSyncMonitorTest extends InstrumentationTestCase {
|
| +@RunWith(BaseJUnit4ClassRunner.class)
|
| +public class VSyncMonitorTest {
|
| private static final int FRAME_COUNT = 60;
|
|
|
| private static class VSyncDataCollector implements VSyncMonitor.Listener {
|
| @@ -74,7 +80,7 @@ public class VSyncMonitorTest extends InstrumentationTestCase {
|
| return ThreadUtils.runOnUiThreadBlockingNoException(new Callable<VSyncMonitor>() {
|
| @Override
|
| public VSyncMonitor call() {
|
| - Context context = getInstrumentation().getContext();
|
| + Context context = InstrumentationRegistry.getInstrumentation().getContext();
|
| return new VSyncMonitor(context, listener);
|
| }
|
| });
|
| @@ -92,6 +98,7 @@ public class VSyncMonitorTest extends InstrumentationTestCase {
|
| }
|
|
|
| // Check that the vsync period roughly matches the timestamps that the monitor generates.
|
| + @Test
|
| @MediumTest
|
| @DisabledTest(message = "crbug.com/674129")
|
| public void testVSyncPeriod() throws InterruptedException {
|
| @@ -100,30 +107,30 @@ public class VSyncMonitorTest extends InstrumentationTestCase {
|
| VSyncMonitor monitor = createVSyncMonitor(collector);
|
|
|
| long reportedFramePeriod = monitor.getVSyncPeriodInMicroseconds();
|
| - assertTrue(reportedFramePeriod > 0);
|
| + Assert.assertTrue(reportedFramePeriod > 0);
|
|
|
| - assertFalse(collector.isDone());
|
| + Assert.assertFalse(collector.isDone());
|
| requestVSyncMonitorUpdate(monitor);
|
| collector.waitTillDone();
|
| - assertTrue(collector.isDone());
|
| + Assert.assertTrue(collector.isDone());
|
|
|
| // Check that the median frame rate is within 10% of the reported frame period.
|
| - assertTrue(collector.mFrameCount == FRAME_COUNT - 1);
|
| + Assert.assertTrue(collector.mFrameCount == FRAME_COUNT - 1);
|
| Arrays.sort(collector.mFramePeriods, 0, collector.mFramePeriods.length);
|
| long medianFramePeriod = collector.mFramePeriods[collector.mFramePeriods.length / 2];
|
| if (Math.abs(medianFramePeriod - reportedFramePeriod) > reportedFramePeriod * .1) {
|
| - fail("Measured median frame period " + medianFramePeriod
|
| + Assert.fail("Measured median frame period " + medianFramePeriod
|
| + " differs by more than 10% from the reported frame period "
|
| + reportedFramePeriod + " for requested frames");
|
| }
|
|
|
| - Context context = getInstrumentation().getContext();
|
| + Context context = InstrumentationRegistry.getInstrumentation().getContext();
|
| float refreshRate = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
|
| .getDefaultDisplay().getRefreshRate();
|
| if (refreshRate < 30.0f) {
|
| // Reported refresh rate is most likely incorrect.
|
| // Estimated vsync period is expected to be lower than (1000000 / 30) microseconds
|
| - assertTrue(monitor.getVSyncPeriodInMicroseconds() < 1000000 / 30);
|
| + Assert.assertTrue(monitor.getVSyncPeriodInMicroseconds() < 1000000 / 30);
|
| }
|
| }
|
| }
|
|
|