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) {
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) {
content::WebContents* helpee_content = SetUpTest();
LoadScript(helpee_content, FILE_PATH_LITERAL("it2me_browser_test.js"));
......
......@@ -249,7 +249,7 @@ browserTest.enterPIN = function(pin, opt_expectError) {
if (opt_expectError) {
return browserTest.expectConnectionError(
remoting.DesktopConnectedView.Mode.ME2ME,
remoting.Error.Tag.INVALID_ACCESS_CODE);
[remoting.Error.Tag.INVALID_ACCESS_CODE]);
} else {
return browserTest.expectConnected();
}
......@@ -258,10 +258,10 @@ browserTest.enterPIN = function(pin, opt_expectError) {
/**
* @param {remoting.DesktopConnectedView.Mode} connectionMode
* @param {string} errorTag
* @param {Array<remoting.Error.Tag>} errorTags
* @return {Promise}
*/
browserTest.expectConnectionError = function(connectionMode, errorTag) {
browserTest.expectConnectionError = function(connectionMode, errorTags) {
var AppMode = remoting.AppMode;
var Timeout = browserTest.Timeout;
......@@ -285,12 +285,14 @@ browserTest.expectConnectionError = function(connectionMode, errorTag) {
/** @type {Element} */
var errorDiv = document.getElementById('connect-error-message');
var actual = errorDiv.innerText;
var expected = l10n.getTranslationOrError(errorTag);
var expected = errorTags.map(function(/** string */errorTag) {
return l10n.getTranslationOrError(errorTag);
});
browserTest.clickOnControl(finishButton);
if (actual != expected) {
return Promise.reject('Unexpected failure. actual:' + actual +
' expected:' + expected);
if (expected.indexOf(actual) === -1) {
return Promise.reject('Unexpected failure. actual: ' + actual +
' expected: ' + expected.join(','));
}
});
......
......@@ -64,9 +64,10 @@ browserTest.InvalidAccessCode.prototype.run = function(data) {
browserTest.ConnectIt2Me.clickOnAccessButton().then(function() {
document.getElementById('access-code-entry').value = data.accessCode;
browserTest.clickOnControl('connect-button');
var ErrorTag = remoting.Error.Tag;
return browserTest.expectConnectionError(
remoting.DesktopConnectedView.Mode.IT2ME,
remoting.Error.Tag.INVALID_ACCESS_CODE);
[ErrorTag.INVALID_ACCESS_CODE, ErrorTag.HOST_IS_OFFLINE]);
}).then(function() {
browserTest.pass();
}, function(/** * */reason) {
......@@ -97,7 +98,19 @@ browserTest.GetAccessCode.prototype.run = function() {
Number.isInteger(numericAccessCode) && numericAccessCode > 0,
"The access code should be a positive integer.");
browserTest.pass();
}, function(/** * */reason) {
browserTest.fail(/** @type {Error} */(reason));
}).catch(function(/** 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() {
*/
remoting.DesktopRemoting.prototype.handleConnectionFailed = function(
connector, error) {
/** @type {remoting.DesktopRemoting} */
var that = this;
/** @param {boolean} success */
var onHostListRefresh = function(success) {
var onHostListRefresh = function(/** boolean */ success) {
if (success) {
var host = remoting.hostList.getHostForId(connector.getHostId());
if (host) {
......@@ -274,9 +271,12 @@ remoting.DesktopRemoting.prototype.handleConnectionFailed = function(
that.handleError(error);
};
var mode = this.app_.getSessionConnector().getConnectionMode();
if (error.hasTag(remoting.Error.Tag.HOST_IS_OFFLINE) &&
that.refreshHostJidIfOffline_) {
that.refreshHostJidIfOffline_ = false;
mode === remoting.DesktopConnectedView.Mode.ME2ME &&
this.refreshHostJidIfOffline_) {
this.refreshHostJidIfOffline_ = false;
// The plugin will be re-created when the host finished refreshing
remoting.hostList.refresh(onHostListRefresh);
} else {
......
......@@ -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=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_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_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
......
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