#!/bin/sh
set -eu
# Compile only schemas shipped by the standalone viewer and its common package.
# This remains a regression check even if font-manager is already installed.
mkdir -p "$AUTOPKGTEST_TMP/schemas"
for package in font-manager-common font-viewer; do
    dpkg-query -L "$package" | while IFS= read -r file; do
        case "$file" in
            /usr/share/glib-2.0/schemas/*.gschema.xml)
                cp "$file" "$AUTOPKGTEST_TMP/schemas/"
                ;;
        esac
    done
done
glib-compile-schemas --strict "$AUTOPKGTEST_TMP/schemas"
export GSETTINGS_SCHEMA_DIR="$AUTOPKGTEST_TMP/schemas"
export GSETTINGS_BACKEND=memory
mode=$(gsettings get com.github.FontManager.FontViewer preview-mode)
test "$mode" = "'waterfall'"
gsettings range com.github.FontManager.FontViewer preview-mode
gsettings list-keys com.github.FontManager.FontViewer
