| 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..fb5b0cd52d6cafbd5e30e85a0dba3d01a04991af 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,4 +1,4 @@
|
| -// 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.
|
|
|
| @@ -6,7 +6,6 @@ package org.chromium.content.browser;
|
|
|
| import android.content.Context;
|
| import android.support.test.filters.MediumTest;
|
| -import android.test.InstrumentationTestCase;
|
| import android.view.WindowManager;
|
|
|
| import org.chromium.base.ThreadUtils;
|
| @@ -15,11 +14,17 @@ import org.chromium.ui.VSyncMonitor;
|
|
|
| import java.util.Arrays;
|
| import java.util.concurrent.Callable;
|
| +import org.junit.Test;
|
| +import org.chromium.base.test.BaseJUnit4ClassRunner;
|
| +import org.junit.runner.RunWith;
|
| +import android.support.test.InstrumentationRegistry;
|
| +import org.junit.Assert;
|
|
|
| /**
|
| * 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 +79,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 +97,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 +106,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);
|
| }
|
| }
|
| }
|
|
|