chromium/components/page_info/core/about_this_site_service_unittest.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/page_info/core/about_this_site_service.h"

#include <memory>
#include <string_view>

#include "base/memory/raw_ptr.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "components/optimization_guide/core/optimization_guide_decision.h"
#include "components/optimization_guide/proto/common_types.pb.h"
#include "components/page_info/core/about_this_site_validation.h"
#include "components/page_info/core/features.h"
#include "components/page_info/core/proto/about_this_site_metadata.pb.h"
#include "components/search_engines/prepopulated_engines.h"
#include "components/search_engines/search_engines_test_environment.h"
#include "components/search_engines/template_url_service.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace page_info {
_;
Invoke;
Return;

AboutThisSiteStatus;
AboutThisSiteInteraction;
DecisionWithMetadata;
OptimizationGuideDecision;
OptimizationMetadata;

class MockAboutThisSiteService : public AboutThisSiteService {};

class MockTabHelper : public AboutThisSiteService::TabHelper {};

proto::AboutThisSiteMetadata CreateValidMetadata() {}

proto::AboutThisSiteMetadata CreateInvalidDescription() {}

OptimizationGuideDecision ReturnDescription(const GURL& url,
                                            OptimizationMetadata* metadata) {}

OptimizationGuideDecision ReturnInvalidDescription(
    const GURL& url,
    OptimizationMetadata* metadata) {}

OptimizationGuideDecision ReturnNoResult(const GURL& url,
                                         OptimizationMetadata* metadata) {}

OptimizationGuideDecision ReturnUnknown(const GURL& url,
                                        OptimizationMetadata* metadata) {}

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

// Tests that correct proto messages are accepted.
TEST_P(AboutThisSiteServiceTest, ValidResponse) {}

// Tests the language specific feature check.
TEST_P(AboutThisSiteServiceTest, FeatureCheck) {}

// Tests that incorrect proto messages are discarded.
TEST_P(AboutThisSiteServiceTest, InvalidResponse) {}

// Tests that no response is handled.
TEST_P(AboutThisSiteServiceTest, NoResponse) {}

// Tests that unknown response is handled.
TEST_P(AboutThisSiteServiceTest, Unknown) {}

// Tests that ATP not shown when Google is not set as DSE
TEST_P(AboutThisSiteServiceTest, NotShownWhenNoGoogleDSE) {}

// Tests that IP addresses and localhost are handled.
TEST_P(AboutThisSiteServiceTest, LocalHosts) {}

// Tests the local creation of the Diner URL for navigation.
TEST_P(AboutThisSiteServiceTest, CreateMoreAboutUrlForNavigation) {}

// Tests the local creation of the Diner URL for navigation with anchor.
TEST_P(AboutThisSiteServiceTest, CreateMoreAboutUrlForNavigationWithAnchor) {}

// Tests the local creation of the Diner URL for navigation from an origin with
// path.
TEST_P(AboutThisSiteServiceTest, CreateMoreAboutUrlForNavigationWithPath) {}

// Tests the local creation of the Diner URL for navigation from an invalid
// origin.
TEST_P(AboutThisSiteServiceTest, CreateMoreAboutUrlForNavigationInvalid) {}

// Tests the local creation of the Diner URL for navigation from an invalid
// origin (blank).
TEST_P(AboutThisSiteServiceTest, CreateMoreAboutUrlForNavigationInvalidBlank) {}

// Tests the local creation of the Diner URL for navigation from an invalid
// origin (file).
TEST_P(AboutThisSiteServiceTest, CreateMoreAboutUrlForNavigationInvalidFile) {}

// Test with TabHelper based fetching enabled and disabled.
INSTANTIATE_TEST_SUITE_P();

}  // namespace page_info