#include "chrome/updater/net/network.h"
#include <cstdint>
#include <memory>
#include <string>
#include "base/base_paths.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/memory/scoped_refptr.h"
#include "base/notreached.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/task_environment.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "chrome/updater/net/network.h"
#include "chrome/updater/policy/service.h"
#include "chrome/updater/test/unit_test_util.h"
#include "components/update_client/network.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_WIN)
#include <Urlmon.h>
#endif
namespace updater {
namespace {
RunClosure;
ResponseStartedCallback;
ProgressCallback;
PostRequestCompleteCallback;
DownloadToFileCompleteCallback;
class UpdaterNetworkTest : public ::testing::Test { … };
class UpdaterDownloadTest : public ::testing::Test { … };
}
TEST_F(UpdaterNetworkTest, NetworkFetcherPostRequest) { … }
TEST_F(UpdaterNetworkTest, NetworkFetcherDownloadToFile) { … }
TEST_F(UpdaterDownloadTest, NetworkFetcher) { … }
#if BUILDFLAG(IS_WIN)
TEST_F(UpdaterDownloadTest, URLMonFetcher) {
EXPECT_FALSE(base::PathExists(dest_));
EXPECT_HRESULT_SUCCEEDED(
::URLDownloadToFile(nullptr, base::ASCIIToWide(gurl_.spec()).c_str(),
dest_.value().c_str(), 0, nullptr));
EXPECT_TRUE(base::PathExists(dest_));
}
#endif
}