diff options
Diffstat (limited to 'chromium/components/ntp_snippets/contextual/contextual_suggestions_fetcher_impl_unittest.cc')
-rw-r--r-- | chromium/components/ntp_snippets/contextual/contextual_suggestions_fetcher_impl_unittest.cc | 50 |
1 files changed, 3 insertions, 47 deletions
diff --git a/chromium/components/ntp_snippets/contextual/contextual_suggestions_fetcher_impl_unittest.cc b/chromium/components/ntp_snippets/contextual/contextual_suggestions_fetcher_impl_unittest.cc index 1f27157fc28..1b8a993618b 100644 --- a/chromium/components/ntp_snippets/contextual/contextual_suggestions_fetcher_impl_unittest.cc +++ b/chromium/components/ntp_snippets/contextual/contextual_suggestions_fetcher_impl_unittest.cc @@ -147,36 +147,18 @@ std::string SerializedResponseProto(const std::string& peek_text, } // namespace -class TestUrlKeyedDataCollectionConsentHelper - : public unified_consent::UrlKeyedDataCollectionConsentHelper { - public: - TestUrlKeyedDataCollectionConsentHelper() = default; - ~TestUrlKeyedDataCollectionConsentHelper() override = default; - - bool IsEnabled() override { return is_enabled_; } - void SetIsEnabled(bool enabled) { is_enabled_ = enabled; } - - private: - bool is_enabled_ = false; -}; - class ContextualSuggestionsFetcherTest : public testing::Test { public: ContextualSuggestionsFetcherTest() { shared_url_loader_factory_ = base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>( &test_factory_); - auto consent_helper = - std::make_unique<TestUrlKeyedDataCollectionConsentHelper>(); - consent_helper_ = consent_helper.get(); fetcher_ = std::make_unique<ContextualSuggestionsFetcherImpl>( - shared_url_loader_factory_, std::move(consent_helper), "en"); + shared_url_loader_factory_, "en"); } ~ContextualSuggestionsFetcherTest() override {} - void SetUp() override { consent_helper()->SetIsEnabled(true); } - void SetFakeResponse(const std::string& response_data, net::HttpStatusCode response_code = net::HTTP_OK, network::URLLoaderCompletionStatus status = @@ -210,15 +192,10 @@ class ContextualSuggestionsFetcherTest : public testing::Test { TestURLLoaderFactory* test_factory() { return &test_factory_; } - TestUrlKeyedDataCollectionConsentHelper* consent_helper() { - return consent_helper_; - } - private: base::test::ScopedTaskEnvironment scoped_task_environment_; network::TestURLLoaderFactory test_factory_; scoped_refptr<network::SharedURLLoaderFactory> shared_url_loader_factory_; - TestUrlKeyedDataCollectionConsentHelper* consent_helper_; std::unique_ptr<ContextualSuggestionsFetcherImpl> fetcher_; DISALLOW_COPY_AND_ASSIGN(ContextualSuggestionsFetcherTest); @@ -435,25 +412,7 @@ TEST_F(ContextualSuggestionsFetcherTest, RequestHeaderSetCorrectly) { "ContextualSuggestions.FetchRequestProtoSizeKB", 1); } -TEST_F(ContextualSuggestionsFetcherTest, CookiesIncludedWhenConsentIsEnabled) { - network::ResourceRequest last_resource_request; - - test_factory()->SetInterceptor( - base::BindLambdaForTesting([&](const network::ResourceRequest& request) { - last_resource_request = request; - })); - - SetFakeResponse(SerializedResponseProto("Peek Text", DefaultClusters())); - - MockClustersCallback callback; - SendAndAwaitResponse(GURL("http://www.article.com/"), &callback); - - int load_flags = last_resource_request.load_flags; - EXPECT_EQ(0, load_flags & net::LOAD_DO_NOT_SEND_COOKIES); -} - -TEST_F(ContextualSuggestionsFetcherTest, CookiesExcludedWhenConsentIsDisabled) { - consent_helper()->SetIsEnabled(false); +TEST_F(ContextualSuggestionsFetcherTest, CredentialsExcluded) { network::ResourceRequest last_resource_request; test_factory()->SetInterceptor( @@ -465,10 +424,7 @@ TEST_F(ContextualSuggestionsFetcherTest, CookiesExcludedWhenConsentIsDisabled) { MockClustersCallback callback; SendAndAwaitResponse(GURL("http://www.article.com/"), &callback); - - int load_flags = last_resource_request.load_flags; - EXPECT_EQ(net::LOAD_DO_NOT_SEND_COOKIES, - load_flags & net::LOAD_DO_NOT_SEND_COOKIES); + EXPECT_FALSE(last_resource_request.allow_credentials); } TEST_F(ContextualSuggestionsFetcherTest, ProtocolError) { |