#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/dom_distiller/content/browser/distillable_page_utils.h"
#include <cstring>
#include <memory>
#include <optional>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/dom_distiller/core/dom_distiller_switches.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace dom_distiller {
namespace {
_;
AllOf;
Field;
InvokeWithoutArgs;
Not;
Optional;
Pointee;
SizeIs;
const char kSimpleArticlePath[] = …;
const char kSimpleArticleIFramePath[] = …;
const char kArticlePath[] = …;
const char kNonArticlePath[] = …;
const char* kAllPaths[] = …;
class MockObserver : public DistillabilityObserver { … };
const auto kWaitAfterLastCall = …;
const auto kWaitNoExpectedCall = …;
}
template <const char Option[]>
class TestOption : public InProcessBrowserTest { … };
MATCHER(IsDistillable,
"Result " + std::string(negation ? "isn't" : "is") + " distillable") { … }
MATCHER(IsLast, "Result " + std::string(negation ? "isn't" : "is") + " last") { … }
MATCHER(IsMobileFriendly,
"Result " + std::string(negation ? "isn't" : "is") +
" mobile friendly") { … }
DistillablePageUtilsBrowserTestAlways;
IN_PROC_BROWSER_TEST_F(DistillablePageUtilsBrowserTestAlways,
AllRealPathsCallObserverOnceWithIsDistillable) { … }
IN_PROC_BROWSER_TEST_F(DistillablePageUtilsBrowserTestAlways,
LocalUrlsDoNotCallObserver) { … }
DistillablePageUtilsBrowserTestNone;
IN_PROC_BROWSER_TEST_F(DistillablePageUtilsBrowserTestNone, NeverCallObserver) { … }
DistillablePageUtilsBrowserTestOGArticle;
IN_PROC_BROWSER_TEST_F(DistillablePageUtilsBrowserTestOGArticle,
ArticlesCallObserverOnceWithIsDistillable) { … }
IN_PROC_BROWSER_TEST_F(DistillablePageUtilsBrowserTestOGArticle,
NonArticleCallsObserverOnceWithIsNotDistillable) { … }
DistillablePageUtilsBrowserTestAdaboost;
IN_PROC_BROWSER_TEST_F(DistillablePageUtilsBrowserTestAdaboost,
SimpleArticlesCallObserverTwiceWithIsDistillable) { … }
IN_PROC_BROWSER_TEST_F(DistillablePageUtilsBrowserTestAdaboost,
NonArticleCallsObserverTwiceWithIsNotDistillable) { … }
DistillablePageUtilsBrowserTestAllArticles;
IN_PROC_BROWSER_TEST_F(DistillablePageUtilsBrowserTestAllArticles,
SimpleArticlesCallObserverTwiceWithIsDistillable) { … }
IN_PROC_BROWSER_TEST_F(DistillablePageUtilsBrowserTestAllArticles,
NonArticlesCallObserverTwiceWithIsNotDistillable) { … }
#if BUILDFLAG(IS_LINUX) && defined(MEMORY_SANITIZER)
#define MAYBE_ObserverNotCalledAfterRemoval …
#else
#define MAYBE_ObserverNotCalledAfterRemoval …
#endif
IN_PROC_BROWSER_TEST_F(DistillablePageUtilsBrowserTestAllArticles,
MAYBE_ObserverNotCalledAfterRemoval) { … }
}