diff --git a/tests/auto/qml/codemodel/basic/basic.pro b/tests/auto/qml/codemodel/basic/basic.pro new file mode 100644 index 0000000000000000000000000000000000000000..ae7f351d00f4e88f16b0ddf08ad9653cf7a83e97 --- /dev/null +++ b/tests/auto/qml/codemodel/basic/basic.pro @@ -0,0 +1,37 @@ +TEMPLATE = app + +# this build works only in-source or inside a qtcreator shadow +# build if the test's shadow build directory is QTC-BUILD/tests/auto/qml/codemodel/basic + +QTCREATOR_SOURCE=$$PWD/../../../../.. +QTCREATOR_BUILD=$$OUT_PWD/../../../../.. +# can we check that this is a valid build dir? + +OUT_PWD_SAVE=$$OUT_PWD +OUT_PWD=QTCREATOR_BUILD +include($$QTCREATOR_SOURCE/qtcreator.pri) +OUT_PWD=$$OUT_PWD_SAVE + +LIBS += -L$$IDE_PLUGIN_PATH/Nokia +unix: QMAKE_LFLAGS += \'-Wl,-rpath,$${IDE_LIBRARY_PATH}\' \'-Wl,-rpath,$${IDE_PLUGIN_PATH}/Nokia\' + +QT += core network + +CONFIG += qtestlib testcase + +# DEFINES+=QTCREATOR_UTILS_STATIC_LIB QML_BUILD_STATIC_LIB +DEFINES+=QTCREATORDIR=\\\"$$IDE_SOURCE_TREE\\\" +DEFINES+=QT_CREATOR QTCREATOR_TEST + +DEPENDPATH += .. + +include($$IDE_SOURCE_TREE/src/libs/utils/utils-lib.pri) +include($$IDE_SOURCE_TREE/src/plugins/qmljstools/qmljstools.pri) + +TARGET = tst_codemodel_basic +win32: TARGET = $$IDE_APP_PATH/$$TARGET + +CONFIG += console +CONFIG -= app_bundle +SOURCES += \ + tst_basic.cpp diff --git a/tests/auto/qml/codemodel/basic/tst_basic.cpp b/tests/auto/qml/codemodel/basic/tst_basic.cpp new file mode 100644 index 0000000000000000000000000000000000000000..49bc05906aaf36704ee7ef3c53ef8f62da73ade8 --- /dev/null +++ b/tests/auto/qml/codemodel/basic/tst_basic.cpp @@ -0,0 +1,111 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + + +#include <QScopedPointer> +#include <QLatin1String> +#include <QGraphicsObject> + +#include <qmljs/qmljsinterpreter.h> +#include <qmljs/qmljsdocument.h> +#include <qmljs/qmljslookupcontext.h> +#include <qmljstools/qmljsrefactoringchanges.h> +#include <qmljstools/qmljsmodelmanager.h> + +#include <QtTest> + +using namespace QmlJS; +using namespace QmlJSTools; + +class tst_Basic : public QObject +{ + Q_OBJECT +public: + tst_Basic(); + +private slots: + void initTestCase(); + void cleanupTestCase(); + + void testMetaInfo(); +}; + +class TestModelManager : public Internal::ModelManager +{ +public: + virtual ~TestModelManager() {} + void loadFile(QString fileName) + { + refreshSourceFiles(QStringList() << fileName, false).waitForFinished(); + } +}; + +tst_Basic::tst_Basic() +{ + +} + +void tst_Basic::initTestCase() +{ +} + +void tst_Basic::cleanupTestCase() +{ +} + +void tst_Basic::testMetaInfo() +{ + TestModelManager modelManager; + modelManager.loadFile(QString(QTCREATORDIR) + "/tests/auto/qml/qmldesigner/data/fx/usingmybutton.qml"); + + Snapshot snapshot = modelManager.snapshot(); + Document::Ptr doc = snapshot.document(QString(QTCREATORDIR) + "/tests/auto/qml/qmldesigner/data/fx/usingmybutton.qml"); + QVERIFY(doc && doc->isQmlDocument()); + + LookupContext::Ptr lookupContext = LookupContext::create(doc, snapshot, QList<AST::Node>()); + + Interpreter::Value *v = lookupContext->evaluate(); + Interpreter::ObjectValue *ov = lookupContext->context()->lookupType(doc, QStringList() << "Qt" << "Rectangle"); + qDebug() << ov->className(); + doc->bind(); // per-doc data + + qDebug() << lookupContext->context()->scopeChain().qmlTypes->importInfo("Rectangle", lookupContext->context()).name(); + +// Snapshot snapshot; +// QmlJSRefactoringChanges changes(&modelManager, snapshot); +// QmlJSRefactoringFile file = changes.file(QString(QTCREATORDIR) + "/tests/auto/qml/qmldesigner/data/fx/usingmybutton.qml"); +// QVERIFY(file.isValid()); + +// snapshot.insert(file.qmljsDocument()); + +} + +QTEST_MAIN(tst_Basic); + +#include "tst_basic.moc" diff --git a/tests/auto/qml/codemodel/codemodel.pro b/tests/auto/qml/codemodel/codemodel.pro new file mode 100644 index 0000000000000000000000000000000000000000..25867e50d71113a1cb3793867634fa21f1705df0 --- /dev/null +++ b/tests/auto/qml/codemodel/codemodel.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +SUBDIRS += basic diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index 2a9535262d00958164f0b30443129fdd1d94dd3e..ab1589b604c6006063928f18249bb8c15875096d 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -2,4 +2,5 @@ TEMPLATE = subdirs SUBDIRS += qmldesigner \ # qmleditor \ - qmlprojectmanager + qmlprojectmanager \ + codemodel