chromium/components/feed/core/v2/feed_network_impl_unittest.cc

// Copyright 2020 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/feed_network_impl.h"

#include <memory>
#include <utility>

#include "base/base64.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "build/chromeos_buildflags.h"
#include "components/feed/core/common/pref_names.h"
#include "components/feed/core/proto/v2/wire/client_info.pb.h"
#include "components/feed/core/proto/v2/wire/feed_query.pb.h"
#include "components/feed/core/proto/v2/wire/request.pb.h"
#include "components/feed/core/proto/v2/wire/response.pb.h"
#include "components/feed/core/proto/v2/wire/upload_actions_request.pb.h"
#include "components/feed/core/proto/v2/wire/upload_actions_response.pb.h"
#include "components/feed/core/proto/v2/wire/web_feeds.pb.h"
#include "components/feed/core/v2/feed_network.h"
#include "components/feed/core/v2/public/types.h"
#include "components/feed/core/v2/test/callback_receiver.h"
#include "components/feed/feed_feature_list.h"
#include "components/prefs/testing_pref_service.h"
#include "components/signin/public/base/consent_level.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/variations/scoped_variations_ids_provider.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/http/http_util.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/url_loader_completion_status.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/protobuf/src/google/protobuf/io/coded_stream.h"
#include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h"
#include "third_party/zlib/google/compression_utils.h"
#include "url/gurl.h"

namespace feed {
namespace {

constexpr char kEmail[] =;

MATCHER_P(EqualsProto,
          message,
          "Match a proto Message equal to the matcher's argument.") {}

ElementsAre;
QueryRequestResult;

feedwire::ClientInfo ExpectHasClientInfoHeader(
    network::ResourceRequest request) {}

void ExpectNoClientInfoHeader(network::ResourceRequest request) {}

feedwire::Request GetTestFeedRequest(feedwire::FeedQuery::RequestReason reason =
                                         feedwire::FeedQuery::MANUAL_REFRESH) {}

feedwire::Response GetTestFeedResponse() {}

feedwire::UploadActionsRequest GetTestActionRequest() {}

feedwire::UploadActionsResponse GetTestActionResponse() {}

class TestDelegate : public FeedNetworkImpl::Delegate {};

class FeedNetworkTest : public testing::Test {};

TEST_F(FeedNetworkTest, SendQueryRequestEmpty) {}

TEST_F(FeedNetworkTest, SendQueryRequestSendsValidRequest) {}

// These tests need ClearPrimaryAccount() which isn't supported by ChromeOS.
// RevokeSyncConsent() sometimes clears the account rather than just changing
// the consent level so we may as well sign out and sign back in ourselves.
#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(FeedNetworkTest, SendQueryRequestPersonalized_AccountSignin) {}

#endif  // !BUILDFLAG(IS_CHROMEOS_ASH)

TEST_F(FeedNetworkTest, SendQueryRequestPersonalized_AccountSync) {}

TEST_F(FeedNetworkTest, SendQueryRequestForceSignedOut) {}

TEST_F(FeedNetworkTest, SendQueryRequestInvalidResponse) {}

TEST_F(FeedNetworkTest, SendQueryRequestReceivesResponse) {}

TEST_F(FeedNetworkTest, SendQueryRequestIgnoresBodyForNon200Response) {}

TEST_F(FeedNetworkTest, SendQueryRequestFailsForWrongUser) {}

TEST_F(FeedNetworkTest, CancelRequest) {}

TEST_F(FeedNetworkTest, RequestTimeout) {}

TEST_F(FeedNetworkTest, AccountTokenFetchTimeout) {}

TEST_F(FeedNetworkTest, AccountTokenRefreshCompleteAfterFetchTimeout) {}

TEST_F(FeedNetworkTest, AccountTokenRefreshCompleteBeforeFetchTimeout) {}

TEST_F(FeedNetworkTest, FetchImmediatelyAbortsIfOffline) {}

TEST_F(FeedNetworkTest, ParallelRequests) {}

TEST_F(FeedNetworkTest, ShouldReportResponseStatusCode) {}

TEST_F(FeedNetworkTest, ShouldIncludeAPIKeyForAuthError) {}

// Disabled for chromeos, which doesn't allow for there not to be a signed in
// user.
#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(FeedNetworkTest, ShouldIncludeAPIKeyForNoSignedInUser) {}
#endif

TEST_F(FeedNetworkTest, TestDurationHistogram) {}

// Verify that the kHostOverrideHost pref overrides the feed host
// and returns the Bless nonce if one sent in the response.
TEST_F(FeedNetworkTest, TestHostOverrideWithAuthHeader) {}

TEST_F(FeedNetworkTest, TestHostOverrideWithPath) {}

TEST_F(FeedNetworkTest, TestHostOverrideWithPathTrailingSlash) {}

TEST_F(FeedNetworkTest, SendApiRequest_UploadActions) {}

TEST_F(FeedNetworkTest, SendApiRequest_DecodesClientInfo_WithClientInstanceId) {}

TEST_F(FeedNetworkTest, SendApiRequest_DecodesClientInfo_WithSessionId) {}

TEST_F(FeedNetworkTest, SendApiRequest_UploadActionsFailsForWrongUser) {}

TEST_F(FeedNetworkTest, SendApiRequestSendsValidRequest_UploadActions) {}

TEST_F(FeedNetworkTest, SendApiRequest_Unfollow) {}

TEST_F(FeedNetworkTest, SendApiRequest_ListWebFeedsSendsCorrectContentType) {}

TEST_F(FeedNetworkTest,
       SendApiRequest_DiscoFeedRequestsSendResponseEncodingHeader) {}

TEST_F(FeedNetworkTest, TestOverrideHostDoesNotAffectDiscoverApis) {}

TEST_F(FeedNetworkTest, TestOverrideDiscoverEndpoint) {}

TEST_F(FeedNetworkTest, AppCloseRefreshRequestReasonHasUrl) {}

TEST_F(FeedNetworkTest, SendAsynccDataRequest) {}

}  // namespace
}  // namespace feed