diff options
author | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-08 01:26:46 +0000 |
---|---|---|
committer | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-08 01:26:46 +0000 |
commit | 3c2216cd87438196389b5076095a5f1d627b1ca2 (patch) | |
tree | cbe1a1d4746b21503dd9e7213a81201ac14e6320 | |
parent | f0ef2da98a8bc281600d565ff7788f2bec129d9f (diff) | |
download | chromium_src-3c2216cd87438196389b5076095a5f1d627b1ca2.zip chromium_src-3c2216cd87438196389b5076095a5f1d627b1ca2.tar.gz chromium_src-3c2216cd87438196389b5076095a5f1d627b1ca2.tar.bz2 |
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
-rw-r--r-- | o3d/samples/beachdemo/beachdemo.js | 12 | ||||
-rw-r--r-- | o3d/samples/o3djs/performance.js | 25 | ||||
-rw-r--r-- | o3d/tests/selenium/selenium_utilities.py | 3 |
3 files changed, 28 insertions, 12 deletions
diff --git a/o3d/samples/beachdemo/beachdemo.js b/o3d/samples/beachdemo/beachdemo.js index 4b99bd9..901cfd9 100644 --- a/o3d/samples/beachdemo/beachdemo.js +++ b/o3d/samples/beachdemo/beachdemo.js @@ -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. */ diff --git a/o3d/samples/o3djs/performance.js b/o3d/samples/o3djs/performance.js index 055bf2e..e81396f 100644 --- a/o3d/samples/o3djs/performance.js +++ b/o3d/samples/o3djs/performance.js @@ -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;
}
}
-}
+};
+
diff --git a/o3d/tests/selenium/selenium_utilities.py b/o3d/tests/selenium/selenium_utilities.py index 84444e1..a5d5b3d 100644 --- a/o3d/tests/selenium/selenium_utilities.py +++ b/o3d/tests/selenium/selenium_utilities.py @@ -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)) |