예제 #1
0
def stepCheckRandomNotesOnStatusBar(test, device):
    expectedText = _("Total", device) + ": %s " % test['noteCount']
    text = app.search.status.getText(device)
    test.fail(expectedText in text,
              "Status bar text does not contain: '%s'" % expectedText)
예제 #2
0
    def __init__(self, *path):
        Widget.__init__(self, *path)

        self.define("toolbar", Widget(filler(), toolbar()))
        self.define("toolbar.Delete", Button(button__(_("Delete"))))
        self.define("text", Entry(filler(), scrollpane(), text()))
예제 #3
0
                           stepClickButton(button='8'),
                           stepCalculateResult(result="165"),
                           description="Calculate 823 - 658")

caseMultiplication = TestCase(stepClickButton(button='4'),
                              stepClickButton(button='6'),
                              stepClickButton(button='2'),
                              stepClickButton(button='*'),
                              stepClickButton(button='8'),
                              stepClickButton(button='5'),
                              stepClickButton(button='7'),
                              stepCalculateResult(result="395934"),
                              description="Calculate 462 * 857")

caseDivision = TestCase(stepClickButton(button='5'),
                        stepClickButton(button='6'),
                        stepClickButton(button='/'),
                        stepClickButton(button='8'),
                        stepCalculateResult(result='7'),
                        description="Calculate 56 / 8")

caseMalformed = TestCase(stepClickButton(button='1'),
                        stepClickButton(button='0'),
                        stepClickButton(button='%'),
                        stepClickButton(button='2'),
                        stepClickButton(button='9'),
                        stepCalculateResult(result="10%29",
                                            status=_("Malformed expression")),
                        description="Calculate 10 % 29")

예제 #4
0
class Tomboy(Model):
    '''
    Model of Tomboy application
    '''

    root = App(
        "tomboy --search", searcher("AT-SPI"),
        structure(role="APPLICATION",
                  searchers=(frame(_("Search All Notes")), )))
    #Search window
    #    Menu
    root.define("search", Widget(frame(_("Search All Notes"))))
    root.define("search.menu", Widget(menubar__()))
    root.define("search.menu.File", Menu(menu(_("File"))))
    root.define("search.menu.File.New", MenuItem(menuitem(_("New"))))
    root.define("search.menu.File.Notebooks", Menu(menu(_("Notebooks"))))
    root.define("search.menu.File.Notebooks.NewNotebook",
                MenuItem(menuitem(_("New Notebook..."))))
    root.define("search.menu.File.Open", MenuItem(menuitem(_("Open..."))))
    root.define("search.menu.File.Close", MenuItem(menuitem(_("Close"))))
    root.define("search.menu.File.Quit", MenuItem(menuitem(_("Quit"))))
    root.define("search.menu.Edit", Menu(menu(_("Edit"))))
    root.define("search.menu.Edit.Preferences",
                MenuItem(menuitem(_("Preferences"))))

    #    Notes
    root.define(
        "search.noteList",
        List(
            splitpane__(),
            structure(role="SCROLL_PANE",
                      searchers=(tablecolumnheader__(_("Note")), )), table()))
    root.define(
        "search.notebookList",
        List(
            splitpane__(),
            structure(role="SCROLL_PANE",
                      searchers=(tablecolumnheader__(_("Notebooks")), )),
            table()))
    #    Input
    root.define(
        "search.input",
        Widget(filler(), filler(),
               structure(role="FILLER", searchers=(button__(), text__()))))
    root.define("search.input.text", Entry(text__()))
    root.define("search.input.menu", SearchMenu(combobox__(), menu()))
    #    Status bar
    root.define("search.status", Widget(filler(), filler(), statusbar()))

    #Note windows
    root.define("notes", Notes())

    #Preferences dialog
    root.define("preferences", Dialog(dialog(_("Tomboy Preferences"))))
    root.define("preferences.Close", Button(button__(_("Close"))))
    root.define("preferences.tabs", Widget(pagetablist__()))
    root.define("preferences.tabs.Editing", Widget(pagetab(_("Editing"))))
    root.define("preferences.tabs.Editing.OpenNewNoteTemplate",
                Button(button__(_("Open New Note Template"))))
    root.define("preferences.tabs.Hotkeys", Widget(pagetab(_("Hotkeys"))))

    #Question dialog
    root.define(
        "question",
        Dialog(structure(role="DIALOG", searchers=(icon__(_("Question")), ))))
    root.define("question.Delete", Button(button__(_("Delete"))))
    root.define("question.Cancel", Button(button__(_("Cancel"))))

    # New notebook dialog
    root.define(
        "newNotebook",
        Dialog(
            structure(role="DIALOG",
                      searchers=(label__("&.*" + _("Create a new notebook") +
                                         ".*"), ))))
    root.define("newNotebook.text", Entry(text__()))
    root.define("newNotebook.Create", Button(button__(_("Create"))))
    root.define("newNotebook.Cancel", Button(button__(_("Cancel"))))

    def kill(self, device):
        '''
        Kills the Tomboy application.

        :param device: A device to perform the operation on
        :type device: tadek.connection.device.Device
        :return: True if successful or there is nothing to kill, False otherwise
        :rtype: boolean
        '''
        pids = self.systemCommand(device, "pgrep tomboy")[1]
        if pids:
            self.systemCommand(device, "kill %s" % pids)
            return self.isClosed(device)
        return True

    def removeSettings(self, device):
        '''
        Removes configuration files of Tomboy application from user's home

        :param device: A device to perform the operation on
        :type device: tadek.connection.device.Device
        :return: True if successful or there is nothing to remove, False
            otherwise
        :rtype: boolean
        '''
        path = "~/.local/share/tomboy"
        self.systemCommand(device, "rm -R %s/*" % path)
        lsOut = self.systemCommand(device, "ls %s -1 | wc -l" % path)[1]
        return not (lsOut.strip() != "0")
