From 4912f4992dc051cbe7c54bd468f29044bbc92ac8 Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Thu, 1 Dec 2016 14:34:57 -0500 Subject: [PATCH] Start of webglstub parameter --- Specs/Scene/SceneSpec.js | 2 +- Specs/createScene.js | 25 +++++++++++++++++++------ Specs/customizeJasmine.js | 6 +++++- Specs/karma-main.js | 6 ++++-- Specs/spec-main.js | 10 +++++++--- gulpfile.js | 3 ++- index.html | 1 + index.release.html | 3 +++ package.json | 1 + 9 files changed, 43 insertions(+), 14 deletions(-) diff --git a/Specs/Scene/SceneSpec.js b/Specs/Scene/SceneSpec.js index f6c6237a29a..e33fe51ec80 100644 --- a/Specs/Scene/SceneSpec.js +++ b/Specs/Scene/SceneSpec.js @@ -1,5 +1,5 @@ /*global defineSuite*/ -defineSuite([ +fdefineSuite([ 'Core/BoundingSphere', 'Core/Cartesian2', 'Core/Cartesian3', diff --git a/Specs/createScene.js b/Specs/createScene.js index c6b516bcb96..3e684ed882c 100644 --- a/Specs/createScene.js +++ b/Specs/createScene.js @@ -17,9 +17,11 @@ define([ destroyCanvas) { 'use strict'; +// TODO: check for window.webglStub in createContext // TODO: expectRenderForSpecs that passes in time for ModelSpec.js and maybe others // TODO: expectRenderForSpecs for picking // TODO: update https://github.com/AnalyticalGraphicsInc/cesium/tree/master/Documentation/Contributors/TestingGuide with when/why to use these +// * index.html and command line: npm run test-webgl-stub function createScene(options) { options = defaultValue(options, {}); @@ -59,14 +61,25 @@ define([ this.render(); var rgba = this.context.readPixels(); - // Most tests want to compare the rendered rgba to a known rgba, but some - // only want to compare some rgba components or use a more complicated - // expectation. These cases are handled with a callback. - if (expectationCallbackOrExpectedRgba instanceof Function) { - return expectationCallbackOrExpectedRgba(rgba); + // When the WebGL stub is used, all WebGL function calls are noops so + // the expectation is not verified. This allows running all the WebGL + // tests, to exercise as much Cesium code as possible, even if the system + // doesn't have a WebGL implementation or a reliable one. + if (window.webglStub) { + // Most tests want to compare the rendered rgba to a known rgba, but some + // only want to compare some rgba components or use a more complicated + // expectation. These cases are handled with a callback. + if (expectationCallbackOrExpectedRgba instanceof Function) { + return expectationCallbackOrExpectedRgba(rgba); + } + + expect(rgba).toEqual(expectationCallbackOrExpectedRgba); + } else { + // To avoid Jasmine's spec has no expecttions error + expect(true).toEqual(true); + } - expect(rgba).toEqual(expectationCallbackOrExpectedRgba); return undefined; }; diff --git a/Specs/customizeJasmine.js b/Specs/customizeJasmine.js index ec6c965d263..e857b01912a 100644 --- a/Specs/customizeJasmine.js +++ b/Specs/customizeJasmine.js @@ -9,7 +9,7 @@ define([ equalsMethodEqualityTester) { "use strict"; - return function (env, includedCategory, excludedCategory, webglValidation, release) { + return function (env, includedCategory, excludedCategory, webglValidation, webglStub, release) { function defineSuite(deps, name, suite, categories, focus) { /*global define,describe,fdescribe*/ if (typeof suite === 'object' || typeof suite === 'string') { @@ -137,6 +137,10 @@ define([ window.webglValidation = true; } + if (webglStub) { + window.webglStub = true; + } + //env.catchExceptions(true); env.beforeEach(function () { diff --git a/Specs/karma-main.js b/Specs/karma-main.js index 9433609f61a..69575ab18f1 100644 --- a/Specs/karma-main.js +++ b/Specs/karma-main.js @@ -5,13 +5,15 @@ var included = ''; var excluded = ''; var webglValidation = false; + var webglStub = false; var release = false; if(__karma__.config.args){ included = __karma__.config.args[0]; excluded = __karma__.config.args[1]; webglValidation = __karma__.config.args[2]; - release = __karma__.config.args[3]; + webglStub = __karma__.config.args[3]; + release = __karma__.config.args[4]; } var toRequire = ['Cesium']; @@ -55,7 +57,7 @@ ], function( customizeJasmine) { - customizeJasmine(jasmine.getEnv(), included, excluded, webglValidation, release); + customizeJasmine(jasmine.getEnv(), included, excluded, webglValidation, webglStub, release); var specFiles = Object.keys(__karma__.files).filter(function(file) { return /Spec\.js$/.test(file); diff --git a/Specs/spec-main.js b/Specs/spec-main.js index f034b71aa49..82c826a0ec5 100644 --- a/Specs/spec-main.js +++ b/Specs/spec-main.js @@ -210,10 +210,14 @@ window.webglValidation = true; } - var queryStringForSpecFocus = Cesium.clone(queryString); - if (queryStringForSpecFocus.category === 'none') { + if (queryString.webglStub !== undefined) { + window.webglStub = true; + } + + var queryStringForSpecFocus = Cesium.clone(queryString); + if (queryStringForSpecFocus.category === 'none') { delete queryStringForSpecFocus.category; - } + } var catchingExceptions = queryString['catch']; env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions); diff --git a/gulpfile.js b/gulpfile.js index 177bb2dd4d7..78651e58b39 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -618,6 +618,7 @@ gulp.task('test', function(done) { var includeCategory = argv.include ? argv.include : ''; var excludeCategory = argv.exclude ? argv.exclude : ''; var webglValidation = argv.webglValidation ? argv.webglValidation : false; + var webglStub = argv.webglStub ? argv.webglStub : false; var release = argv.release ? argv.release : false; var failTaskOnError = argv.failTaskOnError ? argv.failTaskOnError : false; var suppressPassed = argv.suppressPassed ? argv.suppressPassed : false; @@ -651,7 +652,7 @@ gulp.task('test', function(done) { }, files: files, client: { - args: [includeCategory, excludeCategory, webglValidation, release] + args: [includeCategory, excludeCategory, webglValidation, webglStub, release] } }, function(e) { return done(failTaskOnError ? e : undefined); diff --git a/index.html b/index.html index afb65308d88..f4e70045690 100644 --- a/index.html +++ b/index.html @@ -44,6 +44,7 @@
  • Run all tests (Run with WebGL validation) + (Run with WebGL stub)
  • Select a test to run diff --git a/index.release.html b/index.release.html index 1d26baa058b..570b0585f98 100644 --- a/index.release.html +++ b/index.release.html @@ -63,6 +63,9 @@ Run with WebGL validation
    + Run with WebGL stub +
    +
    Select a test to run
    diff --git a/package.json b/package.json index 5024601558a..38a92f21f61 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,7 @@ "test-webgl": "gulp test --include WebGL", "test-non-webgl": "gulp test --exclude WebGL", "test-webgl-validation": "gulp test --webglValidation", + "test-webgl-stub": "gulp test --webglStub", "test-release": "gulp test --release", "generateStubs": "gulp generateStubs", "sortRequires": "gulp sortRequires",