#!/usr/bin/env python3
#
# Copyright (c) 2024 Stormux
# Copyright (c) 2010-2012 The Orca Team
# Copyright (c) 2012 Igalia, S.L.
# Copyright (c) 2005-2010 Sun Microsystems Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
# Boston MA  02110-1301 USA.
#
# Fork of Orca Screen Reader (GNOME)
# Original source: https://gitlab.gnome.org/GNOME/orca

"""Test flat review on menubar."""

from macaroon.playback import *
import utils

sequence = MacroSequence()
sequence.append(PauseAction(3000))
sequence.append(KeyComboAction("F6"))
sequence.append(PauseAction(3000))
sequence.append(KeyComboAction("KP_8"))
sequence.append(PauseAction(3000))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("KP_7"))
sequence.append(utils.AssertPresentationAction(
    "1. Review previous line.",
    ["BRAILLE LINE:  'File Edit View Insert Format Styles Table Form Tools Window Help $l'",
     "     VISIBLE:  'File Edit View Insert Format Sty', cursor=1",
     "SPEECH OUTPUT: 'File Edit View Insert Format Styles Table Form Tools Window Help'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("KP_5"))
sequence.append(utils.AssertPresentationAction(
    "2. Review current word.",
    ["BRAILLE LINE:  'File Edit View Insert Format Styles Table Form Tools Window Help $l'",
     "     VISIBLE:  'File Edit View Insert Format Sty', cursor=1",
     "SPEECH OUTPUT: 'File'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("KP_6"))
sequence.append(utils.AssertPresentationAction(
    "3. Review next word.",
    ["BRAILLE LINE:  'File Edit View Insert Format Styles Table Form Tools Window Help $l'",
     "     VISIBLE:  'Edit View Insert Format Styles T', cursor=1",
     "SPEECH OUTPUT: 'Edit'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("KP_6"))
sequence.append(utils.AssertPresentationAction(
    "4. Review next word.",
    ["BRAILLE LINE:  'File Edit View Insert Format Styles Table Form Tools Window Help $l'",
     "     VISIBLE:  'View Insert Format Styles Table ', cursor=1",
     "SPEECH OUTPUT: 'View'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("KP_4"))
sequence.append(utils.AssertPresentationAction(
    "5. Review previous word.",
    ["BRAILLE LINE:  'File Edit View Insert Format Styles Table Form Tools Window Help $l'",
     "     VISIBLE:  'Edit View Insert Format Styles T', cursor=1",
     "SPEECH OUTPUT: 'Edit'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("KP_4"))
sequence.append(utils.AssertPresentationAction(
    "6. Review previous word.",
    ["BRAILLE LINE:  'File Edit View Insert Format Styles Table Form Tools Window Help $l'",
     "     VISIBLE:  'File Edit View Insert Format Sty', cursor=1",
     "SPEECH OUTPUT: 'File'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("KP_2"))
sequence.append(utils.AssertPresentationAction(
    "7. Review current char.",
    ["BRAILLE LINE:  'File Edit View Insert Format Styles Table Form Tools Window Help $l'",
     "     VISIBLE:  'File Edit View Insert Format Sty', cursor=1",
     "SPEECH OUTPUT: 'F'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("KP_2"))
sequence.append(KeyComboAction("KP_2"))
sequence.append(utils.AssertPresentationAction(
    "8. Spell current char.",
    ["BRAILLE LINE:  'File Edit View Insert Format Styles Table Form Tools Window Help $l'",
     "     VISIBLE:  'File Edit View Insert Format Sty', cursor=1",
     "BRAILLE LINE:  'File Edit View Insert Format Styles Table Form Tools Window Help $l'",
     "     VISIBLE:  'File Edit View Insert Format Sty', cursor=1",
     "SPEECH OUTPUT: 'F'",
     "SPEECH OUTPUT: 'foxtrot'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("KP_2"))
sequence.append(KeyComboAction("KP_2"))
sequence.append(KeyComboAction("KP_2"))
sequence.append(utils.AssertPresentationAction(
    "9. Unicode for current char.",
    ["BRAILLE LINE:  'File Edit View Insert Format Styles Table Form Tools Window Help $l'",
     "     VISIBLE:  'File Edit View Insert Format Sty', cursor=1",
     "BRAILLE LINE:  'File Edit View Insert Format Styles Table Form Tools Window Help $l'",
     "     VISIBLE:  'File Edit View Insert Format Sty', cursor=1",
     "BRAILLE LINE:  'File Edit View Insert Format Styles Table Form Tools Window Help $l'",
     "     VISIBLE:  'File Edit View Insert Format Sty', cursor=1",
     "SPEECH OUTPUT: 'F'",
     "SPEECH OUTPUT: 'foxtrot'",
     "SPEECH OUTPUT: 'Unicode 0046'"]))

sequence.append(KeyComboAction("<Alt>F4"))

sequence.append(utils.AssertionSummaryAction())
sequence.start()