예제 #5
0
class BasicSuite(TestSuite):

    description = "Tests basic functionalities of the Tomboy application"

    def setUpSuite(self, test, device):
        test.fail(app.kill(device), "Failed to kill Tomboy application")

    def setUpCase(self, test, device):
        test.fail(app.removeSettings(device),
                  "Failed to remove settings of Tomboy application")
        test.fail(
            app.launch(device),
            "Failed to execute command that launches Tomboy application")
        test.fail(app.isOpen(device), "Tomboy application did not run")

    def tearDownCase(self, test, device):
        try:
            test.fail(app.search.menu.File.Quit.click(device),
                      "Failed to click File/Quit")
            test.fail(
                app.isClosed(device),
                "Tomboy application did not close after clicking File/Quit")
        finally:
            test.fail(app.kill(device), "Failed to kill Tomboy application")

    caseSearchWindow = TestCase(
        stepCheckSearchWindow(),
        description="Checks is Search window opens on startup")

    caseAddNote = TestCase(stepAddNewNote(),
                           stepCountNoteListEntries(count=1),
                           stepFindNoteOnList(name=_("New Note") + " 1"),
                           description="Adds a note")

    caseDeleteNote = TestCase(stepAddNewNote(),
                              stepCountNoteListEntries(count=1),
                              stepFindNoteOnList(name=_("New Note") + " 1"),
                              stepDeleteNote(name=_("New Note") + " 1"),
                              stepCountNoteListEntries(count=0),
                              description="Adds a note")

    caseNoteText = TestCase(stepAddNewNote(text="text " * 10),
                            description="Enters a text in note's window")

    caseNoteTitle = TestCase(stepAddNewNote(text="title\n" + "text " * 10),
                             stepFindNoteOnList(name="title"),
                             stepCountNoteListEntries(count=1),
                             description="Sets title of new note")

    caseAddMoreNotes = TestCase(stepAddNewNote(text="note 1\n" + "text " * 10),
                                stepAddNewNote(text="note 2\n" + "text " * 10),
                                stepAddNewNote(text="note 3\n" + "text " * 10),
                                stepCountNoteListEntries(count=3),
                                stepFindNoteOnList(name="note 1"),
                                stepFindNoteOnList(name="note 2"),
                                stepFindNoteOnList(name="note 3"),
                                description="Adds three new notes")

    caseAddRandomNumberOfNotes = TestCase(
        stepAddRandomNotes(),
        stepCheckRandomNotesOnList(),
        stepCheckRandomNotesOnStatusBar(),
        description="Adds a random number of notes")

    caseSearchNotes = TestCase(
        stepAddNewNote(text="yellow blue\n" + "olive red " * 10),
        stepAddNewNote(text="brown green\n" + "black pink " * 10),
        stepAddNewNote(text="black white\n" + "orange yellow " * 10),
        stepCountNoteListEntries(count=3),
        stepFindNoteOnList(name="yellow blue"),
        stepFindNoteOnList(name="brown green"),
        stepFindNoteOnList(name="black white"),
        stepEnterFilterText(text="yellow"),
        stepFindNoteOnList(name="yellow blue"),
        stepFindNoteOnList(name="black white"),
        stepEnterFilterText(text="black"),
        stepFindNoteOnList(name="brown green"),
        stepFindNoteOnList(name="black white"),
        description="Searches notes")

    caseAddNotebook = TestCase(stepCountNotebookListEntries(count=2),
                               stepFindNotebookOnList(name=_("All Notes")),
                               stepFindNotebookOnList(name=_("Unfiled Notes")),
                               stepNewNotebook(name="dummy notebook"),
                               stepCountNotebookListEntries(count=3),
                               stepFindNotebookOnList(name="dummy notebook"),
                               description="Adds a new notebook")

    caseSearchHistory = TestCase(
        stepCheckSearchHistory(list=[]),
        stepEnterFilterText(text="first"),
        stepEnterFilterText(text="second"),
        stepEnterFilterText(text="third"),
        stepCheckSearchHistory(list=["third", "second", "first"]),
        desctiption="Checks search history")

    caseNoteTemplate = TestCase(
        stepOpenPreferences(),
        stepOpenNewNoteTemplate(expectedName=_("New Note Template")),
        stepSetNoteText(name=_("New Note Template"),
                        text=_("New Note Template") + "\n" + "text 123"),
        stepAddNewNote(),
        stepCheckNoteText(name="&" + _("New Note") + " [0-9]+.*",
                          text="&" + _("New Note") + " [0-9]+\ntext 123"),
        description="Sets template for new notes")

    caseNotesPersistance = TestCase(
        stepAddNewNote(text="note 1\n" + "text " * 10),
        stepAddNewNote(text="note 2\n" + "text " * 10),
        stepAddNewNote(text="note 3\n" + "text " * 10),
        stepRestartTomboy(),
        stepCountNoteListEntries(count=3),
        stepFindNoteOnList(name="note 1"),
        stepFindNoteOnList(name="note 2"),
        stepFindNoteOnList(name="note 3"),
        description="Adds three new notes and checks if they are present after "
        "restart")
