Commit b4cbde566b0a22ad31893e3edd70e79d2085747a
1 parent
d6b93ef5
Convert test_packet_bigger_than_one_doubling to native test client
And make it test cross-protocol.
Showing
1 changed file
with
24 additions
and
12 deletions
FlashMQTests/tst_maintests.cpp
| ... | ... | @@ -542,23 +542,35 @@ void MainTests::test_retained_tree() |
| 542 | 542 | |
| 543 | 543 | void MainTests::test_packet_bigger_than_one_doubling() |
| 544 | 544 | { |
| 545 | - TwoClientTestContext testContext; | |
| 545 | + std::vector<ProtocolVersion> protocols {ProtocolVersion::Mqtt311, ProtocolVersion::Mqtt5}; | |
| 546 | 546 | |
| 547 | - QByteArray payload(8000, 3); | |
| 548 | - QString topic = "hugepacket"; | |
| 547 | + for (const ProtocolVersion senderVersion : protocols) | |
| 548 | + { | |
| 549 | + for (const ProtocolVersion receiverVersion : protocols) | |
| 550 | + { | |
| 551 | + FlashMQTestClient sender; | |
| 552 | + FlashMQTestClient receiver; | |
| 549 | 553 | |
| 550 | - testContext.connectSender(); | |
| 551 | - testContext.connectReceiver(); | |
| 552 | - testContext.subscribeReceiver(topic); | |
| 554 | + std::string payload(8000, 3); | |
| 555 | + std::string topic = "hugepacket"; | |
| 553 | 556 | |
| 554 | - testContext.publish(topic, payload); | |
| 555 | - testContext.waitReceiverReceived(1); | |
| 557 | + sender.start(); | |
| 558 | + sender.connectClient(senderVersion); | |
| 556 | 559 | |
| 557 | - QCOMPARE(testContext.receivedMessages.count(), 1); | |
| 560 | + receiver.start(); | |
| 561 | + receiver.connectClient(receiverVersion); | |
| 562 | + receiver.subscribe(topic, 0); | |
| 558 | 563 | |
| 559 | - QMQTT::Message msg = testContext.receivedMessages.first(); | |
| 560 | - QCOMPARE(msg.payload(), payload); | |
| 561 | - QVERIFY(!msg.retain()); | |
| 564 | + sender.publish(topic, payload, 0); | |
| 565 | + receiver.waitForMessageCount(1); | |
| 566 | + | |
| 567 | + MYCASTCOMPARE(receiver.receivedPublishes.size(), 1); | |
| 568 | + | |
| 569 | + MqttPacket &msg = receiver.receivedPublishes.front(); | |
| 570 | + QCOMPARE(msg.getPayloadCopy(), payload); | |
| 571 | + QVERIFY(!msg.getRetain()); | |
| 572 | + } | |
| 573 | + } | |
| 562 | 574 | } |
| 563 | 575 | |
| 564 | 576 | // This tests our write buffer, and that it's emptied during writing already. | ... | ... |