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

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

Issue 2708243004: Auto convert content shell tests to JUnit4 (Closed)
Patch Set: rebase Created 3 years, 9 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 16c37f7831f53d62d1a71398e4f05bf80abedb1b..ab26b15fd995797da1a190e2f7aa8a7d17424c73 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
@@ -5,11 +5,16 @@
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);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698