Browse Source

Update tests for abort

- Add check for explicit error call
Alexey Edelev 5 years ago
parent
commit
6eee72867c
1 changed files with 10 additions and 0 deletions
  1. 10 0
      tests/test_grpc/clienttest.cpp

+ 10 - 0
tests/test_grpc/clienttest.cpp

@@ -123,6 +123,7 @@ TEST_F(ClientTest, StringEchoAsyncAbortTest)
     request.setTestFieldString("sleep");
     QEventLoop waiter;
 
+    bool errorCalled = false;
     AsyncReply* reply = testClient.testMethod(request);
     result.setTestFieldString("Result not changed by echo");
     QObject::connect(reply, &AsyncReply::finished, &app, [reply, &result, &waiter, &testClient]() {
@@ -132,14 +133,19 @@ TEST_F(ClientTest, StringEchoAsyncAbortTest)
         waiter.quit();
     });
 
+    QObject::connect(reply, &AsyncReply::error, reply, [&errorCalled](AbstractChannel::StatusCodes){
+        errorCalled = true;
+    });
     QTimer::singleShot(5000, &waiter, &QEventLoop::quit);
     reply->abort();
 
     waiter.exec();
     ASSERT_STREQ(result.testFieldString().toStdString().c_str(), "Result not changed by echo");
     ASSERT_EQ(testClient.lastError(), AbstractChannel::StatusCodes::Aborted);
+    ASSERT_TRUE(errorCalled);
 
 
+    errorCalled = false;
     reply = testClient.testMethod(request);
     QObject::connect(reply, &AsyncReply::finished, &app, [reply, &result, &waiter, &testClient]() {
         if (testClient.lastError() == AbstractChannel::StatusCodes::Ok) {
@@ -147,6 +153,9 @@ TEST_F(ClientTest, StringEchoAsyncAbortTest)
         }
         waiter.quit();
     });
+    QObject::connect(reply, &AsyncReply::error, reply, [&errorCalled](AbstractChannel::StatusCodes){
+        errorCalled = true;
+    });
 
     QTimer::singleShot(2000, reply, &AsyncReply::abort);
     QTimer::singleShot(5000, &waiter, &QEventLoop::quit);
@@ -155,4 +164,5 @@ TEST_F(ClientTest, StringEchoAsyncAbortTest)
 
     ASSERT_STREQ(result.testFieldString().toStdString().c_str(), "Result not changed by echo");
     ASSERT_EQ(testClient.lastError(), AbstractChannel::StatusCodes::Aborted);
+    ASSERT_TRUE(errorCalled);
 }