Commit 1276d02c authored by Ben Reich's avatar Ben Reich Committed by Commit Bot

[js-code-coverage] Update Provider tests to optionally use $i18n{} label

CL:2559234 introduced changes to disable $i18n{} template replacement
when the --devtools-code-coverage command line flag is passed and only
for the ChromeOS Files app extension in-test.

Introduce a helper to identify when a files app Providers test is in
code coverage mode and use the $i18n{} label instead of the replaced
string.

	--devtools-code-coverage

Bug: 1152612
Test: browser_tests --gtest_filter="Providers/*"
Test: browser_tests --gtest_filter="Providers/*"
Change-Id: I7eb906895f21912e96d18b488e3ca239a9d26dd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2558818Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#831201}
parent 16224751
......@@ -40,6 +40,20 @@
return appId;
}
/**
* Returns $i18n{} label if devtools code coverage is active, otherwise
* replaced text.
*/
async function getExpectedInstallNewServiceLabelText() {
const isDevtoolsCoverageActive =
await sendTestMessage({name: 'isDevtoolsCoverageActive'});
if (isDevtoolsCoverageActive === 'true') {
return '$i18n{INSTALL_NEW_EXTENSION_LABEL}';
}
return 'Install new service';
}
/**
* Clicks on the gear menu.
*/
......@@ -206,9 +220,10 @@
'queryAllElements', appId, selector);
// Check the sub-menu do not contain the |manifest| provider.
const expectedLabelText = await getExpectedInstallNewServiceLabelText();
chrome.test.assertEq(2, submenu.length);
chrome.test.assertEq('SMB file share', submenu[0].text);
chrome.test.assertEq('Install new service', submenu[1].text);
chrome.test.assertEq(expectedLabelText, submenu[1].text);
}
/**
......@@ -283,10 +298,11 @@
const appId = await setUpProvider('manifest.json');
await showProvidersMenu(appId);
const expectedLabelText = await getExpectedInstallNewServiceLabelText();
const selector = '#add-new-services-menu:not([hidden]) ' +
'cr-menu-item[command="#install-new-extension"]:not([disabled])';
const element = await remoteCall.waitForElement(appId, selector);
chrome.test.assertEq('Install new service', element.text);
chrome.test.assertEq(expectedLabelText, element.text);
chrome.test.assertFalse(element.hidden);
};
......@@ -297,10 +313,11 @@
const appId = await setUpProvider('manifest.json');
await showProvidersMenu(appId);
const expectedLabelText = await getExpectedInstallNewServiceLabelText();
const selector = '#add-new-services-menu:not([hidden]) ' +
'cr-menu-item[command="#install-new-extension"][disabled]';
const element = await remoteCall.waitForElement(appId, selector);
chrome.test.assertEq('Install new service', element.text);
chrome.test.assertEq(expectedLabelText, element.text);
chrome.test.assertFalse(element.hidden);
};
})();
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