AutoTest: Sort tests case insensitive inside Tests view

Change-Id: Idd4fb818e5bac8e036dd50dbaec7db843b3cfca4
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2021-06-01 11:51:52 +02:00
parent a3b5306147
commit 018dfc533c
2 changed files with 12 additions and 8 deletions

View File

@@ -367,9 +367,9 @@
Cleanup Functions} or \uicontrol {Show Data Functions}. Double-click a Cleanup Functions} or \uicontrol {Show Data Functions}. Double-click a
function in the list to open its source code in the code editor. function in the list to open its source code in the code editor.
The test cases are listed in alphabetic order. To list them in the order in The test cases are listed in alphabetic, case insensitive order. To list
which they are defined in the source code, select \inlineimage leafsort.png them in the order in which they are defined in the source code,
(\uicontrol {Sort Naturally}). select \inlineimage leafsort.png (\uicontrol {Sort Naturally}).
\section2 Running and Debugging Tests from Code Editor \section2 Running and Debugging Tests from Code Editor

View File

@@ -130,19 +130,23 @@ bool ITestTreeItem::lessThan(const ITestTreeItem *other, ITestTreeItem::SortMode
case Alphabetically: case Alphabetically:
if (lhs == rhs) if (lhs == rhs)
return index().row() > other->index().row(); return index().row() > other->index().row();
return lhs > rhs; return lhs.compare(rhs, Qt::CaseInsensitive) > 0;
case Naturally: { case Naturally: {
if (type() == GroupNode && other->type() == GroupNode) if (type() == GroupNode && other->type() == GroupNode) {
return filePath() > other->filePath(); return filePath().toString().compare(other->filePath().toString(),
Qt::CaseInsensitive) > 0;
}
const Utils::Link &leftLink = data(0, LinkRole).value<Utils::Link>(); const Utils::Link &leftLink = data(0, LinkRole).value<Utils::Link>();
const Utils::Link &rightLink = other->data(0, LinkRole).value<Utils::Link>(); const Utils::Link &rightLink = other->data(0, LinkRole).value<Utils::Link>();
if (leftLink.targetFilePath == rightLink.targetFilePath) { const int comparison = leftLink.targetFilePath.toString().compare(
rightLink.targetFilePath.toString(), Qt::CaseInsensitive);
if (comparison == 0) {
return leftLink.targetLine == rightLink.targetLine return leftLink.targetLine == rightLink.targetLine
? leftLink.targetColumn > rightLink.targetColumn ? leftLink.targetColumn > rightLink.targetColumn
: leftLink.targetLine > rightLink.targetLine; : leftLink.targetLine > rightLink.targetLine;
} }
return leftLink.targetFilePath > rightLink.targetFilePath; return comparison > 0;
} }
} }
return true; return true;