Skip to content

Commit

Permalink
clang-format chrome/test/data/webui and enforce with presubmit
Browse files Browse the repository at this point in the history
R=dpapad@chromium.org
BUG=841000

Change-Id: I883d939366572189204bd22c1dc076ef37d60fe0
Reviewed-on: https://chromium-review.googlesource.com/1058676
Commit-Queue: Dan Beam (no longer on Chrome) <dbeam@chromium.org>
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558959}
  • Loading branch information
danbeam authored and Commit Bot committed May 16, 2018
1 parent a81e005 commit bf5a9a2
Show file tree
Hide file tree
Showing 113 changed files with 6,153 additions and 6,393 deletions.
5 changes: 1 addition & 4 deletions chrome/test/data/webui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
// found in the LICENSE file.

module.exports = {
'env': {
'browser': true,
'es6': true
},
'env': {'browser': true, 'es6': true},
'rules': {
'no-restricted-properties': 'off',
},
Expand Down
2 changes: 2 additions & 0 deletions chrome/test/data/webui/PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def _CommonChecks(input_api, output_api):
input_api, output_api)
finally:
sys.path = old_sys_path
results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api,
check_js=True)
return results


Expand Down
17 changes: 7 additions & 10 deletions chrome/test/data/webui/a11y/accessibility_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ AccessibilityTest.filterViolations_ = function(violations, filter) {
for (let violation of violations) {
if (violation.id in filter) {
let exclusionRule = filter[violation.id];
violation.nodes = violation.nodes.filter(
(node) => !exclusionRule(node));
violation.nodes = violation.nodes.filter((node) => !exclusionRule(node));
}

if (violation.nodes.length > 0) {
Expand All @@ -120,8 +119,8 @@ AccessibilityTest.define = function(testFixture, testDef) {
testDef.setup = testDef.setup || (() => {});

// Define a test for each audit rule separately.
let rules = axeOptions.runOnly ?
axeOptions.runOnly.values : AccessibilityTest.ruleIds;
let rules = axeOptions.runOnly ? axeOptions.runOnly.values :
AccessibilityTest.ruleIds;
rules.forEach((ruleId) => {
// Skip rules disabled in axeOptions.
if (axeOptions.rules && ruleId in axeOptions.rules &&
Expand All @@ -134,18 +133,16 @@ AccessibilityTest.define = function(testFixture, testDef) {
// Replace hyphens, which break the build.
newTestDef.name = newTestDef.name.replace(new RegExp('-', 'g'), '_');
newTestDef.axeOptions = Object.assign({}, axeOptions);
newTestDef.axeOptions.runOnly = {
type: 'rule',
values: [ruleId]
};
newTestDef.axeOptions.runOnly = {type: 'rule', values: [ruleId]};

TEST_F(testFixture, newTestDef.name, () => {
// Define the mocha tests
suite(newTestDef.name, () => {
setup(newTestDef.setup.bind(newTestDef));
for (let testMember in newTestDef.tests) {
test(testMember, AccessibilityTest.getMochaTest_(
testMember, newTestDef));
test(
testMember,
AccessibilityTest.getMochaTest_(testMember, newTestDef));
}
});
mocha.grep(newTestDef.name).run();
Expand Down
46 changes: 23 additions & 23 deletions chrome/test/data/webui/about_invalidations_browsertest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ InvalidationsWebUITest.prototype = {
// Test that registering an invalidations appears properly on the textarea.
TEST_F('InvalidationsWebUITest', 'testRegisteringNewInvalidation', function() {
var invalidationsLog = $('invalidations-log');
var invalidation = [{
isUnknownVersion: 'true',
objectId: {name: 'EXTENSIONS', source: 1004}
}];
var invalidation = [
{isUnknownVersion: 'true', objectId: {name: 'EXTENSIONS', source: 1004}}
];
invalidationsLog.value = '';
chrome.invalidations.logInvalidations(invalidation);
var isContained =
invalidationsLog.value.indexOf(
'Received Invalidation with type ' +
'"EXTENSIONS" version "Unknown" with payload "undefined"') != -1;
invalidationsLog.value.indexOf(
'Received Invalidation with type ' +
'"EXTENSIONS" version "Unknown" with payload "undefined"') != -1;
expectTrue(isContained, 'Actual log is:' + invalidationsLog.value);

});
Expand All @@ -46,27 +45,26 @@ TEST_F('InvalidationsWebUITest', 'testChangingInvalidationsState', function() {
var newNewState = 'TRANSIENT_INVALIDATION_ERROR';

chrome.invalidations.updateInvalidatorState(newState);
var isContainedState = invalidationsState.textContent.indexOf(
'INVALIDATIONS_ENABLED') != -1;
var isContainedState =
invalidationsState.textContent.indexOf('INVALIDATIONS_ENABLED') != -1;
expectTrue(isContainedState, 'could not change the invalidations text');

invalidationsLog.value = '';
chrome.invalidations.updateInvalidatorState(newNewState);
var isContainedState2 = invalidationsState.textContent.indexOf(
'TRANSIENT_INVALIDATION_ERROR') != -1;
'TRANSIENT_INVALIDATION_ERROR') != -1;
expectTrue(isContainedState2, 'could not change the invalidations text');
var isContainedLog =
invalidationsLog.value.indexOf(
'Invalidations service state changed to ' +
'"TRANSIENT_INVALIDATION_ERROR"') != -1;
var isContainedLog = invalidationsLog.value.indexOf(
'Invalidations service state changed to ' +
'"TRANSIENT_INVALIDATION_ERROR"') != -1;
expectTrue(isContainedLog, 'Actual log is:' + invalidationsLog.value);
});

// Test that objects ids appear on the table.
TEST_F('InvalidationsWebUITest', 'testRegisteringNewIds', function() {
var newDataType = [
{ name: 'EXTENSIONS', source: 1004, totalCount: 0},
{ name: 'FAVICON_IMAGE', source: 1004, totalCount: 0}
{name: 'EXTENSIONS', source: 1004, totalCount: 0},
{name: 'FAVICON_IMAGE', source: 1004, totalCount: 0}
];
var pattern1 = ['Fake', '1004', 'EXTENSIONS', '0', '0', '', '', ''];
var pattern2 = ['Fake', '1004', 'FAVICON_IMAGE', '0', '0', '', '', ''];
Expand All @@ -84,10 +82,10 @@ TEST_F('InvalidationsWebUITest', 'testRegisteringNewIds', function() {
var pattern1Test = true;
var pattern2Test = true;
for (var cell = 0; cell < oidTable.rows[row].cells.length; cell++) {
pattern1Test = pattern1Test
&& (pattern1[cell] == oidTable.rows[row].cells[cell].textContent);
pattern2Test = pattern2Test
&& (pattern2[cell] == oidTable.rows[row].cells[cell].textContent);
pattern1Test = pattern1Test &&
(pattern1[cell] == oidTable.rows[row].cells[cell].textContent);
pattern2Test = pattern2Test &&
(pattern2[cell] == oidTable.rows[row].cells[cell].textContent);
}
if (pattern1Test)
expectEquals('greyed', oidTable.rows[row].className);
Expand All @@ -99,12 +97,14 @@ TEST_F('InvalidationsWebUITest', 'testRegisteringNewIds', function() {
if (foundPattern2)
expectTrue(foundPattern1, 'The entries were not ordererd');
}
expectTrue(foundPattern1 && foundPattern2, "couldn't find both objects ids");
expectTrue(foundPattern1 && foundPattern2, 'couldn\'t find both objects ids');
});

// Test that registering new handlers appear on the website.
TEST_F('InvalidationsWebUITest', 'testUpdatingRegisteredHandlers', function() {
function text() { return $('registered-handlers').textContent; }
function text() {
return $('registered-handlers').textContent;
}
chrome.invalidations.updateHandlers(['FakeApi', 'FakeClient']);
expectNotEquals(text().indexOf('FakeApi'), -1);
expectNotEquals(text().indexOf('FakeClient'), -1);
Expand All @@ -118,5 +118,5 @@ TEST_F('InvalidationsWebUITest', 'testUpdatingRegisteredHandlers', function() {
TEST_F('InvalidationsWebUITest', 'testUpdatingInternalDisplay', function() {
var newDetailedStatus = {MessagesSent: 1};
chrome.invalidations.updateDetailedStatus(newDetailedStatus);
expectEquals( $('internal-display').value, '{\n \"MessagesSent\": 1\n}');
expectEquals($('internal-display').value, '{\n \"MessagesSent\": 1\n}');
});
Loading

0 comments on commit bf5a9a2

Please sign in to comment.