Exemple #1
0
    def test_Should_give_a_YesNo_box(self):

        mes = "Do you want to do the YesNo Box tests?"
        result = actions.YesNo(mes, "Starting the MessageTest (YesNo Box)")
        if not result:
            print 'YesNo Box tests (MessageTest) skipped'
            return

        res = actions.YesNo('Please answer "Yes"', "MessageTest")
        self.assert_(res,
                     "Result should be True when you really answered *Yes*")
        res = actions.YesNo("Please answer\n'No'", "MessageTest")
        self.failIf(res,
                    "Result should be False when you really answered *No*")
        for alert, icon in enumerate(['query', 'warning', 'critical']):
            if alert:
                mes = '''This is a test question\n\nicon=%s and
                      \nalert(number of bells ringing)=%s\n\nIs this OK?''' % (
                    icon, alert)
            else:
                mes = '''This is a test question\n\n\ticon=%s and
                      \n\tno alert (sound heard)\n\nIs this OK?''' % icon
            print 'alerts: ', alert
            result = actions.YesNo(mes, "MessageTest", icon=icon, alert=alert)
            self.assertEquals(
                True, result,
                "you answered NO to test: %s" % self.squeeze_whitespace(mes))
Exemple #2
0
 def test_Should_handle_embedded_quotes_and_newlines(self):
     mes = 'Do you want to do the "handle_embedded_quotes_and_newlines" test?'
     result = actions.YesNo(
         mes, 'Starting the handle_embedded_quotes_and_newlines Test')
     if not result:
         print 'handle_embedded_quotes_and_newlines (MessageTest) skipped'
         return
     mes1 = 'This has embedded newlines: \n and \\r characters: \r in it:\n' \
           'and embedded quotes: " and \'\n\n\n' \
           'Please answer OK'
     mes2 = 'This has embedded newlines: \n and \\r characters: \r in it:\n' \
           'and embedded quotes: " and \'\n\n\n' \
           'Please answer Yes if there are embedded newlines and quotes in this Dialog and in previous one'
     result = actions.Message(
         mes1, "\"'\n\rhandle_embedded_quotes_and_newlines (MessageTest)")
     result = actions.YesNo(
         mes2,
         "\"\"'\"\r\nhandle_embedded_quotes_and_newlines (MessageTest)")
     self.assertEquals(
         True, result,
         "you answered NO to test: %s" % self.squeeze_whitespace(mes2))
Exemple #3
0
    def test_Should_give_a_message(self):
        mes = "Do you want to do the Message Box tests?"
        result = actions.YesNo(mes, "Starting the MessageTest (Message Box)")
        if not result:
            print 'Message Box tests (MessageTest) skipped'
            return


##        for alert,icon in enumerate([16, 32, 48, 64]):
##            mes = '''This is a test message with\n\n\ticon=%s and\n
##                  \talert=%s\n\nplease answer "OK"'''% (icon, alert)
##            actions.Message(mes, "MessageTest", icon=icon, alert=alert)

        actions.Message(
            'This is a the default test message\n\nPlease answer "OK"',
            "MessageTest")

        for alert, icon in enumerate(['information', 'warning', 'critical']):
            if alert:
                mes = '''This is a test message
                         \nicon=%s and
                         \nalert (number of bells ringing)=%s
                         \nPlease answer "OK"''' % (icon, alert)
            else:
                mes = '''This is a test message
                         \n\ticon=%s and
                         \n\tno alert (sound heard)
                         \nPlease answer "OK"''' % icon
            actions.Message(mes, "MessageTest", icon=icon, alert=alert)
        mes = '''Where all of the previous messages correct,
                 \nespecially the icons and the number of alerts?
              '''
        result = actions.YesNo(mes,
                               "Evaluation of MessageTest",
                               icon=icon,
                               alert=alert)
        self.assertEquals(
            True, result,
            "you answered NO to test: %s" % self.squeeze_whitespace(mes))
    def doTestBringupApplications(self, apps, preserveApps, prompt=1):
        """do the testing of bringing up and destroying applications

        switching is done several times, also after killing the window.
        switching with UnimacroBringUp several times is fast and comes back
        to the same window, if not killed in between.

        In these tests the different combinations are checked.        

        """
        destroyApps = [a for a in apps if a not in preserveApps]
        if prompt:
            mes = [
                "Do you want to do the Bringup applications tests?", "",
                'using %s' % apps,
                'keeping open: %s' % preserveApps,
                'destroying after testing: %s' % destroyApps
            ]
            if type(prompt) == types.StringType:
                mes.insert(0, prompt + '\n\n')
            result = actions.YesNo(mes,
                                   "Starting the Bringup applicationsTest ")
            if not result:
                print 'Bringup applications test skipped'
                return

        appString = ', '.join(apps)

        # these should correspond with "name" in [bringup app] section of actions.ini
        # call for edit actions to inspect these:
        expectedMods = dict(zip(apps, apps))
        expectedMods.update(specialMods)

        # bring them up:
        for app in apps:
            result = actions.UnimacroBringUp(app)
            if result:
                self.assert_mod(
                    expectedMods[app],
                    " (round 1) when bringing up %s (%s)" % (app, appString))
            else:
                self.fail(
                    " (round 1) did not get result from switching to app: %s (%s)"
                    % (app, appString))

        # and do it again:
        for app in apps:
            result = actions.UnimacroBringUp(app)
            if result:
                self.assert_mod(
                    expectedMods[app],
                    " (round 2) when bringing up %s (%s)" % (app, appString))
            else:
                self.fail(
                    " (round 2) did not get result from switching to app: %s (%s)"
                    % (app, appString))

            result = actions.UnimacroBringUp(app)
            if result:
                self.assert_mod(
                    expectedMods[app],
                    " (round 2, double!) when bringing up %s (%s)" %
                    (app, appString))
            else:
                self.fail(
                    " (round 2, double!) did not get result from switching to app: %s (%s)"
                    % (app, appString))
        # do it in reverse order, kill the window, except for pythonwin and uedit32 (preserveApps):
        apps.reverse()
        for app in apps:
            result = actions.UnimacroBringUp(app)
            if result:
                self.assert_mod(
                    expectedMods[app],
                    " (round 3) when bringing up %s (%s)" % (app, appString))
            else:
                self.fail(
                    " (round 3, revers order) did not get result from switching to app: %s (%s)"
                    % (app, appString))
            if app not in preserveApps:
                actions.do_KW()
                self.failIf_mod(
                    app, "(round 3) kill window did not succeed for app\n\n"
                    "(THIS MAY BE A TEST ARTEFACT OR A FAILURE OF THE KW (KillWindow) ACTION: %s (%s)"
                    % (app, appString))

        # again reverse order, bringup again and kill the window, except for pythonwin and uedit32:
        for app in apps:
            result = actions.UnimacroBringUp(app)
            if result:
                self.assert_mod(
                    expectedMods[app],
                    " (round 4, after killing previous app)) when bringing up %s (%s)"
                    % (app, appString))
            else:
                self.fail(
                    " (round 4, after killing previous app)) did not get result from switching to app: %s (%s)"
                    % (app, appString))
            if app not in preserveApps:
                actions.do_KW()
                self.failIf_mod(
                    app,
                    "(round 4, after killing previous app)) kill window did not succeed for app: %s (%s)"
                    % (app, appString))
        return 1


# no main statement, run from command in _unimacrotest.py.