gnome-desktop-testing r2 - in trunk: . bin gedit gedit/data gnometesting seahorse seahorse/data



Author: nagappan
Date: Sun Feb  8 22:02:26 2009
New Revision: 2
URL: http://svn.gnome.org/viewvc/gnome-desktop-testing?rev=2&view=rev

Log:
Uploading 0.1 version of gnome-desktop-testing files

Added:
   trunk/COPYING
   trunk/MAINTAINERS
   trunk/bin/
   trunk/bin/gnome-desktop-test   (contents, props changed)
   trunk/conffile.ini
   trunk/gedit/
   trunk/gedit/data/
   trunk/gedit/data/ascii.txt
   trunk/gedit/data/ascii_data.xml
   trunk/gedit/data/utf8.txt
   trunk/gedit/data/utf8_data.xml
   trunk/gedit/gedit_chains.py
   trunk/gedit/gedit_chains.xml
   trunk/gnometesting/
   trunk/gnometesting/__init__.py
   trunk/gnometesting/check.py
   trunk/gnometesting/gnome.py
   trunk/gnometesting/gnome_constants.py
   trunk/gnometesting/utils.py
   trunk/report.xsl
   trunk/seahorse/
   trunk/seahorse/data/
   trunk/seahorse/data/generate_pgp.xml
   trunk/seahorse/generate_pgp.py
   trunk/seahorse/generate_pgp.xml

Added: trunk/COPYING
==============================================================================
--- (empty file)
+++ trunk/COPYING	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,167 @@
+           GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+  This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+  0. Additional Definitions. 
+
+  As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+  "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+  An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+  A "Combined Work" is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+  The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+  The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+  1. Exception to Section 3 of the GNU GPL.
+
+  You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+  2. Conveying Modified Versions.
+
+  If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+   a) under this License, provided that you make a good faith effort to
+   ensure that, in the event an Application does not supply the
+   function or data, the facility still operates, and performs
+   whatever part of its purpose remains meaningful, or
+
+   b) under the GNU GPL, with none of the additional permissions of
+   this License applicable to that copy.
+
+  3. Object Code Incorporating Material from Library Header Files.
+
+  The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+   a) Give prominent notice with each copy of the object code that the
+   Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the object code with a copy of the GNU GPL and this license
+   document.
+
+  4. Combined Works.
+
+  You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+   a) Give prominent notice with each copy of the Combined Work that
+   the Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
+   document.
+
+   c) For a Combined Work that displays copyright notices during
+   execution, include the copyright notice for the Library among
+   these notices, as well as a reference directing the user to the
+   copies of the GNU GPL and this license document.
+
+   d) Do one of the following:
+
+       0) Convey the Minimal Corresponding Source under the terms of this
+       License, and the Corresponding Application Code in a form
+       suitable for, and under terms that permit, the user to
+       recombine or relink the Application with a modified version of
+       the Linked Version to produce a modified Combined Work, in the
+       manner specified by section 6 of the GNU GPL for conveying
+       Corresponding Source.
+
+       1) Use a suitable shared library mechanism for linking with the
+       Library.  A suitable mechanism is one that (a) uses at run time
+       a copy of the Library already present on the user's computer
+       system, and (b) will operate properly with a modified version
+       of the Library that is interface-compatible with the Linked
+       Version. 
+
+   e) Provide Installation Information, but only if you would otherwise
+   be required to provide such information under section 6 of the
+   GNU GPL, and only to the extent that such information is
+   necessary to install and execute a modified version of the
+   Combined Work produced by recombining or relinking the
+   Application with a modified version of the Linked Version. (If
+   you use option 4d0, the Installation Information must accompany
+   the Minimal Corresponding Source and Corresponding Application
+   Code. If you use option 4d1, you must provide the Installation
+   Information in the manner specified by section 6 of the GNU GPL
+   for conveying Corresponding Source.)
+
+  5. Combined Libraries.
+
+  You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+   a) Accompany the combined library with a copy of the same work based
+   on the Library, uncombined with any other library facilities,
+   conveyed under the terms of this License.
+
+   b) Give prominent notice with the combined library that part of it
+   is a work based on the Library, and explaining where to find the
+   accompanying uncombined form of the same work.
+
+  6. Revised Versions of the GNU Lesser General Public License.
+
+  The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+  Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+  If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
+

Added: trunk/MAINTAINERS
==============================================================================
--- (empty file)
+++ trunk/MAINTAINERS	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,7 @@
+Ara Pulido
+E-mail: ara ubuntu com 
+Userid: ara
+
+Nagappan Alagappan
+E-mail: nagappan gmail com
+Userid: nagappan

