// Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_BROWSER_ATTRIBUTION_REPORTING_SQL_QUERY_PLAN_TEST_UTIL_H_ #define CONTENT_BROWSER_ATTRIBUTION_REPORTING_SQL_QUERY_PLAN_TEST_UTIL_H_ #include <iosfwd> #include <optional> #include <string> #include <vector> #include "base/files/file_path.h" #include "base/types/expected.h" #include "testing/gmock/include/gmock/gmock.h" namespace content { // TODO(crbug.com/40252981): Move these utilities to //sql once they are trialed // in the attribution_reporting directory. // This type wraps a returned sqlite query plan, as returned from EXPLAIN QUERY // PLAN. struct SqlQueryPlan { … }; // Only for diagnostic messages, not for test expectations, as the underlying // query plan format is fragile and should not be relied upon. std::ostream& operator<<(std::ostream&, const SqlQueryPlan&); testing::Matcher<SqlQueryPlan> UsesIndex(std::string name, std::vector<std::string> columns = {}); testing::Matcher<SqlQueryPlan> UsesCoveringIndex( std::string name, std::vector<std::string> columns = {}); testing::Matcher<SqlQueryPlan> UsesPrimaryKey(); // Enum explaining why a full scan on a query is needed. For use when annotating // tests which use queries that perform a full table scan. enum class SqlFullScanReason { … }; // This class runs the sqlite_dev_shell to call EXPLAIN QUERY PLAN on provided // queries, in the context of the passed in `db_path`. class SqlQueryPlanExplainer { … }; std::ostream& operator<<(std::ostream&, SqlQueryPlanExplainer::Error); } // namespace content #endif // CONTENT_BROWSER_ATTRIBUTION_REPORTING_SQL_QUERY_PLAN_TEST_UTIL_H_