chromium/chrome/browser/screen_ai/main_content_extraction_browsertest.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/screen_ai/screen_ai_install_state.h"
#include "chrome/browser/screen_ai/screen_ai_service_router.h"
#include "chrome/browser/screen_ai/screen_ai_service_router_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/metrics/content/subprocess_metrics_provider.h"
#include "content/public/test/browser_test.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/dns/mock_host_resolver.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "services/screen_ai/buildflags/buildflags.h"
#include "services/screen_ai/public/cpp/utilities.h"
#include "services/screen_ai/public/mojom/screen_ai_service.mojom.h"
#include "ui/accessibility/accessibility_features.h"
#include "ui/accessibility/ax_features.mojom-features.h"

namespace {

#if !BUILDFLAG(USE_FAKE_SCREEN_AI)

const constexpr char* kTestPageRelativeURL =;

// It is expected that the extracted main content from the above url would have
// the text below.
// Since the output is generated using a model that is sensitive to updates and
// rendering detailts, we cannot ensure the entire generated text is a fixed
// string, but at least this longer paragraph is expected to be in it.
const constexpr char* kExpectedText =;

// Looks in to the given `ids` of the `tree_nodes` and returns true if either of
// them or their children have `kExpectedText`.
bool HasExpectedText(const std::vector<ui::AXNodeData>& tree_nodes,
                     std::vector<ui::AXNodeID> ids) {}

#endif

}  // namespace

namespace screen_ai {

class MainContentExtractionTest : public InProcessBrowserTest {};

// Tests that calling main content extraction without content gets replied.
IN_PROC_BROWSER_TEST_F(MainContentExtractionTest, EmptyInput) {}

// Fake library always returns empty.
#if !BUILDFLAG(USE_FAKE_SCREEN_AI)

// Tests main content extraction on a simple page with content.
IN_PROC_BROWSER_TEST_F(MainContentExtractionTest, RequestWithContent) {}

// Test requesting several extractions without waiting for the previous ones to
// finish.
IN_PROC_BROWSER_TEST_F(MainContentExtractionTest, MultipleRequests) {}
#endif  //! BUILDFLAG(USE_FAKE_SCREEN_AI)

}  // namespace screen_ai