浏览代码

Add unit test html views

Tristan VALCKE 7 年之前
父节点
当前提交
65995ab490
共有 3 个文件被更改,包括 283 次插入0 次删除
  1. 128 0
      test/perf.html
  2. 26 0
      test/unit/UnitTests.html
  3. 129 0
      test/unit/unittests_editor_toRemoveAfterEditorES6Refactoring.html

+ 128 - 0
test/perf.html

@@ -0,0 +1,128 @@
+<!DOCTYPE html>
+<html lang="en">
+	<body>
+
+		<script src="../build/three.min.js"></script>
+		<script src="../examples/js/math/TypeArrayVector3.js"></script>
+
+		<script>
+
+			var Benchmark = function ( title, test ) {
+
+				var titleDom = document.createElement( 'div' );
+				titleDom.style.fontWeight = 'bold';
+				titleDom.textContent = title;
+				document.body.appendChild( titleDom );
+
+				var msDom = document.createElement( 'div' );
+				document.body.appendChild( msDom );
+
+				this.run = function () {
+
+					var start = performance.now();
+
+					test();
+
+					msDom.textContent = performance.now() - start;
+
+				}
+
+			};
+
+
+			var vector11 = new THREE.Vector3( 1.2, 2.3, 3.4 );
+			var vector12 = new THREE.Vector3( 1.2, 2.3, 3.4 );
+			var vector13 = new THREE.Vector3( 1.2, 2.3, 3.4 );
+
+			var vector21 = new THREE.TypeArrayVector3( 1.2, 2.3, 3.4 );
+			var vector22 = new THREE.TypeArrayVector3( 1.2, 2.3, 3.4 );
+			var vector23 = new THREE.TypeArrayVector3( 1.2, 2.3, 3.4 );
+
+			var benchmarks = [
+
+				new Benchmark( 'new Vector3()', function () {
+
+					for ( var i = 0; i < 10000; i ++ ) {
+
+						var vector = new THREE.Vector3( 1, 1, 1 );
+
+					}
+
+				} ),
+
+				new Benchmark( 'new TypeArrayVector3()', function () {
+
+					for ( var i = 0; i < 10000; i ++ ) {
+
+						var vector = new THREE.TypeArrayVector3( 1, 1, 1 );
+
+					}
+
+				} ),
+
+				new Benchmark( 'Vector3 add()', function () {
+
+					for ( var i = 0; i < 10000000; i ++ ) {
+
+						vector11.add( vector12 );
+
+					}
+
+				} ),
+
+				new Benchmark( 'TypeArrayVector3 add()', function () {
+
+					for ( var i = 0; i < 10000000; i ++ ) {
+
+						vector21.add( vector22 );
+
+					}
+
+				} ),
+
+				new Benchmark( 'Vector3 addVectors()', function () {
+
+					for ( var i = 0; i < 10000000; i ++ ) {
+
+						vector11.addVectors( vector12, vector13 );
+
+					}
+
+				} ),
+
+				new Benchmark( 'TypeArrayVector3 addVectors()', function () {
+
+					for ( var i = 0; i < 10000000; i ++ ) {
+
+						vector21.addVectors( vector22, vector23 );
+
+					}
+
+				} )
+
+			];
+
+			function update () {
+
+				vector11 = new THREE.Vector3( Math.random(), Math.random(), Math.random() );
+				vector12 = new THREE.Vector3( Math.random(), Math.random(), Math.random() );
+
+				vector21 = new THREE.TypeArrayVector3().set( vector11.x, vector11.y, vector11.z );
+				vector22 = new THREE.TypeArrayVector3().set( vector12.x, vector12.y, vector12.z );
+
+				for ( var i = 0, l = benchmarks.length; i < l; i ++ ) {
+
+					benchmarks[ i ].run();
+
+				}
+
+				setTimeout( update, 2000 );
+
+			}
+
+			update();
+
+		</script>
+
+	</body>
+</html>

+ 26 - 0
test/unit/UnitTests.html