Added: trunk/bin/gnome-desktop-test
==============================================================================
--- (empty file)
+++ trunk/bin/gnome-desktop-test	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,212 @@
+#!/usr/bin/env python
+
+import os
+import re
+import sys
+import logging
+
+from logging import StreamHandler, FileHandler, Formatter
+from optparse import OptionParser
+from stat import ST_MODE, S_IMODE
+from subprocess import Popen, PIPE
+
+
+# Globals
+TESTS_SHARE = "."
+
+
+def error(message, *args):
+    message = "Error: %s\n" % message
+    sys.stderr.write(message % args)
+    sys.exit(1)
+
+def safe_change_mode(path, mode):
+    if not os.path.exists(path):
+        error("Path does not exist: %s", path)
+
+    old_mode = os.stat(path)[ST_MODE]
+    if mode != S_IMODE(old_mode):
+        os.chmod(path, mode)
+
+def safe_make_directory(path, mode=0755):
+    if os.path.exists(path):
+        if not os.path.isdir(path):
+            error("Path is not a directory: %s", path)
+
+        safe_change_mode(path, mode)
+    else:
+        logging.debug("Creating directory: %s", path)
+        os.makedirs(path, mode)
+
+def safe_run_command(command):
+    logging.debug("Running command: %s" % command)
+    p = Popen(command, stdout=PIPE, shell=True)
+    (pid, status) = os.waitpid(p.pid, 0)
+    if status:
+        error("Command failed: %s", command)
+
+    return p.stdout.read()
+
+def is_valid_application_directory(application_directory, applications):
+    application = os.path.basename(application_directory)
+    if applications is not None and application not in applications:
+        logging.debug("Application name `%s' not in specified options: %s",
+            application, ", ".join(applications))
+        return False
+
+    pattern = r"[a-z0-9][-_a-z0-9+.]*"
+    if not re.match(pattern, application, re.I):
+        logging.debug("Application name `%s' does not match pattern: %s",
+            application, pattern)
+        return False
+
+    if not os.path.isdir(application_directory):
+        logging.debug("Application directory `%s' is not a directory",
+            application_directory)
+        return False
+
+    return True
+
+def is_valid_suite_file(suite_file, suites):
+    # Support specifying suites with or without the extension
+    if suites is not None:
+        suites = [os.path.splitext(s)[0] + ".xml" for s in suites]
+
+    suite = os.path.basename(suite_file)
+    if suites is not None and suite not in suites:
+        logging.debug("Suite name `%s' not in specified options: %s",
+            suite, ", ".join(suites))
+        return False
+
+    pattern = r"[a-z0-9][-_a-z0-9+.]*.xml"
+    if not re.match(pattern, suite, re.I):
+        logging.debug("Suite name `%s' does not match pattern: %s",
+            suite, pattern)
+        return False
+
+    if not os.path.isfile(suite_file):
+        logging.debug("Suite file `%s' is not a file",
+            suite_file)
+        return False
+
+    return True
+
+def filter_suite_files(applications, suites):
+    if not os.path.isdir(TESTS_SHARE):
+        error("Share directory `%s' is not a directory.", TESTS_SHARE)
+
+    # Filter applications
+    suite_files = []
+    for application in os.listdir(TESTS_SHARE):
+        application_directory = os.path.join(TESTS_SHARE, application)
+        if not is_valid_application_directory(application_directory, applications):
+            continue
+
+        # Filter suites
+        for suite in os.listdir(application_directory):
+            suite_file = os.path.join(application_directory, suite)
+            if not is_valid_suite_file(suite_file, suites):
+                continue
+
+            suite_files.append(suite_file)
+
+    return suite_files
+
+def run_suite_file(suite_file, log_file):
+    conf_file = os.path.join(TESTS_SHARE, "conffile.ini")
+    if not os.path.exists(conf_file):
+        error("Configuration file `%s' does not exist.", conf_file)
+
+    command = "ldtprunner --conf=%s %s > %s" \
+        % (conf_file, suite_file, log_file)
+    safe_run_command(command)
+
+def convert_log_file(log_file, html_file):
+    xsl_file = os.path.join(TESTS_SHARE, "report.xsl")
+    if not os.path.exists(xsl_file):
+        error("XSL file `%s' does not exist.", xsl_file)
+
+    command = "xsltproc -o %s %s %s" \
+        % (html_file, xsl_file, log_file)
+    safe_run_command(command)
+
+def process_suite_file(suite_file, target_directory):
+    application_name = os.path.basename(os.path.dirname(suite_file))
+    application_target = os.path.join(target_directory, application_name)
+    safe_make_directory(application_target)
+
+    suite_name = os.path.basename(suite_file)
+    log_file = os.path.join(application_target,
+        suite_name.replace(".xml", ".log"))
+    run_suite_file(suite_file, log_file)
+
+    html_file = log_file.replace(".log", ".html")
+    convert_log_file(log_file, html_file)
+
+def main(args=sys.argv):
+    usage = "%prog [OPTIONS]"
+    parser = OptionParser(usage=usage)
+
+    default_target = "~/.gnome-desktop-tests"
+    default_log_level = "critical"
+
+    parser.add_option("-l", "--log",
+                      metavar="FILE",
+                      help="The file to write the log to.")
+    parser.add_option("--log-level",
+                      default=default_log_level,
+                      help="One of debug, info, warning, error or critical.")
+    parser.add_option("-a", "--application",
+                      action="append",
+                      type="string",
+                      default=None,
+                      help="Application name to test. Option can be repeated "
+                           "and defaults to all applications")
+    parser.add_option("-s", "--suite",
+                      action="append",
+                      type="string",
+                      default=None,
+                      help="Suite name to test within applications. Option "
+                           "can be repeated and default to all suites")
+    parser.add_option("-t", "--target",
+                      metavar="FILE",
+                      default=default_target,
+                      help="Target directory for logs and reports. Defaults "
+                           "to: %default")
+
+    (options, args) = parser.parse_args(args[1:])
+
+    # Set logging early
+    log_level = logging.getLevelName(options.log_level.upper())
+    log_handlers = []
+    log_handlers.append(StreamHandler())
+    if options.log:
+        log_filename = options.log
+        log_handlers.append(FileHandler(log_filename))
+
+    format = ("%(asctime)s %(levelname)-8s %(message)s")
+    if log_handlers:
+        for handler in log_handlers:
+            handler.setFormatter(Formatter(format))
+            logging.getLogger().addHandler(handler)
+        if log_level:
+            logging.getLogger().setLevel(log_level)
+    elif not logging.getLogger().handlers:
+        logging.disable(logging.CRITICAL)
+
+    options.target = os.path.expanduser(options.target)
+    if os.path.exists(options.target) and not os.path.isdir(options.target):
+        parser.error("Target directory `%s' exists but is not a directory.",
+            options.target)
+
+    # Filter suite files from project directory
+    suite_files = filter_suite_files(options.application, options.suite)
+
+    # Run filtered suite file
+    for suite_file in suite_files:
+        process_suite_file(suite_file, options.target)
+
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main())

