#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/permissions/permission_auditing_database.h"
#include <memory>
#include "base/check.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "sql/test/scoped_error_expecter.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace permissions {
ElementsAre;
IsEmpty;
namespace {
base::Time TimeFromTimestamp(const int64_t& time) { … }
constexpr ContentSettingsType kTestTypes[] = …;
constexpr char kTestUrl1[] = …;
constexpr char kTestUrl2[] = …;
std::string GetUniqueUrl(int id) { … }
url::Origin GetOrigin(const char* url) { … }
PermissionUsageSession SessionLike(ContentSettingsType type,
const char* url,
const PermissionUsageSession& session) { … }
}
class PermissionAuditingDatabaseTest : public testing::Test { … };
TEST_F(PermissionAuditingDatabaseTest, IsUsageHistorySizeCorrect) { … }
TEST_F(PermissionAuditingDatabaseTest,
IsUsageHistoryDifferentForDifferentPermissionsAndOrigins) { … }
TEST_F(PermissionAuditingDatabaseTest, AreFieldsStoredCorrectlyInUsageHistory) { … }
TEST_F(PermissionAuditingDatabaseTest, UsageHistoryContainsOnlyLastSessions) { … }
TEST_F(PermissionAuditingDatabaseTest, GetLastPermissionUsageTime) { … }
TEST_F(PermissionAuditingDatabaseTest, UpdateEndTime) { … }
TEST_F(PermissionAuditingDatabaseTest, DeleteSessionsBetween) { … }
TEST_F(PermissionAuditingDatabaseTest,
DeleteSessionsBetweenWithUnspecifiedEndTime) { … }
TEST_F(PermissionAuditingDatabaseTest,
DeleteSessionsBetweenWithUnspecifiedStartTime) { … }
TEST_F(PermissionAuditingDatabaseTest,
DeleteSessionsBetweenWithUnspecifiedStartAndEndTime) { … }
TEST_F(PermissionAuditingDatabaseTest,
StorePermissionUsageChecksTimerangeConstraint) { … }
TEST_F(PermissionAuditingDatabaseTest,
StorePermissionUsageDoesntAccpetExistingRecord) { … }
TEST_F(PermissionAuditingDatabaseTest, UpdateEndTimeChecksTimerangeConstraint) { … }
}