@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>ThreeJS Unit Tests - Using Files in /src</title>
+        <link rel="stylesheet" href="../../node_modules/qunitjs/qunit/qunit.css">
+    </head>
+    <body>
+
+        <div id="qunit"></div>
+        <div id="qunit-fixture"></div>
+
+        <script src="../../node_modules/qunitjs/qunit/qunit.js"></script>
+
+        <!-- We need three.js because qunit-utils cannot be es6 module and use THREE stuff... -->
+        <script src="../../build/three.js"></script>
+        <script src="SmartComparer.js"></script>
+        <script src="qunit-utils.js"></script>
+
+        <!-- add sources to test below -->
+        <!--<script src="three.editor.unit.js"></script>-->
+        <!--<script src="three.example.unit.js"></script>-->
+        <script src="three.source.unit.js"></script>
+
+    </body>
+</html>

+ 129 - 0
test/unit/unittests_editor_toRemoveAfterEditorES6Refactoring.html

@@ -0,0 +1,129 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>ThreeJS Unit Tests - Using Files in /editor</title>
+  <link rel="stylesheet" href="../../node_modules/qunitjs/qunit/qunit.css">
+</head>
+<body>
+
+  <div id="qunit"></div>
+  <div id="qunit-fixture"></div>
+
+  <script src="../../node_modules/qunitjs/qunit/qunit.js"></script>
+  <script src="qunit-utils.js"></script>
+  <script src="SmartComparer.js"></script>
+
+<!-- add sources to test below -->
+<script src="../../build/three.min.js"></script>
+
+<script src="../../editor/js/libs/codemirror/codemirror.js"></script>
+<script src="../../editor/js/libs/codemirror/mode/javascript.js"></script>
+<script src="../../editor/js/libs/esprima.js"></script>
+
+<script src="../../editor/js/libs/sortable.min.js"></script>
+<script src="../../editor/js/libs/signals.min.js"></script>
+<script src="../../editor/js/libs/ui.js"></script>
+<script src="../../editor/js/libs/ui.three.js"></script>
+
+<script src="../../editor/js/libs/app.js"></script>
+<script src="../../editor/js/Player.js"></script>
+<script src="../../editor/js/Script.js"></script>
+
+<!--
+<script src="../examples/js/effects/VREffect.js"></script>
+<script src="../examples/js/controls/VRControls.js"></script>
+-->
+
+<script src="../../editor/js/Storage.js"></script>
+
+<script src="../../editor/js/Editor.js"></script>
+<script src="../../editor/js/Config.js"></script>
+<script src="../../editor/js/Loader.js"></script>
+<script src="../../editor/js/Menubar.js"></script>
+<script src="../../editor/js/Menubar.File.js"></script>
+<script src="../../editor/js/Menubar.Edit.js"></script>
+<script src="../../editor/js/Menubar.Add.js"></script>
+<script src="../../editor/js/Menubar.Play.js"></script>
+<script src="../../editor/js/Menubar.View.js"></script>
+<script src="../../editor/js/Menubar.Examples.js"></script>
+<script src="../../editor/js/Menubar.Help.js"></script>
+<script src="../../editor/js/Menubar.Status.js"></script>
+<script src="../../editor/js/Sidebar.js"></script>
+<script src="../../editor/js/Sidebar.Project.js"></script>
+<script src="../../editor/js/Sidebar.Scene.js"></script>
+<!--<script src="../../editor/js/Sidebar.Object3D.js"></script>-->
+<script src="../../editor/js/Sidebar.Animation.js"></script>
+<script src="../../editor/js/Sidebar.Geometry.js"></script>
+<script src="../../editor/js/Sidebar.Geometry.Geometry.js"></script>
+<script src="../../editor/js/Sidebar.Geometry.BufferGeometry.js"></script>
+<script src="../../editor/js/Sidebar.Geometry.Modifiers.js"></script>
+<script src="../../editor/js/Sidebar.Geometry.BoxGeometry.js"></script>
+<script src="../../editor/js/Sidebar.Geometry.CircleGeometry.js"></script>
+<script src="../../editor/js/Sidebar.Geometry.CylinderGeometry.js"></script>
+<script src="../../editor/js/Sidebar.Geometry.IcosahedronGeometry.js"></script>
+<script src="../../editor/js/Sidebar.Geometry.PlaneGeometry.js"></script>
+<script src="../../editor/js/Sidebar.Geometry.SphereGeometry.js"></script>
+<script src="../../editor/js/Sidebar.Geometry.TorusGeometry.js"></script>
+<script src="../../editor/js/Sidebar.Geometry.TorusKnotGeometry.js"></script>
+<script src="../../editor/js/Sidebar.Material.js"></script>
+<script src="../../editor/js/Sidebar.Script.js"></script>
+<script src="../../editor/js/Toolbar.js"></script>
+<script src="../../editor/js/Viewport.js"></script>
+<script src="../../editor/js/Viewport.Info.js"></script>
+<script src="../../editor/js/History.js"></script>
+
+<!-- command object classes -->
+<script src="../../editor/js/Command.js"></script>
+<script src="../../editor/js/commands/AddObjectCommand.js"></script>
+<script src="../../editor/js/commands/AddScriptCommand.js"></script>
+<script src="../../editor/js/commands/MoveObjectCommand.js"></script>
+<script src="../../editor/js/commands/MultiCmdsCommand.js"></script>
+<script src="../../editor/js/commands/RemoveObjectCommand.js"></script>
+<script src="../../editor/js/commands/RemoveScriptCommand.js"></script>
+<script src="../../editor/js/commands/SetColorCommand.js"></script>
+<script src="../../editor/js/commands/SetGeometryCommand.js"></script>
+<script src="../../editor/js/commands/SetGeometryValueCommand.js"></script>
+<script src="../../editor/js/commands/SetMaterialCommand.js"></script>
+<script src="../../editor/js/commands/SetMaterialColorCommand.js"></script>
+<script src="../../editor/js/commands/SetMaterialMapCommand.js"></script>
+<script src="../../editor/js/commands/SetMaterialValueCommand.js"></script>
+<script src="../../editor/js/commands/SetPositionCommand.js"></script>
+<script src="../../editor/js/commands/SetRotationCommand.js"></script>
+<script src="../../editor/js/commands/SetScaleCommand.js"></script>
+<script src="../../editor/js/commands/SetSceneCommand.js"></script>
+<script src="../../editor/js/commands/SetScriptValueCommand.js"></script>
+<script src="../../editor/js/commands/SetUuidCommand.js"></script>
+<script src="../../editor/js/commands/SetValueCommand.js"></script>
+
+
+<!-- add class-based unit tests below -->
+<script src="editor/CommonUtilities.js"></script>
+
+<!-- Undo-Redo tests -->
+<script src="editor/old_to_convert/AddObjectCommandAndRemoveObjectCommand.tests.js"></script>
+<script src="editor/old_to_convert/AddScriptCommand.tests.js"></script>
+<script src="editor/old_to_convert/MoveObjectCommand.tests.js"></script>
+<script src="editor/old_to_convert/MultiCmdsCommand.tests.js"></script>
+<script src="editor/old_to_convert/RemoveScriptCommand.tests.js"></script>
+<script src="editor/old_to_convert/SetColorCommand.tests.js"></script>
+<script src="editor/old_to_convert/SetGeometryCommand.tests.js"></script>
+<script src="editor/old_to_convert/SetGeometryValueCommand.tests.js"></script>
+<script src="editor/old_to_convert/SetMaterialCommand.tests.js"></script>
+<script src="editor/old_to_convert/SetMaterialColorCommand.tests.js"></script>
+<script src="editor/old_to_convert/SetMaterialMapCommand.tests.js"></script>
+<script src="editor/old_to_convert/SetMaterialValueCommand.tests.js"></script>
+<script src="editor/old_to_convert/SetPositionCommand.tests.js"></script>
+<script src="editor/old_to_convert/SetRotationCommand.tests.js"></script>
+<script src="editor/old_to_convert/SetScaleCommand.tests.js"></script>
+<script src="editor/old_to_convert/SetSceneCommand.tests.js"></script>
+<script src="editor/old_to_convert/SetScriptValueCommand.tests.js"></script>
+<script src="editor/old_to_convert/SetUuidCommand.tests.js"></script>
+<script src="editor/old_to_convert/SetValueCommand.tests.js"></script>
+<script src="editor/old_to_convert/NestedDoUndoRedo.tests.js"></script>
+<script src="editor/old_to_convert/Serialization.tests.js"></script>
+<script src="editor/old_to_convert/NegativeCases.tests.js"></script>
+<script src="editor/old_to_convert/MassUndoAndRedo.tests.js"></script>
+
+</body>
+</html>