Added: trunk/conffile.ini
==============================================================================
--- (empty file)
+++ trunk/conffile.ini	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,25 @@
+[loggers]
+keys=root
+
+[handlers]
+keys=ldtp
+
+[formatters]
+keys=ldtp
+
+[logger_root]
+class=StreamHandler
+level=NOTSET
+handlers=ldtp
+args=(sys.stdout,)
+
+[handler_ldtp]
+class=StreamHandler
+level=NOTSET
+formatter=ldtp
+args=(sys.stdout,)
+stream=sys.stdout
+
+[formatter_ldtp]
+format=%(message)s
+datefmt=

Added: trunk/gedit/data/ascii.txt
==============================================================================
--- (empty file)
+++ trunk/gedit/data/ascii.txt	Sun Feb  8 22:02:26 2009
@@ -0,0 +1 @@
+This is a very basic string!

Added: trunk/gedit/data/ascii_data.xml
==============================================================================
--- (empty file)
+++ trunk/gedit/data/ascii_data.xml	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<data>
+    <oracle>./gedit/data/ascii.txt</oracle>
+    <string>This is a very basic string!</string>
+</data>

Added: trunk/gedit/data/utf8.txt
==============================================================================
--- (empty file)
+++ trunk/gedit/data/utf8.txt	Sun Feb  8 22:02:26 2009
@@ -0,0 +1 @@
+This is a japanese string: ååæè - ãããã

Added: trunk/gedit/data/utf8_data.xml
==============================================================================
--- (empty file)
+++ trunk/gedit/data/utf8_data.xml	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<data>
+    <oracle>./gedit/data/utf8.txt</oracle>
+    <string>This is a japanese string: ååæè - ãããã</string>
+</data>

Added: trunk/gedit/gedit_chains.py
==============================================================================
--- (empty file)
+++ trunk/gedit/gedit_chains.py	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+
+from ooldtp import *
+from ldtp import *
+from ldtputils import *
+
+from time import *
+
+from gnometesting.gnome import *
+from gnometesting.check import *
+
+try:
+
+    test = GEdit()
+
+    dataXml  = LdtpDataFileParser(datafilename)    
+    oracle = dataXml.gettagvalue("oracle")[0]
+    chain  = dataXml.gettagvalue("string")[0]
+    test_file = strftime("/tmp/" + "%Y%m%d_%H%M%S" + ".txt", gmtime((time())))
+    
+    start_time = time()
+    
+    test.open()
+    test.write_text(chain)
+    test.save(test_file)
+    test.exit()
+
+    stop_time = time()
+    
+    elapsed = stop_time - start_time
+    
+    testcheck = FileComparison(oracle, test_file)
+    check = testcheck.perform_test()
+
+    log ('elapsed_time: ' + str(elapsed), 'comment')
+    
+    if check == FAIL:
+        log ('Files differ.', 'CAUSE')
+        log ('Files differ.', 'ERROR')
+
+except LdtpExecutionError, msg:
+    raise
+
+
+

Added: trunk/gedit/gedit_chains.xml
==============================================================================
--- (empty file)
+++ trunk/gedit/gedit_chains.xml	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<ldtp>
+  <logfile>/dev/null</logfile>
+  <group>
+    <testcaseid>SavedAsciiTestCase</testcaseid>
+    <script>
+      <testcase>SavedAsciiTestCase</testcase>
+      <name>./gedit/gedit_chains.py</name>
+      <data>./gedit/data/ascii_data.xml</data>
+    </script>
+  </group>
+  <group>
+      <testcaseid>SavedUTF8TestCase</testcaseid>
+    <script>
+      <testcase>SavedUTF8TestCase</testcase>
+      <name>./gedit/gedit_chains.py</name>
+      <data>./gedit/data/utf8_data.xml</data>
+    </script>
+  </group>
+</ldtp>

