| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |