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

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

Issue 611313003: Use estimated vsync period on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused constant Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/android/java/src/org/chromium/ui/VSyncMonitor.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.SystemClock; 8 import android.os.SystemClock;
9 import android.test.InstrumentationTestCase; 9 import android.test.InstrumentationTestCase;
10 import android.test.suitebuilder.annotation.MediumTest; 10 import android.test.suitebuilder.annotation.MediumTest;
11 import android.view.WindowManager;
11 12
12 import org.chromium.base.ThreadUtils; 13 import org.chromium.base.ThreadUtils;
13 import org.chromium.ui.VSyncMonitor; 14 import org.chromium.ui.VSyncMonitor;
14 15
15 import java.util.Arrays; 16 import java.util.Arrays;
16 import java.util.concurrent.Callable; 17 import java.util.concurrent.Callable;
17 18
18 /** 19 /**
19 * Tests VSyncMonitor to make sure it generates correct VSync timestamps. 20 * Tests VSyncMonitor to make sure it generates correct VSync timestamps.
20 */ 21 */
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 102
102 // Check that the median frame rate is within 10% of the reported frame period. 103 // Check that the median frame rate is within 10% of the reported frame period.
103 assertTrue(collector.mFrameCount == totalFrames - 1); 104 assertTrue(collector.mFrameCount == totalFrames - 1);
104 Arrays.sort(collector.mFramePeriods, 0, collector.mFramePeriods.length); 105 Arrays.sort(collector.mFramePeriods, 0, collector.mFramePeriods.length);
105 long medianFramePeriod = collector.mFramePeriods[collector.mFramePeriods .length / 2]; 106 long medianFramePeriod = collector.mFramePeriods[collector.mFramePeriods .length / 2];
106 if (Math.abs(medianFramePeriod - reportedFramePeriod) > reportedFramePer iod * .1) { 107 if (Math.abs(medianFramePeriod - reportedFramePeriod) > reportedFramePer iod * .1) {
107 fail("Measured median frame period " + medianFramePeriod 108 fail("Measured median frame period " + medianFramePeriod
108 + " differs by more than 10% from the reported frame period " 109 + " differs by more than 10% from the reported frame period "
109 + reportedFramePeriod + " for requested frames"); 110 + reportedFramePeriod + " for requested frames");
110 } 111 }
112
113 if (enableJBVSync) {
114 Context context = getInstrumentation().getContext();
115 float refreshRate = ((WindowManager) context.getSystemService(Contex t.WINDOW_SERVICE))
116 .getDefaultDisplay().getRefreshRate();
117 if (refreshRate < 30.0f) {
118 // Reported refresh rate is most likely incorrect.
119 // Estimated vsync period is expected to be lower than (1000000 / 30) microseconds
120 assertTrue(monitor.getVSyncPeriodInMicroseconds() < 1000000 / 30 );
121 }
122 }
111 } 123 }
112 124
113 // Check that the vsync period roughly matches the timestamps that the monit or generates. 125 // Check that the vsync period roughly matches the timestamps that the monit or generates.
114 @MediumTest 126 @MediumTest
115 public void testVSyncPeriodAllowJBVSync() throws InterruptedException { 127 public void testVSyncPeriodAllowJBVSync() throws InterruptedException {
116 performVSyncPeriodTest(true); 128 performVSyncPeriodTest(true);
117 } 129 }
118 130
119 // Check that the vsync period roughly matches the timestamps that the monit or generates. 131 // Check that the vsync period roughly matches the timestamps that the monit or generates.
120 @MediumTest 132 @MediumTest
(...skipping 20 matching lines...) Expand all
141 @MediumTest 153 @MediumTest
142 public void testVSyncActivationFromIdleAllowJBVSync() throws InterruptedExce ption { 154 public void testVSyncActivationFromIdleAllowJBVSync() throws InterruptedExce ption {
143 performVSyncActivationFromIdle(true); 155 performVSyncActivationFromIdle(true);
144 } 156 }
145 157
146 @MediumTest 158 @MediumTest
147 public void testVSyncActivationFromIdleDisallowJBVSync() throws InterruptedE xception { 159 public void testVSyncActivationFromIdleDisallowJBVSync() throws InterruptedE xception {
148 performVSyncActivationFromIdle(false); 160 performVSyncActivationFromIdle(false);
149 } 161 }
150 } 162 }
OLDNEW
« no previous file with comments | « no previous file | ui/android/java/src/org/chromium/ui/VSyncMonitor.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698