forked from qt-creator/qt-creator
Add simple stub non-functional autotest.
Done-with: Thomas Hartmann
This commit is contained in:
@@ -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
|
||||
@@ -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"
|
||||
@@ -0,0 +1,3 @@
|
||||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += basic
|
||||
@@ -2,4 +2,5 @@ TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += qmldesigner \
|
||||
# qmleditor \
|
||||
qmlprojectmanager
|
||||
qmlprojectmanager \
|
||||
codemodel
|
||||
|
||||
Reference in New Issue
Block a user