#include "chrome/browser/safe_browsing/download_protection/download_feedback.h"
#include <memory>
#include <utility>
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/multipart_uploader.h"
#include "components/safe_browsing/core/common/proto/csd.pb.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/test/test_shared_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace safe_browsing {
namespace {
class FakeUploader : public MultipartUploadRequest { … };
FakeUploader::FakeUploader(
const GURL& base_url,
const std::string& metadata,
const base::FilePath& file_path,
uint64_t file_size,
Callback finish_callback,
const net::NetworkTrafficAnnotationTag& traffic_annotation)
: … { … }
class FakeUploaderFactory : public ConnectorUploadRequestFactory { … };
std::unique_ptr<ConnectorUploadRequest>
FakeUploaderFactory::CreateStringRequest(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const GURL& base_url,
const std::string& metadata,
const std::string& data,
const net::NetworkTrafficAnnotationTag& traffic_annotation,
ConnectorUploadRequest::Callback callback) { … }
std::unique_ptr<ConnectorUploadRequest> FakeUploaderFactory::CreateFileRequest(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const GURL& base_url,
const std::string& metadata,
BinaryUploadService::Result get_data_result,
const base::FilePath& file_path,
uint64_t file_size,
const net::NetworkTrafficAnnotationTag& traffic_annotation,
ConnectorUploadRequest::Callback callback) { … }
std::unique_ptr<ConnectorUploadRequest> FakeUploaderFactory::CreatePageRequest(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const GURL& base_url,
const std::string& metadata,
BinaryUploadService::Result get_data_result,
base::ReadOnlySharedMemoryRegion page_region,
const net::NetworkTrafficAnnotationTag& traffic_annotation,
ConnectorUploadRequest::Callback callback) { … }
}
class DownloadFeedbackTest : public testing::Test { … };
TEST_F(DownloadFeedbackTest, CompleteUpload) { … }
TEST_F(DownloadFeedbackTest, CancelUpload) { … }
}