Added: trunk/gnometesting/__init__.py
==============================================================================

Added: trunk/gnometesting/check.py
==============================================================================
--- (empty file)
+++ trunk/gnometesting/check.py	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,56 @@
+"""
+This is the check.py module.
+
+The check module provides different ways to check if the test failed or passed
+"""
+import filecmp
+import os
+import sys
+
+FAIL = "fail"
+PASS = "pass"
+
+class Check:
+    """
+    Superclass for the rest of the test checks
+    """
+    def __init__(self):
+        return
+
+class FileComparison(Check):
+    """
+    Test check for file comparison. If two files are equal, the test passes.
+    """
+    def __init__(self, oracle, test):
+        """
+        Main constructor. It requires two existing files paths.
+
+        @type oracle: string
+        @param oracle: The path to the oracle file to compare the test file against.
+
+        @type test: string
+        @param test: The path to the test file to compare the test file against.
+        """
+
+        Check.__init__(self)
+
+        if not (os.path.exists(oracle) and os.path.exists(test)):
+            print "Both oracle and test file must exist"
+            sys.exit(0)
+
+        self.oracle = oracle
+        self.test   = test
+
+    def perform_test(self):
+        """
+        Perform the test check. 
+
+        It the two files are equal, the test passes. Otherwise, it fails.
+        """
+        if filecmp.cmp(self.oracle, self.test):
+            return PASS
+        else:
+            return FAIL
+
+
+

Added: trunk/gnometesting/gnome.py
==============================================================================
--- (empty file)
+++ trunk/gnometesting/gnome.py	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,459 @@
+"""
+This is the "gnome" module.
+
+The gnome module provides wrappers for LDTP to make the write of Gnome tests easier. 
+"""
+from ooldtp import *
+from ldtp import *
+from ldtputils import *
+import gnome_constants
+from time import *
+from re import *
+
+def open_and_check_app(app_name, window_title_txt):
+    """
+    Given an application, it tries to open it.
+     
+    @type app_name: string
+    @param app_name: The command to start the application.
+    
+    @type window_title_txt: string 
+    @param window_title_txt: The name of the window to recognize once opened.
+        
+        The naming convention is the following:
+        
+        E{-} Prepend 'frm' if the window is a form, or 'dlg' if the window is a dialog.
+        
+        E{-} Append the window name with no spaces.
+              
+        Example: For the window Disk Usage Analyzer, the window name would be frmDiskUsageAnalyzer.
+    
+    """
+    
+    launchapp(app_name)
+
+    wait(2)
+    response = waittillguiexist(window_title_txt, '', 20)
+    
+    if response == 0:
+        raise LdtpExecutionError, "The " + window_title_txt + " window was not found."    
+
+class Application:
+    """
+    Supperclass for the rest of the applications
+    """
+    def __init__(self, name = ""):
+        self.name = name
+      
+    def remap(self):
+        """
+        It reloads the application map for the given context.
+        """
+        remap(self.name)
+
+    def exit(self, close_type='menu', close_name='mnuQuit'):
+        """
+        Given an application, it tries to quit it.
+         
+        @type close_type: string
+        @param close_type: The type of close widget of the application. Types: menu, button.
+        @type close_name: string
+        @param close_name: The name of the exit widget of the application. If not mentioned the default will be used ("Quit").
+        """
+        try:
+            app = context(self.name)
+            try:
+                close_widget = app.getchild(close_name)
+            except LdtpExecutionError, msg:
+                raise LdtpExecutionError, "The " + close_name + " widget was not found."
+
+            if close_type == 'menu':
+                close_widget.selectmenuitem()
+            elif close_type == 'button':
+                close_widget.click()
+            else:
+                raise LdtpExecutionError, "Wrong close item type."
+            response = waittillguinotexist(self.name, '', 20)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "Mmm, something went wrong when closing the application: " + str(msg)
+
+    def save(self, save_menu='mnuSave'):
+        """
+        Given an application, it tries to save the current document. 
+        This method gives very basic functionality. Please, override this method in the subclasses for error checking.
+         
+        @type save_menu: string
+        @param save_menu: The name of the Save menu of the application. If not mentioned the default will be used ("Save").
+        """
+        try:
+            app = context(self.name)
+            try:
+                actualMenu = app.getchild(save_menu)
+            except LdtpExecutionError, msg:
+                raise LdtpExecutionError, "The " + save_menu + " menu was not found."
+
+            actualMenu.selectmenuitem()
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "Mmm, something went wrong when saving the current document:" + str(msg)
+
+    def write_text(self, text, txt_field=''):
+        """
+        Given an application it tries to write text to its current buffer.
+        """
+        app = context(self.name)
+
+        if txt_field == '':
+            try:
+                enterstring(text)
+            except LdtpExecutionError, msg:
+                raise LdtpExecutionError, "We couldn't write text: " + str(msg)
+        else:
+            try:
+                app_txt_field = app.getchild(txt_field)
+            except LdtpExecutionError, msg:
+                raise LdtpExecutionError, "The " + txt_field + " text field was not found: " + str(msg)
+            try:
+                app_txt_field.settextvalue(text)
+            except LdtpExecutionError, msg:
+                raise LdtpExecutionError, "We couldn't write text: " + str(msg)
+
+class Seahorse(Application):
+    """
+    Seahorse manages the Seahorse application.
+    """
+ 
+    def __init__(self):
+        Application.__init__(self, gnome_constants.SH_WINDOW)
+
+    def open(self):
+        open_and_check_app(gnome_constants.SH_LAUNCHER, gnome_constants.SH_WINDOW)
+
+    def new_key(self, key_type):
+        
+        seahorse = context(self.name)
+        
+        try:
+            mnu_new_key = seahorse.getchild(gnome_constants.SH_MNU_NEWKEY)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The new key menu was not found: " + str(msg)
+
+        try:
+            mnu_new_key.selectmenuitem() 
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "There was a problem when selecting new key menu item: " + str(msg)
+
+        try:
+            waittillguiexist(gnome_constants.SH_NEWKEY_DLG)
+            dlg_new_key = context(gnome_constants.SH_NEWKEY_DLG)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The new key dialog was not found: " + str(msg)
+
+        try:
+            table  = dlg_new_key.getchild(role = 'table')
+            types_table = table[0]
+
+            for i in range(0, types_table.getrowcount(), 1):
+                text = types_table.getcellvalue(i, 1)
+                candidate = text.split('\n')[0]
+                if candidate == key_type:
+                    types_table.selectrowindex(i)
+                    break
+                wait(1)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "Error getting the key types table: " + str(msg)
+
+        try:
+            btn_continue = dlg_new_key.getchild(gnome_constants.SH_BTN_CONTINUE)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The continue button at the new key dialog was not found: " + str(msg)
+
+        try:
+            btn_continue.click() 
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "There was a problem when clicking the continue button: " + str(msg)
+        
+    def new_pgp_key(self, full_name, email, comment, passphrase):
+        
+        self.new_key(gnome_constants.SH_TYPE_PGP)
+
+        try:
+            waittillguiexist(gnome_constants.SH_NEWPGP_DLG)
+            dlg_new_pgp = context(gnome_constants.SH_NEWPGP_DLG)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The new key dialog was not found: " + str(msg)
+
+        try:
+            txt_field = dlg_new_pgp.getchild(gnome_constants.SH_DLG_NEWPGP_FULLNAME)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The " + txt_field + " text field was not found: " + str(msg)
+        try:
+            txt_field.settextvalue(full_name)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "We couldn't write text: " + str(msg)
+
+        try:
+            txt_field = dlg_new_pgp.getchild(gnome_constants.SH_DLG_NEWPGP_EMAIL)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The " + txt_field + " text field was not found: " + str(msg)
+        try:
+            txt_field.settextvalue(email)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "We couldn't write text: " + str(msg)
+   
+        try:
+            txt_field = dlg_new_pgp.getchild(gnome_constants.SH_DLG_NEWPGP_COMMENT)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The " + txt_field + " text field was not found: " + str(msg)
+        try:
+            txt_field.settextvalue(comment)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "We couldn't write text: " + str(msg)
+
+        try:
+            btn_create = dlg_new_pgp.getchild(gnome_constants.SH_BTN_NEWPGP_CREATE)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The create button at the new PGP key dialog was not found: " + str(msg)
+
+        try:
+            btn_create.click() 
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "There was a problem when clicking the create button " + str(msg)
+       
+        try:
+            waittillguiexist(gnome_constants.SH_DLG_NEWPGP_PASS)
+            dlg_new_pgp_pass = context(gnome_constants.SH_DLG_NEWPGP_PASS)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The new pgp key passphrase dialog was not found: " + str(msg)
+
+        try:
+            enterstring(passphrase)
+            enterstring("<tab>")
+            enterstring(passphrase)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "Error entering passphrase" + str(msg)
+ 
+        try:
+            btn_pass_ok = dlg_new_pgp_pass.getchild(gnome_constants.SH_BTN_PASS_OK)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The OK button at the new PGP key passphrase dialog was not found: " + str(msg)
+
+        try:
+            btn_pass_ok.click() 
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "There was a problem when clicking the OK button " + str(msg)
+ 
+        try:
+            waittillguiexist(gnome_constants.SH_DLG_GENERATING_PGP)
+            waittillguinotexist(gnome_constants.SH_DLG_GENERATING_PGP)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The new pgp generating key dialog was not found: " + str(msg)
+
+
+class GEdit(Application):
+    """
+    GEdit manages the Gedit application.
+    """
+ 
+    def __init__(self):
+        Application.__init__(self, gnome_constants.GE_WINDOW)
+
+    def write_text(self, text):
+        """
+        It writes text to the current buffer of the Gedit window.
+
+        @type text: string
+        @param text: The text string to be written to the current buffer.
+        """
+        Application.write_text(self, text, gnome_constants.GE_TXT_FIELD)
+
+    def save(self, filename):
+        """
+        It tries to save the current opened buffer to the filename passed as parameter.
+
+        TODO: It does not manage the overwrite dialog yet.
+
+        @type filename: string
+        @param filename: The name of the file to save the buffer to.
+        """
+        Application.save(self)
+        gedit = context(self.name)
+
+        try:
+            waittillguiexist(gnome_constants.GE_SAVE_DLG)
+            save_dialog = context(gnome_constants.GE_SAVE_DLG)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The Gedit save dialog was not found: " + str(msg)
+        try:
+            save_dlg_txt_filename = save_dialog.getchild(gnome_constants.GE_SAVE_DLG_TXT_NAME)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The filename txt field in Gedit save dialog was not found: " + str(msg)
+        try:
+            wait(2)
+            save_dlg_txt_filename.settextvalue(filename)
+        except LdtpExecutionError, msg:
+           raise LdtpExecutionError, "We couldn't write text: " + str(msg)
+
+        try:
+            save_dlg_btn_save = save_dialog.getchild(gnome_constants.GE_SAVE_DLG_BTN_SAVE)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The button Save in Gedit save dialog was not found: " + str(msg)
+        
+        try:
+            save_dlg_btn_save.click()
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "There was an error when pushing the Save button: " + str(msg)
+
+        waittillguinotexist(gnome_constants.GE_SAVE_DLG)
+        
+    def open(self):
+        """
+        It opens the gedit application and raises an error if the application
+        didn't start properly.
+
+        """
+        open_and_check_app(gnome_constants.GE_LAUNCHER, gnome_constants.GE_WINDOW)
+
+    def exit(self, save=False, filename=''):
+        """
+        Given a gedit window, it tries to exit the application.
+        By default, it exits without saving. This behaviour can be changed to save (or save as) on exit.
+         
+        @type save: boolean
+        @param save: If True, the edited file will be saved on exit.
+
+        @type filename: string
+        @param filename: The file name to save the buffer to 
+        """
+
+        # Exit using the Quit menu 
+        try:
+            gedit = context(self.name)
+            try:
+                actualMenu = gedit.getchild(gnome_constants.GE_MNU_QUIT)
+            except LdtpExecutionError, msg:
+                raise LdtpExecutionError, "The " + quit_menu + " menu was not found."
+            actualMenu.selectmenuitem()
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "Mmm, something went wrong when closing the application: " + str(msg)
+
+        response = waittillguiexist(gnome_constants.GE_QUESTION_DLG, '', 20)
+    
+        # If the text has changed, the save dialog will appear
+        if response == 1:
+            try:
+                question_dialog = context(gnome_constants.GE_QUESTION_DLG)
+            except LdtpExecutionError, msg:
+                raise LdtpExecutionError, "The Gedit question dialog was not found: " + str(msg)
+            
+            # Test if the file needs to be saved
+            if save:
+                try:
+                    question_dlg_btn_save = question_dialog.getchild(gnome_constants.GE_QUESTION_DLG_BTN_SAVE)
+                    question_dlg_btn_save.click()
+                except LdtpExecutionError, msg:
+                    # If the Save button was not found, we will try to find the Save As
+                    try:
+                        question_dlg_btn_save = question_dialog.getchild(gnome_constants.GE_QUESTION_DLG_BTN_SAVE_AS)
+                        question_dlg_btn_save.click()
+                    except LdtpExecutionError, msg:
+                        raise LdtpExecutionError, "The save or save as buttons in Gedit question dialog were not found: " + str(msg)
+
+                    try:
+                        waittillguiexist(gnome_constants.GE_SAVE_DLG)
+                        save_dialog = context(gnome_constants.GE_SAVE_DLG)
+                    except LdtpExecutionError, msg:
+                        raise LdtpExecutionError, "The Gedit save dialog was not found: " + str(msg)
+                    try:
+                        save_dlg_txt_filename = save_dialog.getchild(gnome_constants.GE_SAVE_DLG_TXT_NAME)
+                    except LdtpExecutionError, msg:
+                        raise LdtpExecutionError, "The filename txt field in Gedit save dialog was not found: " + str(msg)
+                    try:
+                        wait(2)
+                        save_dlg_txt_filename.settextvalue(filename)
+                    except LdtpExecutionError, msg:
+                        raise LdtpExecutionError, "We couldn't write text: " + str(msg)
+
+                    try:
+                        save_dlg_btn_save = save_dialog.getchild(gnome_constants.GE_SAVE_DLG_BTN_SAVE)
+                    except LdtpExecutionError, msg:
+                        raise LdtpExecutionError, "The save button in Gedit save dialog was not found: " + str(msg)
+        
+                    try:
+                        save_dlg_btn_save.click()
+                    except LdtpExecutionError, msg:
+                        raise LdtpExecutionError, "There was an error when pushing the Save button: " + str(msg)
+
+                    waittillguinotexist(gnome_constants.GE_SAVE_DLG)
+            
+            else:
+                try:
+                    question_dlg_btn_close = question_dialog.getchild(gnome_constants.GE_QUESTION_DLG_BTN_CLOSE)
+                    question_dlg_btn_close.click()
+                except LdtpExecutionError, msg:
+                    raise LdtpExecutionError, "It was not possible to click the close button: " + str(msg)
+
+            response = waittillguinotexist(self.name, '', 20)
+ 
+class PolicyKit(Application):
+    """
+    PolicyKit class manages the GNOME pop up that ask for password for admin activities.
+    """
+    
+    def __init__(self, password):
+        """
+        UpdateManager class main constructor
+        
+        @type password: string
+        @param password: User's password for administrative tasks.
+
+        """
+        Application.__init__(self, gnome_constants.SU_WINDOW)
+        self.password = password
+    
+    def wait(self):
+        """
+        Wait for the pop up window asking for the password to appear.
+
+        @return 1, if the gksu window exists, 0 otherwise.
+        """
+        return waittillguiexist(gnome_constants.SU_WINDOW)
+        
+    def set_password(self):
+        """
+        It enters the password in the text field and clicks enter. 
+        """
+        
+        polKit = context(gnome_constants.SU_WINDOW)
+        
+        try:
+            enterstring (self.password)
+            enterstring ("<enter>")
+            
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The PolicyKit txt field for the password was not found."
+   
+# TODO: Change this to use ooldtp
+#        try:
+#            btnOK = polKit.getchild(gnome_constants.SU_BTN_OK)
+#        except LdtpExecutionError, msg:
+#            raise LdtpExecutionError, "The GtkSudo OK button was not found."
+#          
+#        btnOK.click()
+    
+        #This also have problems because of the lack of accesibiliy information
+        #waittillguinotexist (gnome_constants.SU_WINDOW)
+        
+    def cancel(self):
+        polKit = context(gnome_constants.SU_WINDOW)
+
+        try:
+            cancelButton = polKit.getchild(gnome_constants.SU_BTN_CANCEL)
+        except LdtpExecutionError, msg:
+            raise LdtpExecutionError, "The PolicyKit cancel button was not found."
+          
+        cancelButton.click()
+        waittillguinotexist (gnome_constants.SU_WINDOW)
+        
+
+        
+    

Added: trunk/gnometesting/gnome_constants.py
==============================================================================
--- (empty file)
+++ trunk/gnometesting/gnome_constants.py	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,43 @@
+"""
+This is the "gnome_constants" module.
+
+The gnome_constants provides the "object map" to be used in gnome.py 
+"""
+
+TOP_PANEL = 'frmTopExpandedEdgePanel'
+
+
+# GtkSudo Popup (prefix = SU)
+SU_WINDOW     = "dlg0"
+SU_TXT_PASS   = "txtPassword"
+SU_BTN_OK     = "btnOK"
+SU_BTN_CANCEL = "btnCancel"
+
+# GEdit constants (prefix = GE)
+GE_WINDOW     = "frm*-gedit"
+GE_TXT_FIELD  = "txt1"
+GE_LAUNCHER   = "gedit"
+GE_SAVE_DLG   = "dlgSave*"
+GE_SAVE_DLG_TXT_NAME = "txtName"
+GE_SAVE_DLG_BTN_SAVE = "btnSave"
+GE_QUESTION_DLG = "dlgQuestion"
+GE_QUESTION_DLG_BTN_SAVE = "btnSave"
+GE_QUESTION_DLG_BTN_SAVE_AS = "btnSaveAs"
+GE_QUESTION_DLG_BTN_CLOSE = "btnClosewithoutSaving"
+GE_MNU_QUIT = "mnuQuit"
+
+# Seahorse contants (prefix = SH)
+SH_WINDOW       = "frmPasswordsandEncryptionKeys"
+SH_LAUNCHER     = "seahorse"
+SH_MNU_NEWKEY   = "mnuCreateNewKey"
+SH_NEWKEY_DLG   = "dlgCreateaNewKey"
+SH_BTN_CONTINUE = "btnContinue"
+SH_TYPE_PGP            = "PGP Key"
+SH_NEWPGP_DLG          = "dlgCreateaPGPKey"
+SH_DLG_NEWPGP_FULLNAME = "txtFullName"
+SH_DLG_NEWPGP_EMAIL    = "txtEmailAddress"
+SH_DLG_NEWPGP_COMMENT  = "txtComment"
+SH_BTN_NEWPGP_CREATE   = "btnCreate"
+SH_DLG_NEWPGP_PASS     = "dlgPassphraseforNewPGPKey"
+SH_BTN_PASS_OK         = "btnOK"
+SH_DLG_GENERATING_PGP  = "dlgGeneratingkey"

