#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/update_client/update_checker.h"
#include <initializer_list>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/check_deref.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "base/values.h"
#include "base/version.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "components/prefs/testing_pref_service.h"
#include "components/update_client/activity_data_service.h"
#include "components/update_client/component.h"
#include "components/update_client/net/url_loader_post_interceptor.h"
#include "components/update_client/persisted_data.h"
#include "components/update_client/test_activity_data_service.h"
#include "components/update_client/test_configurator.h"
#include "components/update_client/test_utils.h"
#include "components/update_client/update_engine.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace update_client {
namespace {
constexpr char kUpdateItemId[] = …;
}
class UpdateCheckerTest : public testing::TestWithParam<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
UpdateCheckerTest::UpdateCheckerTest()
: … { … }
UpdateCheckerTest::~UpdateCheckerTest() = default;
void UpdateCheckerTest::SetUp() { … }
void UpdateCheckerTest::TearDown() { … }
void UpdateCheckerTest::RunThreads() { … }
void UpdateCheckerTest::Quit() { … }
void UpdateCheckerTest::UpdateCheckComplete(
const std::optional<ProtocolParser::Results>& results,
ErrorCategory error_category,
int error,
int retry_after_sec) { … }
scoped_refptr<UpdateContext> UpdateCheckerTest::MakeMockUpdateContext() const { … }
std::unique_ptr<Component> UpdateCheckerTest::MakeComponent() const { … }
std::unique_ptr<Component> UpdateCheckerTest::MakeComponent(
const std::string& brand) const { … }
std::unique_ptr<Component> UpdateCheckerTest::MakeComponent(
const std::string& brand,
const std::string& install_data_index,
bool allow_updates_on_metered_connection) const { … }
std::optional<base::Value::Dict> UpdateCheckerTest::ParseRequest(
int request_number) { … }
base::Value UpdateCheckerTest::GetFirstAppAsValue(
const base::Value::Dict& request) { … }
base::Value::Dict UpdateCheckerTest::GetFirstAppAsDict(
const base::Value::Dict& request) { … }
TEST_P(UpdateCheckerTest, UpdateCheckSuccess) { … }
TEST_P(UpdateCheckerTest, UpdateCheckInvalidAp) { … }
TEST_P(UpdateCheckerTest, UpdateCheckSuccessNoBrand) { … }
TEST_P(UpdateCheckerTest, UpdateCheckFallback) { … }
TEST_P(UpdateCheckerTest, UpdateCheckError) { … }
TEST_P(UpdateCheckerTest, UpdateCheckDownloadPreference) { … }
TEST_P(UpdateCheckerTest, UpdateCheckCupError) { … }
TEST_P(UpdateCheckerTest, UpdateCheckRequiresEncryptionError) { … }
TEST_P(UpdateCheckerTest, UpdateCheckLastRollCall) { … }
TEST_P(UpdateCheckerTest, UpdateCheckLastActive) { … }
TEST_P(UpdateCheckerTest, UpdateCheckInstallSource) { … }
TEST_P(UpdateCheckerTest, ComponentDisabled) { … }
TEST_P(UpdateCheckerTest, UpdateCheckUpdateDisabled) { … }
TEST_P(UpdateCheckerTest, UpdateDisabledByMeteredConnection) { … }
TEST_P(UpdateCheckerTest, SameVersionUpdateAllowed) { … }
TEST_P(UpdateCheckerTest, NoUpdateActionRun) { … }
TEST_P(UpdateCheckerTest, UpdatePauseResume) { … }
TEST_P(UpdateCheckerTest, UpdateResetUpdateChecker) { … }
TEST_P(UpdateCheckerTest, ParseErrorProtocolVersionMismatch) { … }
TEST_P(UpdateCheckerTest, ParseErrorAppStatusErrorUnknownApplication) { … }
TEST_P(UpdateCheckerTest, DomainJoined) { … }
}