#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <stddef.h>
#include <stdint.h>
#include <cstdio>
#include <memory>
#include <string>
#include <vector>
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/process/process_handle.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "base/timer/mock_timer.h"
#include "components/visitedlink/browser/partitioned_visitedlink_writer.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
#include "components/visitedlink/browser/visitedlink_event_listener.h"
#include "components/visitedlink/browser/visitedlink_writer.h"
#include "components/visitedlink/common/visitedlink.mojom.h"
#include "components/visitedlink/common/visitedlink_common.h"
#include "components/visitedlink/core/visited_link.h"
#include "components/visitedlink/renderer/visitedlink_reader.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/test_utils.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "url/gurl.h"
BrowserThread;
MockRenderProcessHost;
RenderViewHostTester;
namespace content {
class SiteInstance;
}
namespace visitedlink {
namespace {
URLs;
const char kTestPrefix[] = …;
constexpr int kTestCount = …;
GURL TestURL(int i) { … }
std::vector<VisitedLinkReader*> g_readers;
class TestVisitedLinkDelegate : public VisitedLinkDelegate { … };
void TestVisitedLinkDelegate::RebuildTable(
const scoped_refptr<URLEnumerator>& enumerator) { … }
void TestVisitedLinkDelegate::BuildVisitedLinkTable(
const scoped_refptr<VisitedLinkEnumerator>& enumerator) { … }
void TestVisitedLinkDelegate::AddURLForRebuild(const GURL& url) { … }
void TestVisitedLinkDelegate::AddVisitedLinkForRebuild(
const VisitedLink& link) { … }
class TestURLIterator : public VisitedLinkWriter::URLIterator { … };
TestURLIterator::TestURLIterator(const URLs& urls)
: … { … }
const GURL& TestURLIterator::NextURL() { … }
bool TestURLIterator::HasNextURL() const { … }
class TestVisitedLinkIterator
: public PartitionedVisitedLinkWriter::VisitedLinkIterator { … };
TestVisitedLinkIterator::TestVisitedLinkIterator(
const std::vector<VisitedLink>& links)
: … { … }
const VisitedLink& TestVisitedLinkIterator::NextVisitedLink() { … }
bool TestVisitedLinkIterator::HasNextVisitedLink() const { … }
}
class TrackingVisitedLinkEventListener
: public PartitionedVisitedLinkWriter::Listener,
public VisitedLinkWriter::Listener { … };
class VisitedLinkTest : public testing::Test { … };
TEST_F(VisitedLinkTest, DatabaseIO) { … }
TEST_F(VisitedLinkTest, DatabaseIOAddURLs) { … }
TEST_F(VisitedLinkTest, Delete) { … }
TEST_F(VisitedLinkTest, BigDelete) { … }
TEST_F(VisitedLinkTest, DeleteAll) { … }
TEST_F(VisitedLinkTest, Resizing) { … }
TEST_F(VisitedLinkTest, Rebuild) { … }
TEST_F(VisitedLinkTest, BigImport) { … }
TEST_F(VisitedLinkTest, Listener) { … }
TEST_F(VisitedLinkTest, HashRangeWraparound) { … }
TEST_F(VisitedLinkTest, ResizeErrorHandling) { … }
enum TestMode { … };
class PartitionedVisitedLinkTest
: public testing::Test,
public ::testing::WithParamInterface<TestMode> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(PartitionedVisitedLinkTest, BuildPartitionedTable) { … }
TEST_P(PartitionedVisitedLinkTest, BuildPartitionedTableWithSelfLinks) { … }
TEST_P(PartitionedVisitedLinkTest, NotVisitedEmptyDB) { … }
TEST_P(PartitionedVisitedLinkTest, NotVisitedSomeFieldsMatch) { … }
TEST_P(PartitionedVisitedLinkTest, AddAndDelete) { … }
TEST_P(PartitionedVisitedLinkTest, AddAndDeleteSelfLink) { … }
TEST_P(PartitionedVisitedLinkTest, DoesNotAddSubframeSelfLinks) { … }
TEST_P(PartitionedVisitedLinkTest, DeleteWithCollisions) { … }
TEST_P(PartitionedVisitedLinkTest, DeleteAll) { … }
TEST_P(PartitionedVisitedLinkTest, Resizing) { … }
TEST_P(PartitionedVisitedLinkTest, HashRangeWraparound) { … }
TEST_P(PartitionedVisitedLinkTest, Listener) { … }
class VisitCountingContext : public mojom::VisitedLinkNotificationSink { … };
class VisitRelayingRenderProcessHost : public MockRenderProcessHost { … };
class VisitedLinkRenderProcessHostFactory
: public content::RenderProcessHostFactory { … };
class VisitedLinkEventsTest : public content::RenderViewHostTestHarness { … };
TEST_F(VisitedLinkEventsTest, Coalescence) { … }
TEST_F(VisitedLinkEventsTest, Basics) { … }
TEST_F(VisitedLinkEventsTest, TabVisibility) { … }
TEST_F(VisitedLinkEventsTest, IgnoreRendererCreationFromDifferentContext) { … }
class PartitionedVisitedLinkEventsTest
: public content::RenderViewHostTestHarness { … };
TEST_F(PartitionedVisitedLinkEventsTest, Coalescence) { … }
TEST_F(PartitionedVisitedLinkEventsTest, Basics) { … }
TEST_F(PartitionedVisitedLinkEventsTest, TabVisibility) { … }
TEST_F(PartitionedVisitedLinkEventsTest,
IgnoreRendererCreationFromDifferentContext) { … }
class VisitedLinkCompletelyResetEventTest : public VisitedLinkEventsTest { … };
TEST_F(VisitedLinkCompletelyResetEventTest, LoadTable) { … }
}