diff options
author | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2016-03-01 15:32:46 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2016-03-02 09:47:22 +0000 |
commit | b15cff11a50828500ebd7fac282a5ab0bac32e36 (patch) | |
tree | 1e846edb13a867dea8af188789c1c0fc4a426e7e /tests/auto | |
parent | 8623d6ba69e7fedf4e534855edea7d8428a2e57b (diff) |
API: Allow to retrieve the direct parents of a given artifact.
Change-Id: Ic463b4bee7cb16c0a4e92439bde59ba8ad047478
Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/api/testdata/generated-files-list/generated-files-list.qbs | 12 | ||||
-rw-r--r-- | tests/auto/api/testdata/generated-files-list/main.cpp | 11 | ||||
-rw-r--r-- | tests/auto/api/testdata/generated-files-list/mainwindow.cpp | 14 | ||||
-rw-r--r-- | tests/auto/api/testdata/generated-files-list/mainwindow.h | 22 | ||||
-rw-r--r-- | tests/auto/api/testdata/generated-files-list/mainwindow.ui | 24 | ||||
-rw-r--r-- | tests/auto/api/tst_api.cpp | 33 | ||||
-rw-r--r-- | tests/auto/api/tst_api.h | 1 |
7 files changed, 117 insertions, 0 deletions
diff --git a/tests/auto/api/testdata/generated-files-list/generated-files-list.qbs b/tests/auto/api/testdata/generated-files-list/generated-files-list.qbs new file mode 100644 index 000000000..004452f21 --- /dev/null +++ b/tests/auto/api/testdata/generated-files-list/generated-files-list.qbs @@ -0,0 +1,12 @@ +import qbs + +CppApplication { + Depends { name: "Qt.widgets" } + files: [ + "main.cpp", + "mainwindow.cpp", + "mainwindow.h", + "mainwindow.ui" + ] +} + diff --git a/tests/auto/api/testdata/generated-files-list/main.cpp b/tests/auto/api/testdata/generated-files-list/main.cpp new file mode 100644 index 000000000..b48f94ec8 --- /dev/null +++ b/tests/auto/api/testdata/generated-files-list/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include <QApplication> + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/tests/auto/api/testdata/generated-files-list/mainwindow.cpp b/tests/auto/api/testdata/generated-files-list/mainwindow.cpp new file mode 100644 index 000000000..49d64fce7 --- /dev/null +++ b/tests/auto/api/testdata/generated-files-list/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/tests/auto/api/testdata/generated-files-list/mainwindow.h b/tests/auto/api/testdata/generated-files-list/mainwindow.h new file mode 100644 index 000000000..1e645a339 --- /dev/null +++ b/tests/auto/api/testdata/generated-files-list/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> + +QT_BEGIN_NAMESPACE +namespace Ui { class MainWindow; } +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/tests/auto/api/testdata/generated-files-list/mainwindow.ui b/tests/auto/api/testdata/generated-files-list/mainwindow.ui new file mode 100644 index 000000000..6050363fa --- /dev/null +++ b/tests/auto/api/testdata/generated-files-list/mainwindow.ui @@ -0,0 +1,24 @@ +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle" > + <string>MainWindow</string> + </property> + <widget class="QMenuBar" name="menuBar" /> + <widget class="QToolBar" name="mainToolBar" /> + <widget class="QWidget" name="centralWidget" /> + <widget class="QStatusBar" name="statusBar" /> + </widget> + <layoutDefault spacing="6" margin="11" /> + <pixmapfunction></pixmapfunction> + <resources/> + <connections/> +</ui> diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp index fcd673b82..35126e79c 100644 --- a/tests/auto/api/tst_api.cpp +++ b/tests/auto/api/tst_api.cpp @@ -944,6 +944,39 @@ void TestApi::fileTagsFilterOverride() QVERIFY(installableFiles.first().targetFilePath().contains("habicht")); } +void TestApi::generatedFilesList() +{ + qbs::SetupProjectParameters setupParams + = defaultSetupParameters("generated-files-list/generated-files-list.qbs"); + QScopedPointer<qbs::SetupProjectJob> setupJob(qbs::Project().setupProject(setupParams, + m_logSink, 0)); + QVERIFY(waitForFinished(setupJob.data())); + QVERIFY2(!setupJob->error().hasError(), qPrintable(setupJob->error().toString())); + qbs::Project project = setupJob->project(); + const QScopedPointer<qbs::BuildJob> buildJob(project.buildAllProducts(qbs::BuildOptions())); + QVERIFY(waitForFinished(buildJob.data())); + const qbs::ProjectData projectData = project.projectData(); + QCOMPARE(projectData.products().count(), 1); + const qbs::ProductData product = projectData.products().first(); + QString uiFilePath; + foreach (const qbs::GroupData &group, product.groups()) { + foreach (const qbs::SourceArtifact &a, group.sourceArtifacts()) { + if (a.fileTags().contains(QLatin1String("ui"))) { + uiFilePath = a.filePath(); + break; + } + } + if (!uiFilePath.isEmpty()) + break; + } + QVERIFY(!uiFilePath.isEmpty()); + const QStringList directParents = project.generatedFiles(product, uiFilePath, false); + QCOMPARE(directParents.count(), 1); + QCOMPARE(QFileInfo(directParents.first()).fileName(), QLatin1String("ui_mainwindow.h")); + const QStringList allParents = project.generatedFiles(product, uiFilePath, true); + QCOMPARE(allParents.count(), 3); +} + void TestApi::infiniteLoopBuilding() { QFETCH(QString, projectDirName); diff --git a/tests/auto/api/tst_api.h b/tests/auto/api/tst_api.h index 606802f88..6a3f50e1c 100644 --- a/tests/auto/api/tst_api.h +++ b/tests/auto/api/tst_api.h @@ -82,6 +82,7 @@ private slots: void exportWithRecursiveDepends(); void fileTagger(); void fileTagsFilterOverride(); + void generatedFilesList(); void infiniteLoopBuilding(); void infiniteLoopBuilding_data(); void infiniteLoopResolving(); |