Commit 227a4b3a3d531cca3e8b6bdf29a0ea4480e6a595

Authored by Wiebe Cazemier
1 parent b4cbde56

Merged test_very_big_packet and test_packet_bigger_than_one_doubling

And also made it test accross protocol versions.
FlashMQTests/tst_maintests.cpp
... ... @@ -84,8 +84,7 @@ private slots:
84 84 void test_retained_removed();
85 85 void test_retained_tree();
86 86  
87   - void test_packet_bigger_than_one_doubling();
88   - void test_very_big_packet();
  87 + void test_various_packet_sizes();
89 88  
90 89 void test_acl_tree();
91 90 void test_acl_tree2();
... ... @@ -540,61 +539,42 @@ void MainTests::test_retained_tree()
540 539  
541 540 }
542 541  
543   -void MainTests::test_packet_bigger_than_one_doubling()
  542 +void MainTests::test_various_packet_sizes()
544 543 {
545 544 std::vector<ProtocolVersion> protocols {ProtocolVersion::Mqtt311, ProtocolVersion::Mqtt5};
  545 + std::list<std::string> payloads {std::string(8000,3), std::string(10*1024*1024, 5)};
546 546  
547 547 for (const ProtocolVersion senderVersion : protocols)
548 548 {
549 549 for (const ProtocolVersion receiverVersion : protocols)
550 550 {
551   - FlashMQTestClient sender;
552   - FlashMQTestClient receiver;
  551 + for (const std::string &payload : payloads)
  552 + {
  553 + FlashMQTestClient sender;
  554 + FlashMQTestClient receiver;
553 555  
554   - std::string payload(8000, 3);
555   - std::string topic = "hugepacket";
  556 + std::string topic = "hugepacket";
556 557  
557   - sender.start();
558   - sender.connectClient(senderVersion);
  558 + sender.start();
  559 + sender.connectClient(senderVersion);
559 560  
560   - receiver.start();
561   - receiver.connectClient(receiverVersion);
562   - receiver.subscribe(topic, 0);
  561 + receiver.start();
  562 + receiver.connectClient(receiverVersion);
  563 + receiver.subscribe(topic, 0);
563 564  
564   - sender.publish(topic, payload, 0);
565   - receiver.waitForMessageCount(1);
  565 + sender.publish(topic, payload, 0);
  566 + receiver.waitForMessageCount(1, 2);
566 567  
567   - MYCASTCOMPARE(receiver.receivedPublishes.size(), 1);
  568 + MYCASTCOMPARE(receiver.receivedPublishes.size(), 1);
568 569  
569   - MqttPacket &msg = receiver.receivedPublishes.front();
570   - QCOMPARE(msg.getPayloadCopy(), payload);
571   - QVERIFY(!msg.getRetain());
  570 + MqttPacket &msg = receiver.receivedPublishes.front();
  571 + QCOMPARE(msg.getPayloadCopy(), payload);
  572 + QVERIFY(!msg.getRetain());
  573 + }
572 574 }
573 575 }
574 576 }
575 577  
576   -// This tests our write buffer, and that it's emptied during writing already.
577   -void MainTests::test_very_big_packet()
578   -{
579   - TwoClientTestContext testContext;
580   -
581   - QByteArray payload(10*1024*1024, 3);
582   - QString topic = "hugepacket";
583   -
584   - testContext.connectSender();
585   - testContext.connectReceiver();
586   - testContext.subscribeReceiver(topic);
587   -
588   - testContext.publish(topic, payload);
589   - testContext.waitReceiverReceived(1);
590   -
591   - QCOMPARE(testContext.receivedMessages.count(), 1);
592   -
593   - QMQTT::Message msg = testContext.receivedMessages.first();
594   - QCOMPARE(msg.payload(), payload);
595   - QVERIFY(!msg.retain());
596   -}
597   -
598 578 void MainTests::test_acl_tree()
599 579 {
600 580 AclTree aclTree;
... ...
flashmqtestclient.cpp
... ... @@ -166,6 +166,7 @@ void FlashMQTestClient::connectClient(ProtocolVersion protocolVersion, bool clea
166 166 this->client->writeMqttPacketAndBlameThisClient(connectPack);
167 167  
168 168 waitForConnack();
  169 + this->client->setAuthenticated(true);
169 170 }
170 171  
171 172 void FlashMQTestClient::subscribe(const std::string topic, char qos)
... ...