Added: trunk/gnometesting/utils.py
==============================================================================
--- (empty file)
+++ trunk/gnometesting/utils.py	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,4 @@
+
+
+def get_system_language():
+    raise NotImplementedError, "not yet..."
\ No newline at end of file

Added: trunk/report.xsl
==============================================================================
--- (empty file)
+++ trunk/report.xsl	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
+<xsl:template match="/">
+<html>
+    <head>
+	    <title>
+		    GNOME Desktop Tests Report
+	    </title>
+        <style type="text/css">
+    
+        body { font:normal 68% verdana,arial,helvetica; color:#000000; }
+
+        h1 { margin: 0px 0px 5px; font: 165% verdana,arial,helvetica }
+		h2 { margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica }
+      	h3 { margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica }
+      	h4 { margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica }
+		h5 { margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica }
+		h6 { margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica }
+		
+      	table tr th{
+        	font-weight: bold;
+			font: 80% verdana,arial,helvetica
+	        text-align:left;
+    	    background:#a6caf0;
+      	}
+      	table tr td{
+       		background:#eeeee0;
+            font: 80% verdana,arial,helvetica
+      	}
+      
+		hr.dashed {border: none 0; 
+			border-top: 1px dashed #000;
+			border-bottom: 1px dashed #ccc;
+			width: 95%;
+			height: 2px;
+			margin: 10px auto 0 0;
+			text-align: left;
+		}
+		hr.clear {border: none 0; 
+			border-top: 1px solid #ccc;
+			border-bottom: 1px solid #efefef;
+			width: 80%;
+			height: 2px;
+			margin: 10px auto 0 0;
+			text-align: left;
+		}			
+		.passed { color:green;  }
+        .failed { font-weight:bold; color:red; }
+		.warnings {color:orange;}
+		.infos {color:green;}
+        </style>
+	</head>
+	<body>
+	    <h1>GNOME Desktop Tests Report</h1>
+	    <hr class="clear"></hr>
+		<xsl:for-each select="descendant::group">
+			<h2>Group Name: <xsl:value-of select="@name"/></h2>
+			<table class="details">
+			<tr>
+				<th>Test Name</th>
+				<th>Script Name</th>
+				<th>Status</th>
+				<th>Time Elapsed (s)</th>
+				<th>Error</th>
+			</tr>
+			<xsl:for-each select="child::script/child::test">
+				<tr>
+				    <td style="padding: 3px;" align="left" width="40%"><xsl:value-of select="@name"/></td>
+					<td><xsl:value-of select="ancestor::script[last()]/@name"/></td>
+					<xsl:if test="child::pass/child::text() = 0">
+						<td style="padding: 3px;" class="failed" align="right">Failed</td>
+					</xsl:if>
+					<xsl:if test="child::pass/child::text() = 1">
+						<td style="padding: 3px;" class="passed" align="right">Passed</td>
+					</xsl:if>
+					<td style="padding: 3px;" align="right"><xsl:value-of select="substring-after(COMMENT, 'elapsed_time:')"/></td>
+					<td>
+						<table>
+							<xsl:for-each select="child::CAUSE">
+								<tr>
+									<td><xsl:value-of select="text()"/></td>
+								</tr>
+							</xsl:for-each>
+						</table>
+					</td>
+				</tr>
+			</xsl:for-each>
+			</table>
+			<hr class="dashed"></hr>
+		</xsl:for-each>
+	</body>
+</html>
+</xsl:template>
+</xsl:stylesheet>

Added: trunk/seahorse/data/generate_pgp.xml
==============================================================================
--- (empty file)
+++ trunk/seahorse/data/generate_pgp.xml	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<data>
+    <name>Tester Tester</name>
+    <email>tester testworld org</email>
+    <comment>This is a test</comment>
+    <passphrase>passphrase</passphrase>
+</data>

Added: trunk/seahorse/generate_pgp.py
==============================================================================
--- (empty file)
+++ trunk/seahorse/generate_pgp.py	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,36 @@
+from ooldtp import *
+from ldtp import *
+from ldtputils import *
+from time import *
+
+from gnometesting.gnome import *
+
+try:
+  
+    dataXml  = LdtpDataFileParser(datafilename)    
+    name     = dataXml.gettagvalue("name")[0]
+    email    = dataXml.gettagvalue("email")[0]
+    comment  = dataXml.gettagvalue("comment")[0]
+    passphrase  = dataXml.gettagvalue("passphrase")[0]
+
+    
+    seahorse = Seahorse()
+    
+    start_time = time()
+    
+    # Open the update manager and check the repositories
+    seahorse.open()
+    seahorse.new_pgp_key(name, email, comment, passphrase)
+    seahorse.exit()
+        
+    stop_time = time()
+ 
+    elapsed = stop_time - start_time
+    
+    log ('elapsed_time: ' + str(elapsed), 'comment')
+    
+except LdtpExecutionError, msg:
+    raise
+
+
+

Added: trunk/seahorse/generate_pgp.xml
==============================================================================
--- (empty file)
+++ trunk/seahorse/generate_pgp.xml	Sun Feb  8 22:02:26 2009
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<ldtp>
+  <logfile>/dev/null</logfile>
+  <group>
+    <testcaseid>GenerateKeys</testcaseid>
+    <script>
+      <testcase>GeneratePGPKey</testcase>
+      <name>./seahorse/generate_pgp.py</name>
+      <data>./seahorse/data/generate_pgp.xml</data>
+    </script>
+  </group>
+</ldtp>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]