diff options
Diffstat (limited to 'tests/http-gtest-async.cpp')
-rwxr-xr-x | tests/http-gtest-async.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/http-gtest-async.cpp b/tests/http-gtest-async.cpp index 7a22374..3f0a613 100755 --- a/tests/http-gtest-async.cpp +++ b/tests/http-gtest-async.cpp @@ -37,6 +37,7 @@ static bool _completed_flag; static bool _canceled_flag; static bool _paused_flag; static bool _resumed_flag; +static http_error_code_e _error_code; static void _completed_cb(http_transaction_h http_transaction, void *user_data); static void _aborted_cb(http_transaction_h http_transaction, @@ -57,6 +58,7 @@ class HttpAsyncTest: public ::testing::Test { _canceled_flag = false; _paused_flag = false; _resumed_flag = false; + _error_code = HTTP_ERROR_NONE; http_init(); http_session_create(HTTP_SESSION_MODE_NORMAL, &session); @@ -88,6 +90,7 @@ static void _aborted_cb(http_transaction_h http_transaction, http_error_code_e error, void *user_data) { _completed_flag = false; + _error_code = error; if (error == HTTP_ERROR_CANCELED) _canceled_flag = true; HttpTestUtil::stopMainLoop(); @@ -120,7 +123,7 @@ static void _progress_resume_cb(http_transaction_h http_transaction, _resumed_flag = true; } -TEST_F(HttpAsyncTest, SubmitN) +TEST_F(HttpAsyncTest, SubmitN1) { http_transaction_request_set_uri(transaction, "https://untrusted-root.badssl.com"); EXPECT_EQ(HTTP_ERROR_NONE, http_transaction_submit(transaction)); @@ -128,6 +131,32 @@ TEST_F(HttpAsyncTest, SubmitN) HttpTestUtil::runMainLoop(); EXPECT_EQ(false, _completed_flag); +#if !defined USE_LOCALHOST_SERVER + EXPECT_EQ(HTTP_ERROR_SSL_CONNECT_ERROR, _error_code); +#endif +} + +TEST_F(HttpAsyncTest, SubmitN2) +{ + http_transaction_request_set_uri(transaction, "123qw12qw123"); + EXPECT_EQ(HTTP_ERROR_NONE, http_transaction_submit(transaction)); + + HttpTestUtil::runMainLoop(); + + EXPECT_EQ(false, _completed_flag); + EXPECT_EQ(HTTP_ERROR_COULDNT_RESOLVE_HOST, _error_code); +} + +TEST_F(HttpAsyncTest, SubmitN3) +{ + http_transaction_set_timeout(transaction, 2); + http_transaction_request_set_uri(transaction, "192.168.0.248"); + EXPECT_EQ(HTTP_ERROR_NONE, http_transaction_submit(transaction)); + + HttpTestUtil::runMainLoop(); + + EXPECT_EQ(false, _completed_flag); + EXPECT_EQ(HTTP_ERROR_OPERATION_TIMEDOUT, _error_code); } TEST_F(HttpAsyncTest, SubmitP) @@ -147,6 +176,7 @@ TEST_F(HttpAsyncTest, CancelP) HttpTestUtil::runMainLoop(); EXPECT_EQ(true, _canceled_flag); + EXPECT_EQ(HTTP_ERROR_CANCELED, _error_code); } TEST_F(HttpAsyncTest, PauseP) |