Commit c3ceba4b authored by Alessandro Portale's avatar Alessandro Portale

Added test app and test scenarios for the new qml app wizard

parent f347b9e3
......@@ -273,8 +273,8 @@ QString QmlStandaloneApp::path(Path path) const
const QString qmlSubDir = QLatin1String("qml/")
+ (useExistingMainQml() ? m_mainQmlFile.dir().dirName() : m_projectName)
+ QLatin1Char('/');
const QString originsRootQmlApp = templatesRoot(QLatin1String("qmlapp/"));
const QString originsRootShared = templatesRoot(QLatin1String("shared/"));
const QString originsRootQmlApp = templatesRoot() + QLatin1String("qmlapp/");
const QString originsRootShared = templatesRoot() + QLatin1String("shared/");
const QString appViewerTargetSubDir = appViewerOriginsSubDir;
const QString qmlExtension = QLatin1String(".qml");
const QString mainCppFileName = QLatin1String("main.cpp");
......@@ -534,10 +534,12 @@ bool QmlStandaloneApp::addExternalModule(const QString &name, const QFileInfo &d
}
#ifndef CREATORLESSTEST
QString QmlStandaloneApp::templatesRoot(const QString &dirName)
// The definition of QmlStandaloneApp::templatesRoot() for
// CREATORLESSTEST is in tests/manual/qmlstandalone/main.cpp
QString QmlStandaloneApp::templatesRoot()
{
return Core::ICore::instance()->resourcePath()
+ QLatin1String("/templates/") + dirName;
+ QLatin1String("/templates/");
}
static Core::GeneratedFile file(const QByteArray &data, const QString &targetFile)
......
......@@ -179,7 +179,7 @@ private:
QByteArray generateMainCpp(const QString *errorMessage) const;
QByteArray generateProFile(const QString *errorMessage) const;
QByteArray generateDesktopFile(const QString *errorMessage) const;
static QString templatesRoot(const QString &dirName);
static QString templatesRoot();
bool addExternalModule(const QString &uri, const QFileInfo &dir,
const QFileInfo &contentDir);
bool addCppPlugins(QmlModule *module);
......
/**************************************************************************
**
** 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 "qmlstandaloneapp.h"
#include <QtCore>
using namespace Qt4ProjectManager::Internal;
static bool writeFile(const QByteArray &data, const QString &targetFile)
{
const QFileInfo fileInfo(targetFile);
QDir().mkpath(fileInfo.absolutePath());
QFile file(fileInfo.absoluteFilePath());
file.open(QIODevice::WriteOnly);
Q_ASSERT(file.isOpen());
return file.write(data) != -1;
}
bool QmlStandaloneApp::generateFiles(QString *errorMessage) const
{
return writeFile(generateFile(QmlAppGeneratedFileInfo::MainCppFile, errorMessage), path(MainCpp))
&& writeFile(generateFile(QmlAppGeneratedFileInfo::AppProFile, errorMessage), path(AppPro))
&& (useExistingMainQml() ? true : writeFile(generateFile(QmlAppGeneratedFileInfo::MainQmlFile, errorMessage), path(MainQml)))
&& writeFile(generateFile(QmlAppGeneratedFileInfo::AppViewerPriFile, errorMessage), path(AppViewerPri))
&& writeFile(generateFile(QmlAppGeneratedFileInfo::AppViewerCppFile, errorMessage), path(AppViewerCpp))
&& writeFile(generateFile(QmlAppGeneratedFileInfo::AppViewerHFile, errorMessage), path(AppViewerH))
&& writeFile(generateFile(QmlAppGeneratedFileInfo::SymbianSvgIconFile, errorMessage), path(SymbianSvgIcon))
&& writeFile(generateFile(QmlAppGeneratedFileInfo::MaemoPngIconFile, errorMessage), path(MaemoPngIcon));
}
QString QmlStandaloneApp::templatesRoot()
{
return QLatin1String("../../../share/qtcreator/templates/");
}
int main(int argc, char *argv[])
{
QString errorMessage;
const QString projectPath = QLatin1String("testprojects");
{
QmlStandaloneApp sAppNew;
sAppNew.setProjectPath(projectPath);
sAppNew.setProjectName(QLatin1String("new_qml_app"));
if (!sAppNew.generateFiles(&errorMessage))
return 1;
}
{
QmlStandaloneApp sAppImport01;
sAppImport01.setProjectPath(projectPath);
sAppImport01.setProjectName(QLatin1String("imported_scenario_01"));
sAppImport01.setMainQmlFile(QLatin1String("../qmlstandalone/qmlimportscenario_01/myqmlapp.qml"));
if (!sAppImport01.generateFiles(&errorMessage))
return 1;
}
{
const QString rootPath = QLatin1String("../qmlstandalone/qmlimportscenario_02/");
QmlStandaloneApp sAppImport02;
sAppImport02.setProjectPath(projectPath);
sAppImport02.setProjectName(QLatin1String("imported_scenario_02"));
sAppImport02.setMainQmlFile(rootPath + QLatin1String("subfolder1/myqmlapp.qml"));
QStringList moduleNames;
moduleNames.append(QLatin1String("no.trolltech.QmlModule01"));
moduleNames.append(QLatin1String("com.nokia.QmlModule02"));
QStringList importPaths;
importPaths.append(rootPath + QLatin1String("subfolder2/"));
importPaths.append(rootPath + QLatin1String("subfolder3/"));
if (!sAppImport02.setExternalModules(moduleNames, importPaths)) {
qDebug() << sAppImport02.error();
return 2;
}
if (!sAppImport02.generateFiles(&errorMessage))
return 1;
}
return 0;
}
import Qt 4.7
import "qmlproject01"
import "qmlproject02"
Rectangle {
width: 200
height: 200
color: "#ddddff"
Text {
id: title
text: "main"
}
Column {
anchors.fill: parent
anchors.margins: title.height + 2
QmlProject01 {
anchors.top: parent.top
height: parent.height / 2
width: parent.width
}
QmlProject02 {
anchors.bottom: parent.bottom
height: parent.height / 2
width: parent.width
}
}
}
import QmlProject 1.0
Project {
QmlFiles {
directory: "."
}
JavaScriptFiles {
directory: "."
}
ImageFiles {
directory: "."
}
// No import pathes, here.
}
import Qt 4.7
Rectangle {
color: "#ddffdd"
Image {
source: "apple.svg"
anchors.right: parent.right
anchors.bottom: parent.bottom
}
Text {
text: "QmlProject01"
font.pointSize: 14
}
}
<svg height="100%" version="1.1" viewBox="0 0 50 50" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg">
<defs>
</defs>
<metadata>
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:title/>
</cc:Work>
</rdf:RDF>
</metadata>
<path d="m22.7,3.84c-1.06,3.24-1.17,7.42-0.191,12.7" fill="none" stroke="#830" stroke-width="2.5"/>
<path d="m36.8,12.9c6.24,3.02,11.1,9.74,10.3,16.9-0.548,5.22-3.35,10.1-7.3,13.5-3.99,2.83-7.36-0.79-11.9-0.037-4.75,0.587-8.68,3.8-13.3,1.88-8.57-3.18-12.1-6.91-12.2-16.4,0.0813-6.01,2.05-12,7.75-14.6,2.95-1.03,8.83-0.118,12,0.363,4.83-3.24,9.26-3.55,14.6-1.61z" fill="#3A0"/>
<path d="m14,16.1c0.683,1.19-1.08,1.56-2.56,3.1-1.48,1.53-2.28,4.13-3.78,3.92-1.5-0.21-0.485-4.18,1.47-5.74,1.95-1.56,4.19-2.47,4.87-1.28z" fill="#FFF" opacity="0.5"/>
</svg>
\ No newline at end of file
import QmlProject 1.0
Project {
QmlFiles {
directory: "."
}
JavaScriptFiles {
directory: "."
}
ImageFiles {
directory: "."
}
// No import pathes, here.
}
import Qt 4.7
Rectangle {
color: "#ffdddd"
Image {
source: "tomato.svg"
anchors.right: parent.right
anchors.bottom: parent.bottom
}
Text {
text: "QmlProject02"
font.pointSize: 14
}
}
import QmlProject 1.0
Project {
QmlFiles {
directory: "."
}
JavaScriptFiles {
directory: "."
}
ImageFiles {
directory: "."
}
// No import pathes, here.
}
<svg height="100%" id="svg2" version="1.1" viewBox="0 0 50 50" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg">
<defs id="defs14">
</defs>
<metadata id="metadata4">
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:title/>
</cc:Work>
</rdf:RDF>
</metadata>
<path d="M24.7,5.65c-2.7,2.23-3.2,5.65-2.2,10.8" fill="none" stroke="#080" stroke-width="2.5"/>
<path d="m41.6,16.9c6.71,7.89,3.30,18.5-2.42,23.6-5.73,5.11-16.2,6.50-26.6,1.84-10.4-4.7-13.1-21.3-3.65-27,9.45-5.68,26-6.29,32.6,1.6z" fill="#F00"/>
<path d="m15.6,15.3c0.683,1.19-1.88,1.16-4.97,4.10-2.95,2.8-2.64,6.7-4.14,6.5-1.50-0.2,0.72-7,2.67-8.5,1.95-1.56,5.80-3.27,6.48-2.08z" fill="#FFF" opacity="0.5"/>
</svg>
\ No newline at end of file
import QmlProject 1.0
Project {
QmlFiles {
directory: "subfolder1"
}
JavaScriptFiles {
directory: "."
}
ImageFiles {
directory: "."
}
importPaths: [
"subfolder2",
"subfolder3"
]
}
import Qt 4.7
import no.trolltech.QmlModule01 1.0
import com.nokia.QmlModule02 1.0
Rectangle {
width: 200
height: 200
color: "#ddddff"
Text {
id: title
text: "main"
}
Column {
anchors.fill: parent
anchors.margins: title.height + 2
QmlComponent01 {
anchors.top: parent.top
height: parent.height / 2
width: parent.width
}
QmlComponent02 {
anchors.bottom: parent.bottom
height: parent.height / 2
width: parent.width
}
}
}
import Qt 4.7
Rectangle {
color: "#ddffdd"
Image {
source: "apple.svg"
anchors.right: parent.right
anchors.bottom: parent.bottom
}
Text {
text: "QmlComponent01"
font.pointSize: 14
}
}
<svg height="100%" version="1.1" viewBox="0 0 50 50" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg">
<defs>
</defs>
<metadata>
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:title/>
</cc:Work>
</rdf:RDF>
</metadata>
<path d="m22.7,3.84c-1.06,3.24-1.17,7.42-0.191,12.7" fill="none" stroke="#830" stroke-width="2.5"/>
<path d="m36.8,12.9c6.24,3.02,11.1,9.74,10.3,16.9-0.548,5.22-3.35,10.1-7.3,13.5-3.99,2.83-7.36-0.79-11.9-0.037-4.75,0.587-8.68,3.8-13.3,1.88-8.57-3.18-12.1-6.91-12.2-16.4,0.0813-6.01,2.05-12,7.75-14.6,2.95-1.03,8.83-0.118,12,0.363,4.83-3.24,9.26-3.55,14.6-1.61z" fill="#3A0"/>
<path d="m14,16.1c0.683,1.19-1.08,1.56-2.56,3.1-1.48,1.53-2.28,4.13-3.78,3.92-1.5-0.21-0.485-4.18,1.47-5.74,1.95-1.56,4.19-2.47,4.87-1.28z" fill="#FFF" opacity="0.5"/>
</svg>
\ No newline at end of file
QmlComponent01 1.0 QmlComponent01.qml
\ No newline at end of file
import Qt 4.7
Rectangle {
color: "#ffdddd"
Image {
source: "tomato.svg"
anchors.right: parent.right
anchors.bottom: parent.bottom
}
Text {
text: "QmlComponent02"
font.pointSize: 14
}
}
QmlComponent02 1.0 QmlComponent02.qml
\ No newline at end of file
<svg height="100%" id="svg2" version="1.1" viewBox="0 0 50 50" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg">
<defs id="defs14">
</defs>
<metadata id="metadata4">
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:title/>
</cc:Work>
</rdf:RDF>
</metadata>
<path d="M24.7,5.65c-2.7,2.23-3.2,5.65-2.2,10.8" fill="none" stroke="#080" stroke-width="2.5"/>
<path d="m41.6,16.9c6.71,7.89,3.30,18.5-2.42,23.6-5.73,5.11-16.2,6.50-26.6,1.84-10.4-4.7-13.1-21.3-3.65-27,9.45-5.68,26-6.29,32.6,1.6z" fill="#F00"/>
<path d="m15.6,15.3c0.683,1.19-1.88,1.16-4.97,4.10-2.95,2.8-2.64,6.7-4.14,6.5-1.50-0.2,0.72-7,2.67-8.5,1.95-1.56,5.80-3.27,6.48-2.08z" fill="#FFF" opacity="0.5"/>
</svg>
\ No newline at end of file
CREATORSOURCEDIR = ../../../
DEFINES += \
CREATORLESSTEST
APPSOURCEDIR = $$CREATORSOURCEDIR/src/plugins/qt4projectmanager/wizards
HEADERS += \
$$APPSOURCEDIR/qmlstandaloneapp.h
SOURCES += \
$$APPSOURCEDIR/qmlstandaloneapp.cpp \
main.cpp
INCLUDEPATH += $$APPSOURCEDIR
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment