summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <[email protected]>2016-10-20 19:50:37 +0200
committerAleix Pol <[email protected]>2016-10-24 16:13:36 +0200
commit6a089bbd0f9867265498a261a2052edb59861813 (patch)
treeccaab15b81ee0127808c586fe096e18e2d5ed929
parent0f44967ccc5e846115eca37c3b80d56b2bf01d34 (diff)
Let dummy backend resources have different sizes
-rw-r--r--libdiscover/backends/DummyBackend/DummyBackend.cpp2
-rw-r--r--libdiscover/backends/DummyBackend/DummyResource.cpp2
-rw-r--r--libdiscover/backends/DummyBackend/DummyResource.h2
-rw-r--r--libdiscover/backends/DummyBackend/tests/UpdateDummyTest.cpp1
4 files changed, 5 insertions, 2 deletions
diff --git a/libdiscover/backends/DummyBackend/DummyBackend.cpp b/libdiscover/backends/DummyBackend/DummyBackend.cpp
index a2c4a9d..9290d33 100644
--- a/libdiscover/backends/DummyBackend/DummyBackend.cpp
+++ b/libdiscover/backends/DummyBackend/DummyBackend.cpp
@@ -96,6 +96,7 @@ void DummyBackend::populate(const QString& n)
for(int i=start; i<start+m_startElements; i++) {
const QString name = n+QLatin1Char(' ')+QString::number(i);
DummyResource* res = new DummyResource(name, false, this);
+ res->setSize(100+(m_startElements-i));
res->setState(AbstractResource::State(1+(i%3)));
m_resources.insert(name, res);
connect(res, &DummyResource::stateChanged, this, &DummyBackend::updatesCountChanged);
@@ -105,6 +106,7 @@ void DummyBackend::populate(const QString& n)
const QString name = QStringLiteral("techie")+QString::number(i);
DummyResource* res = new DummyResource(name, true, this);
res->setState(AbstractResource::State(1+(i%3)));
+ res->setSize(300+(m_startElements-i));
m_resources.insert(name, res);
connect(res, &DummyResource::stateChanged, this, &DummyBackend::updatesCountChanged);
}
diff --git a/libdiscover/backends/DummyBackend/DummyResource.cpp b/libdiscover/backends/DummyBackend/DummyResource.cpp
index 80ffca8..42ace11 100644
--- a/libdiscover/backends/DummyBackend/DummyResource.cpp
+++ b/libdiscover/backends/DummyBackend/DummyResource.cpp
@@ -68,7 +68,7 @@ QString DummyResource::comment()
int DummyResource::size()
{
- return 123;
+ return m_size;
}
QUrl DummyResource::homepage()
diff --git a/libdiscover/backends/DummyBackend/DummyResource.h b/libdiscover/backends/DummyBackend/DummyResource.h
index 8010652..0e78056 100644
--- a/libdiscover/backends/DummyBackend/DummyResource.h
+++ b/libdiscover/backends/DummyBackend/DummyResource.h
@@ -53,6 +53,7 @@ public:
void fetchChangelog() override;
void fetchScreenshots() override;
void setState(State state);
+ void setSize(int size) { m_size = size; }
void setAddons(const AddonList& addons);
void setAddonInstalled(const QString& addon, bool installed);
@@ -65,6 +66,7 @@ public:
QString m_iconName;
QList<PackageState> m_addons;
bool m_isTechnical;
+ int m_size;
};
#endif // DUMMYRESOURCE_H
diff --git a/libdiscover/backends/DummyBackend/tests/UpdateDummyTest.cpp b/libdiscover/backends/DummyBackend/tests/UpdateDummyTest.cpp
index 112f36a..41d542e 100644
--- a/libdiscover/backends/DummyBackend/tests/UpdateDummyTest.cpp
+++ b/libdiscover/backends/DummyBackend/tests/UpdateDummyTest.cpp
@@ -87,7 +87,6 @@ private Q_SLOTS:
AbstractResource* res = qobject_cast<AbstractResource*>(resourceIdx.data(UpdateModel::ResourceRole).value<QObject*>());
QVERIFY(res);
- QCOMPARE(resourceIdx.data(UpdateModel::SizeRole).toString(), QStringLiteral("123 B"));
QCOMPARE(Qt::CheckState(resourceIdx.data(Qt::CheckStateRole).toInt()), Qt::Checked);
QVERIFY(m->setData(resourceIdx, int(Qt::Unchecked), Qt::CheckStateRole));