예제 #6
0
class Calculator(Model):
    root = App("gcalctool", searcher("AT-SPI"), application("gcalctool"))
    # Menu
    root.define("menu", Widget(filler__(), menubar()))
    root.define("menu.Calculator", Menu(menu(_("Calculator"))))
    root.define("menu.Calculator.Copy", MenuItem(menuitem(_("Copy"))))
    root.define("menu.Calculator.Paste", MenuItem(menuitem(_("Paste"))))
    root.define("menu.Calculator.Quit", MenuItem(menuitem(_("Quit"))))
    root.define("menu.View", Menu(menu(_("View"))))
    root.define("menu.View.Basic", MenuItem(radiomenuitem(_("Basic"))))
    root.define("menu.View.Advanced", MenuItem(radiomenuitem(_("Advanced"))))
    root.define("menu.View.Financial", MenuItem(radiomenuitem(_("Financial"))))
    root.define("menu.View.Scientific",
                MenuItem(radiomenuitem(_("Scientific"))))
    root.define("menu.View.Programming",
                MenuItem(radiomenuitem(_("Programming"))))
    root.define("menu.Help", Menu(menu(_("Help"))))
    root.define("menu.Help.Contents", MenuItem(menuitem(_("Contents"))))
    root.define("menu.Help.About", MenuItem(menuitem(_("About"))))
    # Display
    root.define("display", Widget(viewport__()))
    root.define("display.entry", Entry(searcher__(role="EDITBAR")))
    root.define("display.status", Widget(text__()))
    # Views
    root.define("buttons", Widget(filler__(), panel(count=6)))
    root.define("buttons.Zero", Button(button__('0')))
    root.define("buttons.One", Button(button__('1')))
    root.define("buttons.Two", Button(button__('2')))
    root.define("buttons.Three", Button(button__('3')))
    root.define("buttons.Four", Button(button__('4')))
    root.define("buttons.Five", Button(button__('5')))
    root.define("buttons.Six", Button(button__('6')))
    root.define("buttons.Seven", Button(button__('7')))
    root.define("buttons.Eight", Button(button__('8')))
    root.define("buttons.Nine", Button(button__('9')))
    root.define("buttons.Point", Button(button__('.')))
    root.define("buttons.Add", Button(button__('+')))
    root.define("buttons.Subtract", Button(button__('−')))
    root.define("buttons.Multiply", Button(button__('×')))
    root.define("buttons.Divide", Button(button__('÷')))
    root.define("buttons.Percentage", Button(button__('%')))
    root.define("buttons.Calculate", Button(button__('=')))
    root.define("buttons.Clear", Button(button__(_("Clr"))))
    root.define("view", Widget())
    root.define("view.Basic", Widget(frame(_("Calculator"))))
    root.define("view.Advanced",
                Widget(frame(_("Calculator") + " —" + _(" Advanced"))))
    root.define("view.Financial",
                Widget(frame(_("Calculator") + " —" + _(" Financial"))))
    root.define("view.Scientific",
                Widget(frame(_("Calculator") + " —" + _(" Scientific"))))
    root.define("view.Programming",
                Widget(frame(_("Calculator") + " —" + _(" Programming"))))
    # Dialogs
    root.define("dialogs", Widget())
    root.define("dialogs.About", Dialog(dialog("&" + _("About") + ".*")))
    root.define("dialogs.About.buttons", Widget())
    root.define("dialogs.About.buttons.Credits",
                Button(button__(_("Credits"))))
    root.define("dialogs.About.buttons.Licence",
                Button(button__(_("Licence"))))
    root.define("dialogs.About.buttons.Close", Button(button__(_("Close"))))
