don't make failed applet block the corona

This commit is contained in:
Marco Martin 2014-07-14 14:22:36 +02:00
parent bcf5b9aa8e
commit 6666445af5
6 changed files with 31 additions and 5 deletions

View File

@ -7,6 +7,7 @@ include(ECMMarkAsTest)
include(ECMAddTests)
find_package(KF5CoreAddons REQUIRED)
find_package(KF5XmlGui REQUIRED)
find_package(Qt5Widgets REQUIRED)
# add_definitions( -DKDESRCDIR=${CMAKE_CURRENT_SOURCE_DIR} )
@ -37,12 +38,12 @@ PLASMA_UNIT_TESTS(
)
add_executable(storagetest storagetest.cpp ../src/plasma/private/storage.cpp ../src/plasma/private/storagethread.cpp)
target_link_libraries(storagetest Qt5::Gui Qt5::Test Qt5::Sql KF5::KIOCore KF5::Plasma KF5::CoreAddons )
target_link_libraries(storagetest Qt5::Gui Qt5::Test Qt5::Sql KF5::KIOCore KF5::Plasma KF5::CoreAddons)
set(coronatest_srcs coronatest.cpp)
qt5_add_resources(coronatest_srcs coronatestresources.qrc)
ecm_add_test(${coronatest_srcs} TEST_NAME coronatest LINK_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Test KF5::KIOCore KF5::Plasma KF5::CoreAddons)
ecm_add_test(${coronatest_srcs} TEST_NAME coronatest LINK_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Test KF5::KIOCore KF5::Plasma KF5::CoreAddons KF5::XmlGui)
add_test(plasma-storagetest storagetest)
ecm_mark_as_test(storagetest)

View File

@ -19,13 +19,19 @@
#include "coronatest.h"
#include <ksycoca.h>
#include <kactioncollection.h>
#include <QStandardPaths>
#include <QAction>
#include <QApplication>
Plasma::Applet *SimpleLoader::internalLoadApplet(const QString &name, uint appletId,
const QVariantList &args)
{
return new SimpleApplet();
if (name == "simpleapplet") {
return new SimpleApplet();
} else {
return 0;
}
}
SimpleCorona::SimpleCorona(QObject *parent)
@ -124,6 +130,21 @@ void CoronaTest::startupCompletion()
//TODO: applet creation and deletion
}
void CoronaTest::addRemoveApplets()
{
m_corona->containments().first()->createApplet("invalid");
QCOMPARE(m_corona->containments().first()->applets().count(), 3);
//remove action present
QVERIFY(m_corona->containments().first()->applets().first()->actions()->action("remove"));
//kill an applet
m_corona->containments().first()->applets().first()->actions()->action("remove")->trigger();
QSignalSpy spy(m_corona->containments().first()->applets().first(), SIGNAL(destroyed()));
QVERIFY(spy.wait(1000));
QCOMPARE(m_corona->containments().first()->applets().count(), 2);
}
//this test has to be the last, since systemimmutability
//can't be programmatically unlocked
void CoronaTest::immutability()

View File

@ -66,6 +66,7 @@ public Q_SLOTS:
private Q_SLOTS:
void restore();
void startupCompletion();
void addRemoveApplets();
void immutability();
private:

View File

@ -4,7 +4,7 @@ formfactor=0
immutability=1
lastScreen=0
location=0
plugin=invalid
plugin=simpleapplet
[Containments][1][Applets][2]
immutability=1
@ -12,7 +12,7 @@ plugin=invalid
[Containments][1][Applets][3]
immutability=1
plugin=invalid
plugin=simpleapplet
[General]
immutability=1

View File

@ -437,6 +437,8 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi
delete applet;
}
applet = containment = new Containment(q, 0, id);
//if it's a dummy containment, just say its ui is ready, not blocking the corona
applet->updateConstraints(Plasma::Types::UiReadyConstraint);
// we want to provide something and don't care about the failure to launch
containment->setFormFactor(Plasma::Types::Planar);

View File

@ -209,6 +209,7 @@ Applet *ContainmentPrivate::createApplet(const QString &name, const QVariantList
qWarning() << "Applet" << name << "could not be loaded.";
applet = new Applet(0, QString(), id);
applet->setLaunchErrorMessage(i18n("Could not find requested component: %1", name));
applet->updateConstraints(Plasma::Types::UiReadyConstraint);
}
q->addApplet(applet);