Skip to content

Commit

Permalink
Chrome Remote Desktop client integration for host OS details.
Browse files Browse the repository at this point in the history
This will add the first pass integration for the client to have an
understanding of what kind of host OS and what the host OS version it will be
connecting to. There is also a minor update to the client side test runner to
add an optional parameter (--build-path) to allow each testing for the newer
style of gn builds that want to target the out/Default directory. Build path
defaults to "out/Debug" as before, but it is now overridable to a new target.

R=kelvinp@chromium.org
BUG=534902

Review URL: https://codereview.chromium.org/1373913002

Cr-Commit-Position: refs/heads/master@{#351352}
  • Loading branch information
nicholss authored and Commit bot committed Sep 29, 2015
1 parent 20e1ede commit 284d97f
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 20 deletions.
25 changes: 18 additions & 7 deletions remoting/tools/run_webapp_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def GetChromePath():
return chrome_path


def BuildTestPageUri(opt_module=None, opt_coverage=False):
def BuildTestPageUri(build_path, opt_module=None, opt_coverage=False):
"""Builds the Uri for the test page with params."""
script_path = os.path.dirname(__file__)

test_page_path = os.path.join(script_path,
'../../out/Debug/remoting/unittests/unittests.html')
'../../' + build_path + '/remoting/unittests/unittests.html')
test_page_path = 'file://' + os.path.abspath(test_page_path)

test_page_params = {}
Expand All @@ -45,15 +45,15 @@ def BuildTestPageUri(opt_module=None, opt_coverage=False):
return '"' + test_page_path + '"'


def BuildCommandLine(chrome_path, opt_module, opt_coverage):
def BuildCommandLine(chrome_path, build_path, opt_module, opt_coverage):
"""Builds the command line to execute."""
command = []
command.append('"' + chrome_path + '"')
command.append('--user-data-dir=' + tempfile.gettempdir())
# The flag |--allow-file-access-from-files| is required so that we can open
# JavaScript files using XHR and instrument them for code coverage.
command.append(' --allow-file-access-from-files')
test_page_path = BuildTestPageUri(opt_module, opt_coverage)
test_page_path = BuildTestPageUri(build_path, opt_module, opt_coverage)
command.append(test_page_path)
return ' '.join(command)

Expand All @@ -67,9 +67,16 @@ def ParseArgs():
help='The path of the chrome binary to run the test.',
default=chrome_path)
parser.add_argument(
'--module', help='only run tests that belongs to MODULE')
'--module',
help='only run tests that belongs to MODULE')
parser.add_argument(
'--coverage', help='run the test with code coverage', action='store_true')
'--coverage',
help='run the test with code coverage',
action='store_true')
parser.add_argument(
'--build-path',
help='The output build path for remoting. (out/Debug)',
default='out/Debug')

return parser.parse_args(sys.argv[1:])

Expand All @@ -84,7 +91,11 @@ def main():
print 'binary to run the test.'
return 1

command_line = BuildCommandLine(args.chrome_path, args.module, args.coverage)
command_line = BuildCommandLine(
args.chrome_path,
args.build_path,
args.module,
args.coverage)
os.system(command_line)
return 0