예제 #7
0
    def __init__(self, *path):
        Widget.__init__(self, *path)

        self.define("toolbar", Widget(filler(), toolbar()))
        self.define("toolbar.Delete", Button(button__(_("Delete"))))
        self.define("text", Entry(filler(), scrollpane(), text()))
예제 #8
0
                           stepClickButton(button='5'),
                           stepClickButton(button='8'),
                           stepCalculateResult(result="165"),
                           description="Calculate 823 - 658")

caseMultiplication = TestCase(stepClickButton(button='4'),
                              stepClickButton(button='6'),
                              stepClickButton(button='2'),
                              stepClickButton(button='*'),
                              stepClickButton(button='8'),
                              stepClickButton(button='5'),
                              stepClickButton(button='7'),
                              stepCalculateResult(result="395934"),
                              description="Calculate 462 * 857")

caseDivision = TestCase(stepClickButton(button='5'),
                        stepClickButton(button='6'),
                        stepClickButton(button='/'),
                        stepClickButton(button='8'),
                        stepCalculateResult(result='7'),
                        description="Calculate 56 / 8")

caseMalformed = TestCase(stepClickButton(button='1'),
                         stepClickButton(button='0'),
                         stepClickButton(button='%'),
                         stepClickButton(button='2'),
                         stepClickButton(button='9'),
                         stepCalculateResult(result="10%29",
                                             status=_("Malformed expression")),
                         description="Calculate 10 % 29")