Commit 9f6c0197 authored by kochi's avatar kochi Committed by Commit bot

Give better assertion fail message on focus move test

Old:
assert_true: should move from XXX to YYY expected true got false

New (actually in one line):
assert_equals: Focus should move forward from XXX to YYY
expected Element node <input id="YYY"></input> but
got Element node <input id="ZZZ">

Review-Url: https://codereview.chromium.org/2430313003
Cr-Commit-Position: refs/heads/master@{#427019}
parent 35feaa96
......@@ -42,7 +42,7 @@ function shouldNavigateFocus(from, to, direction)
else
navigateFocusBackward();
return isInnermostActiveElement(to);
return true;
}
function navigateFocusForward()
......@@ -57,16 +57,28 @@ function navigateFocusBackward()
eventSender.keyDown('\t', ['shiftKey']);
}
function assert_focus_navigation(from, to, direction)
{
const result = shouldNavigateFocus(from, to, direction);
assert_true(result, 'Failed to focus ' + from);
const message = 'Focus should move ' + direction +
' from ' + from + ' to ' + to;
var toElement = getNodeInComposedTree(to);
assert_equals(innermostActiveElement(), toElement, message);
}
function assert_focus_navigation_forward(elements)
{
assert_true(elements.length >= 2,
'length of elements should be greater than or equal to 2.');
for (var i = 0; i + 1 < elements.length; ++i)
assert_true(shouldNavigateFocus(elements[i], elements[i + 1], 'forward'),
'Focus should move from ' + elements[i] + ' to ' + elements[i + 1]);
assert_focus_navigation(elements[i], elements[i + 1], 'forward');
}
function assert_focus_navigation_backward(elements)
{
assert_true(elements.length >= 2,
'length of elements should be greater than or equal to 2.');
for (var i = 0; i + 1 < elements.length; ++i)
assert_true(shouldNavigateFocus(elements[i], elements[i + 1], 'backward'),
'Focus should move from ' + elements[i] + ' to ' + elements[i + 1]);
assert_focus_navigation(elements[i], elements[i + 1], 'backward');
}
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