./ 0000755 0000156 0000165 00000000000 12705421115 011073 5 ustar jenkins jenkins ./tests/ 0000755 0000156 0000165 00000000000 12705421114 012234 5 ustar jenkins jenkins ./tests/shared.pri 0000644 0000156 0000165 00000003475 12705421114 014227 0 ustar jenkins jenkins PROVIDER = Canonical
## Where the Qt Creator headers are located at
QTCREATOR_SOURCES = $$(QTC_SOURCE)
isEmpty(QTCREATOR_SOURCES):QTCREATOR_SOURCES=/usr/src/qtcreator
## Where our plugin will be compiled to
IDE_BUILD_TREE = $$(QTC_BUILD)
isEmpty(IDE_BUILD_TREE):IDE_BUILD_TREE=../../builddir
UBUNTU_LOCAL_BUILD = $$(UBUNTU_QTC_PLUGIN_LOCALBUILD)
!isEmpty(UBUNTU_LOCAL_BUILD) {
message("!!!!!!!!!!BUILDING LOCAL VERSION OF PLUGIN !!!!!!!!!!!!!!!!!!!")
USE_USER_DESTDIR = yes
PATHSTR = '\\"$${PWD}/../share/qtcreator\\"'
DEFINES += UBUNTU_RESOURCE_PATH_LOCAL=\"$${PATHSTR}\" UBUNTU_BUILD_LOCAL
}
include($$QTCREATOR_SOURCES/qtcreator.pri)
isEmpty(TEMPLATE):TEMPLATE=app
QT += testlib
CONFIG += qt warn_on console depend_includepath testcase
CONFIG -= app_bundle
DEFINES -= QT_NO_CAST_FROM_ASCII
# prefix test binary with tst_
!contains(TARGET, ^tst_.*):TARGET = $$join(TARGET,,"tst_")
QMAKE_RPATHDIR += $$IDE_BUILD_TREE/$$IDE_LIBRARY_BASENAME/qtcreator
QMAKE_RPATHDIR += $$IDE_PLUGIN_PATH/QtProject
QMAKE_RPATHDIR += $$IDE_PLUGIN_PATH/Canonical
IDE_PLUGIN_RPATH = $$join(QMAKE_RPATHDIR, ":")
QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$${IDE_PLUGIN_RPATH}\'
INCLUDEPATH += $$QTCREATOR_SOURCES/src/
## make sure the QtProject libs are available when building locally
!isEmpty(UBUNTU_LOCAL_BUILD) {
DESTDIRAPPNAME = "qtcreator"
DESTDIRBASE = "$$(XDG_DATA_HOME)"
isEmpty(DESTDIRBASE):DESTDIRBASE = "$$(HOME)/.local/share/data"
else:DESTDIRBASE = "$$DESTDIRBASE/data"
LIBS += -L$$DESTDIRBASE/QtProject/$$DESTDIRAPPNAME/plugins/$$QTCREATOR_VERSION/QtProject
LIBS += -L$$DESTDIRBASE/QtProject/$$DESTDIRAPPNAME/plugins/$$QTCREATOR_VERSION/Canonical
}
LIBS += -L$$[QT_INSTALL_LIBS]/qtcreator
LIBS += -L$$[QT_INSTALL_LIBS]/qtcreator/plugins/QtProject
LIBS += -L$$[QT_INSTALL_LIBS]/qtcreator/plugins/Canonical
./tests/tests.pro 0000644 0000156 0000165 00000000156 12705421114 014122 0 ustar jenkins jenkins TEMPLATE = subdirs
SUBDIRS = validation \
adbportlist \
ubuntuversion \
manifest \
autopilot
./tests/autopilot-lookup.py 0000755 0000156 0000165 00000004254 12705421114 016145 0 ustar jenkins jenkins #!/usr/bin/env python
from autopilot.introspection import get_proxy_object_for_existing_process
from autopilot.introspection.dbus import StateNotFoundError
import sys
import subprocess
import re
if __name__ == '__main__':
def findInnermostChild (objectlist, x,y):
for child in objectlist:
try:
object_rect = child.globalRect
except AttributeError:
#object does not have a rect but maybe the childs?
children = child.get_children()
if (len(children) > 0):
findInnermostChild(children,x,y)
continue
except StateNotFoundError:
print "StateNotFoundError"
return
x1 = int(object_rect.x)
x2 = int(x1 + object_rect.width)
y1 = int(object_rect.y)
y2 = int(y1 + object_rect.height)
if (x >= x1 and x <= x2 and y >= y1 and y <= y2):
children = child.get_children()
if (len(children) > 0):
findInnermostChild(children,x,y)
else:
child.print_tree(output=sys.stdout, maxdepth=1, _curdepth=0)
if len(sys.argv) < 2:
print "Error: please supply executable"
sys.exit(1)
app_exec = str(sys.argv[1])
introspec_obj=None
proc = subprocess.Popen([app_exec,'-testability'],stderr=subprocess.PIPE)
while True:
line = proc.stderr.readline()
if not line:
break;
if not introspec_obj:
retry=0
while(retry < 5):
print("Trying to get the Proxy object")
try:
introspec_obj = get_proxy_object_for_existing_process(pid=proc.pid)
print("Done")
break
except:
retry+=1
match = re.match(r"MOUSEDOWN\s+([0-9]+):([0-9]+)",line)
if match:
print ("MouseDown:", match.group(1),match.group(2))
print ("Searching innermost object")
findInnermostChild(introspec_obj.get_children(),int(match.group(1)),int(match.group(2)))
print ("Done")
./tests/validation/ 0000755 0000156 0000165 00000000000 12705421114 014366 5 ustar jenkins jenkins ./tests/validation/resources.qrc 0000644 0000156 0000165 00000000220 12705421114 017101 0 ustar jenkins jenkins
simplesection.json
fulloutput.json
./tests/validation/tst_validation.h 0000644 0000156 0000165 00000001535 12705421114 017567 0 ustar jenkins jenkins #ifndef TST_VALIDATION_H
#define TST_VALIDATION_H
#include
#include "ubuntuvalidationresultmodel.h"
class QEventLoop;
class tst_Validation : public QObject
{
Q_OBJECT
public:
tst_Validation();
private slots:
void testSimpleSectionParse ();
void testCompleteOutput();
void testIncrementalParse();
private:
void testFullOutputLint(Ubuntu::Internal::ClickRunChecksParser::DataItem *item, bool* passed);
void testFullOutputDesktop(Ubuntu::Internal::ClickRunChecksParser::DataItem *item, bool *passed);
void testFullOutputSecurity(Ubuntu::Internal::ClickRunChecksParser::DataItem *item, bool *passed);
void testFullOutputFunctional(Ubuntu::Internal::ClickRunChecksParser::DataItem *item, bool *passed);
Ubuntu::Internal::ClickRunChecksParser *m_parser;
QEventLoop* m_loop;
};
#endif // TST_VALIDATION_H
./tests/validation/simplesection.json 0000644 0000156 0000165 00000000573 12705421114 020144 0 ustar jenkins jenkins = functional =
{
"error": {
"error1": {
"link": "http://somelink.com",
"text": "Error text"
}
},
"info": {
"test1": {
"text": "OK"
},
"test2": {
"text": "OK"
},
"test3": {
"text": "OK"
}
},
"warn": {
"warning1": {
"link": "http://somelink.com/warning",
"text": "Warning message"
}
}
}
./tests/validation/fulloutput.json 0000644 0000156 0000165 00000002076 12705421114 017511 0 ustar jenkins jenkins = lint =
{
"error": {
"lint_error": {
"text": "errorText"
}
},
"info": {
"lint_info1": {
"text": "OK"
},
"lint_info2": {
"text": "OK"
},
"lint_info3": {
"text": "OK"
}
},
"warn": {}
}
= desktop =
{
"error": {
"desktop_error (test1)": {
"link": "http://somelink.com",
"text": "Error text for desktop file"
}
},
"info": {
"desktop_info (test1)": {
"text": "OK"
}
},
"warn": {
"desktop_warn (test1)": {
"link": "http://somelink.com/warning",
"text": "Warning text for desktop file"
}
}
}
= security =
{
"error": {},
"info": {
"security_test1 (test.json)": {
"text": "OK"
},
"security_test2 (test.json)": {
"text": "OK"
},
"security_test3 (test.json)": {
"text": "OK"
}
},
"warn": {}
}
= functional =
{
"error": {},
"info": {
"functional_test1": {
"text": "OK"
},
"functional_test2": {
"text": "OK"
},
"functional_test3": {
"text": "OK"
}
},
"warn": {}
}
./tests/validation/validation.pro 0000644 0000156 0000165 00000000726 12705421114 017247 0 ustar jenkins jenkins QT = core gui
CONFIG += c++11
#QTC_LIB_DEPENDS += utils
include(../shared.pri)
PLUGIN_SRC_ROOT = $${PWD}/../../src/ubuntu
INCLUDEPATH += $${PLUGIN_SRC_ROOT}
HEADERS += \
$${PLUGIN_SRC_ROOT}/ubuntuvalidationresultmodel.h \
tst_validation.cpp \
tst_validation.h
SOURCES += \
$${PLUGIN_SRC_ROOT}/ubuntuvalidationresultmodel.cpp \
tst_validation.cpp
OTHER_FILES += \
simplesection.json \
fulloutput.json
RESOURCES += \
resources.qrc
./tests/validation/tst_validation.cpp 0000644 0000156 0000165 00000017370 12705421114 020126 0 ustar jenkins jenkins #include "tst_validation.h"
#include
#include
#include
#include
#include
using namespace Ubuntu::Internal;
#define VERIFY_ITEM(item,itemType,itemText,itemIcon,cCount) \
do { \
QCOMPARE(item->type,itemType); \
QCOMPARE(item->text,itemText); \
QCOMPARE(item->icon,itemIcon); \
QCOMPARE(item->children.size(),cCount); \
}while(0)
tst_Validation::tst_Validation() :
m_parser(0) ,
m_loop(new QEventLoop(this))
{
}
/*!
* \brief tst_Validation::testSimpleSectionParse
* Tries to parse a simple section
*/
void tst_Validation::testSimpleSectionParse()
{
QList items;
ClickRunChecksParser parser;
auto appendItemCallback = [this,&items](ClickRunChecksParser::DataItem *newItem){
items.append(newItem);
};
connect(&parser,&ClickRunChecksParser::parsedNewTopLevelItem,appendItemCallback);
QFile sourceFile(":/validation/simplesection.json");
QVERIFY(sourceFile.open(QIODevice::ReadOnly));
QTextStream in(&sourceFile);
parser.beginRecieveData(in.readAll());
//until now no item can be available because we have only one section
//and the parser always waits for end of the document, or begin of the next section
QVERIFY(items.isEmpty());
parser.endRecieveData();
QVERIFY(items.length() == 1);
VERIFY_ITEM(items[0],QString("functional"),QString("No description"),ClickRunChecksParser::Error,5);
VERIFY_ITEM(items[0]->children[0],QString("error1"),QString("Error text"),ClickRunChecksParser::Error,0);
QCOMPARE(items[0]->children[0]->link,QUrl("http://somelink.com"));
VERIFY_ITEM(items[0]->children[1],QString("warning1"),QString("Warning message"),ClickRunChecksParser::Warning,0);
QCOMPARE(items[0]->children[1]->link,QUrl("http://somelink.com/warning"));
VERIFY_ITEM(items[0]->children[2],QString("test1"),QString("OK"),ClickRunChecksParser::Check,0);
VERIFY_ITEM(items[0]->children[3],QString("test2"),QString("OK"),ClickRunChecksParser::Check,0);
VERIFY_ITEM(items[0]->children[4],QString("test3"),QString("OK"),ClickRunChecksParser::Check,0);
qDeleteAll(items.begin(),items.end());
}
void tst_Validation::testFullOutputLint(ClickRunChecksParser::DataItem *item, bool *passed)
{
VERIFY_ITEM(item,QString("lint"),QString("No description"),ClickRunChecksParser::Error,4);
VERIFY_ITEM(item->children[0],QString("lint_error"),QString("errorText"),ClickRunChecksParser::Error,0);
VERIFY_ITEM(item->children[1],QString("lint_info1"),QString("OK"),ClickRunChecksParser::Check,0);
VERIFY_ITEM(item->children[2],QString("lint_info2"),QString("OK"),ClickRunChecksParser::Check,0);
VERIFY_ITEM(item->children[3],QString("lint_info3"),QString("OK"),ClickRunChecksParser::Check,0);
*passed=true;
}
void tst_Validation::testFullOutputDesktop(ClickRunChecksParser::DataItem *item, bool *passed)
{
VERIFY_ITEM(item,QString("desktop"),QString("No description"),ClickRunChecksParser::Error,3);
VERIFY_ITEM(item->children[0],QString("desktop_error (test1)"),QString("Error text for desktop file"),ClickRunChecksParser::Error,0);
QCOMPARE(item->children[0]->link,QUrl("http://somelink.com"));
VERIFY_ITEM(item->children[1],QString("desktop_warn (test1)"),QString("Warning text for desktop file"),ClickRunChecksParser::Warning,0);
QCOMPARE(item->children[1]->link,QUrl("http://somelink.com/warning"));
VERIFY_ITEM(item->children[2],QString("desktop_info (test1)"),QString("OK"),ClickRunChecksParser::Check,0);
*passed=true;
}
void tst_Validation::testFullOutputSecurity(ClickRunChecksParser::DataItem *item, bool *passed)
{
VERIFY_ITEM(item,QString("security"),QString("No description"),ClickRunChecksParser::Check,3);
VERIFY_ITEM(item->children[0],QString("security_test1 (test.json)"),QString("OK"),ClickRunChecksParser::Check,0);
VERIFY_ITEM(item->children[1],QString("security_test2 (test.json)"),QString("OK"),ClickRunChecksParser::Check,0);
VERIFY_ITEM(item->children[2],QString("security_test3 (test.json)"),QString("OK"),ClickRunChecksParser::Check,0);
*passed=true;
}
void tst_Validation::testFullOutputFunctional(ClickRunChecksParser::DataItem *item, bool *passed)
{
VERIFY_ITEM(item,QString("functional"),QString("No description"),ClickRunChecksParser::Check,3);
VERIFY_ITEM(item->children[0],QString("functional_test1"),QString("OK"),ClickRunChecksParser::Check,0);
VERIFY_ITEM(item->children[1],QString("functional_test2"),QString("OK"),ClickRunChecksParser::Check,0);
VERIFY_ITEM(item->children[2],QString("functional_test3"),QString("OK"),ClickRunChecksParser::Check,0);
*passed=true;
}
/*!
* \brief tst_Validation::testCompleteOutput
* Tests to parse a complete output from click-run-checks
*/
void tst_Validation::testCompleteOutput()
{
QList items;
ClickRunChecksParser parser;
connect(&parser,&ClickRunChecksParser::parsedNewTopLevelItem,
[this,&items](ClickRunChecksParser::DataItem *newItem){
items.append(newItem);
});
QFile sourceFile(":/validation/fulloutput.json");
QVERIFY(sourceFile.open(QIODevice::ReadOnly));
QTextStream in(&sourceFile);
parser.beginRecieveData(in.readAll());
//until now only 3 of the 4 items can be available because we have four sections
//and the parser always waits for end of the document, or begin of the next section
QCOMPARE(items.length(),3);
parser.endRecieveData();
QCOMPARE(items.length(),4);
bool passed = false;
testFullOutputLint(items[0],&passed);
if(!passed) return;
passed = false;
testFullOutputDesktop(items[1],&passed);
if(!passed) return;
passed = false;
testFullOutputSecurity(items[2],&passed);
if(!passed) return;
passed = false;
testFullOutputFunctional(items[3],&passed);
if(!passed) return;
qDeleteAll(items.begin(),items.end());
}
/**
* @brief tst_Validation::testIncrementalParse
* Tests the incremental parsing of ClickRunChecksParser,
* reads the fulloutput.json file and splits it up in chunks
*/
void tst_Validation::testIncrementalParse()
{
QList items;
ClickRunChecksParser parser;
connect(&parser,&ClickRunChecksParser::parsedNewTopLevelItem,
[this,&items](ClickRunChecksParser::DataItem *newItem){
items.append(newItem);
});
QFile sourceFile(":/validation/fulloutput.json");
QVERIFY(sourceFile.open(QIODevice::ReadOnly));
QTextStream in(&sourceFile);
QString input = in.readAll();
//parse to somewhere in the middle of a section
int offset = input.indexOf("info",input.indexOf("= desktop ="));
parser.addRecievedData(input.left(offset));
input = input.mid(offset);
//one section should be available now
QCOMPARE(items.length(),1);
bool passed = false;
testFullOutputLint(items[0],&passed);
if(!passed) return;
/*
* Try to parse more than one section,
* Add the beginning of the next section so the
* parser knows where the last one ends
*/
QString functionalSectionStart("= functional =");
offset = input.indexOf(functionalSectionStart)+functionalSectionStart.length();
parser.addRecievedData(input.left(offset));
input = input.mid(offset);
//there should be 3 sections now
QCOMPARE(items.length(),3);
passed = false;
testFullOutputDesktop(items[1],&passed);
if(!passed) return;
passed = false;
testFullOutputSecurity(items[2],&passed);
if(!passed) return;
//parse the remaining bits
parser.endRecieveData(input);
//there should be 4 sections now
QCOMPARE(items.length(),4);
passed = false;
testFullOutputFunctional(items[3],&passed);
if(!passed) return;
qDeleteAll(items.begin(),items.end());
}
QTEST_GUILESS_MAIN(tst_Validation)
./tests/com.ubuntu.pkexec.ubuntu-sdk-autopilot.policy 0000644 0000156 0000165 00000003742 12705421114 023156 0 ustar jenkins jenkins
Ubuntu SDK
http://developer.ubuntu.com
Authentication is required to create click chroot
ubuntu-sdk
auth_admin
auth_admin
yes
/usr/share/qtcreator/ubuntu/scripts/click_create_target
true
Authentication is required to destroy click chroot
ubuntu-sdk
auth_admin
auth_admin
yes
/usr/share/qtcreator/ubuntu/scripts/click_destroy_target
true
Authentication is required to create emulator instance
ubuntu-sdk
auth_admin
auth_admin
yes
/usr/share/qtcreator/ubuntu/scripts/local_create_emulator
true
./tests/ubuntuversion/ 0000755 0000156 0000165 00000000000 12705421114 015164 5 ustar jenkins jenkins ./tests/ubuntuversion/lsb-release 0000644 0000156 0000165 00000000201 12705421114 017276 0 ustar jenkins jenkins DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.10
DISTRIB_CODENAME=utopic
DISTRIB_DESCRIPTION="Ubuntu Utopic Unicorn (development branch)"
./tests/ubuntuversion/resources.qrc 0000644 0000156 0000165 00000000147 12705421114 017707 0 ustar jenkins jenkins
lsb-release
./tests/ubuntuversion/tst_ubuntuversiontest.h 0000644 0000156 0000165 00000000375 12705421114 022064 0 ustar jenkins jenkins #ifndef TST_UBUNTUVERSIONTEST_H
#define TST_UBUNTUVERSIONTEST_H
#include
class UbuntuVersionTest : public QObject
{
Q_OBJECT
public:
UbuntuVersionTest();
private slots:
void testParse ();
};
#endif // TST_UBUNTUVERSIONTEST_H
./tests/ubuntuversion/ubuntuversion.pro 0000644 0000156 0000165 00000000671 12705421114 020642 0 ustar jenkins jenkins QT = core gui
CONFIG += c++11
QTC_LIB_DEPENDS += utils
QTC_PLUGIN_DEPENDS += coreplugin
include(../shared.pri)
PLUGIN_SRC_ROOT = $${PWD}/../../src/ubuntu
INCLUDEPATH += $${PLUGIN_SRC_ROOT}
DEFINES += SRCDIR=\\\"$$PWD/\\\"
SOURCES += tst_ubuntuversiontest.cpp \
$${PLUGIN_SRC_ROOT}/ubuntuversion.cpp
HEADERS += \
tst_ubuntuversiontest.h \
$${PLUGIN_SRC_ROOT}/ubuntuversion.h
OTHER_FILES +=
RESOURCES += \
resources.qrc
./tests/ubuntuversion/tst_ubuntuversiontest.cpp 0000644 0000156 0000165 00000001236 12705421114 022414 0 ustar jenkins jenkins #include
#include
#include "tst_ubuntuversiontest.h"
#include
#include
using namespace Ubuntu::Internal;
UbuntuVersionTest::UbuntuVersionTest()
{
}
void UbuntuVersionTest::testParse()
{
QScopedPointer ver(UbuntuVersion::fromLsbFile(":/ubuntuversion/lsb-release"));
QVERIFY(!ver.isNull());
QCOMPARE(ver->id(),QStringLiteral("Ubuntu"));
QCOMPARE(ver->release(),QStringLiteral("14.10"));
QCOMPARE(ver->codename(),QStringLiteral("utopic"));
QCOMPARE(ver->description(),QStringLiteral("\"Ubuntu Utopic Unicorn (development branch)\""));
}
QTEST_GUILESS_MAIN(UbuntuVersionTest)
./tests/device/ 0000755 0000156 0000165 00000000000 12705421114 013473 5 ustar jenkins jenkins ./tests/device/check-packages 0000755 0000156 0000165 00000003533 12705421114 016256 0 ustar jenkins jenkins #!/bin/bash
################################################################################
# Copyright 2013 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; version 2.1.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .
#
# Author: Juhapekka Piiroinen
################################################################################
# Required packages
PACKAGES="software-properties-common gdebi-core fakeroot dh-make build-essential qt5-default qtbase5-dev qtdeclarative5-dev libqt5xmlpatterns5-dev qtscript5-dev qttools5-dev qt3d5-dev qtmultimedia5-dev libqt5svg5-dev libqt5graphicaleffects5 qtdeclarative5-dev-tools qttools5-dev-tools qtlocation5-dev qtpim5-dev qt-components-ubuntu ubuntu-dev-tools debhelper openssh-server"
# Failure counter
F_I=0
# Success counter
S_I=0
# Total counter
T_I=0
#######################################
# Checks for package availability
echo
for PACKAGE in ${PACKAGES}; do
echo -n "Checking if '${PACKAGE}' is available... "
FOUND=`apt-cache policy ${PACKAGE}|grep -i candidate|wc -l`
if [[ ${FOUND} -eq 0 ]]; then
echo "!NOT FOUND!"
let "F_I = $F_I + 1"
else
echo "[OK]"
let "S_I = $S_I + 1"
fi
let "T_I = $T_I + 1"
done
#######################################
# Print summary
echo
echo " Found packages: ${S_I}/${T_I}"
echo " Missing packages: ${F_I}/${T_I}"
echo
exit ${F_I}
./tests/autopilot/ 0000755 0000156 0000165 00000000000 12705421114 014254 5 ustar jenkins jenkins ./tests/autopilot/ubuntusdk-autopilot.files 0000644 0000156 0000165 00000000135 12705421114 021341 0 ustar jenkins jenkins qtcreator/tests/__init__.py
qtcreator/tests/test_simple_app_template.py
qtcreator/__init__.py ./tests/autopilot/ubuntusdk-autopilot.includes 0000644 0000156 0000165 00000000000 12705421114 022034 0 ustar jenkins jenkins ./tests/autopilot/autopilot.pro 0000644 0000156 0000165 00000000510 12705421114 017012 0 ustar jenkins jenkins TEMPLATE=aux
OTHER_FILES += \
ubuntusdk-autopilot.config \
ubuntusdk-autopilot.files \
ubuntusdk-autopilot.includes \
ubuntusdk-autopilot.creator \
qtcreator_plugin_ubuntu/__init__.py \
qtcreator_plugin_ubuntu/tests/__init__.py \
qtcreator_plugin_ubuntu/tests/test_qtcreator_plugin_functionality.py
./tests/autopilot/qtcreator_plugin_ubuntu/ 0000755 0000156 0000165 00000000000 12705421114 021240 5 ustar jenkins jenkins ./tests/autopilot/qtcreator_plugin_ubuntu/__init__.py 0000644 0000156 0000165 00000000503 12705421114 023347 0 ustar jenkins jenkins # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2014 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
"""qtcreator autopilot tests."""
./tests/autopilot/qtcreator_plugin_ubuntu/tests/ 0000755 0000156 0000165 00000000000 12705421114 022402 5 ustar jenkins jenkins ./tests/autopilot/qtcreator_plugin_ubuntu/tests/__init__.py 0000644 0000156 0000165 00000021574 12705421114 024524 0 ustar jenkins jenkins # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2014 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
"""qtcreator autopilot tests."""
from autopilot.input import Mouse, Pointer
from autopilot.testcase import AutopilotTestCase
import shutil
import tempfile
import os
import re
import time
import datetime
class QtCreatorTestCase(AutopilotTestCase):
def setUp(self):
self.pointing_device = Pointer(Mouse.create())
# sdk_test_mode = os.environ['SDK_TEST_MODE']
sdk_test_mode = os.environ.get('SDK_TEST_MODE','auto')
if sdk_test_mode != 'manual':
self._set_temporary_home_directory()
self._set_click_chroot_suffix()
super(QtCreatorTestCase, self).setUp()
self.launch_qt_creator()
def launch_qt_creator(self):
# self.patch_environment('HOME','/home/balogh')
self.ide = self.launch_test_application('qtcreator')
def _create_temporary_directory(self):
self.temporary_directory = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.temporary_directory)
def _set_temporary_home_directory(self):
self._create_temporary_directory()
sourcedir = os.environ['HOME']+"/.bazaar"
destdir = self.temporary_directory + "/.bazaar"
shutil.copytree(sourcedir, destdir, symlinks=False, ignore=None)
sourcedir = os.environ['HOME']+"/.config/QtProject/qtcreator"
destdir = self.temporary_directory + "/.config/QtProject/qtcreator"
shutil.copytree(sourcedir, destdir, symlinks=False, ignore=None)
sourcedir = os.environ['HOME']+"/.config/ubuntu-sdk"
destdir = self.temporary_directory + "/.config/ubuntu-sdk"
shutil.copytree(sourcedir, destdir, symlinks=False, ignore=None)
sourcedir = os.environ['HOME']+"/.local/share/data/QtProject/qtcreator"
destdir = self.temporary_directory + "/.local/share/data/QtProject/qtcreator"
shutil.copytree(sourcedir, destdir, symlinks=False, ignore=None)
self.patch_environment('HOME', self.temporary_directory)
print os.environ['HOME']
os.chdir(os.environ['HOME'])
if not os.path.exists('.config/ubuntu-sdk'):
os.makedirs('.config/ubuntu-sdk')
open('.config/ubuntu-sdk/firstrun', 'w')
def _set_click_chroot_suffix(self):
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y%m%d%H%M%S')
os.environ["CLICK_CHROOT_SUFFIX"] = "testing" + st
def _get_main_window(self):
return self.ide.wait_select_single(
'Core::Internal::MainWindow'
)
def _get_welcome_tab_view(self):
return self.ide.wait_select_single(
'QWidgetWindow', objectName='Core::Internal::MainWindowClassWindow'
)
def _get_left_tabbar(self):
main_window = self._get_main_window()
return main_window.select_single(
'Core::Internal::FancyTabBar'
)
def _get_number_of_tabs(self):
tabs = self._get_left_tabbar().select_many(
'Core::Internal::FancyTab'
)
return len(tabs)
def _get_current_active_tab_name(self):
return self._get_left_tabbar().selectedTabLabel
def _get_new_project_button(self):
return self._get_welcome_tab_view().wait_select_single(
'Button', text='New Project'
)
def _get_new_project_dialog(self):
return self._get_main_window().wait_select_single(
'Core::Internal::NewDialog'
)
def _click_new_project_dialog_choose_button(self):
button = self._get_new_project_dialog().select_single(
'QPushButton', text='&Choose...'
)
self.pointing_device.click_object(button)
def _get_new_project_wizard_dialog(self):
return self.ide.wait_select_single(
'Ubuntu::Internal::UbuntuProjectApplicationWizardDialog'
)
def _get_new_project_name_input_field(self):
return self._get_new_project_wizard_dialog().select_single(
'Utils::ProjectNameValidatingLineEdit'
)
def _get_new_project_location_field(self):
return self._get_new_project_wizard_dialog().select_single(
'Utils::PathChooser'
)
def _clear_input_field(self, input_field):
self.pointing_device.click_object(input_field)
self.pointing_device.click()
self.pointing_device.click()
self.keyboard.press_and_release('Backspace')
def _type_new_project_name(self, project):
input_field = self._get_new_project_name_input_field()
self._clear_input_field(input_field)
self.keyboard.type(project)
def _type_new_project_location(self, location):
location_field = self._get_new_project_location_field()
self._clear_input_field(location_field)
self.keyboard.type(location)
def click_new_project_button(self):
new_button = self._get_new_project_button()
self.pointing_device.click_object(new_button)
return self._get_new_project_dialog()
def _get_wizard_finish_button(self):
return self._get_new_project_wizard_dialog().select_single(
'QPushButton', text='&Finish')
def _get_wizard_next_button(self):
return self._get_new_project_wizard_dialog().select_single(
'QPushButton', text='&Next >')
def _click_wizard_finish_button(self):
finish_button = self._get_wizard_finish_button()
self.pointing_device.click_object(finish_button)
def _click_wizard_next_button(self):
next_button = self._get_wizard_next_button()
self.pointing_device.click_object(next_button)
def _createAndOpenProject(self,typeString,name):
""" Open the New File and Project dialog by triggering the right action """
action = self.ide.wait_select_single('QAction', text = '&New File or Project...')
action.slots.trigger()
new_project_dialog = self._get_main_window().wait_select_single('Core::Internal::NewDialog')
""" Choose the App with Simple UI template in the Ubuntu category """
ubuntu_modelindex = new_project_dialog.wait_select_single('QModelIndex', text=' Ubuntu')
self.pointing_device.click_object(ubuntu_modelindex)
app_with_simple_ui_modelindex = new_project_dialog.wait_select_single('QModelIndex', text=typeString)
self.pointing_device.click_object(app_with_simple_ui_modelindex)
choose_pushbutton = new_project_dialog.wait_select_single('QPushButton', text='Choose...')
self.pointing_device.click_object(choose_pushbutton)
application_wizard_dialog = self._get_main_window().wait_select_single('Ubuntu::Internal::UbuntuProjectApplicationWizardDialog')
""" Clear the default project name and enter the test name to the edit line and hit the Next->Next->Finish buttons """
projectname_lineedit = application_wizard_dialog.wait_select_single('Utils::ProjectNameValidatingLineEdit')
projectname_lineedit.slots.clear()
projectname_lineedit.slots.setText(name)
next_pushbutton = application_wizard_dialog.wait_select_single('QPushButton', text = '&Next >')
next_pushbutton.slots.click()
next_pushbutton = application_wizard_dialog.wait_select_single('QPushButton', text = '&Next >')
next_pushbutton.slots.click()
for index, checkbox_kit in enumerate(application_wizard_dialog.select_many('QCheckBox')):
if re.search('GCC ubuntu-sdk', checkbox_kit.text):
checkbox_kit.slots.setChecked(True)
checkbox_kit = application_wizard_dialog.wait_select_single('QCheckBox', text ='Desktop')
checkbox_kit.slots.setChecked(False)
next_pushbutton = application_wizard_dialog.wait_select_single('QPushButton', text = '&Next >')
next_pushbutton.slots.click()
next_pushbutton = application_wizard_dialog.wait_select_single('QPushButton', text = '&Finish')
next_pushbutton.slots.click()
def switch_to_tab_by_name(self, tab_name):
current_tab = self._get_current_active_tab_name()
if tab_name == current_tab:
return
tabbar = self._get_left_tabbar()
tabbar_height = tabbar.height
number_of_tabs = self._get_number_of_tabs()
tbar_x, tbar_y, tbar_width, tbar_height = tabbar.globalRect
tab_number = 1
while current_tab != tab_name and not tab_number > number_of_tabs:
tab_center = ((tabbar_height / number_of_tabs) * tab_number) - \
((tabbar_height / number_of_tabs) / 2)
tx = tbar_x + tbar_width / 2
ty = tbar_y + tab_center
self.pointing_device.move(tx, ty)
self.pointing_device.click()
current_tab = self._get_current_active_tab_name()
tab_number += 1
./tests/autopilot/qtcreator_plugin_ubuntu/tests/test_qtcreator_plugin_functionality.py 0000644 0000156 0000165 00000023255 12705421114 032354 0 ustar jenkins jenkins # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2014 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
""" qtcreator-plugin-ubuntu autopilot tests."""
from qtcreator_plugin_ubuntu.tests import QtCreatorTestCase
from autopilot.matchers import Eventually
from testtools.matchers import Equals
from autopilot.input import Keyboard
from time import sleep
import re
#class CMakeApplicationTest(QtCreatorTestCase):
class QtCreatorPluginTestPlan(QtCreatorTestCase):
def setUp(self):
super(QtCreatorPluginTestPlan, self).setUp()
# tools -> options -> Build & Run -> Kits -> ".* for armhf (GCC ubuntu-sdk-14.10-utopic)"
def test_existing_kits(self):
""" Open the Options dialog by triggering the right action """
action = self.ide.wait_select_single('QAction', text = '&Options...')
action.slots.trigger()
setting_dialog = self._get_main_window().wait_select_single('Core::Internal::SettingsDialog')
""" Se/lect the Ubuntu category and click on the Create Click Target button """
ubuntu_modelindex = setting_dialog.wait_select_single('QModelIndex', text='Build & Run')
self.pointing_device.click_object(ubuntu_modelindex)
for index, whatever in enumerate(setting_dialog.select_many('QItemSelectionModel')):
print whatever.text
for index, kit in enumerate(setting_dialog.select_many('QModelIndex')):
if re.search('GCC ubuntu-sdk', kit.text):
print kit.text
# kit_modelindex = setting_dialog.wait_select_single('QModelIndex', text='UbuntuSDK for armhf (GCC ubuntu-sdk-14.10-utopic)')
# kit_modelindex = setting_dialog.wait_select_single('QModelIndex', text=~'.*armhf.*')
# self.pointing_device.click_object(kit_modelindex)
# QWidget -> QTreeView ->
sleep(2)
def test_create_app_with_backend(self):
self._createAndOpenProject('App with QML Extension Library',"appwithbackend")
sleep(20)
""" Try to build the project """
trojanHorse = self.ide.wait_select_single('Ubuntu::Internal::UbuntuTestControl')
sigwatch = trojanHorse.watch_signal("buildFinished()")
trojanHorse.slots.triggerCommand("ProjectExplorer.Build")
self.assertThat(lambda: sigwatch.was_emitted, Eventually(Equals(True)))
sleep(1)
self.assertTrue(trojanHorse.lastBuildSuccess)
def test_create_app_with_simple_ui(self):
self._createAndOpenProject('App with Simple UI',"appwithsimpleui")
""" Change to the Publish mode and click on the Create package button"""
fancy_tab_widget = self._get_main_window().wait_select_single('Core::Internal::FancyTabWidget')
fancy_tab_widget.slots.setCurrentIndex(5)
packaging_widget = fancy_tab_widget.wait_select_single('UbuntuPackagingWidget', objectName = 'UbuntuPackagingWidget')
click_package_pushbutton = packaging_widget.wait_select_single('QPushButton', objectName = 'pushButtonClickPackage')
parser = packaging_widget.wait_select_single('Ubuntu::Internal::ClickRunChecksParser')
sigwatch = parser.watch_signal("finished()")
click_package_pushbutton.slots.click()
self.assertThat(lambda: sigwatch.was_emitted, Eventually(Equals(True)))
""" Check the error type if there was any error during the package creation """
validation_groupbox = packaging_widget.wait_select_single('QGroupBox', objectName = 'groupBoxValidate')
errorinfo_groupbox = validation_groupbox.wait_select_single('QGroupBox', objectName = 'groupBoxErrorInfo')
errortype_label = errorinfo_groupbox.wait_select_single('QLabel', objectName = 'labelErrorType')
self.assertThat(errortype_label.text, Equals(""))
def test_x86_emulator_creation(self):
""" Change to the Devices mode and click on the add new emulator button """
kbd = Keyboard.create("X11")
kbd.press_and_release('Ctrl+9')
devices_quickview = self.ide.wait_select_single('QQuickView', source='file:///usr/share/qtcreator/ubuntu/qml/devicespage.qml')
add_emulator_button = devices_quickview.select_single('Button', text='Add Emulator')
add_emulator_button.visible.wait_for(True)
""" The simple click_object() moves the pointer to the center of the button, but in some environment the responsive area of the button is smaller """
self.pointing_device.move(add_emulator_button.globalRect.x + add_emulator_button.width - 1, add_emulator_button.globalRect.y + add_emulator_button.height - 1)
self.pointing_device.click()
config_emulator_dialog = devices_quickview.wait_select_single('Dialog', title='Create emulator')
emulatorname_textfield = config_emulator_dialog.wait_select_single('TextField', placeholderText = 'Emulator name')
self.pointing_device.click_object(emulatorname_textfield)
kbd = Keyboard.create("X11")
kbd.type("TestX86Emulator", delay=0.1)
create_button = config_emulator_dialog.wait_select_single('Button', text = 'Create')
self.pointing_device.click_object(create_button)
""" Wait the emulator creation to finish """
devices_ubuntulistview = devices_quickview.wait_select_single('UbuntuListView', objectName = 'devicesList')
while True:
if(devices_ubuntulistview.visible): break;
sleep(1)
emulator_listitem = devices_ubuntulistview.wait_select_single('Standard', text = 'TestX86Emulator')
def test_x86_emulator_start(self):
""" Change to the Devices mode, select the TestX86Emulator and deploy it """
kbd = Keyboard.create("X11")
kbd.press_and_release('Ctrl+9')
devices_quickview = self.ide.wait_select_single('QQuickView', source='file:///usr/share/qtcreator/ubuntu/qml/devicespage.qml')
devices_ubuntulistview = devices_quickview.wait_select_single('UbuntuListView', objectName = 'devicesList')
while True:
if(devices_ubuntulistview.visible): break;
sleep(1)
emulator_listitem = devices_ubuntulistview.wait_select_single('Standard', text = 'TestX86Emulator')
self.pointing_device.click_object(emulator_listitem)
# TODO: continue with capturing the started emulator en evaluate the status
def test_x86_fw1410_click_chroot_creation(self):
""" Open the Options dialog by triggering the right action """
action = self.ide.wait_select_single('QAction', text = '&Options...')
action.slots.trigger()
setting_dialog = self._get_main_window().wait_select_single('Core::Internal::SettingsDialog')
""" Select the Ubuntu category and click on the Create Click Target button """
ubuntu_modelindex = setting_dialog.wait_select_single('QModelIndex', text='Ubuntu')
self.pointing_device.click_object(ubuntu_modelindex)
new_target_button = setting_dialog.wait_select_single('QPushButton', text='Create Click Target' )
self.pointing_device.click_object(new_target_button)
""" Select the i386 architecture and 14.10 framework in the dialog and push the OK button """
new_chroot_dialog = self.ide.wait_select_single('Ubuntu::Internal::UbuntuCreateNewChrootDialog')
arch_combobox = new_chroot_dialog.wait_select_single('QComboBox', objectName = 'comboBoxArch')
self.pointing_device.click_object(arch_combobox)
i386_modelindex = new_chroot_dialog.wait_select_single('QModelIndex', text='i386')
self.pointing_device.click_object(i386_modelindex)
series_combobox = new_chroot_dialog.wait_select_single('QComboBox', objectName = 'comboBoxSeries')
self.pointing_device.click_object(series_combobox)
fw1410_modelindex = new_chroot_dialog.wait_select_single('QModelIndex', text='Framework-14.10')
self.pointing_device.click_object(fw1410_modelindex)
button_box = new_chroot_dialog.wait_select_single('QDialogButtonBox', objectName = 'buttonBox')
ok_pushbutton = button_box.wait_select_single('QPushButton', text='&OK')
self.pointing_device.click_object(ok_pushbutton)
""" Open the Click run dialog and wait for it finishes the job """
click_dialog = self.ide.wait_select_single('Ubuntu::Internal::UbuntuClickDialog')
dialog_button_box = click_dialog.wait_select_single('QDialogButtonBox', objectName = 'buttonBox')
close_button = dialog_button_box.wait_select_single('QPushButton', text = '&Close')
while True:
if(close_button.enabled): break;
sleep(1)
output_plaintextedit = click_dialog.wait_select_single('QPlainTextEdit', objectName = 'output')
self.assertFalse('Click exited with errors, please check the output' in output_plaintextedit.plainText)
self.assertTrue('Click exited with no errors' in output_plaintextedit.plainText)
self.pointing_device.click_object(close_button)
def test_plugins(self):
""" Open the About Plugins dialog """
action = self.ide.wait_select_single('QAction', text='About &Plugins...')
action.slots.trigger()
""" Check for each Ubuntu specific plugin in the plugin tree """
plugin_dialog = self._get_main_window().wait_select_single('Core::Internal::PluginDialog')
ubuntu_treewidgetitem = plugin_dialog.wait_select_single('QTreeWidgetItem', text='Ubuntu')
cmake_treewidgetitem = plugin_dialog.wait_select_single('QTreeWidgetItem', text='CMakeProjectManager')
remotelinux_treewidgetitem = plugin_dialog.wait_select_single('QTreeWidgetItem', text='RemoteLinux')
golang_treewidgetitem = plugin_dialog.wait_select_single('QTreeWidgetItem', text='GoLang')
./tests/autopilot/ubuntusdk-autopilot.creator 0000644 0000156 0000165 00000000012 12705421114 021670 0 ustar jenkins jenkins [General]
./tests/autopilot/ubuntusdk-autopilot.config 0000644 0000156 0000165 00000000037 12705421114 021505 0 ustar jenkins jenkins // ADD PREDEFINED MACROS HERE!
./tests/manifest/ 0000755 0000156 0000165 00000000000 12705421114 014042 5 ustar jenkins jenkins ./tests/manifest/tst_manifest.cpp 0000644 0000156 0000165 00000014100 12705421114 017242 0 ustar jenkins jenkins #include
#include
#include "tst_manifest.h"
#include
using namespace Ubuntu::Internal;
const char MANIFEST_TEMPLATE[] = ":/ubuntu/test/manifest/manifest.json.template";
const char APPARMOR_TEMPLATE[] = ":/ubuntu/test/manifest/myapp.json.template";
const char MANIFEST_FILE[] = "/tmp/manifest.json";
UbuntuManifestTest::UbuntuManifestTest()
{
}
void UbuntuManifestTest::testWriteStringValue(const QString &value, StrWriteFunc write, StrReadFunc read)
{
UbuntuClickManifest mani;
QVERIFY( mani.load(MANIFEST_TEMPLATE) );
mani.setFileName(MANIFEST_FILE);
mani.save();
(mani.*write)(value);
QCOMPARE((mani.*read)(),value);
QFile::remove(MANIFEST_FILE);
}
void UbuntuManifestTest::testSave(const QString &templateFile)
{
UbuntuClickManifest mani;
QVERIFY( mani.load(templateFile) );
mani.setFileName(MANIFEST_FILE);
mani.save();
QVERIFY (QFile::exists(MANIFEST_FILE));
QFile file(MANIFEST_FILE);
QVERIFY(file.open(QIODevice::ReadOnly));
QVERIFY(mani.raw() == QString::fromUtf8(file.readAll()));
file.close();
file.remove();
}
void UbuntuManifestTest::testSave()
{
testSave(MANIFEST_TEMPLATE);
}
void UbuntuManifestTest::testWriteAppArmorName()
{
UbuntuClickManifest mani;
QVERIFY( mani.load(MANIFEST_TEMPLATE) );
mani.setFileName(MANIFEST_FILE);
mani.save();
const char AAFILE[] = "some/path/to/myApp.json";
QVERIFY(mani.setAppArmorFileName("myapp",QString(AAFILE)));
QCOMPARE(mani.appArmorFileName("myapp"),QString(AAFILE));
QFile::remove(MANIFEST_FILE);
}
void UbuntuManifestTest::testWriteName()
{
testWriteStringValue(
QString("name"),
&UbuntuClickManifest::setName,
&UbuntuClickManifest::name);
}
void UbuntuManifestTest::testWriteMaintainer()
{
testWriteStringValue(
QString("John Doe"),
&UbuntuClickManifest::setMaintainer,
&UbuntuClickManifest::maintainer);
}
void UbuntuManifestTest::testWriteTitle()
{
testWriteStringValue(
QString("Completely Awesome Title äüö#$%"),
&UbuntuClickManifest::setTitle,
&UbuntuClickManifest::title);
}
void UbuntuManifestTest::testWriteVersion()
{
testWriteStringValue(
QString("1.2.0-test1~ubuntu2"),
&UbuntuClickManifest::setVersion,
&UbuntuClickManifest::version);
}
void UbuntuManifestTest::testWriteDescription()
{
testWriteStringValue(
QString("This is a application description äöüöl?=)(/&%$§\"!\"§$%&/()=>><<-_.,\\*'+#~’^°"),
&UbuntuClickManifest::setDescription,
&UbuntuClickManifest::description);
}
void UbuntuManifestTest::testWriteFrameworkName()
{
UbuntuClickManifest mani;
QVERIFY( mani.load(MANIFEST_TEMPLATE) );
mani.setFileName(MANIFEST_FILE);
mani.save();
QString value = "ubuntu-sdk-14.10";
mani.setFrameworkName(value);
QCOMPARE(mani.frameworkName(),value);
QFile::remove(MANIFEST_FILE);
}
void UbuntuManifestTest::testReadHooks()
{
UbuntuClickManifest mani;
QVERIFY( mani.load(MANIFEST_TEMPLATE) );
mani.setFileName(MANIFEST_FILE);
mani.save();
/*
"myapp": {
"apparmor": "myapp.json",
"desktop": "myapp.desktop"
},
"myapp2": {
"apparmor": "myapp2.json",
"desktop": "myapp2.desktop"
},
"myscope": {
"apparmor": "myscope.json",
"scope": "myscope.ini"
}
*/
QList hooks = mani.hooks();
QCOMPARE(hooks.size(),3);
QCOMPARE(hooks[0].appId,QString("myapp"));
QCOMPARE(hooks[0].appArmorFile,QString("myapp.json"));
QCOMPARE(hooks[0].desktopFile ,QString("myapp.desktop"));
QCOMPARE(hooks[0].scope ,QString());
QCOMPARE(hooks[1].appId,QString("myapp2"));
QCOMPARE(hooks[1].appArmorFile,QString("myapp2.json"));
QCOMPARE(hooks[1].desktopFile ,QString("myapp2.desktop"));
QCOMPARE(hooks[1].scope ,QString());
QCOMPARE(hooks[2].appId,QString("myscope"));
QCOMPARE(hooks[2].appArmorFile,QString("myscope.json"));
QCOMPARE(hooks[2].desktopFile ,QString());
QCOMPARE(hooks[2].scope ,QString("myscope.ini"));
QFile::remove(MANIFEST_FILE);
}
void UbuntuManifestTest::testAppArmorFile()
{
testSave(APPARMOR_TEMPLATE);
}
void UbuntuManifestTest::testWritePolicyVersion ()
{
#ifdef Q_PROCESSOR_POWER
return;
#endif
UbuntuClickManifest mani;
QVERIFY( mani.load(APPARMOR_TEMPLATE) );
mani.setFileName(MANIFEST_FILE);
mani.save();
QString value = "1.2";
mani.setPolicyVersion(value);
QCOMPARE(mani.policyVersion(),value);
value = "0.1";
mani.setPolicyVersion(value);
QCOMPARE(mani.policyVersion(),value);
value = "1.0";
mani.setPolicyVersion(value);
QCOMPARE(mani.policyVersion(),value);
QFile::remove(MANIFEST_FILE);
}
void UbuntuManifestTest::testWritePolicyGroups()
{
UbuntuClickManifest mani;
QVERIFY( mani.load(APPARMOR_TEMPLATE) );
mani.setFileName(MANIFEST_FILE);
mani.save();
/*
"policy_groups": [
"networking",
"someOtherGroup",
"lastGroup"
]
*/
QStringList polGroups = mani.policyGroups();
QCOMPARE(polGroups.size(),3);
QCOMPARE(polGroups[0],QString("networking"));
QCOMPARE(polGroups[1],QString("someOtherGroup"));
QCOMPARE(polGroups[2],QString("lastGroup"));
polGroups.append("addedGroup1");
polGroups.append("addedGroup2");
mani.setPolicyGroups(polGroups);
polGroups = mani.policyGroups();
QCOMPARE(polGroups.size(),5);
QCOMPARE(polGroups[0],QString("networking"));
QCOMPARE(polGroups[1],QString("someOtherGroup"));
QCOMPARE(polGroups[2],QString("lastGroup"));
QCOMPARE(polGroups[3],QString("addedGroup1"));
QCOMPARE(polGroups[4],QString("addedGroup2"));
QFile::remove(MANIFEST_FILE);
}
/*!
* \brief printToOutputPane
* Dummy function
*/
void printToOutputPane(const QString &msg)
{
Q_UNUSED(msg);
}
QTEST_GUILESS_MAIN(UbuntuManifestTest)
./tests/manifest/myapp.json.template 0000644 0000156 0000165 00000000200 12705421114 017665 0 ustar jenkins jenkins {
"policy_groups": [
"networking",
"someOtherGroup",
"lastGroup"
],
"policy_version": 1.1
}
./tests/manifest/manifest.pro 0000644 0000156 0000165 00000001167 12705421114 016377 0 ustar jenkins jenkins QT = core gui qml
CONFIG += c++11
QTC_LIB_DEPENDS += utils
QTC_PLUGIN_DEPENDS += coreplugin cmakeprojectmanager
include(../shared.pri)
PLUGIN_SRC_ROOT = $${PWD}/../../src/ubuntu
INCLUDEPATH += $${PLUGIN_SRC_ROOT}
DEFINES += SRCDIR=\\\"$$PWD/\\\"
DEFINES += IN_TEST_PROJECT
SOURCES += \
tst_manifest.cpp \
$${PLUGIN_SRC_ROOT}/ubuntuclickmanifest.cpp \
$${PLUGIN_SRC_ROOT}/ubuntuclicktool.cpp
HEADERS += \
tst_manifest.h \
$${PLUGIN_SRC_ROOT}/ubuntuclickmanifest.h \
$${PLUGIN_SRC_ROOT}/ubuntuclicktool.h
OTHER_FILES +=
RESOURCES += \
$${PLUGIN_SRC_ROOT}/resources.qrc \
resources_test.qrc
./tests/manifest/resources_test.qrc 0000644 0000156 0000165 00000000242 12705421114 017620 0 ustar jenkins jenkins
manifest.json.template
myapp.json.template
./tests/manifest/manifest.json.template 0000644 0000156 0000165 00000001060 12705421114 020352 0 ustar jenkins jenkins {
"name": "myapp.username",
"description": "description of myapp",
"framework": "myFramework",
"architecture": "all",
"title": "myapp",
"hooks": {
"myapp": {
"apparmor": "myapp.json",
"desktop": "myapp.desktop"
},
"myapp2": {
"apparmor": "myapp2.json",
"desktop": "myapp2.desktop"
},
"myscope": {
"apparmor": "myscope.json",
"scope": "myscope.ini"
}
},
"version": "0.1",
"maintainer": "maintainerName"
}
./tests/manifest/tst_manifest.h 0000644 0000156 0000165 00000001625 12705421114 016717 0 ustar jenkins jenkins #ifndef TST_MANIFEST_H
#define TST_MANIFEST_H
#include
#include
typedef void (Ubuntu::Internal::UbuntuClickManifest::*StrWriteFunc) (QString arg);
typedef QString (Ubuntu::Internal::UbuntuClickManifest::*StrReadFunc) ( );
class UbuntuManifestTest : public QObject
{
Q_OBJECT
public:
UbuntuManifestTest();
private:
void testWriteStringValue (const QString &value, StrWriteFunc write, StrReadFunc read);
void testSave (const QString &templateFile);
private slots:
void testSave ();
void testWriteAppArmorName ();
void testWriteName ();
void testAppArmorFile ();
void testWriteMaintainer();
void testWriteTitle();
void testWriteVersion();
void testWriteDescription();
void testWriteFrameworkName();
void testReadHooks();
void testWritePolicyVersion();
void testWritePolicyGroups();
};
#endif // TST_MANIFEST_H
./tests/adbportlist/ 0000755 0000156 0000165 00000000000 12705421114 014563 5 ustar jenkins jenkins ./tests/adbportlist/resources.qrc 0000644 0000156 0000165 00000000207 12705421114 017303 0 ustar jenkins jenkins
simple_list
complex_list
./tests/adbportlist/tst_localportmanager.cpp 0000644 0000156 0000165 00000005434 12705421114 021521 0 ustar jenkins jenkins #include
#include
#include "tst_localportmanager.h"
tst_LocalPortManager::tst_LocalPortManager()
{
}
void tst_LocalPortManager::testEmptyOutput()
{
QByteArray emptyData;
QBuffer emptyInput(&emptyData);
QVERIFY(emptyInput.open(QIODevice::ReadOnly));
Ubuntu::Internal::UbuntuLocalPortsManager pM;
pM.setPortsRange(10000,11000);
int requiredCount = 20;
Utils::PortList ports = pM.getFreeRange("08866fd9e24cf55a",requiredCount,&emptyInput);
QCOMPARE(ports.count(),requiredCount);
int count = 0;
while(ports.hasMore()) {
int port = ports.getNext();
QCOMPARE(port,10000+count);
count ++;
}
QCOMPARE(count,requiredCount);
}
void tst_LocalPortManager::testSimpleList()
{
QFile in(":/portmanager/simple_list");
QVERIFY(in.open(QIODevice::ReadOnly));
int firstPort = 10000;
int lastPort = 11000;
Ubuntu::Internal::UbuntuLocalPortsManager pM;
pM.setPortsRange(firstPort,lastPort);
int requiredCount = 20;
Utils::PortList ports = pM.getFreeRange("08866fd9e24cf55a",requiredCount,&in);
QCOMPARE(ports.count(),requiredCount);
int max = firstPort + requiredCount;
for (int port = firstPort; port < max; ++port) {
QVERIFY2(ports.contains(port),qPrintable(QStringLiteral("List should contain port: %1").arg(port)));
}
}
void tst_LocalPortManager::testComplexList()
{
QFile in(":/portmanager/complex_list");
QVERIFY(in.open(QIODevice::ReadOnly));
int firstPort = 10000;
int lastPort = 11000;
Ubuntu::Internal::UbuntuLocalPortsManager pM;
pM.setPortsRange(firstPort,lastPort);
int requiredCount = 20;
Utils::PortList ports = pM.getFreeRange("09977feaf35d066b",requiredCount,&in);
in.seek(0);
//the ports should be 0 - 13 and 19 - 24
for (int i = 0; i <= 13; i++)
QVERIFY2(ports.contains(firstPort+i),qPrintable(QStringLiteral("List should contain port: %1").arg(firstPort+i)));
for(int i = 19; i <= 24; i++)
QVERIFY2(ports.contains(firstPort+i),qPrintable(QStringLiteral("List should contain port: %1").arg(firstPort+i)));
while(ports.hasMore())
QVERIFY2(!ports.contains(ports.getNext()),"Ports can not be assigned twice");
ports = pM.getFreeRange("08866fd9e24cf55a",requiredCount,&in);
//the ports should be 8 - 18 and 21 - 29
for (int i = 8; i <= 18; i++)
QVERIFY2(ports.contains(firstPort+i),qPrintable(QStringLiteral("List should contain port: %1").arg(firstPort+i)));
for (int i = 21; i <= 29; i++)
QVERIFY2(ports.contains(firstPort+i),qPrintable(QStringLiteral("List should contain port: %1").arg(firstPort+i)));
while(ports.hasMore())
QVERIFY2(!ports.contains(ports.getNext()),"Ports can not be assigned twice");
}
QTEST_GUILESS_MAIN(tst_LocalPortManager)
./tests/adbportlist/tst_localportmanager.h 0000644 0000156 0000165 00000000534 12705421114 021162 0 ustar jenkins jenkins #ifndef TST_LOCALPORTMANAGER_H
#define TST_LOCALPORTMANAGER_H
#include
#include "localportsmanager.h"
class tst_LocalPortManager : public QObject
{
Q_OBJECT
public:
tst_LocalPortManager();
private slots:
void testEmptyOutput();
void testSimpleList ();
void testComplexList();
};
#endif // TST_LOCALPORTMANAGER_H
./tests/adbportlist/adbportlist.pro 0000644 0000156 0000165 00000000620 12705421114 017632 0 ustar jenkins jenkins QT = core gui
CONFIG += c++11
QTC_LIB_DEPENDS += utils
include(../shared.pri)
PLUGIN_SRC_ROOT = $${PWD}/../../src/ubuntu
INCLUDEPATH += $${PLUGIN_SRC_ROOT}
HEADERS += \
$${PLUGIN_SRC_ROOT}/localportsmanager.h\
tst_localportmanager.h
SOURCES += \
$${PLUGIN_SRC_ROOT}/localportsmanager.cpp \
tst_localportmanager.cpp
OTHER_FILES += simple_list
RESOURCES += \
resources.qrc
./tests/adbportlist/complex_list 0000644 0000156 0000165 00000001045 12705421114 017210 0 ustar jenkins jenkins 09977feaf35d066b tcp:10000 tcp:22
09977feaf35d066b tcp:10001 tcp:10001
09977feaf35d066b tcp:10002 tcp:10002
09977feaf35d066b tcp:10003 tcp:10003
09977feaf35d066b tcp:10004 tcp:10004
09977feaf35d066b tcp:10005 tcp:10005
09977feaf35d066b tcp:10006 tcp:10006
09977feaf35d066b tcp:10007 tcp:10007
08866fd9e24cf55a tcp:10014 tcp:22
08866fd9e24cf55a tcp:10015 tcp:10001
08866fd9e24cf55a tcp:10016 tcp:10002
08866fd9e24cf55a tcp:10017 tcp:10003
08866fd9e24cf55a tcp:10018 tcp:10004
09977feaf35d066b tcp:10019 tcp:10006
09977feaf35d066b tcp:10020 tcp:10007
./tests/adbportlist/simple_list 0000644 0000156 0000165 00000001406 12705421114 017033 0 ustar jenkins jenkins 08866fd9e24cf55a tcp:10000 tcp:22
08866fd9e24cf55a tcp:10001 tcp:10001
08866fd9e24cf55a tcp:10002 tcp:10002
08866fd9e24cf55a tcp:10003 tcp:10003
08866fd9e24cf55a tcp:10004 tcp:10004
08866fd9e24cf55a tcp:10005 tcp:10005
08866fd9e24cf55a tcp:10006 tcp:10006
08866fd9e24cf55a tcp:10007 tcp:10007
08866fd9e24cf55a tcp:10008 tcp:10008
08866fd9e24cf55a tcp:10009 tcp:10009
08866fd9e24cf55a tcp:10010 tcp:10010
08866fd9e24cf55a tcp:10011 tcp:10011
08866fd9e24cf55a tcp:10012 tcp:10012
08866fd9e24cf55a tcp:10013 tcp:10013
08866fd9e24cf55a tcp:10014 tcp:10014
08866fd9e24cf55a tcp:10015 tcp:10015
08866fd9e24cf55a tcp:10016 tcp:10016
08866fd9e24cf55a tcp:10017 tcp:10017
08866fd9e24cf55a tcp:10018 tcp:10018
08866fd9e24cf55a tcp:10019 tcp:10019
08866fd9e24cf55a tcp:10020 tcp:10020
./src/ 0000755 0000156 0000165 00000000000 12705421114 011661 5 ustar jenkins jenkins ./src/ubuntu/ 0000755 0000156 0000165 00000000000 12705421120 013200 5 ustar jenkins jenkins ./src/ubuntu/ubuntudeploystepfactory.cpp 0000644 0000156 0000165 00000011625 12705421114 020737 0 ustar jenkins jenkins #include "ubuntudeploystepfactory.h"
#include "ubuntuprojecthelper.h"
#include "ubuntuconstants.h"
#include "ubuntudirectuploadstep.h"
#include "ubuntupackagestep.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace Ubuntu {
namespace Internal {
QList UbuntuDeployStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const
{
QList types;
if (parent->id() != ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
return types;
Core::Id targetDevice = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(parent->target()->kit());
if(targetDevice != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE && !targetDevice.toString().startsWith(QLatin1String(Ubuntu::Constants::UBUNTU_DEVICE_TYPE_ID)))
return types;
bool isRemote = targetDevice.toString().startsWith(QLatin1String(Ubuntu::Constants::UBUNTU_DEVICE_TYPE_ID));
bool isCMake = parent->target()->project()->id() == CMakeProjectManager::Constants::CMAKEPROJECT_ID;
bool isHTML = parent->target()->project()->id() == Ubuntu::Constants::UBUNTUPROJECT_ID;
bool isQML = parent->target()->project()->id() == "QmlProjectManager.QmlProject";
bool isQMake = parent->target()->project()->id() == QmakeProjectManager::Constants::QMAKEPROJECT_ID;
if (isRemote) {
//IF we have a remote device we just support a ubuntu toolchain
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(parent->target()->kit());
if(tc && tc->type() != QLatin1String(Ubuntu::Constants::UBUNTU_CLICK_TOOLCHAIN_ID))
return types;
}
if(isRemote && ( isHTML || isQML || isCMake || isQMake ) )
types << Constants::UBUNTU_DEPLOY_UPLOADSTEP_ID
<< Constants::UBUNTU_CLICK_PACKAGESTEP_ID;
return types;
}
QString UbuntuDeployStepFactory::displayNameForId(const Core::Id id) const
{
if (id == Constants::UBUNTU_DEPLOY_UPLOADSTEP_ID)
return UbuntuDirectUploadStep::displayName();
else if (id == Constants::UBUNTU_CLICK_PACKAGESTEP_ID)
return tr("UbuntuSDK create click package", "Display name for UbuntuPackageStep id.");
return QString();
}
bool UbuntuDeployStepFactory::canCreate(ProjectExplorer::BuildStepList *parent, const Core::Id id) const
{
return availableCreationIds(parent).contains(id);
}
ProjectExplorer::BuildStep *UbuntuDeployStepFactory::create(ProjectExplorer::BuildStepList *parent, const Core::Id id)
{
if (!canCreate(parent, id))
return 0;
if(id == Constants::UBUNTU_DEPLOY_UPLOADSTEP_ID)
return new UbuntuDirectUploadStep(parent);
else if (id == Constants::UBUNTU_CLICK_PACKAGESTEP_ID) {
UbuntuPackageStep *step = new UbuntuPackageStep(parent);
return step;
}
return 0;
}
bool UbuntuDeployStepFactory::canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const
{
Core::Id toRestore = ProjectExplorer::idFromMap(map);
//backwards compatibility to older projects
if( toRestore == Constants::UBUNTU_DEPLOY_MAKESTEP_ID )
return canCreate(parent,Core::Id(Constants::UBUNTU_CLICK_PACKAGESTEP_ID));
return canCreate(parent,toRestore);
}
ProjectExplorer::BuildStep *UbuntuDeployStepFactory::restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map)
{
Core::Id id = ProjectExplorer::idFromMap(map);
if(!canCreate(parent,id))
return 0;
//backwards compatibility to older projects
if( id == Constants::UBUNTU_DEPLOY_MAKESTEP_ID ) {
UbuntuPackageStep *step = new UbuntuPackageStep(parent);
return step;
}
ProjectExplorer::BuildStep* step = create(parent,id);
if (!step->fromMap(map)) {
delete step;
return 0;
}
return step;
}
bool UbuntuDeployStepFactory::canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const
{
return canCreate(parent,product->id());
}
ProjectExplorer::BuildStep *UbuntuDeployStepFactory::clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product)
{
if (!canClone(parent, product))
return 0;
const Core::Id id = product->id();
if(id == Constants::UBUNTU_DEPLOY_UPLOADSTEP_ID)
return new UbuntuDirectUploadStep(parent, static_cast(product));
else if(id == Core::Id(Constants::UBUNTU_CLICK_PACKAGESTEP_ID))
return new UbuntuPackageStep(parent, static_cast(product));
return 0;
}
} // namespace Internal
} // namespace Ubuntu
./src/ubuntu/ubuntuabstractguieditor.cpp 0000644 0000156 0000165 00000006676 12705421114 020710 0 ustar jenkins jenkins /*
* Copyright 2014 Digia Plc and/or its subsidiary(-ies).
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Benjamin Zeller
*/
#include "ubuntuabstractguieditor.h"
#include "ubuntuabstractguieditorwidget.h"
#include "ubuntuconstants.h"
#include
#include
#include
#include
#include
namespace Ubuntu {
namespace Internal {
UbuntuAbstractGuiEditor::UbuntuAbstractGuiEditor(const Core::Context &context)
: Core::IEditor(), m_toolBar(0), m_actionGroup(0)
{
setContext(context);
}
QWidget *UbuntuAbstractGuiEditor::toolBar()
{
return m_toolBar;
}
UbuntuAbstractGuiEditorWidget *UbuntuAbstractGuiEditor::editorWidget() const
{
return static_cast(m_widget.data());
}
Core::IDocument *UbuntuAbstractGuiEditor::document()
{
return editorWidget()->textEditorWidget()->textDocument();
}
TextEditor::TextEditorWidget *UbuntuAbstractGuiEditor::textEditor() const
{
return editorWidget()->textEditorWidget();
}
int UbuntuAbstractGuiEditor::currentLine() const
{
return textEditor()->textCursor().blockNumber() + 1;
}
int UbuntuAbstractGuiEditor::currentColumn() const
{
QTextCursor cursor = textEditor()->textCursor();
return cursor.position() - cursor.block().position() + 1;
}
void UbuntuAbstractGuiEditor::syncCurrentAction()
{
foreach (QAction *action, m_actionGroup->actions()) {
if (action->data().toInt() == editorWidget()->activePage()) {
action->setChecked(true);
break;
}
}
}
void UbuntuAbstractGuiEditor::createUi()
{
UbuntuAbstractGuiEditorWidget *loc_editorWidget = createGuiEditor();
m_widget = loc_editorWidget;
connect(loc_editorWidget, &UbuntuAbstractGuiEditorWidget::editorViewChanged,
this, &UbuntuAbstractGuiEditor::syncCurrentAction);
m_toolBar = new QToolBar(m_widget.data());
m_actionGroup = new QActionGroup(m_widget.data());
connect(m_actionGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeEditorPage(QAction*)));
QAction *generalAction = m_toolBar->addAction(tr("General"));
generalAction->setData(UbuntuAbstractGuiEditorWidget::General);
generalAction->setCheckable(true);
m_actionGroup->addAction(generalAction);
QAction *sourceAction = m_toolBar->addAction(tr("JSON Source"));
sourceAction->setData(UbuntuAbstractGuiEditorWidget::Source);
sourceAction->setCheckable(true);
m_actionGroup->addAction(sourceAction);
generalAction->setChecked(true);
setWidget(editorWidget());
}
void UbuntuAbstractGuiEditor::changeEditorPage(QAction *action)
{
if(!editorWidget()->setActivePage(static_cast(action->data().toInt()))){
syncCurrentAction();
}
}
} // namespace Internal
} // namespace Ubuntu
./src/ubuntu/ubuntuclickdialog.ui 0000644 0000156 0000165 00000004770 12705421114 017262 0 ustar jenkins jenkins
Ubuntu::Internal::UbuntuClickDialog
0
0
940
563
640
480
Run Click
-
75
true
Run Click
-
Exit Status
-
Qt::Horizontal
QDialogButtonBox::Close
-
0
1
0
15
buttonBox
accepted()
Ubuntu::Internal::UbuntuClickDialog
accept()
88
553
157
274
buttonBox
rejected()
Ubuntu::Internal::UbuntuClickDialog
reject()
88
553
286
274
./src/ubuntu/ubuntusecuritypolicypickerdialog.cpp 0000644 0000156 0000165 00000007224 12705421114 022624 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Juhapekka Piiroinen
*/
#include "ubuntusecuritypolicypickerdialog.h"
#include "ui_ubuntusecuritypolicypickerdialog.h"
UbuntuSecurityPolicyPickerDialog::UbuntuSecurityPolicyPickerDialog(const QString &policyVersion, QWidget *parent) :
QDialog(parent),
ui(new Ui::UbuntuSecurityPolicyPickerDialog)
{
ui->setupUi(this);
this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint | Qt::Popup);
m_model.setPolicyVersion(policyVersion);
m_model.scanPolicyGroups();
connect(&m_model,SIGNAL(scanComplete(bool)),this,SLOT(onScanComplete(bool)));
ui->listViewPolicyGroups->setModel(&m_model);
ui->stackedWidget->setCurrentIndex(0);
QItemSelectionModel *selModel = ui->listViewPolicyGroups->selectionModel();
connect(selModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)),
this, SLOT(onPolicyClicked(QModelIndex)));
connect(&m_info,SIGNAL(infoReady(bool)),this,SLOT(onInfoChanged(bool)));
}
UbuntuSecurityPolicyPickerDialog::~UbuntuSecurityPolicyPickerDialog()
{
delete ui;
}
void UbuntuSecurityPolicyPickerDialog::onScanComplete(bool ok) {
if (ok) {
ui->stackedWidget->setCurrentIndex(1);
ui->listViewPolicyGroups->selectionModel()->setCurrentIndex(m_model.index(0,0),
QItemSelectionModel::SelectCurrent);
ui->listViewPolicyGroups->setFocus();
} else {
ui->stackedWidget->setCurrentIndex(2);
}
}
QStringList UbuntuSecurityPolicyPickerDialog::selectedPolicyGroups() {
QStringList retval;
if (ui->stackedWidget->currentIndex()==2) {
retval.append(ui->lineEditPolicyGroup->text());
} else {
QModelIndexList selected = ui->listViewPolicyGroups->selectionModel()->selectedIndexes();
foreach (QModelIndex idx, selected) {
retval.append(m_model.data(idx,Qt::DisplayRole).toString());
}
}
return retval;
}
void UbuntuSecurityPolicyPickerDialog::on_pushButtonCancel_clicked() {
this->reject();
}
void UbuntuSecurityPolicyPickerDialog::on_pushButtonAdd_clicked() {
this->accept();
}
void UbuntuSecurityPolicyPickerDialog::onPolicyClicked(QModelIndex idx) {
m_info.getInfo(m_model.data(idx,Qt::DisplayRole).toString(),m_model.policyVersion());
}
void UbuntuSecurityPolicyPickerDialog::onInfoChanged(bool ok) {
if (ok) {
QString policyGroupInfo = m_info.info();
policyGroupInfo = policyGroupInfo.replace(QRegExp(QLatin1String("#([^\n]*)")), QLatin1String("#\\1"));
policyGroupInfo = policyGroupInfo.replace(QRegExp(QLatin1String("(# Usage: reserved)"),Qt::CaseInsensitive), QLatin1String("\\1"));
policyGroupInfo = policyGroupInfo.replace(QRegExp(QLatin1String("\n")), QLatin1String("
"));
ui->textBrowserEditInfo->setHtml(policyGroupInfo);
ui->textBrowserEditInfo->show();
} else {
ui->textBrowserEditInfo->hide();
}
}
./src/ubuntu/ubuntudevicenotifier.cpp 0000644 0000156 0000165 00000010213 12705421114 020146 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Juhapekka Piiroinen
*/
#include "ubuntudevicenotifier.h"
enum {
debug = 0
};
IUbuntuDeviceNotifier::IUbuntuDeviceNotifier(QObject *parent)
: QObject(parent)
{
}
UbuntuDeviceNotifier::UbuntuDeviceNotifier(QObject *parent) :
IUbuntuDeviceNotifier(parent)
{
m_dev = udev_new();
m_udevMonitor = NULL;
m_udevMonitor = udev_monitor_new_from_netlink(m_dev,"udev");
if (!m_udevMonitor) {
qWarning() << QLatin1String("could not monitor devices");
return;
}
udev_monitor_filter_add_match_subsystem_devtype(m_udevMonitor,"usb",0);
udev_monitor_enable_receiving(m_udevMonitor);
m_udevMonitorFileDescriptor = udev_monitor_get_fd(m_udevMonitor);
m_udevSocketNotifier = new QSocketNotifier(m_udevMonitorFileDescriptor,QSocketNotifier::Read, this);
connect(m_udevSocketNotifier,SIGNAL(activated(int)),this,SLOT(on_udev_event()));
}
UbuntuDeviceNotifier::~UbuntuDeviceNotifier() {
m_udevSocketNotifier->disconnect(SIGNAL(activated(int)));
m_udevSocketNotifier->deleteLater();
udev_monitor_unref(m_udevMonitor);
udev_unref(m_dev);
}
void UbuntuDeviceNotifier::startMonitoring(const QString &serialNumber) {
m_serialNumber = serialNumber;
// check if the device is connected or disconnected at the moment
struct udev_list_entry *dev_list_entry;
struct udev_device *dev;
struct udev_enumerate *enumerate = udev_enumerate_new(m_dev);
udev_enumerate_add_match_subsystem(enumerate, "usb");
udev_enumerate_add_match_sysattr(enumerate,"serial",serialNumber.toLatin1().constData());
udev_enumerate_scan_devices(enumerate);
struct udev_list_entry *devices = udev_enumerate_get_list_entry(enumerate);
udev_list_entry_foreach(dev_list_entry, devices) {
const char *path;
path = udev_list_entry_get_name(dev_list_entry);
dev = udev_device_new_from_syspath(m_dev, path);
m_devNode = QLatin1String(udev_device_get_devnode(dev));
udev_device_unref(dev);
}
udev_enumerate_unref(enumerate);
}
void UbuntuDeviceNotifier::stopMonitoring() {
m_serialNumber = QLatin1String("");
}
/*!
* \brief UbuntuDeviceNotifier::isConnected
* Returns true if the device that is currently monitored
* is connected.
* \note you need to call startMonitoring() first
*/
bool UbuntuDeviceNotifier::isConnected() const
{
return !m_devNode.isEmpty();
}
void UbuntuDeviceNotifier::on_udev_event() {
if (!m_udevMonitor) {
if(debug) qDebug() << QLatin1String("no monitor");
return;
}
struct udev_device *dev;
dev = udev_monitor_receive_device(m_udevMonitor);
if (!dev) {
if(debug) qDebug() << QLatin1String("no device");
udev_device_unref(dev);
return;
}
QString serial = QLatin1String(udev_device_get_sysattr_value(dev,"serial"));
QString action = QLatin1String(udev_device_get_action(dev));
QString devNode = QLatin1String(udev_device_get_devnode(dev));
udev_device_unref(dev);
if (action == QLatin1String("remove") && (m_devNode == devNode) && m_devNode.isEmpty()==false) {
m_devNode = QLatin1String("");
emit deviceDisconnected();
} else if (action == QLatin1String("add") && m_serialNumber == serial && m_serialNumber.isEmpty()==false) {
emit deviceConnected();
emit deviceConnected(m_serialNumber);
m_devNode = devNode;
} else if (action == QLatin1String("add")) {
if (!serial.isEmpty()) {
emit deviceConnected(serial);
}
}
}
./src/ubuntu/targetupgrademanagerdialog.ui 0000644 0000156 0000165 00000003630 12705421114 021115 0 ustar jenkins jenkins
Ubuntu::Internal::TargetUpgradeManagerDialog
0
0
653
479
Dialog
-
Updates are available for your Kits. Please select those which should be updated.
true
-
-
QDialogButtonBox::Cancel|QDialogButtonBox::Ok
buttonBox
accepted()
Ubuntu::Internal::TargetUpgradeManagerDialog
accept()
440
448
649
41
buttonBox
rejected()
Ubuntu::Internal::TargetUpgradeManagerDialog
reject()
358
457
648
79
./src/ubuntu/ubunturemotedeployconfiguration.cpp 0000644 0000156 0000165 00000013274 12705421114 022461 0 ustar jenkins jenkins /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Benjamin Zeller
*/
#include "ubunturemotedeployconfiguration.h"
#include "ubuntudirectuploadstep.h"
#include "ubuntuprojecthelper.h"
#include "ubuntuconstants.h"
#include "ubuntupackagestep.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace Ubuntu {
namespace Internal {
enum {
debug = 0
};
UbuntuRemoteDeployConfiguration::UbuntuRemoteDeployConfiguration(ProjectExplorer::Target *target)
: DeployConfiguration(target,Constants::UBUNTU_DEPLOYCONFIGURATION_ID)
{
setDefaultDisplayName(tr("Deploy to Ubuntu Device"));
}
UbuntuRemoteDeployConfiguration::UbuntuRemoteDeployConfiguration(ProjectExplorer::Target *target, UbuntuRemoteDeployConfiguration *source) :
DeployConfiguration(target,source)
{
}
ProjectExplorer::NamedWidget *UbuntuRemoteDeployConfiguration::createConfigWidget()
{
return new ProjectExplorer::NamedWidget();
}
UbuntuRemoteDeployConfigurationFactory::UbuntuRemoteDeployConfigurationFactory(QObject *parent)
: DeployConfigurationFactory(parent)
{
setObjectName(QLatin1String("UbuntuDeployConfiguration"));
}
QList UbuntuRemoteDeployConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const
{
QList ids;
if (!parent->project()->supportsKit(parent->kit()))
return ids;
ProjectExplorer::ToolChain *tc
= ProjectExplorer::ToolChainKitInformation::toolChain(parent->kit());
if (!tc || tc->targetAbi().os() != ProjectExplorer::Abi::LinuxOS)
return ids;
Core::Id projectTypeId = parent->project()->id();
qDebug()<<"Project ID: "<kit());
if (devType.toString().startsWith(QLatin1String(Constants::UBUNTU_DEVICE_TYPE_ID)))
ids << Core::Id(Constants::UBUNTU_DEPLOYCONFIGURATION_ID);
return ids;
}
QString UbuntuRemoteDeployConfigurationFactory::displayNameForId(const Core::Id id) const
{
if (id == Core::Id(Constants::UBUNTU_DEPLOYCONFIGURATION_ID))
return tr("Deploy to Ubuntu Device");
return QString();
}
bool UbuntuRemoteDeployConfigurationFactory::canCreate(ProjectExplorer::Target *parent, const Core::Id id) const
{
return availableCreationIds(parent).contains(id);
}
ProjectExplorer::DeployConfiguration *UbuntuRemoteDeployConfigurationFactory::create(ProjectExplorer::Target *parent,
const Core::Id id)
{
QTC_ASSERT(canCreate(parent, id),return 0);
ProjectExplorer::DeployConfiguration * const dc
= new UbuntuRemoteDeployConfiguration(parent);
int step = 0;
UbuntuPackageStep *pckStep = new UbuntuPackageStep(dc->stepList());
dc->stepList()->insertStep(0,pckStep);
UbuntuDirectUploadStep* upload = new UbuntuDirectUploadStep(dc->stepList());
dc->stepList()->insertStep(step+1,upload);
return dc;
}
bool UbuntuRemoteDeployConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const
{
return canCreate(parent, ProjectExplorer::idFromMap(map));
}
ProjectExplorer::DeployConfiguration *UbuntuRemoteDeployConfigurationFactory::restore(ProjectExplorer::Target *parent,
const QVariantMap &map)
{
if (!canRestore(parent, map))
return 0;
UbuntuRemoteDeployConfiguration * const dc
= new UbuntuRemoteDeployConfiguration(parent);
if (!dc->fromMap(map)) {
delete dc;
return 0;
}
return dc;
}
bool UbuntuRemoteDeployConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::DeployConfiguration *product) const
{
return canCreate(parent,product->id());
}
ProjectExplorer::DeployConfiguration *UbuntuRemoteDeployConfigurationFactory::clone(ProjectExplorer::Target *parent,
ProjectExplorer::DeployConfiguration *product)
{
if (!canClone(parent, product))
return 0;
return new UbuntuRemoteDeployConfiguration(parent, qobject_cast(product));
}
} // namespace Internal
} // namespace Ubuntu
./src/ubuntu/ubuntulocalrunconfigurationfactory.h 0000644 0000156 0000165 00000005637 12705421114 022631 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Juhapekka Piiroinen
*/
#ifndef UBUNTURUNCONFIGURATIONFACTORY_H
#define UBUNTURUNCONFIGURATIONFACTORY_H
#include
#include
#include "ubuntuproject.h"
#include "ubuntuconstants.h"
#include "ubuntulocalrunconfiguration.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace Ubuntu {
namespace Internal {
class UbuntuLocalRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
{
Q_OBJECT
public:
explicit UbuntuLocalRunConfigurationFactory() {
setObjectName(QLatin1String("UbuntuRunConfigurationFactory"));
}
QList availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode = UserCreate) const override;
QString displayNameForId(const Core::Id id) const override;
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const override;
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product) const override;
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) override;
private:
bool canHandle(ProjectExplorer::Target *parent) const;
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id) override;
ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent, const QVariantMap &map) override;
};
}
}
#endif // UBUNTURUNCONFIGURATIONFACTORY_H
./src/ubuntu/ubuntuclickdialog.h 0000644 0000156 0000165 00000005062 12705421114 017067 0 ustar jenkins jenkins /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Benjamin Zeller
*/
#ifndef UBUNTU_INTERNAL_UBUNTUCLICKDIALOG_H
#define UBUNTU_INTERNAL_UBUNTUCLICKDIALOG_H
#include
#include
#include
#include
#include "ubuntuclicktool.h"
namespace ProjectExplorer {
class Project;
class Target;
}
namespace Ubuntu {
namespace Internal {
namespace Ui {
class UbuntuClickDialog;
}
class UbuntuClickDialog : public QDialog
{
Q_OBJECT
public:
UbuntuClickDialog (QWidget* parent = 0);
~UbuntuClickDialog ();
void setParameters (const QList ¶ms);
int lastExitCode () const;
public slots:
void runClick ();
static int runClickModal(const ProjectExplorer::ProcessParameters ¶ms, QWidget *parent = 0);
static int runClickModal (const QList ¶ms, QWidget *parent = 0);
static bool createClickChrootModal (bool redetectKits = true , const QString &arch = QString(), const QString &framework = QString(), QWidget *parent = 0);
static int maintainClickModal (const UbuntuClickTool::Target &target, const UbuntuClickTool::MaintainMode &mode);
static int maintainClickModal (const QList &targetList, const UbuntuClickTool::MaintainMode &mode);
// QDialog interface
virtual void done(int code);
protected:
void disableCloseButton (const bool &disabled = true);
void nextTask ();
protected slots:
void on_clickFinished(int exitCode);
void on_clickReadyReadStandardOutput(const QString txt = QString());
void on_clickReadyReadStandardError(const QString txt = QString());
private:
Utils::QtcProcess *m_process;
Ui::UbuntuClickDialog *m_ui;
QList m_tasks;
int m_exitCode;
};
} // namespace Internal
} // namespace Ubuntu
#endif // UBUNTU_INTERNAL_UBUNTUCLICKDIALOG_H
./src/ubuntu/ubuntueditorfactory.h 0000644 0000156 0000165 00000001207 12705421114 017475 0 ustar jenkins jenkins #ifndef UBUNTU_INTERNAL_UBUNTUMANIFESTEDITORFACTORY_H
#define UBUNTU_INTERNAL_UBUNTUMANIFESTEDITORFACTORY_H
#include
namespace Ubuntu {
namespace Internal {
class UbuntuManifestEditorFactory : public Core::IEditorFactory
{
Q_OBJECT
public:
explicit UbuntuManifestEditorFactory();
Core::IEditor *createEditor();
};
class UbuntuApparmorEditorFactory : public Core::IEditorFactory
{
Q_OBJECT
public:
explicit UbuntuApparmorEditorFactory();
Core::IEditor *createEditor();
};
} // namespace Internal
} // namespace Ubuntu
#endif // UBUNTU_INTERNAL_UBUNTUMANIFESTEDITORFACTORY_H
./src/ubuntu/ubuntupolicygroupmodel.h 0000644 0000156 0000165 00000002671 12705421114 020222 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Juhapekka Piiroinen
*/
#ifndef POLICYGROUPMODEL_H
#define POLICYGROUPMODEL_H
#include
#include
#include "ubuntuprocess.h"
namespace Ubuntu {
namespace Internal {
class UbuntuPolicyGroupModel : public QStringListModel
{
Q_OBJECT
public:
explicit UbuntuPolicyGroupModel(QObject *parent = 0);
void setPolicyVersion (const QString &policyVersion);
QString policyVersion () const;
void scanPolicyGroups();
bool isLocal() { return m_bLocal; }
public slots:
void onMessage(QString);
void onFinished(QString, int);
signals:
void scanComplete(bool);
protected:
UbuntuProcess m_process;
QStringList m_replies;
QString m_policyVersion;
bool m_bLocal;
};
}
}
#endif // POLICYGROUPMODEL_H
./src/ubuntu/ubuntuabstractguieditordocument.h 0000644 0000156 0000165 00000003150 12705421114 022074 0 ustar jenkins jenkins /*
* Copyright 2014 Digia Plc and/or its subsidiary(-ies).
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Benjamin Zeller
*/
#ifndef UBUNTU_INTERNAL_UBUNTUMANIFESTDOCUMENT_H
#define UBUNTU_INTERNAL_UBUNTUMANIFESTDOCUMENT_H
#include
#include
namespace Ubuntu {
namespace Internal {
class UbuntuAbstractGuiEditorWidget;
class UbuntuAbstractGuiEditorDocument : public TextEditor::TextDocument
{
public:
UbuntuAbstractGuiEditorDocument(const QString &mimeType, UbuntuAbstractGuiEditorWidget *editorWidget);
bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false);
QString defaultPath() const override;
QString suggestedFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
private:
UbuntuAbstractGuiEditorWidget *m_editorWidget;
};
} // namespace Internal
} // namespace Ubuntu
#endif // UBUNTU_INTERNAL_UBUNTUMANIFESTDOCUMENT_H
./src/ubuntu/ubuntupackagestepconfigwidget.ui 0000644 0000156 0000165 00000003054 12705421114 021670 0 ustar jenkins jenkins
UbuntuPackageStepConfigWidget
0
0
400
300
Form
-
Treat click review errors as warnings
-
Enable debug helper
comboBoxMode
-
<html><head/><body><p>Specifies if the debug helper script <br/>is injected into the click package.</p><p>Auto will only package them when <br/>the project is compiled in debug mode.</p></body></html>
<html><head/><body><p><br/></p></body></html>
./src/ubuntu/ubuntucmakemakestep.h 0000644 0000156 0000165 00000005041 12705421114 017431 0 ustar jenkins jenkins /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Benjamin Zeller
*/
#ifndef UBUNTU_INTERNAL_UBUNTUCMAKEMAKESTEP_H
#define UBUNTU_INTERNAL_UBUNTUCMAKEMAKESTEP_H
#include
#include
#include
namespace Ubuntu {
namespace Internal {
class UbuntuCMakeMakeStepFactory : public ProjectExplorer::IBuildStepFactory
{
Q_OBJECT
public:
// IBuildStepFactory interface
virtual QList availableCreationIds(ProjectExplorer::BuildStepList *parent) const override;
virtual QString displayNameForId(const Core::Id id) const override;
virtual bool canCreate(ProjectExplorer::BuildStepList *parent, const Core::Id id) const override;
virtual ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, const Core::Id id) override;
virtual bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const override;
virtual ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) override;
virtual bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const override;
virtual ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) override;
private:
bool canHandle(const ProjectExplorer::Target *t) const;
};
class UbuntuCMakeMakeStep : public CMakeProjectManager::MakeStep
{
Q_OBJECT
public:
UbuntuCMakeMakeStep(ProjectExplorer::BuildStepList *bsl);
UbuntuCMakeMakeStep(ProjectExplorer::BuildStepList *bsl, UbuntuCMakeMakeStep *bs);
virtual ~UbuntuCMakeMakeStep();
virtual QString makeCommand(ProjectExplorer::ToolChain *tc, const Utils::Environment &env) const override;
friend class UbuntuCMakeMakeStepFactory;
};
} // namespace Internal
} // namespace Ubuntu
#endif // UBUNTU_INTERNAL_UBUNTUCMAKEMAKESTEP_H
./src/ubuntu/resources.qrc 0000644 0000156 0000165 00000002315 12705421114 015725 0 ustar jenkins jenkins
images/ubuntu-64.png
images/ubuntu-128.png
images/ubuntu-qtcreator.png
images/ubuntu-48.png
images/device.png
UbuntuProject.mimetypes.xml
images/irc.png
images/ubuntu-32.png
images/launchpad.png
images/coreapps.png
images/packaging.png
manifest.json.template
myapp.json.template
manifestlib.js
images/view-refresh.png
images/list-add.png
images/reload.svg
images/list-add.svg
images/list-remove.svg
images/security-alert.svg
images/view-expand.svg
images/view-collapse.svg
click-framework.json
images/run.png
images/stop.png
images/warning.png
images/error.png
images/clear.png
./src/ubuntu/ubuntudevicemode.cpp 0000644 0000156 0000165 00000011706 12705421114 017263 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Juhapekka Piiroinen
*/
#include "ubuntudevicemode.h"
#include "ubuntuconstants.h"
#include "ubuntudevicesmodel.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace Ubuntu::Internal;
UbuntuDeviceMode *UbuntuDeviceMode::m_instance = 0;
UbuntuDeviceMode::UbuntuDeviceMode(QObject *parent) :
Core::IMode(parent)
{
Q_ASSERT_X(m_instance == 0, Q_FUNC_INFO,"There can be only one instance of UbuntuDeviceMode");
m_instance = this;
m_qmlControl = new UbuntuQMLDeviceMode(this);
setDisplayName(tr(Ubuntu::Constants::UBUNTU_MODE_DEVICES_DISPLAYNAME));
setIcon(QIcon(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_DEVICES_ICON)));
setPriority(Ubuntu::Constants::UBUNTU_MODE_DEVICES_PRIORITY);
setId(Ubuntu::Constants::UBUNTU_MODE_DEVICES);
setObjectName(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_DEVICES));
setContext(Core::Context("Ubuntu Plugin"));
setContextHelpId(QStringLiteral("Managing Devices"));
m_modeWidget = new QWidget;
QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0);
layout->setSpacing(0);
m_modeWidget->setLayout(layout);
Utils::StyledBar* styledBar = new Utils::StyledBar(m_modeWidget);
layout->addWidget(styledBar);
m_modeView = new QQuickView;
m_modeView->setResizeMode(QQuickView::SizeRootObjectToView);
m_devicesModel = new UbuntuDevicesModel(m_modeView);
connect(m_devicesModel,SIGNAL(logMessage(QString)),m_qmlControl,SLOT(addText(QString)));
connect(m_devicesModel,SIGNAL(stdOutMessage(QString)),m_qmlControl,SLOT(addText(QString)));
connect(m_devicesModel,SIGNAL(stdErrMessage(QString)),m_qmlControl,SLOT(addErrorText(QString)));
QWidget* container = QWidget::createWindowContainer(m_modeView);
container->setMinimumWidth(860);
container->setMinimumHeight(548);
container->setFocusPolicy(Qt::TabFocus);
layout->addWidget(container);
m_modeView->rootContext()->setContextProperty(QLatin1String("devicesModel") ,m_devicesModel);
m_modeView->rootContext()->setContextProperty(QLatin1String("deviceMode") ,m_qmlControl);
m_modeView->rootContext()->setContextProperty(QLatin1String("resourceRoot") ,Constants::UBUNTU_DEVICESCREEN_ROOT);
m_modeView->setSource(QUrl::fromLocalFile(Constants::UBUNTU_DEVICESCREEN_QML));
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), SLOT(modeChanged(Core::IMode*)));
setWidget(m_modeWidget);
}
UbuntuDevice::ConstPtr UbuntuDeviceMode::device()
{
return UbuntuDevice::ConstPtr();
if(m_devicesModel->rowCount() <= 0)
return UbuntuDevice::ConstPtr();
if(!m_deviceIndex.isValid()) {
m_deviceIndex = 0; //device 0 is always the first selected
}
return m_devicesModel->device(m_deviceIndex.toInt());
}
void UbuntuDeviceMode::deviceSelected(const QVariant index)
{
m_deviceIndex = index;
emit updateDeviceActions ();
}
void UbuntuDeviceMode::showAddEmulatorDialog()
{
m_qmlControl->showAddEmulatorDialog();
}
void UbuntuDeviceMode::modeChanged(Core::IMode *mode)
{
Q_UNUSED(mode);
}
void UbuntuDeviceMode::initialize() {
}
UbuntuDeviceMode *UbuntuDeviceMode::instance()
{
return m_instance;
}
UbuntuQMLDeviceMode::UbuntuQMLDeviceMode(UbuntuDeviceMode *parent)
: QObject(parent),
m_mode(parent)
{
}
void UbuntuQMLDeviceMode::showAddEmulatorDialog()
{
emit openAddEmulatorDialog();
}
void UbuntuQMLDeviceMode::deviceSelected(const QVariant index)
{
m_mode->deviceSelected(index);
}
void UbuntuQMLDeviceMode::addText(const QString &arg)
{
QString in = arg;
in.replace(QStringLiteral("\n"),QStringLiteral("
"));
emit appendText(in);
}
void UbuntuQMLDeviceMode::addErrorText(const QString &error)
{
QString in = error;
in.replace(QStringLiteral("\n"),QStringLiteral("
"));
in.prepend(QStringLiteral(""));
in.append(QStringLiteral(""));
emit appendText(in);
}
./src/ubuntu/ubuntusettingsdeviceconnectivitypage.h 0000644 0000156 0000165 00000002722 12705421114 023136 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Juhapekka Piiroinen
*/
#ifndef UBUNTUSETTINGSDEVICECONNECTIVITYPAGE_H
#define UBUNTUSETTINGSDEVICECONNECTIVITYPAGE_H
#include
#include "ubuntusettingsdeviceconnectivitywidget.h"
#include
namespace Ubuntu {
namespace Internal {
class UbuntuSettingsDeviceConnectivityPage : public Core::IOptionsPage
{
Q_OBJECT
public:
explicit UbuntuSettingsDeviceConnectivityPage();
~UbuntuSettingsDeviceConnectivityPage();
QWidget *widget( ) override;
void apply() override;
void finish() override;
protected:
QPointer m_widget;
};
}
}
#endif // UBUNTUSETTINGSDEVICECONNECTIVITYPAGE_H
./src/ubuntu/clicktoolchain.h 0000644 0000156 0000165 00000005572 12705421114 016353 0 ustar jenkins jenkins /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Benjamin Zeller
*/
#ifndef UBUNTU_INTERNAL_CLICKTOOLCHAIN_H
#define UBUNTU_INTERNAL_CLICKTOOLCHAIN_H
#include
#include "ubuntuclicktool.h"
namespace Ubuntu {
namespace Internal {
class ClickToolChainFactory;
class ClickToolChain : public ProjectExplorer::GccToolChain
{
friend class ClickToolChainFactory;
// ToolChain interface
public:
ClickToolChain(const UbuntuClickTool::Target &target,Detection d);
virtual QList suggestedMkspecList() const override;
virtual Utils::FileName suggestedDebugger() const override;
virtual QString type() const override;
virtual QString typeDisplayName() const override;
virtual bool isValid() const override;
virtual void addToEnvironment(Utils::Environment &env) const override;
virtual QString makeCommand(const Utils::Environment &) const override;
virtual bool operator ==(const ProjectExplorer::ToolChain &tc) const override;
virtual ProjectExplorer::ToolChainConfigWidget *configurationWidget() override;
virtual QVariantMap toMap() const override;
QString gnutriplet () const;
static QString gnutriplet (const ProjectExplorer::Abi &abi);
const UbuntuClickTool::Target &clickTarget () const;
static ProjectExplorer::Abi architectureNameToAbi ( const QString &arch );
static QList supportedArchitectures ();
protected:
virtual bool fromMap(const QVariantMap &data) override;
ClickToolChain(const ClickToolChain& other);
ClickToolChain();
private:
UbuntuClickTool::Target m_clickTarget;
// ToolChain interface
public:
virtual Utils::FileName compilerCommand() const override;
};
class ClickToolChainFactory : public ProjectExplorer::ToolChainFactory
{
Q_OBJECT
public:
ClickToolChainFactory();
// ToolChainFactory interface
public:
virtual QList autoDetect() override;
virtual bool canRestore(const QVariantMap &data) override;
virtual ProjectExplorer::ToolChain *restore(const QVariantMap &data) override;
static QList createToolChainsForClickTargets();
};
} // namespace Internal
} // namespace Ubuntu
#endif // UBUNTU_INTERNAL_CLICKTOOLCHAIN_H
./src/ubuntu/ubuntulocalruncontrolfactory.h 0000644 0000156 0000165 00000001401 12705421114 021423 0 ustar jenkins jenkins #ifndef UBUNTULOCALRUNCONTROLFACTORY_H
#define UBUNTULOCALRUNCONTROLFACTORY_H
#include
namespace Ubuntu {
namespace Internal {
class UbuntuLocalRunControlFactory : public ProjectExplorer::IRunControlFactory
{
Q_OBJECT
public:
explicit UbuntuLocalRunControlFactory() {}
virtual ~UbuntuLocalRunControlFactory() {}
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, Core::Id mode) const override;
ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
Core::Id mode, QString *errorMessage) override;
QString displayName() const;
};
} //namespace Internal
} //namespace Ubuntu
#endif // UBUNTULOCALRUNCONTROLFACTORY_H
./src/ubuntu/ubuntufixmanifeststep.cpp 0000644 0000156 0000165 00000005546 12705421114 020375 0 ustar jenkins jenkins #include "ubuntufixmanifeststep.h"
#include "ubuntuconstants.h"
#include
#include
#include
#include
#include
#include
namespace Ubuntu {
namespace Internal {
/*!
* \class UbuntuFixManifestStep
* The UbuntuFixManifestStep can be used to fill in fields into
* a manifest file in the build process, its used in the fat packaging
* process
*/
UbuntuFixManifestStep::UbuntuFixManifestStep(ProjectExplorer::BuildStepList *bsl) :
ProjectExplorer::BuildStep(bsl, Core::Id("UbuntuProjectManager.UbuntuFixManifestStep"))
{
}
QStringList UbuntuFixManifestStep::architectures() const
{
return m_architectures;
}
void UbuntuFixManifestStep::setArchitectures(const QStringList &architectures)
{
m_architectures = architectures;
}
QString UbuntuFixManifestStep::packageDir() const
{
return m_packageDir;
}
void UbuntuFixManifestStep::setPackageDir(const QString &packageDir)
{
m_packageDir = packageDir;
}
bool UbuntuFixManifestStep::init()
{
return true;
}
void UbuntuFixManifestStep::run(QFutureInterface &fi)
{
bool result = false;
if (!m_packageDir.isEmpty() ) {
Utils::FileName manifestFileName = Utils::FileName::fromString(m_packageDir)
.appendPath(QStringLiteral("manifest.json"));
QFile manifestFile(manifestFileName.toString());
if(Q_UNLIKELY(!manifestFile.open(QIODevice::ReadOnly))) {
emit addOutput(tr("Can not open manifest file for reading."),ProjectExplorer::BuildStep::ErrorOutput);
fi.reportFinished(&result);
return;
}
if (m_architectures.isEmpty()) {
emit addOutput(tr("Can not fix manifest file, no architectures are given."),ProjectExplorer::BuildStep::ErrorOutput);
fi.reportFinished(&result);
return;
}
QJsonDocument doc = QJsonDocument::fromJson(manifestFile.readAll());
QJsonObject rootObj = doc.object();
manifestFile.close();
if (m_architectures.size() > 1)
rootObj[QStringLiteral("architecture")] = QJsonArray::fromStringList(m_architectures);
else
rootObj[QStringLiteral("architecture")] = QJsonValue(m_architectures.first());
doc.setObject(rootObj);
if(!manifestFile.open(QIODevice::WriteOnly | QIODevice::Truncate)){
emit addOutput(tr("Can not open manifest file for writing."),ProjectExplorer::BuildStep::ErrorOutput);
fi.reportFinished(&result);
return;
}
manifestFile.write(doc.toJson());
manifestFile.close();
}
result = true;
fi.reportFinished(&result);
}
ProjectExplorer::BuildStepConfigWidget *UbuntuFixManifestStep::createConfigWidget()
{
return new ProjectExplorer::SimpleBuildStepConfigWidget(this);
}
} // namespace Internal
} // namespace Ubuntu
./src/ubuntu/ubuntulocalscopedebugsupport.cpp 0000644 0000156 0000165 00000013667 12705421114 021757 0 ustar jenkins jenkins #include "ubuntulocalscopedebugsupport.h"
#include "ubuntulocalrunconfiguration.h"
#include "ubuntuprojecthelper.h"
#include "ubuntuconstants.h"
#include
#include
#include
#include
#include
#include
namespace Ubuntu {
namespace Internal {
UbuntuLocalScopeDebugSupport::UbuntuLocalScopeDebugSupport(UbuntuLocalRunConfiguration *runConfig,
Debugger::DebuggerRunControl *runControl,
const QString &scopeRunnerPath)
: QObject(runControl)
, m_port(-1)
, m_scopeRunnerPath(scopeRunnerPath)
, m_runControl(runControl)
{
m_executable = runConfig->executable();
m_commandLineArguments = runConfig->commandLineArguments();
ProjectExplorer::EnvironmentAspect *env = runConfig->extraAspect();
if (env) {
m_launcher.setEnvironment(env->environment());
}
connect (runControl, &Debugger::DebuggerRunControl::requestRemoteSetup,
this, &UbuntuLocalScopeDebugSupport::handleRemoteSetupRequested);
connect (&m_launcher,SIGNAL(appendMessage(QString,Utils::OutputFormat)),
m_runControl, SLOT(appendMessage(QString,Utils::OutputFormat)));
connect (&m_launcher, &ProjectExplorer::ApplicationLauncher::processStarted,
this, &UbuntuLocalScopeDebugSupport::handleProcessStarted);
connect (&m_launcher, &ProjectExplorer::ApplicationLauncher::processExited,
this, &UbuntuLocalScopeDebugSupport::handleProcessExited);
connect (&m_launcher, &ProjectExplorer::ApplicationLauncher::bringToForegroundRequested,
m_runControl, &Debugger::DebuggerRunControl::bringApplicationToForeground);
connect (&m_launcher, &ProjectExplorer::ApplicationLauncher::error,
this, &UbuntuLocalScopeDebugSupport::handleError);
connect (m_runControl, &Debugger::DebuggerRunControl::stateChanged,
this, &UbuntuLocalScopeDebugSupport::handleStateChanged);
}
UbuntuLocalScopeDebugSupport::~UbuntuLocalScopeDebugSupport()
{
m_launcher.stop();
}
void UbuntuLocalScopeDebugSupport::handleRemoteSetupRequested()
{
// Inject the debug mode into the INI file, this is not perfect
// as it will stick even for the next non debug run, and even though
// we can then start without gdbserver the timouts will be always set
// high, because the DebugMode=true setting is still there
m_port = getLocalPort();
QStringList args = Utils::QtcProcess::splitArgs(m_commandLineArguments);
if (args.size() < 0) {
Debugger::RemoteSetupResult res;
res.success = false;
res.reason = tr("Not enough arguments to run a scope.");
m_runControl->notifyEngineRemoteSetupFinished(res);
return;
}
QFileInfo iniFile(args.first());
if (!iniFile.isFile()) {
Debugger::RemoteSetupResult res;
res.success = false;
res.reason = tr("Ini filepath %1 is not valid.").arg(args.first());
m_runControl->notifyEngineRemoteSetupFinished(res);
return;
}
QString appId = iniFile.completeBaseName();
//debughelper script name, source and destination path
const QString debScript = QStringLiteral("qtc_device_debughelper.py");
const QString debSourcePath = QStringLiteral("%1/%2").arg(Constants::UBUNTU_SCRIPTPATH).arg(debScript);
QString commTemplate = QStringLiteral("%S scope %1 %C")
.arg(appId); //tell our script the appid
QString defaultSubCmd = QStringLiteral("%1 %R %S ")
.arg(m_scopeRunnerPath);
bool injected = UbuntuProjectHelper::injectScopeDebugHelper(
iniFile.absoluteFilePath(),
debSourcePath,
commTemplate,
defaultSubCmd);
if (!injected) {
Debugger::RemoteSetupResult res;
res.success = false;
res.reason = tr("Could not inject the debug helper");
m_runControl->notifyEngineRemoteSetupFinished(res);
return;
}
args.append(QStringLiteral("--cppdebug"));
args.append(QString::number(m_port));
m_launcher.start(m_appLauncherMode,
m_executable,
Utils::QtcProcess::joinArgs(args));
}
void UbuntuLocalScopeDebugSupport::handleProcessStarted()
{
Debugger::RemoteSetupResult res;
res.success = true;
res.gdbServerPort = m_port;
m_runControl->notifyEngineRemoteSetupFinished(res);
}
void UbuntuLocalScopeDebugSupport::handleProcessExited(int exitCode, QProcess::ExitStatus)
{
if (exitCode != 0)
m_runControl->notifyInferiorIll();
else
m_runControl->debuggingFinished();
}
void UbuntuLocalScopeDebugSupport::handleError(QProcess::ProcessError error)
{
if (error == QProcess::FailedToStart) {
Debugger::RemoteSetupResult res;
res.success = false;
res.reason = tr("The process failed to start");
m_runControl->notifyEngineRemoteSetupFinished(res);
}
if (error == QProcess::Crashed)
m_runControl->notifyInferiorIll();
}
void UbuntuLocalScopeDebugSupport::handleStateChanged(Debugger::DebuggerState state)
{
qDebug() << "Changed to State: "<