#include <map>
#include <optional>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/accessibility/accessibility_labels_service.h"
#include "chrome/browser/accessibility/accessibility_labels_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/language/core/browser/pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/browser_context.h"
#include "content/public/common/content_features.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/scoped_accessibility_mode_override.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/request_handler_util.h"
#include "services/image_annotation/public/cpp/image_processor.h"
#include "services/image_annotation/public/mojom/image_annotation.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/accessibility/accessibility_features.h"
#include "ui/accessibility/ax_enum_util.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node.h"
#include "ui/accessibility/ax_tree.h"
#include "url/gurl.h"
constexpr base::FilePath::CharType kDocRoot[] = …);
namespace {
void DescribeNodesWithAnnotations(const ui::AXNode& node,
std::vector<std::string>* descriptions) { … }
std::vector<std::string> DescribeNodesWithAnnotations(
const ui::AXTreeUpdate& tree_update) { … }
bool HasNodeWithAnnotationStatus(const ui::AXTreeUpdate& tree_update,
ax::mojom::ImageAnnotationStatus status) { … }
class FakeAnnotator : public image_annotation::mojom::Annotator { … };
bool FakeAnnotator::return_ocr_results_ = …;
bool FakeAnnotator::return_label_results_ = …;
std::map<std::string, std::string> FakeAnnotator::custom_label_result_mapping_;
std::optional<image_annotation::mojom::AnnotateImageError>
FakeAnnotator::return_error_code_;
class FakeImageAnnotationService
: public image_annotation::mojom::ImageAnnotationService { … };
void BindImageAnnotatorService(
mojo::PendingReceiver<image_annotation::mojom::ImageAnnotationService>
receiver) { … }
}
class ImageAnnotationBrowserTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(ImageAnnotationBrowserTest,
AnnotateImageInAccessibilityTree) { … }
IN_PROC_BROWSER_TEST_F(ImageAnnotationBrowserTest, ImagesInLinks) { … }
IN_PROC_BROWSER_TEST_F(ImageAnnotationBrowserTest, ImagesInIframe) { … }
IN_PROC_BROWSER_TEST_F(ImageAnnotationBrowserTest, AugmentImageNames) { … }
IN_PROC_BROWSER_TEST_F(ImageAnnotationBrowserTest, AugmentImageNamesInLinks) { … }
IN_PROC_BROWSER_TEST_F(ImageAnnotationBrowserTest, ImageDoc) { … }
IN_PROC_BROWSER_TEST_F(ImageAnnotationBrowserTest, ImageUrl) { … }
IN_PROC_BROWSER_TEST_F(ImageAnnotationBrowserTest, NoAnnotationsAvailable) { … }
IN_PROC_BROWSER_TEST_F(ImageAnnotationBrowserTest, AnnotationError) { … }
IN_PROC_BROWSER_TEST_F(ImageAnnotationBrowserTest, ImageWithSrcSet) { … }
IN_PROC_BROWSER_TEST_F(ImageAnnotationBrowserTest,
DISABLED_AnnotationLanguages) { … }
#if BUILDFLAG(IS_CHROMEOS)
#define MAYBE_DoesntAnnotateInternalPages …
#else
#define MAYBE_DoesntAnnotateInternalPages …
#endif
IN_PROC_BROWSER_TEST_F(ImageAnnotationBrowserTest,
MAYBE_DoesntAnnotateInternalPages) { … }
IN_PROC_BROWSER_TEST_F(ImageAnnotationBrowserTest,
TutorMessageOnlyOnFirstImage) { … }
IN_PROC_BROWSER_TEST_F(ImageAnnotationBrowserTest,
TutorMessageOnlyOnFirstImageInLinks) { … }