summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJamey Hicks <jamey.hicks@nokia.com>2012-06-05 15:44:38 -0400
committerQt by Nokia <qt-info@nokia.com>2012-06-06 15:16:10 +0200
commit1eba2be34bbf26abd47cc3c4f96a44d1e6c3bc0b (patch)
tree80c4b4aa473e045cfe000deab5b4f67105d027ea /tests
parent3a02079d781ac63cfb25dccf57a2781223b5d423 (diff)
Update all the eager views that depend on a source object change
This previous change to this part of the code was to prevent a given object change from being processed multiple times. However, I put the break in the wrong level of the loop, so only the first eager view depending on that source type would be updated, and others would just be marked as updated without being processed. Fixes Bug #16440. Change-Id: I1634a249e4ec6923100950fc5f45e449588b01d2 Reviewed-by: Jing Bai <jing.t.bai@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/partition/json/multi-map.json28
-rw-r--r--tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp73
2 files changed, 101 insertions, 0 deletions
diff --git a/tests/auto/partition/json/multi-map.json b/tests/auto/partition/json/multi-map.json
new file mode 100644
index 00000000..d9de7337
--- /dev/null
+++ b/tests/auto/partition/json/multi-map.json
@@ -0,0 +1,28 @@
+[
+ {
+ "_type": "_schemaType",
+ "name": "MultiMapView1",
+ "schema": {
+ "type": "object",
+ "extends": {"$ref": "View"}
+ }
+ },
+ {
+ "_type": "_schemaType",
+ "name": "MultiMapView2",
+ "schema": {
+ "type": "object",
+ "extends": {"$ref": "View"}
+ }
+ },
+ {
+ "_type": "Map",
+ "targetType": "MultiMapView1",
+ "map": {"MultiMapSourceType": "function (o) { jsondb.emit({key: o }); }"}
+ },
+ {
+ "_type": "Map",
+ "targetType": "MultiMapView2",
+ "map": {"MultiMapSourceType": "function (o) { jsondb.emit({key: o }); }"}
+ }
+]
diff --git a/tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp b/tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp
index bfe6faae..66ff74a4 100644
--- a/tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp
+++ b/tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp
@@ -89,6 +89,7 @@ private slots:
void currentState();
void notificationTriggersView();
void notificationTriggersMapReduce();
+ void notificationTriggersMultiViews();
void typeChangeEagerViewSource();
void invalid();
void privatePartition();
@@ -692,6 +693,78 @@ void TestQJsonDbWatcher::notificationTriggersMapReduce()
QVERIFY(waitForResponse(&remove));
}
+void TestQJsonDbWatcher::notificationTriggersMultiViews()
+{
+ QVERIFY(mConnection);
+
+ QLatin1String query1("[?_type=\"MultiMapView1\"]");
+ QLatin1String query2("[?_type=\"MultiMapView2\"]");
+ QJsonArray array(readJsonFile(":/partition/json/multi-map.json").array());
+
+ QList<QJsonObject> objects;
+ foreach (const QJsonValue v, array)
+ objects.append(v.toObject());
+
+ // create the objects
+ QJsonDbCreateRequest request(objects);
+ mConnection->send(&request);
+ QVERIFY(waitForResponse(&request));
+ QList<QJsonObject> toDelete;
+ foreach (const QJsonObject result, request.takeResults())
+ toDelete.prepend(result);
+
+ {
+ QJsonDbReadRequest read(query1);
+ mConnection->send(&read);
+ QVERIFY(waitForResponse(&read));
+ QList<QJsonObject> objects = read.takeResults();
+ int numObjects = objects.size();
+ QCOMPARE(numObjects, 0);
+ }
+
+ // create two watchers
+ QJsonDbWatcher watcher1;
+ watcher1.setWatchedActions(QJsonDbWatcher::All);
+ watcher1.setQuery(QLatin1String(query1));
+ mConnection->addWatcher(&watcher1);
+ QVERIFY(waitForStatus(&watcher1, QJsonDbWatcher::Active));
+
+ QJsonDbWatcher watcher2;
+ watcher2.setWatchedActions(QJsonDbWatcher::All);
+ watcher2.setQuery(QLatin1String(query2));
+ mConnection->addWatcher(&watcher2);
+ QVERIFY(waitForStatus(&watcher2, QJsonDbWatcher::Active));
+
+ {
+ QJsonObject item;
+ item.insert(JsonDbStrings::Property::type(), QLatin1String("MultiMapSourceType"));
+ QJsonDbCreateRequest request(item);
+ mConnection->send(&request);
+ QVERIFY(waitForResponseAndNotifications(&request, &watcher1, 1));
+
+ QList<QJsonDbNotification> notifications = watcher1.takeNotifications();
+ QCOMPARE(notifications.size(), 1);
+ QJsonDbNotification n = notifications[0];
+ QJsonObject o = n.object();
+ // make sure we got notified on the right object
+ //QCOMPARE(o.value(JsonDbStrings::Property::uuid()), info.value(JsonDbStrings::Property::uuid()));
+
+ // make sure watcher2 got one also
+ notifications = watcher2.takeNotifications();
+ QCOMPARE(notifications.size(), 1);
+
+ }
+ mConnection->removeWatcher(&watcher1);
+ mConnection->removeWatcher(&watcher2);
+
+ foreach (const QJsonObject &object, request.takeResults())
+ toDelete.prepend(object);
+
+ QJsonDbRemoveRequest remove(toDelete);
+ mConnection->send(&remove);
+ QVERIFY(waitForResponse(&remove));
+}
+
void TestQJsonDbWatcher::typeChangeEagerViewSource()
{
QVERIFY(mConnection);