Commit 6f0f0e54 authored by kelvinp's avatar kelvinp Committed by Commit bot

Implements It2MeBrowserTest CancelShare and VerifyAccessCodeNotReusable

This CL implements two P0 browser test cases
- It2MeBrowserTest.CancelShare
- It2MeBrowserTest.VerifyAccessCodeNotReusable

This only behavioral change in this CL is that we will always return INVALID_ACCESS_CODE
for It2Me Connections failed with HOST_IS_OFFLINE.
HOST_IS_OFFLINE suggests that the host portion of the access code
is invalid and we should hide this implementation detail from the user.

BUG=466849,466850

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

Cr-Commit-Position: refs/heads/master@{#320835}
parent e729dfe8
...@@ -42,6 +42,35 @@ IN_PROC_BROWSER_TEST_F(It2MeBrowserTest, MANUAL_Connect) { ...@@ -42,6 +42,35 @@ IN_PROC_BROWSER_TEST_F(It2MeBrowserTest, MANUAL_Connect) {
Cleanup(); Cleanup();
} }
IN_PROC_BROWSER_TEST_F(It2MeBrowserTest, MANUAL_CancelShare) {
content::WebContents* helpee_content = SetUpTest();
LoadScript(helpee_content, FILE_PATH_LITERAL("it2me_browser_test.js"));
std::string access_code = GetAccessCode(helpee_content);
RunJavaScriptTest(helpee_content, "CancelShare", "{}");
content::WebContents* helper_content = SetUpHelperInstance();
RunJavaScriptTest(helper_content, "InvalidAccessCode", "{"
"accessCode: '" + access_code + "'"
"}");
Cleanup();
}
IN_PROC_BROWSER_TEST_F(It2MeBrowserTest, MANUAL_VerifyAccessCodeNonReusable) {
content::WebContents* helpee_content = SetUpTest();
LoadScript(helpee_content, FILE_PATH_LITERAL("it2me_browser_test.js"));
std::string access_code = GetAccessCode(helpee_content);
content::WebContents* helper_content = SetUpHelperInstance();
RunJavaScriptTest(helper_content, "ConnectIt2Me", "{"
"accessCode: '" + access_code + "'"
"}");
RunJavaScriptTest(helper_content, "InvalidAccessCode", "{"
"accessCode: '" + access_code + "'"
"}");
Cleanup();
}
IN_PROC_BROWSER_TEST_F(It2MeBrowserTest, MANUAL_InvalidAccessCode) { IN_PROC_BROWSER_TEST_F(It2MeBrowserTest, MANUAL_InvalidAccessCode) {
content::WebContents* helpee_content = SetUpTest(); content::WebContents* helpee_content = SetUpTest();
LoadScript(helpee_content, FILE_PATH_LITERAL("it2me_browser_test.js")); LoadScript(helpee_content, FILE_PATH_LITERAL("it2me_browser_test.js"));
......
...@@ -249,7 +249,7 @@ browserTest.enterPIN = function(pin, opt_expectError) { ...@@ -249,7 +249,7 @@ browserTest.enterPIN = function(pin, opt_expectError) {
if (opt_expectError) { if (opt_expectError) {
return browserTest.expectConnectionError( return browserTest.expectConnectionError(
remoting.DesktopConnectedView.Mode.ME2ME, remoting.DesktopConnectedView.Mode.ME2ME,
remoting.Error.Tag.INVALID_ACCESS_CODE); [remoting.Error.Tag.INVALID_ACCESS_CODE]);
} else { } else {
return browserTest.expectConnected(); return browserTest.expectConnected();
} }
...@@ -258,10 +258,10 @@ browserTest.enterPIN = function(pin, opt_expectError) { ...@@ -258,10 +258,10 @@ browserTest.enterPIN = function(pin, opt_expectError) {
/** /**
* @param {remoting.DesktopConnectedView.Mode} connectionMode * @param {remoting.DesktopConnectedView.Mode} connectionMode
* @param {string} errorTag * @param {Array<remoting.Error.Tag>} errorTags
* @return {Promise} * @return {Promise}
*/ */
browserTest.expectConnectionError = function(connectionMode, errorTag) { browserTest.expectConnectionError = function(connectionMode, errorTags) {
var AppMode = remoting.AppMode; var AppMode = remoting.AppMode;
var Timeout = browserTest.Timeout; var Timeout = browserTest.Timeout;
...@@ -285,12 +285,14 @@ browserTest.expectConnectionError = function(connectionMode, errorTag) { ...@@ -285,12 +285,14 @@ browserTest.expectConnectionError = function(connectionMode, errorTag) {
/** @type {Element} */ /** @type {Element} */
var errorDiv = document.getElementById('connect-error-message'); var errorDiv = document.getElementById('connect-error-message');
var actual = errorDiv.innerText; var actual = errorDiv.innerText;
var expected = l10n.getTranslationOrError(errorTag); var expected = errorTags.map(function(/** string */errorTag) {
return l10n.getTranslationOrError(errorTag);
});
browserTest.clickOnControl(finishButton); browserTest.clickOnControl(finishButton);
if (actual != expected) { if (expected.indexOf(actual) === -1) {
return Promise.reject('Unexpected failure. actual:' + actual + return Promise.reject('Unexpected failure. actual: ' + actual +
' expected:' + expected); ' expected: ' + expected.join(','));
} }
}); });
......
...@@ -64,9 +64,10 @@ browserTest.InvalidAccessCode.prototype.run = function(data) { ...@@ -64,9 +64,10 @@ browserTest.InvalidAccessCode.prototype.run = function(data) {
browserTest.ConnectIt2Me.clickOnAccessButton().then(function() { browserTest.ConnectIt2Me.clickOnAccessButton().then(function() {
document.getElementById('access-code-entry').value = data.accessCode; document.getElementById('access-code-entry').value = data.accessCode;
browserTest.clickOnControl('connect-button'); browserTest.clickOnControl('connect-button');
var ErrorTag = remoting.Error.Tag;
return browserTest.expectConnectionError( return browserTest.expectConnectionError(
remoting.DesktopConnectedView.Mode.IT2ME, remoting.DesktopConnectedView.Mode.IT2ME,
remoting.Error.Tag.INVALID_ACCESS_CODE); [ErrorTag.INVALID_ACCESS_CODE, ErrorTag.HOST_IS_OFFLINE]);
}).then(function() { }).then(function() {
browserTest.pass(); browserTest.pass();
}, function(/** * */reason) { }, function(/** * */reason) {
...@@ -97,7 +98,19 @@ browserTest.GetAccessCode.prototype.run = function() { ...@@ -97,7 +98,19 @@ browserTest.GetAccessCode.prototype.run = function() {
Number.isInteger(numericAccessCode) && numericAccessCode > 0, Number.isInteger(numericAccessCode) && numericAccessCode > 0,
"The access code should be a positive integer."); "The access code should be a positive integer.");
browserTest.pass(); browserTest.pass();
}, function(/** * */reason) { }).catch(function(/** Error */ reason) {
browserTest.fail(/** @type {Error} */(reason)); browserTest.fail(reason);
}); });
}; };
/** @constructor */
browserTest.CancelShare = function() {};
browserTest.CancelShare.prototype.run = function() {
browserTest.clickOnControl('cancel-share-button');
browserTest.onUIMode(remoting.AppMode.HOST_SHARE_FINISHED).then(function() {
browserTest.pass();
}).catch(function(/** Error */ reason) {
browserTest.fail(reason);
});
};
\ No newline at end of file
...@@ -259,11 +259,8 @@ remoting.DesktopRemoting.prototype.handleDisconnected = function() { ...@@ -259,11 +259,8 @@ remoting.DesktopRemoting.prototype.handleDisconnected = function() {
*/ */
remoting.DesktopRemoting.prototype.handleConnectionFailed = function( remoting.DesktopRemoting.prototype.handleConnectionFailed = function(
connector, error) { connector, error) {
/** @type {remoting.DesktopRemoting} */
var that = this; var that = this;
var onHostListRefresh = function(/** boolean */ success) {
/** @param {boolean} success */
var onHostListRefresh = function(success) {
if (success) { if (success) {
var host = remoting.hostList.getHostForId(connector.getHostId()); var host = remoting.hostList.getHostForId(connector.getHostId());
if (host) { if (host) {
...@@ -274,9 +271,12 @@ remoting.DesktopRemoting.prototype.handleConnectionFailed = function( ...@@ -274,9 +271,12 @@ remoting.DesktopRemoting.prototype.handleConnectionFailed = function(
that.handleError(error); that.handleError(error);
}; };
var mode = this.app_.getSessionConnector().getConnectionMode();
if (error.hasTag(remoting.Error.Tag.HOST_IS_OFFLINE) && if (error.hasTag(remoting.Error.Tag.HOST_IS_OFFLINE) &&
that.refreshHostJidIfOffline_) { mode === remoting.DesktopConnectedView.Mode.ME2ME &&
that.refreshHostJidIfOffline_ = false; this.refreshHostJidIfOffline_) {
this.refreshHostJidIfOffline_ = false;
// The plugin will be re-created when the host finished refreshing // The plugin will be re-created when the host finished refreshing
remoting.hostList.refresh(onHostListRefresh); remoting.hostList.refresh(onHostListRefresh);
} else { } else {
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
/usr/bin/python ../xvfb.py #PROD_DIR# #PROD_DIR#/browser_tests --gtest_filter=Me2MeBrowserTest.MANUAL_Me2Me_v2_Alive_OnLostFocus --run-manual --ui-test-action-timeout=100000 --webapp-unpacked=#PROD_DIR#/remoting/remoting.webapp.v2 --extension-name=Chromoting --accounts-file=../../remoting/tools/internal/test_accounts.json --account-type=gmail --me2me-pin=123456 --override-user-data-dir=/tmp/chromoting_test_profile /usr/bin/python ../xvfb.py #PROD_DIR# #PROD_DIR#/browser_tests --gtest_filter=Me2MeBrowserTest.MANUAL_Me2Me_v2_Alive_OnLostFocus --run-manual --ui-test-action-timeout=100000 --webapp-unpacked=#PROD_DIR#/remoting/remoting.webapp.v2 --extension-name=Chromoting --accounts-file=../../remoting/tools/internal/test_accounts.json --account-type=gmail --me2me-pin=123456 --override-user-data-dir=/tmp/chromoting_test_profile
/usr/bin/python ../xvfb.py #PROD_DIR# #PROD_DIR#/browser_tests --gtest_filter=It2MeBrowserTest.MANUAL_Connect --run-manual --ui-test-action-timeout=100000 --webapp-unpacked=#PROD_DIR#/remoting/remoting.webapp --extension-name=Chromoting --accounts-file=../../remoting/tools/internal/test_accounts.json --account-type=gmail --override-user-data-dir=/tmp/chromoting_test_profile /usr/bin/python ../xvfb.py #PROD_DIR# #PROD_DIR#/browser_tests --gtest_filter=It2MeBrowserTest.MANUAL_Connect --run-manual --ui-test-action-timeout=100000 --webapp-unpacked=#PROD_DIR#/remoting/remoting.webapp --extension-name=Chromoting --accounts-file=../../remoting/tools/internal/test_accounts.json --account-type=gmail --override-user-data-dir=/tmp/chromoting_test_profile
/usr/bin/python ../xvfb.py #PROD_DIR# #PROD_DIR#/browser_tests --gtest_filter=It2MeBrowserTest.MANUAL_InvalidAccessCode --run-manual --ui-test-action-timeout=100000 --webapp-unpacked=#PROD_DIR#/remoting/remoting.webapp --extension-name=Chromoting --accounts-file=../../remoting/tools/internal/test_accounts.json --account-type=gmail --override-user-data-dir=/tmp/chromoting_test_profile /usr/bin/python ../xvfb.py #PROD_DIR# #PROD_DIR#/browser_tests --gtest_filter=It2MeBrowserTest.MANUAL_InvalidAccessCode --run-manual --ui-test-action-timeout=100000 --webapp-unpacked=#PROD_DIR#/remoting/remoting.webapp --extension-name=Chromoting --accounts-file=../../remoting/tools/internal/test_accounts.json --account-type=gmail --override-user-data-dir=/tmp/chromoting_test_profile
/usr/bin/python ../xvfb.py #PROD_DIR# #PROD_DIR#/browser_tests --gtest_filter=It2MeBrowserTest.MANUAL_CancelShare --run-manual --ui-test-action-timeout=100000 --webapp-unpacked=#PROD_DIR#/remoting/remoting.webapp --extension-name=Chromoting --accounts-file=../../remoting/tools/internal/test_accounts.json --account-type=gmail --override-user-data-dir=/tmp/chromoting_test_profile
/usr/bin/python ../xvfb.py #PROD_DIR# #PROD_DIR#/browser_tests --gtest_filter=It2MeBrowserTest.MANUAL_VerifyAccessCodeNonReusable --run-manual --ui-test-action-timeout=100000 --webapp-unpacked=#PROD_DIR#/remoting/remoting.webapp --extension-name=Chromoting --accounts-file=../../remoting/tools/internal/test_accounts.json --account-type=gmail --override-user-data-dir=/tmp/chromoting_test_profile
/usr/bin/python ../xvfb.py #PROD_DIR# #PROD_DIR#/browser_tests --gtest_filter=RemoteDesktopBrowserTest.MANUAL_Cancel_PIN --run-manual --ui-test-action-timeout=100000 --webapp-unpacked=#PROD_DIR#/remoting/remoting.webapp.v2 --extension-name=Chromoting --accounts-file=../../remoting/tools/internal/test_accounts.json --account-type=gmail --me2me-pin=123456 --override-user-data-dir=/tmp/chromoting_test_profile /usr/bin/python ../xvfb.py #PROD_DIR# #PROD_DIR#/browser_tests --gtest_filter=RemoteDesktopBrowserTest.MANUAL_Cancel_PIN --run-manual --ui-test-action-timeout=100000 --webapp-unpacked=#PROD_DIR#/remoting/remoting.webapp.v2 --extension-name=Chromoting --accounts-file=../../remoting/tools/internal/test_accounts.json --account-type=gmail --me2me-pin=123456 --override-user-data-dir=/tmp/chromoting_test_profile
/usr/bin/python ../xvfb.py #PROD_DIR# #PROD_DIR#/browser_tests --gtest_filter=RemoteDesktopBrowserTest.MANUAL_Update_PIN --run-manual --ui-test-action-timeout=100000 --webapp-unpacked=#PROD_DIR#/remoting/remoting.webapp.v2 --extension-name=Chromoting --accounts-file=../../remoting/tools/internal/test_accounts.json --account-type=gmail --me2me-pin=123456 --override-user-data-dir=/tmp/chromoting_test_profile /usr/bin/python ../xvfb.py #PROD_DIR# #PROD_DIR#/browser_tests --gtest_filter=RemoteDesktopBrowserTest.MANUAL_Update_PIN --run-manual --ui-test-action-timeout=100000 --webapp-unpacked=#PROD_DIR#/remoting/remoting.webapp.v2 --extension-name=Chromoting --accounts-file=../../remoting/tools/internal/test_accounts.json --account-type=gmail --me2me-pin=123456 --override-user-data-dir=/tmp/chromoting_test_profile
/usr/bin/python ../xvfb.py #PROD_DIR# #PROD_DIR#/browser_tests --gtest_filter=RemoteDesktopBrowserTest.MANUAL_Invalid_PIN --run-manual --ui-test-action-timeout=100000 --webapp-unpacked=#PROD_DIR#/remoting/remoting.webapp.v2 --extension-name=Chromoting --accounts-file=../../remoting/tools/internal/test_accounts.json --account-type=gmail --me2me-pin=123457 --override-user-data-dir=/tmp/chromoting_test_profile /usr/bin/python ../xvfb.py #PROD_DIR# #PROD_DIR#/browser_tests --gtest_filter=RemoteDesktopBrowserTest.MANUAL_Invalid_PIN --run-manual --ui-test-action-timeout=100000 --webapp-unpacked=#PROD_DIR#/remoting/remoting.webapp.v2 --extension-name=Chromoting --accounts-file=../../remoting/tools/internal/test_accounts.json --account-type=gmail --me2me-pin=123457 --override-user-data-dir=/tmp/chromoting_test_profile
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment