chromium/components/feed/core/v2/api_test/feed_api_test.cc

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

#include "components/feed/core/v2/api_test/feed_api_test.h"

#include <string>
#include <string_view>

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/bind.h"
#include "base/time/time.h"
#include "components/feed/core/common/pref_names.h"
#include "components/feed/core/proto/v2/keyvalue_store.pb.h"
#include "components/feed/core/proto/v2/store.pb.h"
#include "components/feed/core/proto/v2/ui.pb.h"
#include "components/feed/core/proto/v2/wire/chrome_client_info.pb.h"
#include "components/feed/core/proto/v2/wire/reliability_logging_enums.pb.h"
#include "components/feed/core/proto/v2/wire/request.pb.h"
#include "components/feed/core/proto/v2/wire/there_and_back_again_data.pb.h"
#include "components/feed/core/proto/v2/wire/web_feeds.pb.h"
#include "components/feed/core/proto/v2/xsurface.pb.h"
#include "components/feed/core/shared_prefs/pref_names.h"
#include "components/feed/core/v2/config.h"
#include "components/feed/core/v2/enums.h"
#include "components/feed/core/v2/feed_network.h"
#include "components/feed/core/v2/feedstore_util.h"
#include "components/feed/core/v2/prefs.h"
#include "components/feed/core/v2/public/logging_parameters.h"
#include "components/feed/core/v2/public/reliability_logging_bridge.h"
#include "components/feed/core/v2/test/callback_receiver.h"
#include "components/feed/core/v2/test/proto_printer.h"
#include "components/feed/core/v2/test/stream_builder.h"
#include "components/feed/core/v2/test/test_util.h"
#include "components/feed/core/v2/types.h"
#include "components/feed/feed_feature_list.h"
#include "components/leveldb_proto/public/proto_database_provider.h"
#include "components/signin/public/base/signin_pref_names.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace feed {
namespace test {

std::unique_ptr<StreamModel> LoadModelFromStore(const StreamType& stream_type,
                                                FeedStore* store,
                                                StreamModel::Context* context) {}

std::unique_ptr<StreamModelUpdateRequest> StoredModelData(
    const StreamType& stream_type,
    FeedStore* store) {}

std::string ModelStateFor(
    std::unique_ptr<StreamModelUpdateRequest> update_request,
    std::vector<feedstore::DataOperation> operations,
    std::vector<feedstore::DataOperation> more_operations) {}

std::string ModelStateFor(const StreamType& stream_type, FeedStore* store) {}

feedwire::FeedAction MakeFeedAction(int64_t id, size_t pad_size) {}

std::vector<feedstore::StoredAction> ReadStoredActions(FeedStore& store) {}

std::string SerializedOfflineBadgeContent() {}

feedwire::ThereAndBackAgainData MakeThereAndBackAgainData(int64_t id) {}
std::string DatastoreEntryToString(std::string_view key,
                                   std::string_view value) {}

TestUnreadContentObserver::TestUnreadContentObserver() = default;
TestUnreadContentObserver::~TestUnreadContentObserver() = default;
void TestUnreadContentObserver::HasUnreadContentChanged(
    bool has_unread_content) {}

TestSurfaceBase::TestSurfaceBase(const StreamType& stream_type,
                                 FeedStream* stream,
                                 SingleWebFeedEntryPoint entry_point)
    :{}

TestSurfaceBase::~TestSurfaceBase() {}

SurfaceId TestSurfaceBase::GetSurfaceId() const {}

void TestSurfaceBase::CreateWithoutAttach(FeedStream* stream) {}

void TestSurfaceBase::Attach(FeedStream* stream) {}

void TestSurfaceBase::Detach() {}

void TestSurfaceBase::StreamUpdate(const feedui::StreamUpdate& stream_update) {}
void TestSurfaceBase::ReplaceDataStoreEntry(std::string_view key,
                                            std::string_view data) {}
void TestSurfaceBase::RemoveDataStoreEntry(std::string_view key) {}
ReliabilityLoggingBridge& TestSurfaceBase::GetReliabilityLoggingBridge() {}

void TestSurfaceBase::Clear() {}

std::string TestSurfaceBase::DescribeUpdates() {}
std::vector<std::string> TestSurfaceBase::DescribeDataStoreUpdates() {}

std::string TestSurfaceBase::DescribeState() {}
std::map<std::string, std::string> TestSurfaceBase::GetDataStoreEntries()
    const {}
std::string TestSurfaceBase::DescribeDataStore() const {}
LoggingParameters TestSurfaceBase::GetLoggingParameters() const {}
std::string TestSurfaceBase::CurrentState() {}

bool TestSurfaceBase::IsInitialLoadSpinnerUpdate(
    const feedui::StreamUpdate& stream_update) {}

TestForYouSurface::TestForYouSurface(FeedStream* stream)
    :{}
TestWebFeedSurface::TestWebFeedSurface(FeedStream* stream)
    :{}
TestSingleWebFeedSurface::TestSingleWebFeedSurface(
    FeedStream* stream,
    std::string web_feed_id,
    SingleWebFeedEntryPoint entry_point)
    :{}
TestSupervisedFeedSurface::TestSupervisedFeedSurface(FeedStream* stream)
    :{}

TestReliabilityLoggingBridge::TestReliabilityLoggingBridge() = default;
TestReliabilityLoggingBridge::~TestReliabilityLoggingBridge() = default;

std::string TestReliabilityLoggingBridge::GetEventsString() const {}

void TestReliabilityLoggingBridge::ClearEventsString() {}

void TestReliabilityLoggingBridge::LogFeedLaunchOtherStart(
    base::TimeTicks timestamp) {}

void TestReliabilityLoggingBridge::LogCacheReadStart(
    base::TimeTicks timestamp) {}

void TestReliabilityLoggingBridge::LogCacheReadEnd(
    base::TimeTicks timestamp,
    feedwire::DiscoverCardReadCacheResult result) {}

void TestReliabilityLoggingBridge::LogFeedRequestStart(
    NetworkRequestId id,
    base::TimeTicks timestamp) {}

void TestReliabilityLoggingBridge::LogActionsUploadRequestStart(
    NetworkRequestId id,
    base::TimeTicks timestamp) {}

void TestReliabilityLoggingBridge::LogWebFeedRequestStart(
    NetworkRequestId id,
    base::TimeTicks timestamp) {}

void TestReliabilityLoggingBridge::LogSingleWebFeedRequestStart(
    NetworkRequestId id,
    base::TimeTicks timestamp) {}

void TestReliabilityLoggingBridge::LogRequestSent(NetworkRequestId id,
                                                  base::TimeTicks timestamp) {}

void TestReliabilityLoggingBridge::LogResponseReceived(
    NetworkRequestId id,
    int64_t server_receive_timestamp_ns,
    int64_t server_send_timestamp_ns,
    base::TimeTicks client_receive_timestamp) {}

void TestReliabilityLoggingBridge::LogRequestFinished(
    NetworkRequestId id,
    base::TimeTicks timestamp,
    int combined_network_status_code) {}

void TestReliabilityLoggingBridge::LogLoadingIndicatorShown(
    base::TimeTicks timestamp) {}

void TestReliabilityLoggingBridge::LogAboveTheFoldRender(
    base::TimeTicks timestamp,
    feedwire::DiscoverAboveTheFoldRenderResult result) {}

void TestReliabilityLoggingBridge::LogLaunchFinishedAfterStreamUpdate(
    feedwire::DiscoverLaunchResult result) {}

void TestReliabilityLoggingBridge::LogLoadMoreStarted() {}

void TestReliabilityLoggingBridge::LogLoadMoreActionUploadRequestStarted() {}

void TestReliabilityLoggingBridge::LogLoadMoreRequestSent() {}

void TestReliabilityLoggingBridge::LogLoadMoreResponseReceived(
    int64_t server_receive_timestamp_ns,
    int64_t server_send_timestamp_ns) {}

void TestReliabilityLoggingBridge::LogLoadMoreRequestFinished(
    int canonical_status) {}

void TestReliabilityLoggingBridge::LogLoadMoreEnded(bool success) {}

void TestReliabilityLoggingBridge::ReportExperiments(
    const std::vector<int32_t>& experiment_ids) {}

TestImageFetcher::TestImageFetcher(
    scoped_refptr<::network::SharedURLLoaderFactory> url_loader_factory)
    :{}

ImageFetchId TestImageFetcher::Fetch(
    const GURL& url,
    base::OnceCallback<void(NetworkResponse)> callback) {}

TestFeedNetwork::TestFeedNetwork() = default;
TestFeedNetwork::~TestFeedNetwork() = default;

void TestFeedNetwork::SendQueryRequest(
    NetworkRequestType request_type,
    const feedwire::Request& request,
    const AccountInfo& account_info,
    base::OnceCallback<void(QueryRequestResult)> callback) {}

template <typename API>
void DebugLogApiResponse(std::string request_bytes,
                         const FeedNetwork::RawResponse& raw_response) {}

void DebugLogResponse(NetworkRequestType request_type,
                      std::string_view api_path,
                      std::string_view method,
                      std::string request_bytes,
                      const FeedNetwork::RawResponse& raw_response) {}

void TestFeedNetwork::SendDiscoverApiRequest(
    NetworkRequestType request_type,
    std::string_view api_path,
    std::string_view method,
    std::string request_bytes,
    const AccountInfo& account_info,
    std::optional<RequestMetadata> request_metadata,
    base::OnceCallback<void(RawResponse)> callback) {}

void TestFeedNetwork::SendAsyncDataRequest(
    const GURL& url,
    std::string_view request_method,
    net::HttpRequestHeaders request_headers,
    std::string request_body,
    const AccountInfo& account_info,
    base::OnceCallback<void(RawResponse)> callback) {}

void TestFeedNetwork::CancelRequests() {}

void TestFeedNetwork::InjectRealFeedQueryResponse() {}

void TestFeedNetwork::InjectRealFeedQueryResponseWithNoContent() {}

void TestFeedNetwork::InjectEmptyActionRequestResult() {}

std::optional<feedwire::UploadActionsRequest>
TestFeedNetwork::GetActionRequestSent() {}

int TestFeedNetwork::GetActionRequestCount() const {}

void TestFeedNetwork::ClearTestData() {}

void TestFeedNetwork::SendResponse() {}

void TestFeedNetwork::SendResponsesOnCommand(bool on) {}

void TestFeedNetwork::Reply(base::OnceClosure reply_closure) {}

TestWireResponseTranslator::TestWireResponseTranslator() = default;
TestWireResponseTranslator::~TestWireResponseTranslator() = default;
RefreshResponseData TestWireResponseTranslator::TranslateWireResponse(
    feedwire::Response response,
    StreamModelUpdateRequest::Source source,
    const AccountInfo& account_info,
    base::Time current_time) const {}

std::optional<RefreshResponseData>
TestWireResponseTranslator::TranslateStreamSource(
    StreamModelUpdateRequest::Source source,
    const AccountInfo& account_info,
    base::Time current_time) const {}
void TestWireResponseTranslator::InjectResponse(
    std::unique_ptr<StreamModelUpdateRequest> response,
    std::optional<std::string> session_id) {}
void TestWireResponseTranslator::InjectResponse(
    RefreshResponseData response_data) {}
bool TestWireResponseTranslator::InjectedResponseConsumed() const {}

FakeRefreshTaskScheduler::FakeRefreshTaskScheduler() = default;
FakeRefreshTaskScheduler::~FakeRefreshTaskScheduler() = default;
void FakeRefreshTaskScheduler::EnsureScheduled(RefreshTaskId id,
                                               base::TimeDelta run_time) {}
void FakeRefreshTaskScheduler::Cancel(RefreshTaskId id) {}
void FakeRefreshTaskScheduler::RefreshTaskComplete(RefreshTaskId id) {}

void FakeRefreshTaskScheduler::Clear() {}

TestMetricsReporter::TestMetricsReporter(PrefService* prefs)
    :{}
TestMetricsReporter::~TestMetricsReporter() = default;
TestMetricsReporter::StreamMetrics::StreamMetrics() = default;
TestMetricsReporter::StreamMetrics::~StreamMetrics() = default;

void TestMetricsReporter::ContentSliceViewed(const StreamType& stream_type,
                                             int index_in_stream,
                                             int stream_slice_count) {}
void TestMetricsReporter::OnLoadStream(
    const StreamType& stream_type,
    const LoadStreamResultSummary& result_summary,
    const ContentStats& content_stats,
    std::unique_ptr<LoadLatencyTimes> load_latencies) {}
void TestMetricsReporter::OnLoadMoreBegin(const StreamType& stream_type,
                                          SurfaceId surface_id) {}
void TestMetricsReporter::OnLoadMore(const StreamType& stream_type,
                                     LoadStreamStatus final_status,
                                     const ContentStats& content_stats) {}
void TestMetricsReporter::OnBackgroundRefresh(const StreamType& stream_type,
                                              LoadStreamStatus final_status) {}

TestMetricsReporter::StreamMetrics& TestMetricsReporter::Stream(
    const StreamType& stream_type) {}

void TestMetricsReporter::OnUploadActions(UploadActionsStatus status) {}

FeedApiTest::FeedApiTest() = default;
FeedApiTest::~FeedApiTest() = default;
void FeedApiTest::SetUp() {}

void FeedApiTest::TearDown() {}
bool FeedApiTest::IsEulaAccepted() {}
bool FeedApiTest::IsOffline() {}
std::string FeedApiTest::GetCountry() {}
AccountInfo FeedApiTest::GetAccountInfo() {}
bool FeedApiTest::IsSigninAllowed() {}
bool FeedApiTest::IsSupervisedAccount() {}
void FeedApiTest::RegisterFollowingFeedFollowCountFieldTrial(
    size_t follow_count) {}
void FeedApiTest::RegisterFeedUserSettingsFieldTrial(std::string_view group) {}
DisplayMetrics FeedApiTest::GetDisplayMetrics() {}
std::string FeedApiTest::GetLanguageTag() {}
TabGroupEnabledState FeedApiTest::GetTabGroupEnabledState() {}
void FeedApiTest::ClearAll() {}
void FeedApiTest::SetCountry(const std::string& country) {}
void FeedApiTest::PrefetchImage(const GURL& url) {}

void FeedApiTest::CreateStream(
    bool wait_for_initialization,
    bool is_new_tab_search_engine_url_android_enabled) {}

std::unique_ptr<StreamModel> FeedApiTest::CreateStreamModel() {}

bool FeedApiTest::IsTaskQueueIdle() const {}

void FeedApiTest::WaitForIdleTaskQueue() {}

void FeedApiTest::WaitForModelToAutoUnload() {}

void FeedApiTest::UnloadModel(const StreamType& stream_type) {}

std::string FeedApiTest::DumpStoreState(bool print_keys) {}

void FeedApiTest::FollowWebFeed(const WebFeedPageInformation page_info) {}
LoggingParameters FeedApiTest::CreateLoggingParameters() {}
void FeedApiTest::UploadActions(std::vector<feedwire::FeedAction> actions) {}

RefreshTaskId FeedStreamTestForAllStreamTypes::GetRefreshTaskId() const {}

void FeedStreamTestForAllStreamTypes::SetUp() {}

}  // namespace test
}  // namespace feed