chromium/components/update_client/update_checker_unittest.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#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[] =;

}  // namespace

class UpdateCheckerTest : public testing::TestWithParam<bool> {};

// This test is parameterized for |is_foreground|.
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) {}

// This test is parameterized for |is_foreground|.
TEST_P(UpdateCheckerTest, UpdateCheckSuccess) {}

// Tests that an invalid "ap" is not serialized.
TEST_P(UpdateCheckerTest, UpdateCheckInvalidAp) {}

TEST_P(UpdateCheckerTest, UpdateCheckSuccessNoBrand) {}

TEST_P(UpdateCheckerTest, UpdateCheckFallback) {}

// Simulates a 403 server response error.
TEST_P(UpdateCheckerTest, UpdateCheckError) {}

TEST_P(UpdateCheckerTest, UpdateCheckDownloadPreference) {}

// This test is checking that an update check signed with CUP fails, since there
// is currently no entity that can respond with a valid signed response.
// A proper CUP test requires network mocks, which are not available now.
TEST_P(UpdateCheckerTest, UpdateCheckCupError) {}

// Tests that the UpdateCheckers will not make an update check for a
// component that requires encryption when the update check URL is unsecure.
TEST_P(UpdateCheckerTest, UpdateCheckRequiresEncryptionError) {}

// Tests that the PersistedData will get correctly update and reserialize
// the elapsed_days value.
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) {}

// Tests that an update checker object and its underlying SimpleURLLoader can
// be safely destroyed while it is paused.
TEST_P(UpdateCheckerTest, UpdateResetUpdateChecker) {}

// The update response contains a protocol version which does not match the
// expected protocol version.
TEST_P(UpdateCheckerTest, ParseErrorProtocolVersionMismatch) {}

// The update response contains a status |error-unknownApplication| for the
// app. The response is successfully parsed and a result is extracted to
// indicate this status.
TEST_P(UpdateCheckerTest, ParseErrorAppStatusErrorUnknownApplication) {}

TEST_P(UpdateCheckerTest, DomainJoined) {}

}  // namespace update_client