Expand Down
33 changes: 33 additions & 0 deletions remoting/webapp/base/js/chromoting_event.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ remoting.ChromotingEvent = function(type) {
this.browser_version;
/** @private {string} */
this.webapp_version;
/** @type {remoting.ChromotingEvent.Os} */
this.host_os;
/** @type {string} */
this.host_os_version;
/** @type {string} */
this.host_version;
/** @private {string} */
Expand Down Expand Up @@ -167,6 +171,7 @@ remoting.ChromotingEvent.Role = {

/** @enum {number} */
remoting.ChromotingEvent.Os = {
UNKNOWN: 0,
LINUX: 1,
CHROMEOS: 2,
MAC: 3,
Expand All @@ -176,6 +181,34 @@ remoting.ChromotingEvent.Os = {
IOS: 7
};

/**
* Convert the OS type String into the enum value.
*
* @param {string} type
* @return {remoting.ChromotingEvent.Os}
*/
remoting.ChromotingEvent.toOs = function(type) {
type = type.toLowerCase();
switch (type) {
case 'linux':
return remoting.ChromotingEvent.Os.LINUX;
case 'chromeos':
return remoting.ChromotingEvent.Os.CHROMEOS;
case 'mac':
return remoting.ChromotingEvent.Os.MAC
case 'windows':
return remoting.ChromotingEvent.Os.WINDOWS;
case 'other':
return remoting.ChromotingEvent.Os.OTHER;
case 'android':
return remoting.ChromotingEvent.Os.ANDROID;
case 'ios':
return remoting.ChromotingEvent.Os.IOS;
default:
return remoting.ChromotingEvent.Os.UNKNOWN;
}
}

/** @enum {number} */
remoting.ChromotingEvent.SessionState = {
UNKNOWN: 1, // deprecated.
Expand Down
4 changes: 4 additions & 0 deletions remoting/webapp/base/js/host.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ remoting.Host = function(hostId) {
this.publicKey = '';
/** @type {string} */
this.hostVersion = '';
/** @type {remoting.ChromotingEvent.Os} */
this.hostOS = remoting.ChromotingEvent.Os.UNKNOWN;
/** @type {string} */
this.hostOSVersion = '';
/** @type {Array<string>} */
this.tokenUrlPatterns = [];
/** @type {string} */
Expand Down
20 changes: 18 additions & 2 deletions remoting/webapp/base/js/log_to_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ remoting.LogToServer.prototype.log_ = function(entry) {
this.authTotalTime_) / 1000.0;
entry.addSessionDuration(sessionDurationInSeconds);
entry.addApplicationId();
// The host-version will be blank for logs before a session has been created.
// For example, the signal-strategy log-entries won't have host version info.
// The host-version/os/os-version will be blank for logs before a session has
// been created. For example, the signal-strategy log-entries won't have host
// version info.
entry.addHostVersion(this.hostVersion_);

// Send the stanza to the debug log.
Expand Down Expand Up @@ -288,3 +289,18 @@ remoting.LogToServer.prototype.setAuthTotalTime = function(totalTime) {
remoting.LogToServer.prototype.setHostVersion = function(hostVersion) {
this.hostVersion_ = hostVersion;
};

/**
* Stub.
* @param {remoting.ChromotingEvent.Os} hostOS Type of the host OS for
current session.
* @return {void} Nothing.
*/
remoting.LogToServer.prototype.setHostOS = function(hostOS) {};

/**
* Stub.
* @param {string} hostOSVersion Version of the host OS for current session.
* @return {void} Nothing.
*/
remoting.LogToServer.prototype.setHostOSVersion = function(hostOSVersion) {};
15 changes: 14 additions & 1 deletion remoting/webapp/base/js/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ remoting.Logger.prototype.setAuthTotalTime = function(totalTime) {};
*/
remoting.Logger.prototype.setHostVersion = function(hostVersion) {};

/**
* @param {remoting.ChromotingEvent.Os} hostOS Type of the OS the host
* for the current session.
* @return {void} Nothing.
*/
remoting.Logger.prototype.setHostOS = function(hostOS) {};

/**
* @param {string} hostOSVersion Version of the host Os for current session.
* @return {void} Nothing.
*/
remoting.Logger.prototype.setHostOSVersion = function(hostOSVersion) {};

/**
* Set the connection type (direct, stun relay).
*
Expand Down Expand Up @@ -79,4 +92,4 @@ remoting.Logger.MAX_SESSION_ID_AGE = 24 * 60 * 60 * 1000;
// to the server, in milliseconds.
remoting.Logger.CONNECTION_STATS_ACCUMULATE_TIME = 60 * 1000;

})();
})();
17 changes: 16 additions & 1 deletion remoting/webapp/base/js/server_log_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,21 @@ remoting.ServerLogEntry.prototype.addHostVersion = function(hostVersion) {
this.set_(remoting.ServerLogEntry.KEY_HOST_VERSION_, hostVersion);
};

/**
* Stub.
* @param {remoting.ChromotingEvent.Os} hostOS type of the host OS for current
* session.
* @return {void} Nothing.
*/
remoting.ServerLogEntry.prototype.addHostOS = function(hostOS) {};

/**
* Stub.
* @param {string} hostOSVersion Version of the host OS for current session.
* @return {void} Nothing.
*/
remoting.ServerLogEntry.prototype.addHostOSVersion = function(hostOSVersion) {};

/**
* Adds a field specifying the mode to this log entry.
* @param {string} mode The current app mode (It2Me, Me2Me, AppRemoting).
Expand Down Expand Up @@ -454,4 +469,4 @@ remoting.ServerLogEntry.prototype.addXmppError = function(xmppError) {
}
this.set_(remoting.ServerLogEntry.KEY_XMPP_ERROR_RAW_STANZA,
xmppError.raw_stanza);
};
};
18 changes: 17 additions & 1 deletion remoting/webapp/base/js/session_logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ remoting.SessionLogger = function(role, writeLogEntry) {
this.authTotalTime_ = 0;
/** @private */
this.hostVersion_ = '';
/** @private {remoting.ChromotingEvent.Os}*/
this.hostOS_ = remoting.ChromotingEvent.Os.UNKNOWN;
/** @private */
this.hostOSVersion_ = '';

/** @private */
this.mode_ = remoting.ChromotingEvent.Mode.ME2ME;
Expand All @@ -67,6 +71,16 @@ remoting.SessionLogger.prototype.setHostVersion = function(hostVersion) {
this.hostVersion_ = hostVersion;
};

/** @override {remoting.Logger} */
remoting.SessionLogger.prototype.setHostOS = function(hostOS) {
this.hostOS_ = hostOS;
};

/** @override {remoting.Logger} */
remoting.SessionLogger.prototype.setHostOSVersion = function(hostOSVersion) {
this.hostOSVersion_ = hostOSVersion;
};

/** @override {remoting.Logger} */
remoting.SessionLogger.prototype.setConnectionType = function(connectionType) {
this.connectionType_ = toConnectionType(connectionType);
Expand Down Expand Up @@ -237,6 +251,8 @@ remoting.SessionLogger.prototype.fillEvent_ = function(entry) {
entry.connection_type = this.connectionType_;
}
entry.host_version = this.hostVersion_;
entry.host_os = this.hostOS_;
entry.host_os_version = this.hostOSVersion_;
};

/**
Expand Down Expand Up @@ -421,4 +437,4 @@ function toConnectionType(type) {
}
}

})();
})();
28 changes: 26 additions & 2 deletions remoting/webapp/base/js/session_logger_unittest.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ QUnit.test('logClientSessionStateChange()', function(assert){
logger.setLogEntryMode(Event.Mode.ME2ME);
logger.setConnectionType('stun');
logger.setHostVersion('host_version');
logger.setHostOS(remoting.ChromotingEvent.Os.OTHER);
logger.setHostOSVersion('host_os_version');

logger.logClientSessionStateChange(
remoting.ClientSession.State.FAILED,
Expand All @@ -102,6 +104,8 @@ QUnit.test('logClientSessionStateChange()', function(assert){
mode: Event.Mode.ME2ME,
connection_type: Event.ConnectionType.STUN,
host_version: 'host_version',
host_os: remoting.ChromotingEvent.Os.OTHER,
host_os_version: 'host_os_version',
session_id: sessionId
});
});
Expand All @@ -114,6 +118,8 @@ QUnit.test('logClientSessionStateChange() should handle XMPP error',
logger.setLogEntryMode(Event.Mode.ME2ME);
logger.setConnectionType('stun');
logger.setHostVersion('host_version');
logger.setHostOS(remoting.ChromotingEvent.Os.OTHER);
logger.setHostOSVersion('host_os_version');

var xmppError = new remoting.ChromotingEvent.XmppError('<fake-stanza/>');

Expand All @@ -137,6 +143,8 @@ QUnit.test('logClientSessionStateChange() should handle XMPP error',
mode: Event.Mode.ME2ME,
connection_type: Event.ConnectionType.STUN,
host_version: 'host_version',
host_os: remoting.ChromotingEvent.Os.OTHER,
host_os_version: 'host_os_version',
session_id: sessionId,
xmpp_error: {
raw_stanza: '<fake-stanza/>'
Expand All @@ -154,6 +162,8 @@ QUnit.test('logClientSessionStateChange() should handle sessionId change.',
logger.setLogEntryMode(Event.Mode.ME2ME);
logger.setConnectionType('relay');
logger.setHostVersion('host_version');
logger.setHostOS(remoting.ChromotingEvent.Os.OTHER);
logger.setHostOSVersion('host_os_version');
var oldSessionId = logger.getSessionId();

// Expires the session id.
Expand All @@ -175,7 +185,9 @@ QUnit.test('logClientSessionStateChange() should handle sessionId change.',
role: Event.Role.CLIENT,
mode: Event.Mode.ME2ME,
connection_type: Event.ConnectionType.RELAY,
host_version: 'host_version'
host_version: 'host_version',
host_os: remoting.ChromotingEvent.Os.OTHER,
host_os_version: 'host_os_version'
});

verifyEvent(assert, 1, {
Expand All @@ -189,7 +201,9 @@ QUnit.test('logClientSessionStateChange() should handle sessionId change.',
role: Event.Role.CLIENT,
mode: Event.Mode.ME2ME,
connection_type: Event.ConnectionType.RELAY,
host_version: 'host_version'
host_version: 'host_version',
host_os: remoting.ChromotingEvent.Os.OTHER,
host_os_version: 'host_os_version'
});

verifyEvent(assert, 2, {
Expand All @@ -205,6 +219,8 @@ QUnit.test('logClientSessionStateChange() should handle sessionId change.',
mode: Event.Mode.ME2ME,
connection_type: Event.ConnectionType.RELAY,
host_version: 'host_version',
host_os: remoting.ChromotingEvent.Os.OTHER,
host_os_version: 'host_os_version',
session_id: newSessionId
});
});
Expand All @@ -219,6 +235,8 @@ QUnit.test('logClientSessionStateChange() should log session_duration.',
logger.setLogEntryMode(Event.Mode.ME2ME);
logger.setConnectionType('direct');
logger.setHostVersion('host_version');
logger.setHostOS(remoting.ChromotingEvent.Os.OTHER);
logger.setHostOSVersion('host_os_version');
logger.setAuthTotalTime(1000);
clock.tick(2500);

Expand All @@ -239,6 +257,8 @@ QUnit.test('logClientSessionStateChange() should log session_duration.',
mode: Event.Mode.ME2ME,
connection_type: Event.ConnectionType.DIRECT,
host_version: 'host_version',
host_os: remoting.ChromotingEvent.Os.OTHER,
host_os_version: 'host_os_version',
session_id: logger.getSessionId(),
session_duration: 1.5
});
Expand All @@ -253,6 +273,8 @@ QUnit.test('logStatistics()', function(assert) {
logger.setLogEntryMode(Event.Mode.LGAPP);
logger.setConnectionType('direct');
logger.setHostVersion('host_version');
logger.setHostOS(remoting.ChromotingEvent.Os.OTHER);
logger.setHostOSVersion('host_os_version');

// Log the statistics.
logger.logStatistics({
Expand Down Expand Up @@ -297,6 +319,8 @@ QUnit.test('logStatistics()', function(assert) {
mode: Event.Mode.LGAPP,
connection_type: Event.ConnectionType.DIRECT,
host_version: 'host_version',
host_os: remoting.ChromotingEvent.Os.OTHER,
host_os_version: 'host_os_version',
session_id: logger.getSessionId(),
video_bandwidth: 2.0,
capture_latency: 2.0,
Expand Down
Loading

0 comments on commit 284d97f

Please sign in to comment.