Commit 3c2216cd authored by gman@google.com's avatar gman@google.com

Change our selenium tests to call

window.o3d_prepForSelenium if it exists and 
fix becahdemo to use this feature.

Review URL: http://codereview.chromium.org/155191

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20113 0039d316-1c4b-4281-b951-d872f2087c98
parent f0ef2da9
......@@ -1834,9 +1834,21 @@ function onAllLoadingFinished() {
showHint();
window.o3d_prepForSelenium = prepForSelenium;
window.g_finished = true; // for selenium testing.
}
// Put the demo in a consistent state.
function prepForSelenium() {
// Turn off the perf monitor.
g_perfMon = null;
// Set the render targets to a fixed size.
g_renderTargetWidth = 256;
g_renderTargetHeight = 256;
setupRenderTargets();
}
/**
* Creates the client area.
*/
......
......@@ -56,7 +56,7 @@ o3djs.performance.createPerformanceMonitor = function(
targetFPSMin, targetFPSMax, increaseQuality, decreaseQuality, opt_options) {
return new o3djs.performance.PerformanceMonitor(targetFPSMin, targetFPSMax,
increaseQuality, decreaseQuality, opt_options);
}
};
/**
* A class that monitors performance [in terms of FPS] and helps to adjust the
......@@ -77,20 +77,20 @@ o3djs.performance.PerformanceMonitor = function(
/**
* A function to increase quality/lower FPS.
* @type {function(): void}
* @type {function(): void}
*/
this.increaseQuality = increaseQuality;
/**
* A function to decrease quality/raise FPS.
* @type {function(): void}
* @type {function(): void}
*/
this.decreaseQuality = decreaseQuality;
/**
* The mean time taken per frame so far, in seconds. This is only valid once
* we've collected at least minSamples samples.
* @type {number}
* @type {number}
*/
this.meanFrameTime = 0;
......@@ -99,14 +99,14 @@ o3djs.performance.PerformanceMonitor = function(
* or equal to this.damping. After that point, we no longer update
* this.sampleCount, so it will clip at this.damping.
*
* @type {number}
* @type {number}
*/
this.sampleCount = 0;
/**
* The minimum number of samples to collect before trying to adjust quality.
*
* @type {number}
* @type {number}
*/
this.minSamples = opt_options.opt_minSamples || 60;
......@@ -117,7 +117,7 @@ o3djs.performance.PerformanceMonitor = function(
* between 60 and 600 are probably reasonable values, depending on your needs,
* but the number must be no less than minSamples.
*
* @type {number}
* @type {number}
*/
this.damping = opt_options.opt_damping || 120;
......@@ -125,7 +125,7 @@ o3djs.performance.PerformanceMonitor = function(
* The minimum number of samples to take in between adjustments, to cut down
* on overshoot. It defaults to 2 * minSamples.
*
* @type {number}
* @type {number}
*/
this.delayCycles = opt_options.opt_delayCycles || 2 * this.minSamples;
......@@ -137,7 +137,7 @@ o3djs.performance.PerformanceMonitor = function(
if (this.damping < this.minSamples) {
throw Error('Damping must be at least minSamples.');
}
}
};
/**
* Options for the PerformanceMonitor.
......@@ -171,8 +171,8 @@ o3djs.performance.PerformanceMonitor.prototype.onRender = function(seconds) {
var test = true;
if (this.sampleCount < this.damping) {
if (this.sampleCount >= this.minSamples) {
this.scaleInput_ = 1 / (this.sampleCount + 1);
this.scaleMean_ = this.sampleCount * this.scaleInput_;
this.scaleInput_ = 1 / (this.sampleCount + 1);
this.scaleMean_ = this.sampleCount * this.scaleInput_;
} else {
test = false;
}
......@@ -191,5 +191,6 @@ o3djs.performance.PerformanceMonitor.prototype.onRender = function(seconds) {
this.delayCyclesLeft_ = this.delayCycles;
}
}
}
};
......@@ -269,6 +269,9 @@ class SeleniumTestCase(unittest.TestCase):
# wait for it to initialize.
self.session.wait_for_condition(ready_condition, timeout)
self.session.run_script(
"if (window.o3d_prepForSelenium) { window.o3d_prepForSelenium(); }")
if assertion:
self.assertEqual("true", self.session.get_eval(assertion))
......
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