#include "base/feature_list.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/metrics/user_action_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "build/buildflag.h"
#include "components/feed/core/common/pref_names.h"
#include "components/feed/core/proto/v2/wire/feed_entry_point_source.pb.h"
#include "components/feed/core/proto/v2/wire/feed_query.pb.h"
#include "components/feed/core/proto/v2/wire/info_card.pb.h"
#include "components/feed/core/shared_prefs/pref_names.h"
#include "components/feed/core/v2/api_test/feed_api_test.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/feed_stream.h"
#include "components/feed/core/v2/feedstore_util.h"
#include "components/feed/core/v2/prefs.h"
#include "components/feed/core/v2/public/feed_api.h"
#include "components/feed/core/v2/public/feed_service.h"
#include "components/feed/core/v2/public/stream_type.h"
#include "components/feed/core/v2/public/types.h"
#include "components/feed/core/v2/scheduling.h"
#include "components/feed/core/v2/test/callback_receiver.h"
#include "components/feed/core/v2/test/stream_builder.h"
#include "components/feed/feed_feature_list.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace feed {
namespace test {
namespace {
WebFeedChangeReason;
const int kTestInfoCardType1 = …;
const int kTestInfoCardType2 = …;
const int kMinimumViewIntervalSeconds = …;
TEST_F(FeedApiTest, IsArticlesListVisibleByDefault) { … }
TEST_F(FeedApiTest, DoNotRefreshIfArticlesListIsHidden) { … }
TEST_F(FeedApiTest,
DoNotRefreshIfSnippetsByDseDisabled_ignoredWithoutFlagEnabled) { … }
TEST_F(FeedApiTest, DoNotRefreshIfSnippetsByDseDisabled) { … }
TEST_F(FeedApiTest, BackgroundRefreshForYouSuccess) { … }
TEST_F(FeedApiTest, WebFeedDoesNotBackgroundRefresh) { … }
TEST_F(FeedApiTest, BackgroundRefreshPrefetchesImages) { … }
TEST_F(FeedApiTest, BackgroundRefreshNotAttemptedWhenModelIsLoading) { … }
TEST_F(FeedApiTest, BackgroundRefreshNotAttemptedAfterModelIsLoaded) { … }
TEST_F(FeedApiTest, SurfaceReceivesInitialContent) { … }
TEST_F(FeedApiTest, SurfaceReceivesInitialContentLoadedAfterAttach) { … }
TEST_F(FeedApiTest, SurfaceReceivesUpdatedContent) { … }
TEST_F(FeedApiTest, SurfaceReceivesSecondUpdatedContent) { … }
TEST_F(FeedApiTest, RemoveAllContentResultsInZeroState) { … }
TEST_F(FeedApiTest, DetachSurface) { … }
TEST_F(FeedApiTest, DetachSurfaceBeforeReceivingContent) { … }
TEST_F(FeedApiTest, FetchImage) { … }
TEST_F(FeedApiTest, FetchAsyncData) { … }
TEST_F(FeedStreamTestForAllStreamTypes,
ReportContentLifetimeMetricsViaOnLoadStream) { … }
TEST_F(FeedStreamTestForAllStreamTypes,
DoNotReportContentLifetimeMetricsWhenStreamMetadataNotPopulated) { … }
TEST_F(FeedStreamTestForAllStreamTypes,
DoNotReportContentLifetimeStaleAgeWhenNotPopulated) { … }
TEST_F(FeedStreamTestForAllStreamTypes,
DoNotReportContentLifetimeInvalidAgeWhenNotPopulated) { … }
TEST_P(FeedStreamTestForAllStreamTypes, LoadFromNetwork) { … }
TEST_P(FeedStreamTestForAllStreamTypes, UseFeedQueryOverride) { … }
TEST_F(FeedApiTest, FetchAfterStartup) { … }
TEST_F(FeedApiTest, WebFeedLoadWithNoSubscriptionsWithoutOnboarding) { … }
TEST_F(FeedApiTest, WebFeedLoadWithNoSubscriptions) { … }
TEST_F(FeedApiTest, WebFeedContentExprirationWithNoSubscriptions) { … }
TEST_F(FeedApiTest, LoadFromNetworkDiscoFeedEnabled) { … }
TEST_P(FeedNetworkEndpointTest, TestAllNetworkEndpointConfigs) { … }
TEST_F(FeedApiTest, BackgroundRefreshDiscoFeedEnabled) { … }
TEST_P(FeedStreamTestForAllStreamTypes, ForceRefreshForDebugging) { … }
TEST_F(FeedApiTest, RefreshScheduleFlow) { … }
TEST_F(FeedApiTest, ForceRefreshIfMissedScheduledRefresh) { … }
TEST_F(FeedApiTest, LoadFromNetworkBecauseStoreIsStale_NetworkStaleAge) { … }
TEST_F(FeedApiTest, LoadFromNetworkBecauseStoreIsExpired_NetworkExpiredAge) { … }
TEST_P(FeedStreamTestForAllStreamTypes, LoadFromNetworkBecauseStoreIsStale) { … }
TEST_F(FeedApiTest, LoadFromNetworkBecauseStoreIsExpired) { … }
TEST_F(FeedApiTest, LoadStaleDataBecauseNetworkRequestFails) { … }
TEST_P(FeedStreamTestForAllStreamTypes, LoadFailsStoredDataIsExpired) { … }
TEST_F(FeedApiTest, LoadFromNetworkFailsDueToProtoTranslation) { … }
TEST_F(FeedApiTest, DoNotLoadFromNetworkWhenOffline) { … }
TEST_F(FeedApiTest, DoNotLoadStreamWhenArticleListIsHidden) { … }
TEST_F(FeedApiTest, DoNotLoadStreamWhenEulaIsNotAccepted) { … }
TEST_F(FeedApiTest, LoadStreamAfterEulaIsAccepted) { … }
TEST_F(FeedApiTest, WebFeedUsesSignedInRequestAfterHistoryIsDeleted) { … }
TEST_F(FeedApiTest, ShouldMakeFeedQueryRequestConsumesQuota) { … }
TEST_F(FeedApiTest, LoadStreamFromStore) { … }
TEST_F(FeedApiTest, LoadStreamFromStoreValidatesUser) { … }
TEST_F(FeedApiTest, LoadingSpinnerIsSentInitially) { … }
TEST_F(FeedApiTest, DetachSurfaceWhileLoadingModel) { … }
TEST_F(FeedApiTest, AttachMultipleSurfacesLoadsModelOnce) { … }
TEST_P(FeedStreamTestForAllStreamTypes, ModelChangesAreSavedToStorage) { … }
TEST_F(FeedApiTest, ReportActionAfterSurfaceDestroyed) { … }
TEST_F(FeedApiTest, ReportActionAfterSurfaceDestroyedAndCleanedUp) { … }
TEST_F(FeedApiTest, ReportSliceViewedIdentifiesCorrectIndex) { … }
TEST_F(FeedApiTest, ReportSliceViewed_AddViewedContentHashes) { … }
TEST_F(FeedApiTest, ReportOpenInNewTabAction) { … }
TEST_F(FeedApiTest, ReportOpenInNewTabInGroupAction) { … }
TEST_F(FeedApiTest, HasUnreadContentAfterLoadFromNetwork) { … }
TEST_F(FeedApiTest, HasUnreadContentInitially) { … }
TEST_F(FeedApiTest, NetworkFetchWithNoNewContentDoesNotProvideUnreadContent) { … }
TEST_F(FeedApiTest, RemovedUnreadContentObserverDoesNotReceiveCalls) { … }
TEST_F(FeedApiTest, DeletedUnreadContentObserverDoesNotCrash) { … }
TEST_F(FeedApiTest, HasUnreadContentAfterLoadFromStore) { … }
TEST_F(FeedApiTest, FollowForcesRefreshWhileSurfaceAttached_NotWorking) { … }
TEST_F(FeedApiTest, FollowForcesRefresh) { … }
TEST_F(FeedApiTest, ReportFeedViewedUpdatesObservers) { … }
TEST_P(FeedStreamTestForAllStreamTypes, LoadMoreIndicatorSliceId) { … }
TEST_P(FeedStreamTestForAllStreamTypes, LoadMoreAppendsContent) { … }
TEST_P(FeedStreamTestForAllStreamTypes, LoadMorePersistsData) { … }
TEST_F(FeedApiTest, LoadMorePersistAndLoadMore) { … }
TEST_F(FeedApiTest, LoadMoreSendsTokens) { … }
TEST_F(FeedApiTest, LoadMoreAbortsIfNoNextPageToken) { … }
TEST_F(FeedApiTest, LoadMoreFail) { … }
TEST_F(FeedApiTest, LoadMoreWithClearAllInResponse) { … }
TEST_F(FeedApiTest, LoadMoreBeforeLoad) { … }
TEST_F(FeedApiTest, ReadNetworkResponse) { … }
TEST_F(FeedApiTest, ReadNetworkResponseWithNoContent) { … }
TEST_F(FeedApiTest, ClearAllAfterLoadResultsInRefresh) { … }
TEST_F(FeedApiTest, ClearAllWithNoSurfacesAttachedDoesNotReload) { … }
TEST_F(FeedApiTest, ClearAllWhileLoadingMoreDoesNotLoadMore) { … }
TEST_F(FeedApiTest, ClearAllWipesAllState) { … }
TEST_F(FeedApiTest, StorePendingAction) { … }
TEST_F(FeedApiTest, UploadActionWhileSignedOutIsNoOp) { … }
TEST_F(FeedApiTest, SignOutWhileUploadActionDoesNotUpload) { … }
TEST_F(FeedApiTest, ClearAllWhileUploadActionDoesNotUpload) { … }
TEST_F(FeedApiTest, WrongUserUploadActionDoesNotUpload) { … }
TEST_F(FeedApiTest, LoggingPropertiesWithNoAccountDoesNotUpload) { … }
TEST_F(FeedApiTest, StorePendingActionAndUploadNow) { … }
TEST_F(FeedApiTest, ProcessViewActionResultsInDelayedUpload) { … }
TEST_F(FeedApiTest, ProcessViewActionDroppedBecauseNotEnabled) { … }
TEST_F(FeedApiTest, ActionsUploadWithoutConditionsWhenFeatureDisabled) { … }
TEST_F(FeedApiTest, LoadStreamFromNetworkUploadsActions) { … }
TEST_F(FeedApiTest, UploadedActionsHaveSequentialNumbers) { … }
TEST_F(FeedApiTest, LoadMoreUploadsActions) { … }
TEST_F(FeedApiTest, LoadMoreDoesNotUpdateLoggingEnabled) { … }
TEST_F(FeedApiTest, LoadStreamWithLoggingEnabled) { … }
TEST_F(FeedApiTest, BackgroundingAppUploadsActions) { … }
TEST_F(FeedApiTest, BackgroundingAppDoesNotUploadActions) { … }
TEST_F(FeedApiTest, UploadedActionsAreNotSentAgain) { … }
TEST_F(FeedApiTest, UploadActionsOneBatch) { … }
TEST_F(FeedApiTest, UploadActionsMultipleBatches) { … }
TEST_F(FeedApiTest, UploadActionsSkipsStaleActionsByTimestamp) { … }
TEST_F(FeedApiTest, UploadActionsErasesStaleActionsByAttempts) { … }
TEST_F(FeedApiTest, MetadataLoadedWhenDatabaseInitialized) { … }
TEST_F(FeedApiTest, ClearAllWhenDatabaseInitializedForWrongUser) { … }
TEST_F(FeedApiTest, ModelUnloadsAfterTimeout) { … }
TEST_F(FeedApiTest, ModelDoesNotUnloadIfSurfaceIsAttached) { … }
TEST_F(FeedApiTest, ModelUnloadsAfterSecondTimeout) { … }
TEST_F(FeedApiTest, SendsClientInstanceId) { … }
TEST_F(FeedApiTest, SignedOutSessionIdConsistency) { … }
TEST_F(FeedApiTest, ClearAllResetsSessionId) { … }
TEST_F(FeedApiTest, SignedOutSessionIdExpiry) { … }
TEST_F(FeedApiTest, SessionIdPersistsAcrossStreamLoads) { … }
TEST_F(FeedApiTest, PersistentKeyValueStoreIsClearedOnClearAll) { … }
TEST_F(FeedApiTest, LoadMultipleStreams) { … }
TEST_F(FeedApiTest, UnloadOnlyOneOfMultipleModels) { … }
TEST_F(FeedApiTest, ExperimentsAreClearedOnClearAll) { … }
TEST_F(FeedApiTest, CreateAndCommitEphemeralChange) { … }
TEST_F(FeedApiTest, CreateAndCommitEphemeralChangeOnNoOperation) { … }
TEST_F(FeedApiTest, RejectEphemeralChange) { … }
TEST_F(FeedApiTest, StreamDataOverwritesOldStream) { … }
TEST_F(FeedApiTest, HasUnreadContentIsFalseAfterFeedViewed) { … }
TEST_F(FeedApiTest, HasUnreadContentRemainsFalseIfFeedViewedBeforeRefresh) { … }
TEST_F(FeedApiTest,
LoadingForYouStreamTriggersWebFeedRefreshIfNoUnreadContent) { … }
TEST_F(
FeedApiTest,
LoadingForYouStreamDoesNotTriggerWebFeedRefreshIfNoSubscriptionsWhithoutOnboarding) { … }
TEST_F(
FeedApiTest,
LoadForYouStreamDoesNotTriggerWebFeedRefreshContentIfIsAlreadyAvailable) { … }
TEST_F(FeedApiTest, WasUrlRecentlyNavigatedFromFeed) { … }
TEST_F(FeedApiTest, WasUrlRecentlyNavigatedFromFeedMaxHistory) { … }
TEST_F(FeedApiTest, ClearAllOnStartupIfFeedIsDisabled) { … }
#if BUILDFLAG(IS_ANDROID)
TEST_F(FeedApiTest, ClearAllOnStartupIfFeedIsDisabledByDse) {
CallbackReceiver<> on_clear_all;
on_clear_all_ = on_clear_all.BindRepeating();
response_translator_.InjectResponse(MakeTypicalInitialModelState());
TestForYouSurface surface(stream_.get());
WaitForIdleTaskQueue();
profile_prefs_.SetBoolean(feed::prefs::kEnableSnippetsByDse, false);
CreateStream(true,
true);
EXPECT_TRUE(on_clear_all.called());
on_clear_all.Clear();
base::HistogramTester histograms;
CreateStream(true,
true);
EXPECT_FALSE(on_clear_all.called());
}
#endif
TEST_F(FeedApiTest, ReportUserSettingsFromMetadataWaaOnDpOff) { … }
TEST_F(FeedApiTest, ReportUserSettingsFromMetadataWaaOffDpOn) { … }
TEST_F(FeedStreamTestForAllStreamTypes, ManualRefreshWithoutSurfaceIsAborted) { … }
TEST_F(FeedStreamTestForAllStreamTypes, ManualRefreshInterestFeedSuccess) { … }
TEST_F(FeedApiTest, ManualRefreshResetsRequestThrottlerQuota) { … }
TEST_F(FeedStreamTestForAllStreamTypes, ManualRefreshWebFeedSuccess) { … }
TEST_F(FeedApiTest, ManualRefreshFailsBecauseNetworkRequestFails) { … }
TEST_F(FeedApiTest, ManualRefreshSuccessAfterUnload) { … }
TEST_F(FeedApiTest, ManualRefreshSuccessAfterPreviousLoadFailure) { … }
TEST_F(FeedApiTest, ManualRefreshFailesWhenLoadingInProgress) { … }
TEST_F(FeedApiTest, ManualRefresh_MetricsOnNoCardViewed) { … }
TEST_F(FeedApiTest, ManualRefresh_MetricsOnCardsViewed) { … }
TEST_F(FeedApiTest, ManualRefresh_MetricsOnCardsViewedAfterRestart) { … }
TEST_F(FeedApiTest, ForYouContentOrderUnset) { … }
TEST_F(FeedApiTest, ContentOrderIsGroupedByDefault) { … }
TEST_F(FeedApiTest, SetContentOrderReloadsContent) { … }
TEST_F(FeedApiTest, SetContentOrderIsSavedeNotRefreshedIfUnchanged) { … }
TEST_F(FeedApiTest, SignInWhileSurfaceIsOpen) { … }
TEST_F(FeedApiTest, SignOutWhileSurfaceIsOpen) { … }
TEST_F(FeedApiTest, FollowedFromWebPageMenuCount) { … }
TEST_F(FeedApiTest, InfoCardTrackingActions) { … }
TEST_F(FeedApiTest, InvalidateFeedCache_CauseRefreshOnNextLoad) { … }
TEST_F(FeedApiTest, InvalidateFeedCache_DoesNotForceRefreshFeedWhileInUse) { … }
TEST_F(FeedApiTest, InvalidateFeedCache_UnknownDoesNotForceRefreshAnyFeeds) { … }
TEST_F(FeedApiTest, InvalidateFeedCache_DoesNotRefreshOtherFeed) { … }
class FeedCloseRefreshTest : public FeedApiTest { … };
TEST_F(FeedCloseRefreshTest, Scroll) { … }
TEST_F(FeedCloseRefreshTest, Open) { … }
TEST_F(FeedCloseRefreshTest, OpenInNewTab) { … }
TEST_F(FeedCloseRefreshTest, ManualRefreshResetsCoalesceTimestamp) { … }
TEST_F(FeedCloseRefreshTest, FeedViewed) { … }
TEST_F(FeedCloseRefreshTest, ExistingScheduleGetsReplaced) { … }
TEST_F(FeedCloseRefreshTest, Retry) { … }
TEST_F(FeedCloseRefreshTest, RequestType) { … }
TEST_F(FeedApiTest, CheckDuplicatedContents) { … }
TEST_F(FeedApiTest, GetRequestMetadataForSignedOutUser) { … }
TEST_F(FeedApiTest, GetRequestMetadataForSignedInUser) { … }
TEST_F(FeedApiTest, GetRequestMetadataForSigninDisallowedUser) { … }
TEST_F(FeedApiTest, GetRequestMetadataForSigninDisallowedUserWhenSignedIn) { … }
TEST_F(FeedApiTest, GetRequestMetadataWithDefaultSearchEngine) { … }
TEST_F(FeedApiTest, ClearAllOnSigninAllowedPrefChange) { … }
TEST_F(FeedApiTest, RefreshFeedOnStartWithFlag) { … }
TEST_F(FeedApiTest, DoNotRefreshFeedOnStartWithoutFlag) { … }
class SignedOutViewDemotionTest : public FeedApiTest { … };
TEST_F(SignedOutViewDemotionTest, ViewsAreSent) { … }
TEST_F(SignedOutViewDemotionTest, ViewsAreNotStoredWhenSignedIn) { … }
TEST_F(SignedOutViewDemotionTest, ViewsAreNotStoredWhenFeatureIsOff) { … }
TEST_F(SignedOutViewDemotionTest, OldViewsAreDeleted) { … }
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
}
}
}