Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,35 @@ static void testCppQueryExecution(QueryHandler* handler,
QCOMPARE(exec->canFetchMore(), false);
}

static void testCppQueryExecutionFetchMoreOnResultsInserted(QueryHandler* handler,
vector<vector<int>> expected,
const char* query = "")
{
auto ctx = MockQueryContext(handler, "", query);
auto exec = handler->execution(ctx);

QObject::connect(&exec->results, &QueryResults::resultsInserted, exec.get(), [exec=exec.get()]{
exec->fetchMore();
});

uint expected_item_count = 0;
for (const auto &batch : expected)
expected_item_count += batch.size();

exec->fetchMore();

QTRY_COMPARE(exec->results.count(), expected_item_count);
QTRY_COMPARE(exec->canFetchMore(), false);

uint item_count = 0;
for (const auto &batch : expected)
{
for (size_t i = 0; i < batch.size(); ++i)
test_test_item(exec->results[item_count + i].item.get(), batch[i]);
item_count += batch.size();
}
}

static void testCppItemGenerator(GeneratorQueryHandler* handler,
vector<vector<int>> expected,
const char* query = "")
Expand Down Expand Up @@ -990,6 +1019,7 @@ class Handler(GeneratorQueryHandler):
testCppExtensionApi(cpp_inst);
testCppQueryHandlerApi(cpp_inst);
testCppQueryExecution(cpp_inst, {{1}, {1, 2}, {1, 2, 3}});
testCppQueryExecutionFetchMoreOnResultsInserted(cpp_inst, {{1}, {1, 2}, {1, 2, 3}});
testCppItemGenerator(cpp_inst, {{1}, {1, 2}, {1, 2, 3}});
}

Expand Down