#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test of AppData support.

cat <<EOF > xg-gs-1-empty.appdata.xml
<?xml version="1.0"?>
<component type="desktop"/>
EOF

: ${XGETTEXT=xgettext}
${XGETTEXT} -o xg-gs-1.pot xg-gs-1-empty.appdata.xml 2>/dev/null
test $? = 0 || {
  echo "Skipping test: xgettext was built without AppData support"
  Exit 77
}

cat <<EOF > xg-gs-1.appdata.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2013 First Lastname <your@email.com> -->
<component type="desktop">
  <id>gnome-power-statistics.desktop</id>
  <metadata_license>CC0-1.0</metadata_license>
  <project_license>GPL-2.0+ and GFDL-1.3</project_license>
  <name>Power Statistics</name>
  <summary>Observe power management</summary>
  <description>
    <p>
      Power Statistics is a program used to view historical and current battery
      information and will show programs running on your computer using power.
    </p>
    <p>Example list:</p>
    <ul>
      <li>First item</li>
      <li>Second item</li>
    </ul>
    <p>
      You probably only need to install this application if you are having problems
      with your laptop battery, or are trying to work out what programs are using
      significant amounts of power.
    </p>
  </description>
  <screenshots>
    <screenshot type="default">
      <image>http://www.hughsie.com/en_US/main.png</image>
      <caption>The main window showing the application in action</caption>
    </screenshot>
    <screenshot>
      <image>http://www.hughsie.com/en_US/preferences.png</image>
      <caption>The preferences window where you can change the defaults</caption>
    </screenshot>
  </screenshots>
  <url type="homepage">http://www.gnome.org/projects/en_US/gnome-power-manager</url>
  <updatecontact>gnome-power-manager-list@gnome.org</updatecontact>
  <project_group>GNOME</project_group>
</component>
EOF

: ${XGETTEXT=xgettext}
${XGETTEXT} --add-comments -o - xg-gs-1.appdata.xml | grep -v 'POT-Creation-Date' > xg-gs-1.pot || Exit 1

cat <<EOF > xg-gs-1.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: xg-gs-1.appdata.xml:7
msgid "Power Statistics"
msgstr ""

#: xg-gs-1.appdata.xml:8
msgid "Observe power management"
msgstr ""

#: xg-gs-1.appdata.xml:10
msgid ""
"Power Statistics is a program used to view historical and current battery "
"information and will show programs running on your computer using power."
msgstr ""

#: xg-gs-1.appdata.xml:14
msgid "Example list:"
msgstr ""

#: xg-gs-1.appdata.xml:16
msgid "First item"
msgstr ""

#: xg-gs-1.appdata.xml:17
msgid "Second item"
msgstr ""

#: xg-gs-1.appdata.xml:19
msgid ""
"You probably only need to install this application if you are having "
"problems with your laptop battery, or are trying to work out what programs "
"are using significant amounts of power."
msgstr ""

#: xg-gs-1.appdata.xml:28
msgid "The main window showing the application in action"
msgstr ""

#: xg-gs-1.appdata.xml:32
msgid "The preferences window where you can change the defaults"
msgstr ""
EOF

: ${DIFF=diff}
${DIFF} xg-gs-1.ok xg-gs-1.pot
result=$?

exit $result
