#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "base/barrier_closure.h"
#include "base/check_deref.h"
#include "base/containers/flat_map.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/notreached.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/test/bind.h"
#include "base/test/scoped_path_override.h"
#include "base/test/task_environment.h"
#include "base/values.h"
#include "base/version.h"
#include "build/build_config.h"
#include "components/crx_file/crx_verifier.h"
#include "components/prefs/testing_pref_service.h"
#include "components/services/unzip/in_process_unzipper.h"
#include "components/update_client/activity_data_service.h"
#include "components/update_client/crx_downloader_factory.h"
#include "components/update_client/crx_update_item.h"
#include "components/update_client/network.h"
#include "components/update_client/patcher.h"
#include "components/update_client/persisted_data.h"
#include "components/update_client/ping_manager.h"
#include "components/update_client/protocol_definition.h"
#include "components/update_client/protocol_handler.h"
#include "components/update_client/test_configurator.h"
#include "components/update_client/test_installer.h"
#include "components/update_client/test_utils.h"
#include "components/update_client/unpacker.h"
#include "components/update_client/unzip/unzip_impl.h"
#include "components/update_client/unzipper.h"
#include "components/update_client/update_checker.h"
#include "components/update_client/update_client_errors.h"
#include "components/update_client/update_client_internal.h"
#include "components/update_client/update_engine.h"
#include "components/update_client/utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace update_client {
namespace {
template <typename Mock>
auto MakeMockCallback() { … }
template <typename MockUpdateChecker>
class MockUpdateCheckerFactory { … };
bool MakeTestFile(const base::FilePath& from_path, base::FilePath* to_path) { … }
Events;
class MockObserver : public UpdateClient::Observer { … };
class MockActionHandler : public ActionHandler { … };
class MockCrxStateChangeReceiver
: public base::RefCountedThreadSafe<MockCrxStateChangeReceiver> { … };
class MockCrxDownloaderFactory : public CrxDownloaderFactory { … };
}
_;
AnyNumber;
AtLeast;
DoAll;
InSequence;
Invoke;
Mock;
Return;
Unused;
class MockPingManagerImpl : public PingManager { … };
MockPingManagerImpl::MockPingManagerImpl(scoped_refptr<Configurator> config)
: … { … }
MockPingManagerImpl::~MockPingManagerImpl() = default;
void MockPingManagerImpl::SendPing(const Component& component,
const PersistedData& metadata,
Callback callback) { … }
const std::vector<MockPingManagerImpl::PingData>&
MockPingManagerImpl::ping_data() const { … }
const std::vector<base::Value::Dict>& MockPingManagerImpl::events() const { … }
class UpdateClientTest : public testing::Test { … };
UpdateClientTest::UpdateClientTest() { … }
void UpdateClientTest::RunThreads() { … }
TEST_F(UpdateClientTest, OneCrxNoUpdate) { … }
TEST_F(UpdateClientTest, TwoCrxUpdateNoUpdate) { … }
TEST_F(UpdateClientTest, TwoCrxUpdateFirstServerIgnoresSecond) { … }
TEST_F(UpdateClientTest, TwoCrxUpdateNoCrxComponentData) { … }
TEST_F(UpdateClientTest, TwoCrxUpdateNoCrxComponentDataAtAll) { … }
TEST_F(UpdateClientTest, TwoCrxUpdateDownloadTimeout) { … }
TEST_F(UpdateClientTest, OneCrxDiffUpdate) { … }
TEST_F(UpdateClientTest, OneCrxInstallError) { … }
TEST_F(UpdateClientTest, OneCrxDiffUpdateFailsFullUpdateSucceeds) { … }
TEST_F(UpdateClientTest,
OneCrxDiffDownloadSkippedMissingCachedCrxFullUpdateSucceeds) { … }
TEST_F(UpdateClientTest, OneCrxNoUpdateQueuedCall) { … }
TEST_F(UpdateClientTest, OneCrxInstall) { … }
TEST_F(UpdateClientTest, OneCrxInstallNoCrxComponentData) { … }
TEST_F(UpdateClientTest, ConcurrentInstallSameCRX) { … }
TEST_F(UpdateClientTest, EmptyIdList) { … }
TEST_F(UpdateClientTest, DiskFull) { … }
TEST_F(UpdateClientTest, DiskFullDiff) { … }
struct SendPingTestCase { … };
class SendPingTest : public ::testing::WithParamInterface<SendPingTestCase>,
public UpdateClientTest { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(SendPingTest, TestCases) { … }
TEST_F(UpdateClientTest, RetryAfter) { … }
TEST_F(UpdateClientTest, TwoCrxUpdateOneUpdateDisabled) { … }
TEST_F(UpdateClientTest, OneCrxUpdateDownloadTimeout) { … }
TEST_F(UpdateClientTest, OneCrxUpdateCheckFails) { … }
TEST_F(UpdateClientTest, OneCrxErrorUnknownApp) { … }
TEST_F(UpdateClientTest, ActionRun_Install) { … }
TEST_F(UpdateClientTest, ActionRun_NoUpdate) { … }
TEST_F(UpdateClientTest, CustomAttributeNoUpdate) { … }
TEST_F(UpdateClientTest, BadCrxDataCallback) { … }
TEST_F(UpdateClientTest, CancelInstallBeforeTaskStart) { … }
TEST_F(UpdateClientTest, CancelInstallBeforeInstall) { … }
TEST_F(UpdateClientTest, CancelInstallBeforeDownload) { … }
TEST_F(UpdateClientTest, CheckForUpdate_NoUpdate) { … }
TEST_F(UpdateClientTest, CheckForUpdate_UpdateAvailable) { … }
TEST_F(UpdateClientTest, CheckForUpdate_QueueChecks) { … }
TEST_F(UpdateClientTest, CheckForUpdate_Stop) { … }
TEST_F(UpdateClientTest, CheckForUpdate_Errors) { … }
TEST_F(UpdateClientTest, UpdateCheck_UpdateDisabled) { … }
TEST_F(UpdateClientTest, OneCrxCachedUpdate) { … }
}