ndt-dev - [ndt-dev] [ndt] r1138 committed - Merged Issue154 branch into trunk
Subject: NDT-DEV email list created
List archive
- From:
- To:
- Subject: [ndt-dev] [ndt] r1138 committed - Merged Issue154 branch into trunk
- Date: Tue, 04 Nov 2014 15:27:42 +0000
Revision: 1138
Author:
Date: Tue Nov 4 15:27:14 2014 UTC
Log: Merged Issue154 branch into trunk
https://code.google.com/p/ndt/source/detail?r=1138
Modified:
/trunk
/trunk/HTML5-frontend/script.js
/trunk/HTML5-frontend/style.css
/trunk/HTML5-frontend/widget.html
/trunk/flash-client/src/GUI.as
/trunk/flash-client/src/Main.as
/trunk/flash-client/src/NDTConstants.as
/trunk/flash-client/src/NDTPController.as
/trunk/flash-client/src/NDTUtils.as
/trunk/flash-client/src/TestC2S.as
/trunk/flash-client/src/TestS2C.as
/trunk/flash-client/src/UserAgentTools.as
=======================================
--- /trunk/HTML5-frontend/script.js Wed Jun 18 06:12:24 2014 UTC
+++ /trunk/HTML5-frontend/script.js Tue Nov 4 15:27:14 2014 UTC
@@ -5,11 +5,10 @@
setTimeout(initializeTest, 1000);
return;
}
+ checkInstalledPlugins();
initializeTest();
});
-
-
// CONSTANTS
// Testing phases
@@ -57,6 +56,8 @@
function startTest(evt) {
evt.stopPropagation();
evt.preventDefault();
+ document.getElementById('javaButton').disabled = true;
+ document.getElementById('flashButton').disabled = true;
showPage('test', resetGauges);
document.getElementById('rttValue').innerHTML = "";
if (simulate) return simulateTest();
@@ -196,6 +197,8 @@
document.getElementById('jitter').innerHTML = jitter().toPrecision(2);
document.getElementById("test-details").innerHTML = testDetails();
document.getElementById("test-advanced").appendChild(testDiagnosis());
+ document.getElementById('javaButton').disabled = false;
+ document.getElementById('flashButton').disabled = false;
showPage('results');
break;
@@ -467,6 +470,39 @@
return d;
}
+// BACKEND METHODS
+function useJavaAsBackend() {
+ //document.getElementById('javaButton').toggleClass('active');
+ var backendContainer = document.getElementById('backendContainer');
+ while (backendContainer.firstChild) {
+ backendContainer.removeChild(backendContainer.firstChild);
+ }
+
+ var app = document.createElement('applet');
+ app.id = 'NDT';
+ app.name = 'NDT';
+ app.archive = 'Tcpbw100.jar';
+ app.code = 'edu.internet2.ndt.Tcpbw100.class';
+ app.width = '400';
+ app.height = '400';
+ document.getElementById('backendContainer').appendChild(app);
+}
+
+function useFlashAsBackend() {
+ var backendContainer = document.getElementById('backendContainer');
+ while (backendContainer.firstChild) {
+ backendContainer.removeChild(backendContainer.firstChild);
+ }
+
+ var embed = document.createElement('embed');
+ embed.id = 'NDT';
+ embed.name = 'NDT';
+ embed.type = 'application/x-shockwave-flash';
+ embed.src = 'FlashClt.swf';
+ embed.width = '600';
+ embed.height = '400';
+ document.getElementById('backendContainer').appendChild(embed);
+}
// UTILITIES
@@ -474,3 +510,27 @@
if (allowDebug && window.console) console.debug(message);
}
+function checkInstalledPlugins() {
+ var hasFlash = false, hasJava = false;
+ try {
+ var activeXObject = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
+ if(activeXObject) hasFlash = true;
+ } catch(e) {
+ if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) hasFlash = true;
+ }
+
+ if (!hasFlash) {
+ document.getElementById('flashButton').disabled = true
+ }
+
+ if (deployJava.getJREs() == '') {
+ document.getElementById('javaButton').disabled = true;
+ } else {
+ hasJava = true;
+ }
+
+ if (hasJava) {
+ useJavaAsBackend();
+ }
+}
+
=======================================
--- /trunk/HTML5-frontend/style.css Wed Jun 18 06:12:24 2014 UTC
+++ /trunk/HTML5-frontend/style.css Tue Nov 4 15:27:14 2014 UTC
@@ -90,6 +90,22 @@
.controls .button {
-moz-box-shadow: 0 3px 5px #000;
}
+
+.backendButton {
+ width: 200px;
+ height: 50px;
+ font-size: 24px;
+ margin: 10px;
+}
+
+.backendButton .active {
+ background-color:blue;
+}
+
+.backendButton:disabled {
+ background-color:gray;
+ cursor: default;
+}
/* Welcome page */
=======================================
--- /trunk/HTML5-frontend/widget.html Wed Jun 18 06:12:24 2014 UTC
+++ /trunk/HTML5-frontend/widget.html Tue Nov 4 15:27:14 2014 UTC
@@ -10,6 +10,7 @@
<script type="text/javascript" src="jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="gauge.min.js"></script>
<script type="text/javascript" src="script.js"></script>
+ <script type="text/javascript" src="http://www.java.com/js/deployJava.js"></script>
<script type="text/javascript">
var simulate = false;
var allowDebug = false;
@@ -122,11 +123,17 @@
</div>
</div>
-<!--Use embed tag to have flash client being background for JS UI or applet tag if you want to use java applet instead. -->
-<applet id="NDT" name="NDT" code="edu.internet2.ndt.Tcpbw100.class" codebase="<?php print $applet_url ?>" archive="Tcpbw100.jar" width="400" height="400"></applet>
+<div>
+ <button id="javaButton" class="backendButton button" onclick="useJavaAsBackend()" type="button">Use java</button>
+ <button id="flashButton" class="backendButton button" onclick="useFlashAsBackend()" type="button">Use flash</button>
+</div>
-<!--<embed id="NDT" name="NDT" type="application/x-shockwave-flash" src="FlashClt.swf" width="600" height="400" />-->
+<div id="backendContainer">
+ <!--Use embed tag to have flash client being background for JS UI or applet tag if you want to use java applet instead. -->
+ <embed id="NDT" name="NDT" type="application/x-shockwave-flash" src="FlashClt.swf" width="600" height="400" />
+ <!--<applet id="NDT" name="NDT" code="edu.internet2.ndt.Tcpbw100.class" codebase="<?php print $applet_url ?>" archive="Tcpbw100.jar" width="400" height="400"></applet>-->
+</div>
</body>
</html>
=======================================
--- /trunk/flash-client/src/GUI.as Fri Jun 20 08:55:48 2014 UTC
+++ /trunk/flash-client/src/GUI.as Tue Nov 4 15:27:14 2014 UTC
@@ -73,8 +73,8 @@
aboutNDTTextFormat.color = 0x000000;
_aboutNDTText = new TextField();
_aboutNDTText.defaultTextFormat = aboutNDTTextFormat;
- _aboutNDTText.width = 0.75 * _stageWidth;
- _aboutNDTText.height = 0.40 * _stageHeight;
+ _aboutNDTText.width = 0.80 * _stageWidth;
+ _aboutNDTText.height = 0.35 * _stageHeight;
_aboutNDTText.wordWrap = true;
_aboutNDTText.selectable = false;
_aboutNDTText.text = Main.ndt_description;
@@ -95,23 +95,44 @@
_learnMoreLink.buttonMode = true;
_learnMoreLink.mouseChildren = false;
_learnMoreLink.width = 0.50 * _stageWidth;
+ _learnMoreLink.height = 0.17 * _stageWidth;
- // 4) Start button
+ // 4) Bad runtime warning/error
+ var badRuntimeMessageFormat:TextFormat = new TextFormat();
+ badRuntimeMessageFormat.size = 14;
+ badRuntimeMessageFormat.font = "Verdana";
+ badRuntimeMessageFormat.align = TextFormatAlign.CENTER;
+ badRuntimeMessageFormat.color = 0xB02B08;
+ var _badRuntimeMessage:TextField = new TextField();
+ _badRuntimeMessage.defaultTextFormat = badRuntimeMessageFormat;
+ _badRuntimeMessage.width = 0.90 * _stageWidth;
+ _badRuntimeMessage.height = 0.35 * _stageHeight;
+ //_badRuntimeMessage.opaqueBackground = 0x000000;
+ _badRuntimeMessage.wordWrap = true;
+ _badRuntimeMessage.selectable = false;
+ _badRuntimeMessage.text = NDTConstants.BAD_ENV_MESG;
+ if (Main.bad_runtime_action == NDTConstants.ENV_OK) {
+ _badRuntimeMessage.height = 0;
+ }
+
+ // 5) Start button
_startButton = new NDTButton("START", 30, 45, 0.4);
// Position objects within initial screen, using a relative layout.
_mlabLogo.x = (_stageWidth / 2) - (_mlabLogo.width / 2);
_aboutNDTText.x = _stageWidth / 2 - _aboutNDTText.width / 2;
_learnMoreLink.x = _stageWidth / 2 - _learnMoreLink.width / 2;
+ _badRuntimeMessage.x = _stageWidth / 2 - _badRuntimeMessage.width / 2;
_startButton.x = _stageWidth / 2;
var verticalMargin:Number = (_stageHeight - (
_mlabLogo.height + _aboutNDTText.height + _learnMoreLink.height
- + _startButton.height)) / 5;
- _mlabLogo.y = verticalMargin;
- _aboutNDTText.y = _mlabLogo.y + _mlabLogo.height + verticalMargin;
+ + _badRuntimeMessage.height + _startButton.height)) / 6;
+ _mlabLogo.y = 0;
+ _aboutNDTText.y = _mlabLogo.y + _mlabLogo.height;
_learnMoreLink.y = _aboutNDTText.y + _aboutNDTText.height;
- + verticalMargin;
- _startButton.y = _learnMoreLink.y + _learnMoreLink.height
+ _badRuntimeMessage.y = _learnMoreLink.y + _learnMoreLink.height
+ + verticalMargin*3;
+ _startButton.y = _badRuntimeMessage.y + _badRuntimeMessage.height
+ verticalMargin;
// Add initial event listeners.
@@ -124,7 +145,15 @@
this.addChild(_mlabLogo);
this.addChild(_aboutNDTText);
this.addChild(_learnMoreLink);
- this.addChild(_startButton);
+ if (Main.bad_runtime_action != NDTConstants.ENV_OK) {
+ this.addChild(_badRuntimeMessage);
+ TestResults.appendDebugMsg("Bad Runtime detected");
+ }
+ if (Main.bad_runtime_action != NDTConstants.BAD_ENV_ERROR) {
+ this.addChild(_startButton);
+ }
+ else
+ TestResults.appendErrMsg("Halting test due to bad runtime");
}
private function clickLearnMoreLink(e:MouseEvent):void {
=======================================
--- /trunk/flash-client/src/Main.as Mon Jun 30 20:05:07 2014 UTC
+++ /trunk/flash-client/src/Main.as Tue Nov 4 15:27:14 2014 UTC
@@ -30,6 +30,8 @@
public static var client_application:String = NDTConstants.CLIENT_ID;
public static var ndt_description:String = NDTConstants.NDT_DESCRIPTION;
public static var jsonSupport:Boolean = true;
+ public static var bad_runtime_action:String = "warn";
+ //Options are warn, warn-limit, and error (default)
public function Main():void {
if (stage)
@@ -53,6 +55,12 @@
// Set the properties of the SWF from HTML tags.
NDTUtils.initializeFromHTML(this.root.loaderInfo.parameters);
+ //User Agent string is stored in a TestResults var by initFromHTML
+ if (UserAgentTools.goodRuntimeCheck(TestResults.ndt_test_results::userAgent)) {
+ bad_runtime_action = NDTConstants.ENV_OK;
+ } else
+ client_application = NDTConstants.LIMITED_CLIENT_ID;
+
var frame:NDTPController = NDTPController.getInstance();
stage.showDefaultContextMenu = false;
@@ -66,5 +74,21 @@
public static function getHost():String {
return server_hostname;
}
+
+ /**
+ * Function that initializes the NDT server variable set directly through JS.
+ */
+ public static function setHost(hostname:String):String {
+ var js_server_hostname:String = hostname;
+ if (js_server_hostname) {
+ server_hostname = js_server_hostname;
+ TestResults.appendDebugMsg(
+ "Initialized server from JavaScript. Server hostname:"
+ + Main.server_hostname);
+ } else {
+ js_server_hostname = null;
+ }
+ return js_server_hostname;
+ }
}
}
=======================================
--- /trunk/flash-client/src/NDTConstants.as Fri Mar 21 10:33:50 2014 UTC
+++ /trunk/flash-client/src/NDTConstants.as Tue Nov 4 15:27:14 2014 UTC
@@ -21,6 +21,8 @@
// The current version of the protocol is backward compatible to v3.3.12.
public static const LAST_VALID_SERVER_VERSION:String = "v3.3.12";
public static const CLIENT_ID:String = "swf";
+ public static const LIMITED_CLIENT_ID:String = "swf-ltd";
+ public static const BAD_ENV_ACTION:String = "error";
// Client MUST request the TEST_STATUS.
public static const TESTS_REQUESTED_BY_CLIENT:int =
TestType.C2S | TestType.S2C | TestType.META | TestType.STATUS;
@@ -41,7 +43,6 @@
+ "users, they can also help novice users by "
+ "allowing them to provide detailed trouble "
+ "reports to their network administrator.";
-
public static const PROTOCOL_MSG_READ_SUCCESS:int = 0;
public static const PROTOCOL_MSG_READ_ERROR:int = 1;
public static const MSG_HEADER_LENGTH:int = 3;
@@ -162,6 +163,7 @@
public static const HTML_LOCALE:String = "Locale";
public static const HTML_USERAGENT:String = "UserAgentString";
public static const HTML_SERVER_HOSTNAME:String = "ServerHostname";
+ public static const HTML_BAD_ENV_ACTION:String = "BadRuntimeAction";
// Names of NDT variables sent by the server.
public static const MSSSENT:String = "MSSSent";
@@ -231,6 +233,21 @@
public static const SPD:String = "spd";
public static const ASPD:String = "aspd";
public static const OPTRCVRBUFF:String = "optimalRcvrBuffer";
+
+ //Bad environment handlers
+ public static const ENV_OK:String = "none"
+ public static const BAD_ENV_WARN:String = "warn"
+ public static const BAD_ENV_WARN_AND_LIMIT:String = "warn-limit"
+ public static const BAD_ENV_ERROR:String = "error"
+ public static const BAD_ENV_MESG:String =
+ "Due to performance limitations in the Adobe Flash "
+ + "Runtime, the NDT flash test cannot measure "
+ + "high-speed connections accurately unless "
+ + "it is run within Google Chrome "
+ + "on Mac OS and Linux, or any web-browser running "
+ + "on Windows operating systems. Please use one of "
+ + "these platforms or run the NDT Java client "
+ + "to obtain precise measurements.";
}
}
=======================================
--- /trunk/flash-client/src/NDTPController.as Wed Jun 18 07:06:05 2014 UTC
+++ /trunk/flash-client/src/NDTPController.as Tue Nov 4 15:27:14 2014 UTC
@@ -72,11 +72,34 @@
TestResults.clearResults();
}
- var js_server_hostname:String = NDTUtils.hostnameFromJS();
+ var hostnameQueryFn:String = "getNDTServer";
+ if (Main.bad_runtime_action != NDTConstants.ENV_OK) {
+ TestResults.appendDebugMsg("Download-limited Flash Runtime detected");
+ if (Main.bad_runtime_action == NDTConstants.BAD_ENV_WARN_AND_LIMIT) {
+ hostnameQueryFn = "getFallbackNDTServer"
+ TestResults.appendDebugMsg("Reverting to fallback "
+ + "test server due to bad flash runtime");
+ }
+ if (Main.bad_runtime_action == NDTConstants.BAD_ENV_ERROR) {
+ failNDTTest();
+ TestResults.appendErrMsg(NDTConstants.BAD_ENV_MESG);
+ return;
+ }
+ }
+
+ var js_server_hostname:String = NDTUtils.hostnameFromJS(hostnameQueryFn);
if (js_server_hostname) {
Main.server_hostname = js_server_hostname;
_hostname = Main.server_hostname;
- }
+ } else if (Main.bad_runtime_action == NDTConstants.BAD_ENV_WARN_AND_LIMIT) {
+ TestResults.appendErrMsg("This Flash runtime is download-limited, client is "
+ + "set to restrict limited runtimes to fallback servers only, and no
"
+ + "getFallbackNDTServer JavaScript function was defined.");
+ failNDTTest();
+ return;
+ } else if (Main.server_hostname) {
+ _hostname = Main.server_hostname;
+ }
TestResults.recordStartTime();
TestResults.ndt_test_results::ndtTestFailed = false;
=======================================
--- /trunk/flash-client/src/NDTUtils.as Wed Jun 18 07:06:05 2014 UTC
+++ /trunk/flash-client/src/NDTUtils.as Tue Nov 4 15:27:14 2014 UTC
@@ -63,19 +63,20 @@
/**
* Function that initializes the NDT server variable.
*/
- public static function hostnameFromJS():String {
+ public static function hostnameFromJS(queryFn:String):String {
try {
- var js_server_hostname:String = ExternalInterface.call("getNDTServer");
+ var js_server_hostname:String = ExternalInterface.call(queryFn);
if (js_server_hostname) {
TestResults.appendDebugMsg(
- "Initialized server from JavaScript. Server hostname:"
+ "Initialized server from " + queryFn
+ + " JavaScript function. Server hostname: "
+ Main.server_hostname);
} else {
js_server_hostname = null;
}
return js_server_hostname;
} catch(e:Error) {
- TestResults.appendDebugMsg("Failed to call getNDTServer(): "
+ TestResults.appendDebugMsg("Failed to call " + queryFn + "(): "
+ e.toString());
return null;
}
@@ -118,7 +119,7 @@
+ e.toString());
}
- var js_server_hostname:String = hostnameFromJS();
+ var js_server_hostname:String = hostnameFromJS("getNDTServer");
if (js_server_hostname) {
Main.server_hostname = js_server_hostname;
}
@@ -152,6 +153,14 @@
TestResults.appendDebugMsg("Failed to call getNDTDescription(): "
+ e.toString());
}
+ if (NDTConstants.HTML_BAD_ENV_ACTION in paramObject) {
+ var validParams:Array = new Array(NDTConstants.BAD_ENV_WARN,
+ NDTConstants.BAD_ENV_WARN_AND_LIMIT, NDTConstants.BAD_ENV_ERROR);
+ if (validParams.indexOf(paramObject[NDTConstants.HTML_BAD_ENV_ACTION]) > -1)
+ Main.bad_runtime_action = paramObject[NDTConstants.HTML_BAD_ENV_ACTION];
+ // else keep the default value (NDTConstants.BAD_ENV_ACTION).
+ }
+
}
/**
@@ -201,6 +210,8 @@
"get_PcBuffSpdLimit", TestResults.getPcLimit);
ExternalInterface.addCallback(
"getNDTvar", TestResultsUtils.getNDTVariable);
+ ExternalInterface.addCallback(
+ "set_host", Main.setHost);
} catch (e:Error) {
// TODO(tiziana): Find out why ExternalInterface.available does not work
// in some cases and this exception is raised.
=======================================
--- /trunk/flash-client/src/TestC2S.as Fri Jun 20 08:55:01 2014 UTC
+++ /trunk/flash-client/src/TestC2S.as Tue Nov 4 15:27:14 2014 UTC
@@ -87,7 +87,7 @@
TestResults.appendDebugMsg(ResourceManager.getInstance().getString(
NDTConstants.BUNDLE_NAME, "runningOutboundTest", null,
Main.locale));
- TestResults.ndt_test_results::ndtTestStatus = "runningOutboundTest";
+ TestResults.ndt_test_results::ndtTestStatus = "preparingOutboundTest";
addCtlSocketOnReceivedDataListener();
_msg = new Message();
@@ -316,6 +316,7 @@
// Record start time right before it starts sending data, to be as
// accurate as possible.
_c2sTestStartTime = getTimer();
+ TestResults.ndt_test_results::ndtTestStatus = "runningOutboundTest";
_testStage = SEND_DATA;
TestResults.appendDebugMsg("C2S test: SEND_DATA stage.");
=======================================
--- /trunk/flash-client/src/TestS2C.as Fri Jun 20 08:55:01 2014 UTC
+++ /trunk/flash-client/src/TestS2C.as Tue Nov 4 15:27:14 2014 UTC
@@ -84,12 +84,12 @@
NDTConstants.BUNDLE_NAME, "startingTest", null, Main.locale) +
ResourceManager.getInstance().getString(
NDTConstants.BUNDLE_NAME, "s2cThroughput", null, Main.locale))
- NDTUtils.callExternalFunction("startTested", "ServerToClientThroughput");
+ NDTUtils.callExternalFunction("testStarted", "ServerToClientThroughput");
TestResults.appendDebugMsg("S2C test: PREPARE_TEST stage.");
TestResults.appendDebugMsg(
ResourceManager.getInstance().getString(
NDTConstants.BUNDLE_NAME, "runningInboundTest", null, Main.locale));
- TestResults.ndt_test_results::ndtTestStatus = "runningInboundTest";
+ TestResults.ndt_test_results::ndtTestStatus = "preparingInboundTest";
addCtlSocketOnReceivedDataListener();
_msg = new Message();
@@ -294,6 +294,7 @@
// Record start time right before it starts receiving data, to be as
// accurate as possible.
_s2cTestStartTime = getTimer();
+ TestResults.ndt_test_results::ndtTestStatus = "runningInboundTest";
_testStage = RECEIVE_DATA;
TestResults.appendDebugMsg("S2C test: RECEIVE_DATA stage.");
=======================================
--- /trunk/flash-client/src/UserAgentTools.as Sun Feb 2 19:14:17 2014 UTC
+++ /trunk/flash-client/src/UserAgentTools.as Tue Nov 4 15:27:14 2014 UTC
@@ -20,6 +20,7 @@
package {
import mx.resources.ResourceManager;
import mx.utils.StringUtil;
+ import flash.system.Capabilities;
/**
* This class is use to obtain information about who is accessing a web-server.
* When a web browser accesses a web-server, it usually transmits a "User-Agent"
@@ -275,6 +276,17 @@
return ["?", "?", "?"];
return res;
}
+ public static function goodRuntimeCheck(userAgent:String):Boolean {
+ if (getBrowser(userAgent)[1] == 'KHTML(Chrome)') {
+ return true;
+ }
+ var os:String = flash.system.Capabilities.os.substr(0, 3);
+ if (os == "Win") {
+ return true;
+ }
+ else
+ return false;
+ }
}
}
- [ndt-dev] [ndt] r1138 committed - Merged Issue154 branch into trunk, ndt, 11/04/2014
Archive powered by MHonArc 2.6.16.