#include <atomic>
#include <memory>
#include <tuple>
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/task_environment.h"
#include "components/cronet/native/test/test_request_finished_info_listener.h"
#include "components/cronet/native/test/test_upload_data_provider.h"
#include "components/cronet/native/test/test_url_request_callback.h"
#include "components/cronet/native/test/test_util.h"
#include "components/cronet/testing/test_server/test_server.h"
#include "cronet_c.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
TestRequestFinishedInfoListener;
TestUploadDataProvider;
TestUrlRequestCallback;
HasSubstr;
namespace {
class StatusListener { … };
Cronet_UrlRequestStatusListener_Status GetRequestStatus(
Cronet_UrlRequestPtr request,
TestUrlRequestCallback* callback) { … }
enum class RequestFinishedListenerType { … };
int64_t DateToMillis(Cronet_DateTimePtr date_time) { … }
constexpr int64_t kDateOverrunThreshold = …;
void VerifyRequestMetrics(Cronet_MetricsPtr metrics) { … }
Cronet_RequestFinishedInfo_FINISHED_REASON MapFinishedReason(
TestUrlRequestCallback::ResponseStep response_step) { … }
void VerifyRequestFinishedInfoListener(
TestRequestFinishedInfoListener* test_request_finished_info_listener,
const TestUrlRequestCallback& callback) { … }
class UrlRequestTest : public ::testing::TestWithParam<
std::tuple<bool, RequestFinishedListenerType>> { … };
const bool kDirectExecutorEnabled[]{ … };
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(UrlRequestTest, InitChecks) { … }
TEST_P(UrlRequestTest, SimpleGet) { … }
TEST_P(UrlRequestTest, UploadEmptyBodySync) { … }
TEST_P(UrlRequestTest, UploadSync) { … }
TEST_P(UrlRequestTest, SSLCertificateError) { … }
TEST_P(UrlRequestTest, SSLUpload) { … }
TEST_P(UrlRequestTest, UploadMultiplePiecesSync) { … }
TEST_P(UrlRequestTest, UploadMultiplePiecesAsync) { … }
TEST_P(UrlRequestTest, UploadChangesDefaultMethod) { … }
TEST_P(UrlRequestTest, UploadWithSetMethod) { … }
TEST_P(UrlRequestTest, UploadWithBigRead) { … }
TEST_P(UrlRequestTest, UploadWithDirectExecutor) { … }
TEST_P(UrlRequestTest, UploadRedirectSync) { … }
TEST_P(UrlRequestTest, UploadRedirectAsync) { … }
TEST_P(UrlRequestTest, UploadWithBadLength) { … }
TEST_P(UrlRequestTest, UploadWithBadLengthBufferAligned) { … }
TEST_P(UrlRequestTest, UploadReadFailSync) { … }
TEST_P(UrlRequestTest, UploadReadFailAsync) { … }
TEST_P(UrlRequestTest, UploadRewindFailSync) { … }
TEST_P(UrlRequestTest, UploadRewindFailAsync) { … }
TEST_P(UrlRequestTest, UploadChunked) { … }
TEST_P(UrlRequestTest, UploadChunkedLastReadZeroLengthBody) { … }
TEST_P(UrlRequestTest, UploadFailsWithoutInitializingStream) { … }
TEST_P(UrlRequestTest, DISABLED_UploadCancelReadSync) { … }
TEST_P(UrlRequestTest, UploadCancelReadAsync) { … }
TEST_P(UrlRequestTest, DISABLED_UploadCancelRewindSync) { … }
TEST_P(UrlRequestTest, UploadCancelRewindAsync) { … }
TEST_P(UrlRequestTest, SimpleRequest) { … }
TEST_P(UrlRequestTest, ReceiveBackAnnotations) { … }
TEST_P(UrlRequestTest, UrlParamsAnnotationsUnchanged) { … }
TEST_P(UrlRequestTest, MultiRedirect) { … }
TEST_P(UrlRequestTest, CancelRequest) { … }
TEST_P(UrlRequestTest, FailedRequestHostNotFound) { … }
void UrlRequestTest::TestCancel(
TestUrlRequestCallback::FailureType failure_type,
TestUrlRequestCallback::ResponseStep failure_step,
bool expect_response_info,
bool expect_error) { … }
TEST_P(UrlRequestTest, TestCancel) { … }
TEST_P(UrlRequestTest, PerfTest) { … }
TEST_P(UrlRequestTest, GetStatus) { … }
class UrlRequestTestNoParam : public ::testing::Test { … };
TEST_F(UrlRequestTestNoParam,
RequestFinishedListenerWithoutExecutorReturnsError) { … }
TEST_F(UrlRequestTestNoParam,
UseRequestFinishedInfoAfterUrlRequestDestructionSuccess) { … }
TEST_F(UrlRequestTestNoParam,
UseRequestFinishedInfoAfterUrlRequestDestructionFailure) { … }
TEST_F(UrlRequestTestNoParam,
CorrelateCallbackAndRequestInfoWithoutSynchronization) { … }
}