make the uiloaded tests pass
work in case of every order the various applets and containments emit uiready REVIEW:119284
This commit is contained in:
parent
eb172f0d34
commit
188d131d77
@ -28,7 +28,9 @@ Plasma::Applet *SimpleLoader::internalLoadApplet(const QString &name, uint apple
|
||||
const QVariantList &args)
|
||||
{
|
||||
if (name == "simpleapplet") {
|
||||
return new SimpleApplet();
|
||||
return new SimpleApplet(0, QString(), appletId);
|
||||
} else if (name == "simplecontainment") {
|
||||
return new SimpleContainment(0, QString(), appletId);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@ -66,6 +68,22 @@ SimpleApplet::SimpleApplet(QObject *parent , const QString &serviceId, uint appl
|
||||
}
|
||||
|
||||
|
||||
SimpleContainment::SimpleContainment(QObject *parent , const QString &serviceId, uint appletId)
|
||||
: Plasma::Containment(parent, serviceId, appletId)
|
||||
{
|
||||
QTime time = QTime::currentTime();
|
||||
qsrand((uint)time.msec());
|
||||
|
||||
//updateConstraints(Plasma::Types::UiReadyConstraint);
|
||||
m_timer.setSingleShot(true);
|
||||
m_timer.setInterval(qrand() % ((500 + 1) - 100) + 100);
|
||||
m_timer.start();
|
||||
connect(&m_timer, &QTimer::timeout, [=]() {
|
||||
updateConstraints(Plasma::Types::UiReadyConstraint);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void runKBuildSycoca()
|
||||
{
|
||||
@ -117,13 +135,10 @@ void CoronaTest::restore()
|
||||
|
||||
void CoronaTest::startupCompletion()
|
||||
{
|
||||
QEXPECT_FAIL("", "Uiready behavior broken in master.", Continue);
|
||||
QVERIFY(!m_corona->isStartupCompleted());
|
||||
QEXPECT_FAIL("", "Uiready behavior broken in master.", Continue);
|
||||
QVERIFY(!m_corona->containments().first()->isUiReady());
|
||||
|
||||
QSignalSpy spy(m_corona, SIGNAL(startupCompleted()));
|
||||
QEXPECT_FAIL("", "Uiready behavior broken in master.", Continue);
|
||||
QVERIFY(spy.wait(1000));
|
||||
|
||||
QVERIFY(m_corona->isStartupCompleted());
|
||||
|
@ -55,6 +55,16 @@ private:
|
||||
QTimer m_timer;
|
||||
};
|
||||
|
||||
class SimpleContainment : public Plasma::Containment
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimpleContainment(QObject *parent = 0, const QString &serviceId = QString(), uint appletId = 0);
|
||||
private:
|
||||
QTimer m_timer;
|
||||
};
|
||||
|
||||
class CoronaTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -4,7 +4,7 @@ formfactor=0
|
||||
immutability=1
|
||||
lastScreen=0
|
||||
location=0
|
||||
plugin=simpleapplet
|
||||
plugin=simplecontainment
|
||||
|
||||
[Containments][1][Applets][2]
|
||||
immutability=1
|
||||
|
@ -281,6 +281,12 @@ void Containment::restoreContents(KConfigGroup &group)
|
||||
|
||||
d->createApplet(plugin, QVariantList(), appId);
|
||||
}
|
||||
|
||||
for (Applet *applet : Containment::applets()) {
|
||||
if (!applet->pluginInfo().isValid()) {
|
||||
applet->updateConstraints(Plasma::Types::UiReadyConstraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Plasma::Types::ContainmentType Containment::containmentType() const
|
||||
@ -536,7 +542,7 @@ QHash<QString, ContainmentActions *> &Containment::containmentActions()
|
||||
|
||||
bool Containment::isUiReady() const
|
||||
{
|
||||
return d->uiReady && Applet::d->started;
|
||||
return d->uiReady && d->appletsUiReady && Applet::d->started;
|
||||
}
|
||||
|
||||
void Containment::setActivity(const QString &activityId)
|
||||
|
@ -540,8 +540,9 @@ QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigGroup &con
|
||||
if (!containment->isUiReady() && containment->lastScreen() < q->numScreens()) {
|
||||
++containmentsStarting;
|
||||
QObject::connect(containment, &Plasma::Containment::uiReadyChanged, [=](bool ready) {
|
||||
if (!ready)
|
||||
if (!ready) {
|
||||
return;
|
||||
}
|
||||
|
||||
--containmentsStarting;
|
||||
if (containmentsStarting <= 0) {
|
||||
|
@ -357,9 +357,10 @@ void AppletPrivate::scheduleConstraintsUpdate(Plasma::Types::Constraints c)
|
||||
|
||||
if (c & Plasma::Types::StartupCompletedConstraint) {
|
||||
started = true;
|
||||
if (q->isContainment())
|
||||
if (q->isContainment()) {
|
||||
qobject_cast<Containment*>(q)->d->setStarted();
|
||||
}
|
||||
}
|
||||
|
||||
pendingConstraints |= c;
|
||||
}
|
||||
|
@ -47,7 +47,8 @@ ContainmentPrivate::ContainmentPrivate(Containment *c):
|
||||
location(Types::Floating),
|
||||
lastScreen(-1), // never had a screen
|
||||
type(Plasma::Types::NoContainmentType),
|
||||
uiReady(false)
|
||||
uiReady(false),
|
||||
appletsUiReady(false)
|
||||
{
|
||||
//if the parent is an applet (i.e we are the systray)
|
||||
//we want to follow screen changed signals from the parent's containment
|
||||
@ -210,7 +211,6 @@ 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);
|
||||
@ -235,28 +235,30 @@ void ContainmentPrivate::setStarted()
|
||||
if (!q->Applet::d->started) {
|
||||
q->Applet::d->started = true;
|
||||
|
||||
if (uiReady)
|
||||
if (uiReady) {
|
||||
emit q->uiReadyChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ContainmentPrivate::setUiReady()
|
||||
{
|
||||
//if we are the containment and there is still some uncomplete applet, we're still incomplete
|
||||
if (!uiReady && loadingApplets.isEmpty()) {
|
||||
if (!uiReady) {
|
||||
uiReady = true;
|
||||
if (q->Applet::d->started)
|
||||
if (q->Applet::d->started && appletsUiReady && loadingApplets.isEmpty()) {
|
||||
emit q->uiReadyChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ContainmentPrivate::appletLoaded(Applet* applet)
|
||||
{
|
||||
loadingApplets.remove(q);
|
||||
loadingApplets.remove(applet);
|
||||
|
||||
if (loadingApplets.isEmpty() && !uiReady) {
|
||||
uiReady = true;
|
||||
if (q->Applet::d->started) {
|
||||
if (loadingApplets.isEmpty() && !appletsUiReady) {
|
||||
appletsUiReady = true;
|
||||
if (q->Applet::d->started && uiReady) {
|
||||
emit q->uiReadyChanged(true);
|
||||
}
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ public:
|
||||
QString activityId;
|
||||
Types::ContainmentType type;
|
||||
bool uiReady : 1;
|
||||
bool appletsUiReady : 1;
|
||||
|
||||
static const char defaultWallpaper[];
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user