Warning, file /graphics/krita/sdk/tests/testutil.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  *  SPDX-FileCopyrightText: 2007 Boudewijn Rempt <boud@valdyas.org>
0003  *  SPDX-FileCopyrightText: 2011 Dmitry Kazakov <dimula73@gmail.com>
0004  *
0005  *  SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 
0008 #include <testutil.h>
0009 #include <KoResource.h>
0010 #include <KoMD5Generator.h>
0011 
0012 namespace TestUtil
0013 {
0014 
0015 QStringList getHierarchy(KisNodeSP root, const QString &prefix) {
0016     QStringList list;
0017 
0018     QString nextPrefix;
0019     if (root->parent()) {
0020         nextPrefix = prefix + "+";
0021         list << prefix + root->name();
0022     }
0023 
0024     KisNodeSP node = root->firstChild();
0025     while (node) {
0026         list += getHierarchy(node, nextPrefix);
0027         node = node->nextSibling();
0028     }
0029 
0030     return list;
0031 }
0032 
0033 bool checkHierarchy(KisNodeSP root, const QStringList &expected)
0034 {
0035     QStringList result = getHierarchy(root);
0036     if (result != expected) {
0037         qDebug() << "Failed to compare hierarchy:";
0038         qDebug() << "   " << ppVar(result);
0039         qDebug() << "   " << ppVar(expected);
0040         return false;
0041     }
0042 
0043     return true;
0044 }
0045 }