Unverified Commit bce5574c authored by Mikkel Nygaard Ravn's avatar Mikkel Nygaard Ravn Committed by GitHub

Remove test flakiness (#13252)

parent 368c1251
......@@ -52,8 +52,11 @@ public class MainActivity extends FlutterActivity {
producerTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
renderer.drawFrame();
framesProduced.incrementAndGet();
final long time = System.currentTimeMillis();
if (frameRate(framesProduced, startTime, time) < fps) {
renderer.drawFrame();
framesProduced.incrementAndGet();
}
}
}, 0, 1000 / fps);
consumerTimer = new Timer();
......@@ -78,13 +81,14 @@ public class MainActivity extends FlutterActivity {
producerTimer.cancel();
consumerTimer.cancel();
endTime = System.currentTimeMillis();
Log.e("TET", "Stopped at " + endTime);
result.success(null);
break;
case "getProducedFrameRate":
result.success(framesProduced.get() * 1000 / (double) (endTime - startTime));
result.success(frameRate(framesProduced, startTime, endTime));
break;
case "getConsumedFrameRate":
result.success(framesConsumed.get() * 1000 / (double) (endTime - startTime));
result.success(frameRate(framesConsumed, startTime, endTime));
break;
default: result.notImplemented();
}
......@@ -110,6 +114,10 @@ public class MainActivity extends FlutterActivity {
});
}
double frameRate(AtomicInteger frameCounter, long startTime, long endTime) {
return frameCounter.get() * 1000 / (double) (endTime - startTime);
}
@Override
protected void onDestroy() {
if (surface != null) {
......
......@@ -55,7 +55,7 @@ Future<Null> main() async {
final String statsFast = await driver.getText(summary);
final Match matchFast = statsRegExp.matchAsPrefix(statsFast);
expect(matchFast, isNotNull);
expect(double.parse(matchFast.group(1)), closeTo(flutterFrameRate * 2.0, 10.0));
expect(double.parse(matchFast.group(1)), closeTo(flutterFrameRate * 2.0, 5.0));
expect(double.parse(matchFast.group(2)), closeTo(flutterFrameRate, 10.0));
expect(int.parse(matchFast.group(3)), 1);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment