Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r1136 committed - Applied Jordan's patch

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r1136 committed - Applied Jordan's patch


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r1136 committed - Applied Jordan's patch
  • Date: Mon, 03 Nov 2014 15:30:55 +0000

Revision: 1136
Author:

Date: Mon Nov 3 15:30:35 2014 UTC
Log: Applied Jordan's patch

https://code.google.com/p/ndt/source/detail?r=1136

Modified:
/branches/Issue154/flash-client/src/GUI.as
/branches/Issue154/flash-client/src/Main.as
/branches/Issue154/flash-client/src/NDTConstants.as
/branches/Issue154/flash-client/src/NDTPController.as
/branches/Issue154/flash-client/src/NDTUtils.as
/branches/Issue154/flash-client/src/TestC2S.as
/branches/Issue154/flash-client/src/TestS2C.as
/branches/Issue154/flash-client/src/UserAgentTools.as

=======================================
--- /branches/Issue154/flash-client/src/GUI.as Fri Jun 20 08:55:48 2014 UTC
+++ /branches/Issue154/flash-client/src/GUI.as Mon Nov 3 15:30:35 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 {
=======================================
--- /branches/Issue154/flash-client/src/Main.as Mon Jun 30 20:05:07 2014 UTC
+++ /branches/Issue154/flash-client/src/Main.as Mon Nov 3 15:30:35 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;
+ }
}
}
=======================================
--- /branches/Issue154/flash-client/src/NDTConstants.as Fri Mar 21 10:33:50 2014 UTC
+++ /branches/Issue154/flash-client/src/NDTConstants.as Mon Nov 3 15:30:35 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.";
}
}

=======================================
--- /branches/Issue154/flash-client/src/NDTPController.as Wed Jun 18 07:06:05 2014 UTC
+++ /branches/Issue154/flash-client/src/NDTPController.as Mon Nov 3 15:30:35 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;
=======================================
--- /branches/Issue154/flash-client/src/NDTUtils.as Wed Jun 18 07:06:05 2014 UTC
+++ /branches/Issue154/flash-client/src/NDTUtils.as Mon Nov 3 15:30:35 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.
=======================================
--- /branches/Issue154/flash-client/src/TestC2S.as Fri Jun 20 08:55:01 2014 UTC
+++ /branches/Issue154/flash-client/src/TestC2S.as Mon Nov 3 15:30:35 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.");
=======================================
--- /branches/Issue154/flash-client/src/TestS2C.as Fri Jun 20 08:55:01 2014 UTC
+++ /branches/Issue154/flash-client/src/TestS2C.as Mon Nov 3 15:30:35 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.");
=======================================
--- /branches/Issue154/flash-client/src/UserAgentTools.as Sun Feb 2 19:14:17 2014 UTC
+++ /branches/Issue154/flash-client/src/UserAgentTools.as Mon Nov 3 15:30:35 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] r1136 committed - Applied Jordan's patch, ndt, 11/03/2014

Archive powered by MHonArc 2.6.16.

Top of Page