File indexing completed on 2024-06-09 04:25:43

0001 /*
0002  *  Author 2021 Agata Cacko <cacko.azh@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include <TestKisTagSelectionWidget.h>
0008 
0009 #include <QTest>
0010 #include <QDialog>
0011 
0012 #include <QVBoxLayout>
0013 
0014 #include "kis_debug.h"
0015 
0016 #include <KisTagSelectionWidget.h>
0017 
0018 
0019 void TestKisTagSelectionWidget::test()
0020 {
0021     KisTagSelectionWidget* widget = new KisTagSelectionWidget();
0022     QList<KoID> selected = createSelectedTags();
0023     QList<KoID> rest = createAvailableTags();
0024     widget->setTagList(true, selected, rest);
0025     //widget->m_addTagButton->actions()
0026 
0027     WdgCloseableLabel* label = firstCloseableLabel(widget->m_layout);
0028     qCritical() << "Label is null or not: " << (label ? "not null" : "null");
0029     if (label) {
0030         QList<QAction*> actionsList = label->actions();
0031         qCritical() << actionsList.count();
0032     }
0033 
0034 
0035 
0036 
0037 
0038 
0039     delete widget;
0040 }
0041 
0042 
0043 WdgCloseableLabel* TestKisTagSelectionWidget::firstCloseableLabel(QLayout* layout)
0044 {
0045     QLayoutItem* item;
0046     qCritical() << "layout has count: " << layout->count();
0047     for (int i = 0; i < layout->count(); i++) {
0048         item = layout->itemAt(i);
0049         if (item->widget()) {
0050             qCritical() << "ok, we have a widget " << i;
0051             qCritical() << item->widget()->inherits("WdgCloseableLabel");
0052             qCritical() << item->widget()->inherits("WdgAddTagLabel");
0053             qCritical() << item->widget()->inherits("WdgAddTagsCategoriesLabel");
0054 
0055             WdgCloseableLabel* label = dynamic_cast<WdgCloseableLabel*>(item->widget());
0056             if (label) {
0057                 return label;
0058             }
0059         }
0060     }
0061     return 0;
0062 }
0063 
0064 
0065 
0066 QList<KoID> TestKisTagSelectionWidget::createAvailableTags()
0067 {
0068     QList<KoID> response;
0069 
0070     //response.append(CustomTagSP(new CustomTag("tag1", QVariant(1))));
0071     //response.append(CustomTagSP(new CustomTag("tag2", QVariant(2))));
0072     //response.append(CustomTagSP(new CustomTag("tag3", QVariant(3))));
0073     //response.append(CustomTagSP(new CustomTag("tag4", QVariant(4))));
0074     //response.append(CustomTagSP(new CustomTag("tag5", QVariant(5))));
0075     //response.append(CustomTagSP(new CustomTag("tag6", QVariant(6))));
0076 
0077     return response;
0078 }
0079 
0080 QList<KoID> TestKisTagSelectionWidget::createSelectedTags()
0081 {
0082     QList<KoID> response;
0083     //response.append(CustomTagSP(new CustomTag("tag11", QVariant(11))));
0084     //response.append(CustomTagSP(new CustomTag("tag12", QVariant(12))));
0085     //response.append(CustomTagSP(new CustomTag("tag13", QVariant(13))));
0086     //response.append(CustomTagSP(new CustomTag("tag14", QVariant(14))));
0087 
0088     return response;
0089 }
0090 
0091 QTEST_MAIN(TestKisTagSelectionWidget)