Changeset View
Changeset View
Standalone View
Standalone View
autotests/libs/itemstoretest.cpp
Show First 20 Lines • Show All 376 Lines • ▼ Show 20 Line(s) | 367 | { | |||
---|---|---|---|---|---|
377 | // item don't overwrite the remote id. | 377 | // item don't overwrite the remote id. | ||
378 | Item item2(job->item().id()); | 378 | Item item2(job->item().id()); | ||
379 | ItemFetchJob *fetchJob = new ItemFetchJob(item2); | 379 | ItemFetchJob *fetchJob = new ItemFetchJob(item2); | ||
380 | AKVERIFYEXEC(fetchJob); | 380 | AKVERIFYEXEC(fetchJob); | ||
381 | QCOMPARE(fetchJob->items().size(), 1); | 381 | QCOMPARE(fetchJob->items().size(), 1); | ||
382 | QVERIFY(fetchJob->items().first().remoteId().isEmpty()); | 382 | QVERIFY(fetchJob->items().first().remoteId().isEmpty()); | ||
383 | } | 383 | } | ||
384 | 384 | | |||
385 | void ItemStoreTest::itemModifyJobShouldOnlySendModifiedAttributes() | ||||
386 | { | ||||
387 | // Given an item with an attribute (created on the server) | ||||
388 | Item item; | ||||
389 | item.setMimeType(QStringLiteral("text/directory")); | ||||
390 | item.attribute<TestAttribute>(Item::AddIfMissing)->data = "initial"; | ||||
391 | ItemCreateJob *job = new ItemCreateJob(item, res1_foo); | ||||
392 | AKVERIFYEXEC(job); | ||||
393 | item = job->item(); | ||||
394 | QCOMPARE(item.attributes().count(), 1); | ||||
395 | | ||||
396 | // When one job modifies this attribute, and another one does an unrelated change | ||||
397 | Item item1(item.id()); | ||||
398 | item1.attribute<TestAttribute>(Item::AddIfMissing)->data = "modified"; | ||||
399 | ItemModifyJob *mjob = new ItemModifyJob(item1); | ||||
400 | mjob->disableRevisionCheck(); | ||||
401 | AKVERIFYEXEC(mjob); | ||||
402 | | ||||
403 | item.setFlag("added_test_flag_1"); | ||||
404 | // this job shouldn't send the old attribute again | ||||
405 | ItemModifyJob *mjob2 = new ItemModifyJob(item); | ||||
406 | mjob2->disableRevisionCheck(); | ||||
407 | AKVERIFYEXEC(mjob2); | ||||
408 | | ||||
409 | // Then the item has the new value for the attribute (the other one didn't send the old attribute value) | ||||
410 | { | ||||
411 | auto *fetchJob = new ItemFetchJob(Item(item.id())); | ||||
412 | ItemFetchScope fetchScope; | ||||
413 | fetchScope.fetchAllAttributes(true); | ||||
414 | fetchJob->setFetchScope(fetchScope); | ||||
415 | AKVERIFYEXEC(fetchJob); | ||||
416 | QCOMPARE(fetchJob->items().size(), 1); | ||||
417 | const Item fetchedItem = fetchJob->items().first(); | ||||
418 | QCOMPARE(fetchedItem.flags().count(), 1); | ||||
419 | QCOMPARE(fetchedItem.attributes().count(), 1); | ||||
420 | QCOMPARE(fetchedItem.attribute<TestAttribute>()->data, "modified"); | ||||
421 | } | ||||
422 | } |