Commit ace114c5 authored by Volker Krause's avatar Volker Krause
Browse files

Fix loading of provider data when changing the product identifier

parent ec25e5f2
......@@ -242,6 +242,38 @@ private slots:
QVERIFY(c3 == c1 + 2);
}
void testProductIdChange()
{
{
Provider p0;
}
int c1 = -1;
{
Provider p1;
auto s1 = new StartCountSource;
p1.addDataSource(s1, Provider::BasicUsageStatistics);
p1.setSurveyInterval(90);
const auto c0 = s1->data().toMap().value(QLatin1String("value")).toInt();
p1.setProductIdentifier(QStringLiteral("org.kde.some.other.test"));
p1.setSurveyInterval(-1);
p1.setSurveyInterval(1);
c1 = s1->data().toMap().value(QLatin1String("value")).toInt();
QVERIFY(c0 != c1);
}
{
Provider p2;
auto s2 = new StartCountSource;
p2.addDataSource(s2, Provider::BasicUsageStatistics);
p2.setProductIdentifier(QStringLiteral("org.kde.some.other.test"));
QCOMPARE(p2.surveyInterval(), 1);
const auto c2 = s2->data().toMap().value(QLatin1String("value")).toInt();
QCOMPARE(c1 + 1, c2);
}
}
};
QTEST_MAIN(ProviderTest)
......
......@@ -100,8 +100,8 @@ private slots:
// submit data
Provider provider;
provider.setStatisticsCollectionMode(Provider::DetailedUsageStatistics);
provider.setProductIdentifier(QStringLiteral("org.kde.UserFeedback.UnitTestProduct"));
provider.setStatisticsCollectionMode(Provider::DetailedUsageStatistics);
provider.setFeedbackServer(serverUrl);
provider.addDataSource(new ScreenInfoSource, Provider::DetailedUsageStatistics);
provider.addDataSource(new PlatformInfoSource, Provider::DetailedUsageStatistics);
......@@ -142,8 +142,8 @@ private slots:
// this must pass without ending in an infinite loop
Provider provider;
provider.setStatisticsCollectionMode(Provider::DetailedUsageStatistics);
provider.setProductIdentifier(QStringLiteral("org.kde.UserFeedback.UnitTestProduct"));
provider.setStatisticsCollectionMode(Provider::DetailedUsageStatistics);
provider.setFeedbackServer(serverUrl);
provider.addDataSource(new ScreenInfoSource, Provider::DetailedUsageStatistics);
provider.addDataSource(new PlatformInfoSource, Provider::DetailedUsageStatistics);
......
......@@ -70,13 +70,6 @@ ProviderPrivate::ProviderPrivate(Provider *qq)
, encouragementDelay(300)
, encouragementInterval(-1)
{
auto domain = QCoreApplication::organizationDomain().split(QLatin1Char('.'));
std::reverse(domain.begin(), domain.end());
productId = domain.join(QLatin1String("."));
if (!productId.isEmpty())
productId += QLatin1Char('.');
productId += QCoreApplication::applicationName();
submissionTimer.setSingleShot(true);
QObject::connect(&submissionTimer, SIGNAL(timeout()), q, SLOT(submit()));
......@@ -409,9 +402,13 @@ Provider::Provider(QObject *parent) :
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
d->load();
d->startCount++;
d->storeOne(QStringLiteral("ApplicationStartCount"), d->startCount);
auto domain = QCoreApplication::organizationDomain().split(QLatin1Char('.'));
std::reverse(domain.begin(), domain.end());
auto id = domain.join(QLatin1String("."));
if (!id.isEmpty())
id += QLatin1Char('.');
id += QCoreApplication::applicationName();
setProductIdentifier(id);
}
Provider::~Provider()
......@@ -430,6 +427,11 @@ void Provider::setProductIdentifier(const QString &productId)
if (productId == d->productId)
return;
d->productId = productId;
d->load();
d->startCount++;
d->storeOne(QStringLiteral("ApplicationStartCount"), d->startCount);
emit providerSettingsChanged();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment