#!/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 of learn mode."""

from macaroon.playback import *
import utils

sequence = MacroSequence()

sequence.append(KeyPressAction(0, None, "KP_Insert"))
sequence.append(TypeAction("h"))
sequence.append(KeyReleaseAction(0, None, "KP_Insert"))

sequence.append(PauseAction(2000))
sequence.append(KeyComboAction("F1"))
sequence.append(PauseAction(2000))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "1. Down",
    ["BRAILLE LINE:  ' Before You Begin h2'",
     "     VISIBLE:  ' Before You Begin h2', cursor=2",
     "SPEECH OUTPUT: 'Before You Begin'",
     "SPEECH OUTPUT: 'heading level 2'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "2. Down",
    ["BRAILLE LINE:  ' If you are not yet familiar with the navigation commands provided by your desktop environment, you are encouraged to read that documentation first.'",
     "     VISIBLE:  'If you are not yet familiar with', cursor=1",
     "SPEECH OUTPUT: 'If you are not yet familiar with the navigation commands provided '"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "3. Down",
    ["BRAILLE LINE:  'If you are not yet familiar with the navigation commands provided by your desktop environment, you are encouraged to read that documentation first.'",
     "     VISIBLE:  'If you are not yet familiar with', cursor=1",
     "SPEECH OUTPUT: 'by your desktop environment, you are encouraged to read that '"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "4. Down",
    ["BRAILLE LINE:  'If you are not yet familiar with the navigation commands provided by your desktop environment, you are encouraged to read that documentation first.'",
     "     VISIBLE:  'If you are not yet familiar with', cursor=1",
     "SPEECH OUTPUT: 'documentation first.'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "5. Down",
    ["BRAILLE LINE:  ' Getting Started h2'",
     "     VISIBLE:  ' Getting Started h2', cursor=2",
     "SPEECH OUTPUT: 'Getting Started'",
     "SPEECH OUTPUT: 'heading level 2'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "6. Down",
    ["BRAILLE LINE:  ' Welcome to Cthulhu'",
     "     VISIBLE:  ' Welcome to Cthulhu', cursor=2",
     "SPEECH OUTPUT: 'Welcome to Cthulhu'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "7. Down",
    ["BRAILLE LINE:  ' Welcome to Cthulhu'",
     "     VISIBLE:  ' Welcome to Cthulhu', cursor=2",
     "SPEECH OUTPUT: 'Welcome to Cthulhu'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "8. Down",
    ["BRAILLE LINE:  ' reader'",
     "     VISIBLE:  ' reader', cursor=2",
     "SPEECH OUTPUT: 'reader'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "9. Down",
    ["BRAILLE LINE:  ' The Cthulhu Modifier'",
     "     VISIBLE:  ' The Cthulhu Modifier', cursor=2",
     "SPEECH OUTPUT: 'The Cthulhu Modifier'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "10. Down",
    ["BRAILLE LINE:  ' The Cthulhu Modifier'",
     "     VISIBLE:  ' The Cthulhu Modifier', cursor=2",
     "SPEECH OUTPUT: 'The Cthulhu Modifier'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "11. Down",
    ["BRAILLE LINE:  ' A key that works like Shift,'",
     "     VISIBLE:  ' A key that works like Shift,', cursor=2",
     "SPEECH OUTPUT: 'A key that works like Shift,'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "12. Down",
    ["BRAILLE LINE:  ' Configuration'",
     "     VISIBLE:  ' Configuration', cursor=2",
     "SPEECH OUTPUT: 'Configuration'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "13. Down",
    ["BRAILLE LINE:  ' Configuration'",
     "     VISIBLE:  ' Configuration', cursor=2",
     "SPEECH OUTPUT: 'Configuration'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "14. Down",
    ["BRAILLE LINE:  ' \"Learn\" Mode'",
     "     VISIBLE:  ' \"Learn\" Mode', cursor=2",
     "SPEECH OUTPUT: '\"Learn\" Mode'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "15. Down",
    ["BRAILLE LINE:  ' \"Learn\" Mode'",
     "     VISIBLE:  ' \"Learn\" Mode', cursor=2",
     "SPEECH OUTPUT: '\"Learn\" Mode'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "16. Down",
    ["BRAILLE LINE:  ' Keyboard Layout'",
     "     VISIBLE:  ' Keyboard Layout', cursor=2",
     "SPEECH OUTPUT: 'Keyboard Layout'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "17. Down",
    ["BRAILLE LINE:  ' Keyboard Layout'",
     "     VISIBLE:  ' Keyboard Layout', cursor=2",
     "SPEECH OUTPUT: 'Keyboard Layout'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "18. Down",
    ["BRAILLE LINE:  ' layout'",
     "     VISIBLE:  ' layout', cursor=2",
     "SPEECH OUTPUT: 'layout'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "19. Down",
    ["BRAILLE LINE:  ' CapsLock in Laptop Layout'",
     "     VISIBLE:  ' CapsLock in Laptop Layout', cursor=2",
     "SPEECH OUTPUT: 'CapsLock in Laptop Layout'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Down"))
sequence.append(utils.AssertPresentationAction(
    "20. Down",
    ["BRAILLE LINE:  ' CapsLock in Laptop Layout'",
     "     VISIBLE:  ' CapsLock in Laptop Layout', cursor=2",
     "SPEECH OUTPUT: 'CapsLock in Laptop Layout'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "21. Up",
    ["BRAILLE LINE:  ' CapsLock in Laptop Layout'",
     "     VISIBLE:  ' CapsLock in Laptop Layout', cursor=2",
     "SPEECH OUTPUT: 'CapsLock in Laptop Layout'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "22. Up",
    ["BRAILLE LINE:  ' layout'",
     "     VISIBLE:  ' layout', cursor=2",
     "SPEECH OUTPUT: 'layout'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "23. Up",
    ["BRAILLE LINE:  ' Keyboard Layout'",
     "     VISIBLE:  ' Keyboard Layout', cursor=2",
     "SPEECH OUTPUT: 'Keyboard Layout'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "24. Up",
    ["BRAILLE LINE:  ' Keyboard Layout'",
     "     VISIBLE:  ' Keyboard Layout', cursor=2",
     "SPEECH OUTPUT: 'Keyboard Layout'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "25. Up",
    ["BRAILLE LINE:  ' \"Learn\" Mode'",
     "     VISIBLE:  ' \"Learn\" Mode', cursor=2",
     "SPEECH OUTPUT: '\"Learn\" Mode'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "26. Up",
    ["BRAILLE LINE:  ' \"Learn\" Mode'",
     "     VISIBLE:  ' \"Learn\" Mode', cursor=2",
     "SPEECH OUTPUT: '\"Learn\" Mode'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "27. Up",
    ["BRAILLE LINE:  ' Configuration'",
     "     VISIBLE:  ' Configuration', cursor=2",
     "SPEECH OUTPUT: 'Configuration'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "28. Up",
    ["BRAILLE LINE:  ' Configuration'",
     "     VISIBLE:  ' Configuration', cursor=2",
     "SPEECH OUTPUT: 'Configuration'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "29. Up",
    ["BRAILLE LINE:  ' A key that works like Shift,'",
     "     VISIBLE:  ' A key that works like Shift,', cursor=2",
     "SPEECH OUTPUT: 'A key that works like Shift,'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "30. Up",
    ["BRAILLE LINE:  ' The Cthulhu Modifier'",
     "     VISIBLE:  ' The Cthulhu Modifier', cursor=2",
     "SPEECH OUTPUT: 'The Cthulhu Modifier'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "31. Up",
    ["BRAILLE LINE:  ' The Cthulhu Modifier'",
     "     VISIBLE:  ' The Cthulhu Modifier', cursor=2",
     "SPEECH OUTPUT: 'The Cthulhu Modifier'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "32. Up",
    ["BRAILLE LINE:  ' reader'",
     "     VISIBLE:  ' reader', cursor=2",
     "SPEECH OUTPUT: 'reader'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "33. Up",
    ["BRAILLE LINE:  ' Welcome to Cthulhu'",
     "     VISIBLE:  ' Welcome to Cthulhu', cursor=2",
     "SPEECH OUTPUT: 'Welcome to Cthulhu'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "34. Up",
    ["BRAILLE LINE:  ' Welcome to Cthulhu'",
     "     VISIBLE:  ' Welcome to Cthulhu', cursor=2",
     "SPEECH OUTPUT: 'Welcome to Cthulhu'",
     "SPEECH OUTPUT: 'link'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "35. Up",
    ["BRAILLE LINE:  ' Getting Started h2'",
     "     VISIBLE:  ' Getting Started h2', cursor=2",
     "SPEECH OUTPUT: 'Getting Started'",
     "SPEECH OUTPUT: 'heading level 2'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "36. Up",
    ["BRAILLE LINE:  'documentation first.'",
     "     VISIBLE:  'documentation first.', cursor=1",
     "SPEECH OUTPUT: 'documentation first.'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "37. Up",
    ["BRAILLE LINE:  'by your desktop environment, you are encouraged to read that '",
     "     VISIBLE:  'by your desktop environment, you', cursor=1",
     "SPEECH OUTPUT: 'by your desktop environment, you are encouraged to read that '"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "38. Up",
    ["BRAILLE LINE:  ' If you are not yet familiar with the navigation commands provided '",
     "     VISIBLE:  'If you are not yet familiar with', cursor=1",
     "SPEECH OUTPUT: 'If you are not yet familiar with the navigation commands provided '"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "39. Up",
    ["BRAILLE LINE:  ' Before You Begin h2'",
     "     VISIBLE:  ' Before You Begin h2', cursor=2",
     "SPEECH OUTPUT: 'Before You Begin'",
     "SPEECH OUTPUT: 'heading level 2'"]))

sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Up"))
sequence.append(utils.AssertPresentationAction(
    "40. Up",
    ["BRAILLE LINE:  ' Cthulhu's logo Cthulhu Screen Reader h1'",
     "     VISIBLE:  'Cthulhu's logo Cthulhu Screen Reader h', cursor=1",
     "SPEECH OUTPUT: 'Cthulhu's logo'",
     "SPEECH OUTPUT: ' Cthulhu Screen Reade'",
     "SPEECH OUTPUT: 'heading level 1'"]))

sequence.append(KeyComboAction("<Alt>F4"))
sequence.append(utils.AssertionSummaryAction())
sequence.start()
