当前位置: 首页>>代码示例>>Python>>正文


Python Pointer.click方法代码示例

本文整理汇总了Python中autopilot.input.Pointer.click方法的典型用法代码示例。如果您正苦于以下问题:Python Pointer.click方法的具体用法?Python Pointer.click怎么用?Python Pointer.click使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在autopilot.input.Pointer的用法示例。


在下文中一共展示了Pointer.click方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GtkSpinButton

# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import click [as 别名]
class GtkSpinButton(AutopilotGtkEmulatorBase):
    """ Emulator class for a GtSpinButton instance"""
    def __init__(self, *args):
        super(GtkSpinButton, self).__init__(*args)
        self.pointing_device = Pointer(Mouse.create())
        self.kbd = Keyboard.create()

    def enter_value(self, value):
        self._select_entry()
        self.kbd.type(value)
        expectThat(self.text).equals(
            value,
            msg="Expected spinbutton value '{0}' to equal {1}"
                .format(self.text, value))

    def _select_entry(self, ):
        self.pointing_device.move_to_object(self)
        pos = self.pointing_device.position()
        x = pos[0]
        y = pos[1]
        x -= 15  # px
        self.pointing_device.move(x, y)
        self.pointing_device.click()
        self.kbd.press_and_release('Ctrl+a')
        self.kbd.press_and_release('Delete')
开发者ID:linuxmint,项目名称:ubiquity,代码行数:27,代码来源:gtkcontrols.py

示例2: UbuntuHTML5TestCaseBase

# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import click [as 别名]
class UbuntuHTML5TestCaseBase(AutopilotTestCase):
    BROWSER_CONTAINER_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../tools/qml/webview.qml')
    INSTALLED_BROWSER_CONTAINER_PATH = '/usr/share/ubuntu-html5-theme/autopilot-tests/qml/webview.qml'
    arch = subprocess.check_output(
        ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip()
    BROWSER_QML_APP_LAUNCHER = "/usr/lib/" + arch + "/qt5/bin/qmlscene"

    # TODO: fix version
    LOCAL_HTML_EXAMPLES_PATH = os.path.abspath("%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../0.1/examples/'))
    INSTALLED_HTML_EXAMPLES_PATH = '/usr/share/ubuntu-html5-theme/0.1/examples'

    APPS_SUBFOLDER_NAME = 'apps'

    BASE_PATH = ''

    def get_browser_container_path(self):
        if os.path.exists(self.BROWSER_CONTAINER_PATH):
            return self.BROWSER_CONTAINER_PATH
        return self.INSTALLED_BROWSER_CONTAINER_PATH

    def create_file_url_from(self, filepath):
        return 'file://' + filepath

    def setup_base_path(self):
        if os.path.exists(self.LOCAL_HTML_EXAMPLES_PATH):
            self.BASE_PATH = self.LOCAL_HTML_EXAMPLES_PATH
        else:
            self.BASE_PATH = self.INSTALLED_HTML_EXAMPLES_PATH

    def setUp(self):
        self.setup_base_path()
        self.pointer = Pointer(Mouse.create())
        self.app = self.launch_test_application(self.BROWSER_QML_APP_LAUNCHER, self.get_browser_container_path())
        self.webviewContainer = self.get_webviewContainer()
        self.watcher = self.webviewContainer.watch_signal('resultUpdated(QString)')
        super(UbuntuHTML5TestCaseBase, self).setUp()

    def tearDown(self):
        super(UbuntuHTML5TestCaseBase, self).tearDown()

    def pick_app_launcher(self, app_path):
        # force Qt app introspection:
        from autopilot.introspection.qt import QtApplicationLauncher
        return QtApplicationLauncher()

    def get_webviewContainer(self):
        return self.app.select_single(objectName="webviewContainer")

    def get_webview(self):
        return self.app.select_single(objectName="webview")

    def get_addressbar(self):
        return self.app.select_single(objectName="addressbar")

    def get_button(self):
        return self.app.select_single(objectName="browseButton")

    def get_title(self):
        return self.get_webview().title

    def assert_url_eventually_loaded(self, url):
        webview = self.get_webview()
        self.assertThat(webview.loadProgress, Eventually(Equals(100)))
        self.assertThat(webview.loading, Eventually(Equals(False)))
        self.assertThat(webview.url, Eventually(Equals(url)))

    def click_dom_node_with_id(self, id):
        webview = self.get_webviewContainer()
        webview.slots.clickElementById(id)
        self.assertThat(lambda: self.watcher.num_emissions, Eventually(Equals(1)))

    def click_any_dom_node_by_selector(self, selector):
        webview = self.get_webviewContainer()
        webview.slots.clickAnyElementBySelector(selector)
        self.assertThat(lambda: self.watcher.num_emissions, Eventually(Equals(1)))

    def is_dom_node_visible(self, id):
        webview = self.get_webviewContainer()
        prev_emissions = self.watcher.num_emissions
        webview.slots.isNodeWithIdVisible(id)
        self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))
        return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']

    def eval_expression_in_page_unsafe(self, expr):
        webview = self.get_webviewContainer()
        prev_emissions = self.watcher.num_emissions
        webview.slots.evalInPageUnsafe(expr)
        self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))
        return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']
        
    def get_dom_node_id_attribute(self, id, attribute):
        webview = self.get_webviewContainer()
        prev_emissions = self.watcher.num_emissions
        webview.slots.getAttributeForElementWithId(id, attribute)
        self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))
        return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']

    def browse_to_url(self, url):
        addressbar = self.get_addressbar()
        self.pointer.move_to_object(addressbar)
#.........这里部分代码省略.........
开发者ID:fczuardi,项目名称:ubuntu-html5-theme,代码行数:103,代码来源:__init__.py

示例3: DefaultInstallTests

# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import click [as 别名]
class DefaultInstallTests(AutopilotTestCase):

    def setUp(self):
        super(DefaultInstallTests, self).setUp()
        self.app = self.launch_application()
        #properties = self.app.get_properties()
        #print(properties)
        self.pointing_device = Pointer(Mouse.create())
        
    def launch_application(self):
        '''
        Hmm... launch ubiquity


        :returns: The application proxy object.
        '''
        my_process = int(os.environ['UBIQUITY_PID'])
        my_dbus = str(os.environ['DBUS_SESSION_BUS_ADDRESS'])
        return get_proxy_object_for_existing_process(
            pid=my_process, dbus_bus=my_dbus)
    
    def test_default_install(self):
        '''
            Test install using all default values
        '''
        #Ubuntu: Lets get the focus back to ubiquity window
        #Comment out this line if running test on xubuntu/lubuntu and make sure terminal
        # is not on top of ubiquity when starting the test.
        #FIXME: Need setup and teardown to be implemented so we can lose this all together
        self.keyboard.press_and_release('Super+1')
        
        main_window = self.app.select_single(
            'GtkWindow', name='live_installer')
        self.assertThat(main_window.title, Equals("Install"))
        # This method runs the ubiquity_ methods to navigate
        # testing through the install pages
        self.run_default_install_test()
        
        #Then finally here check that the complete dialog appears
        
        self.ubiquity_did_install_complete()
    
    def run_default_install_test(self):
        '''
            this can be easily used when debugging. If the test exits on a
            particular page, you can comment out the pages prior to the exit point
            and reset current page to its default state, then run test again.
            The test will start from the page it exited on. This can save alot of
            hassle having to setup the whole test again, just to fix a small error.
        '''
        #Page 1
        self.ubiquity_welcome_page_test()
        #Page 2
        self.ubiquity_preparing_page_test()
        ##Page 3
        self.ubiquity_install_type_page_test()
        #Page 4
        self.ubiquity_where_are_you_page_test()
        #Page 5
        self.ubiquity_keyboard_page_test()
        #Page 6
        self.ubiquity_who_are_you_page_test()
        #page 7
        self.ubiquity_progress_bar_test()
        
    def ubiquity_welcome_page_test(self):
        '''
            Tests that all needed objects on the Welcome page are accessible    
            And can also be navigated to.            
            Once confirmed continue with install accepting all defaults
        '''
        self.get_ubiquity_objects()
        
        self.assertThat(self.headerlabel.label, Eventually(Contains('Welcome')))
        #Can we navigate to the quit button? This fails the test if object
        # has no position attribs
        self.pointing_device.move_to_object(self.quit_button)
        self.assertThat(self.continue_button.label, Equals('Continue'))
        #Can we navigate to the continue button?
        self.pointing_device.move_to_object(self.continue_button)
        #Finally lets move on to the next page
        self.pointing_device.click()
        
    def ubiquity_preparing_page_test(self):
        
        self.wait_for_button_state_changed()
        #Check the next page title
        self.assertThat(self.headerlabel.label,
                        Eventually(Contains('Preparing to install')))
        #lets get all the page objects
        
        self.get_ubiquity_objects()
        '''
            Lets test we can go back to the welcome page and come back here
        '''
        #Click back
        self.pointing_device.move_to_object(self.back_button)
        self.pointing_device.click()
        
        self.wait_for_button_state_changed()
#.........这里部分代码省略.........
开发者ID:queer1,项目名称:ubiquity,代码行数:103,代码来源:test_default.py

示例4: GtkBox

# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import click [as 别名]
class GtkBox(GtkContainers):
    """ Emulator class for a GtkBox instance """
    def __init__(self, *args):
        super(GtkBox, self).__init__(*args)
        self.pointing_device = Pointer(Mouse.create())
        self.kbd = Keyboard.create()

    def get_random_language(self, ):
        """ gets a random language from the 'stepLanguage' page

        :returns: A random TreeView item from the language treeview
        :raises: EmulatorException if function is not called from the
                step language page object

        You can now use select_language_item

        """
        logger.debug("get_random_language()")
        if self.name == 'stepLanguage':
            language_item = self._get_install_language()
            if language_item is None:
                raise ValueError("Language could not be selected")
            return language_item
        raise RuntimeError("Function can only be used from a stepLanguage "
                           "page object. Use .select_single('GtkBox, "
                           "name='stepLanguage')")

    def select_language(self, item):
        """ Selects a language for the install

        You can either use get_random_language or if you want to set the
        install language instead of randomly selecting an item. Then select
        from the treeview using GtkTreeView.select_item and pass the returned
        item to select_language

        :param item: A treeview item object
        :raises: exception if function not called from stepLanguage page object


        """
        if self.name == 'stepLanguage':
            logger.debug("select_language()")
            treeview = self.select_single('GtkTreeView')
            treeview.click()
            #for sanity lets ensure we always start at the top of the list
            logger.debug("Selecting top item of treeview list")
            self.kbd.press_and_release('Home')
            tree_items = treeview.get_all_items()
            top_item = tree_items[0]
            #If we are at the top
            if top_item.selected:
                logger.debug("top item {0} selected"
                             .format(top_item.accessible_name))
                #Now select required Language
                self.kbd.type(item.accessible_name[0:2])
                item.click()
                #check selected
                if item.selected:
                    logger.debug("Install language successfully selected! :-)")
                    return
                raise ValueError("Could not select Item")
            raise ValueError("Top item  not selected")
        raise ValueError("Function can only be used from a stepLanguage page "
                         "object. Use .select_single('GtkBox, "
                         "name='stepLanguage')")

    def _get_install_language(self, ):
        """ Gets a random language for the install

        :returns: an object of a TreeView item for the chosen language
        """
        logger.debug("_get_install_language()")
        treeview = self.select_single('GtkTreeView')
        #lets get all items
        treeview_items = treeview.get_all_items()

        #get a language which the first two chars can be ascii decoded
        test_language = self._get_decode_ascii_item(treeview_items)
        return test_language

    def _get_decode_ascii_item(self, items):
        """ decodes a list of unicode items """
        logger.debug("_get_decode_ascii_item()")
        # at the moment we can't select all locales as this would be a pain
        # to figure out all encodings for keyboard input
        lang_item = None
        l_ascii = None
        while True:
            lang_item = random.choice(items)
            l_unicode = lang_item.accessible_name
            logger.debug("Attempting to decode %s" % l_unicode)
            lan = l_unicode[0:2]
            try:
                l_ascii = lan.encode('ascii')
            except UnicodeEncodeError:
                logger.debug("%s could not be decoded" % l_unicode)
                pass
            if l_ascii:
                logger.debug("%s decoded successfully" % l_unicode)
                break
#.........这里部分代码省略.........
开发者ID:hamonikr-root,项目名称:ubiquity,代码行数:103,代码来源:gtkcontainers.py

示例5: UbuntuTouchAppTestCase

# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import click [as 别名]
class UbuntuTouchAppTestCase(AutopilotTestCase):
    """A common test case class that provides several useful methods for the tests."""

    if model() == 'Desktop':
        scenarios = [
        ('with mouse', dict(input_device_class=Mouse))
        ]
    else:
        scenarios = [
        ('with touch', dict(input_device_class=Touch))
        ]

    @property
    def main_window(self):
        return MainWindow(self.app)


    def setUp(self):
        self.pointing_device = Pointer(self.input_device_class.create())
        super(UbuntuTouchAppTestCase, self).setUp()
        self.launch_test_qml()


    def launch_test_qml(self):
        # If the test class has defined a 'test_qml' class attribute then we
        # write it to disk and launch it inside the QML Scene. If not, then we
        # silently do nothing (presumably the test has something else planned).
        arch = subprocess.check_output(["dpkg-architecture",
        "-qDEB_HOST_MULTIARCH"]).strip()
        if hasattr(self, 'test_qml') and isinstance(self.test_qml, basestring):
            qml_path = mktemp(suffix='.qml')
            open(qml_path, 'w').write(self.test_qml)
            self.addCleanup(remove, qml_path)

            self.app = self.launch_test_application(
                "/usr/lib/" + arch + "/qt5/bin/qmlscene",
                "-I", get_module_include_path(),
                qml_path,
                app_type='qt')

        if hasattr(self, 'test_qml_file') and isinstance(self.test_qml_file, basestring):
            qml_path = self.test_qml_file
            self.app = self.launch_test_application(
                "/usr/lib/" + arch + "/qt5/bin/qmlscene",
                "-I", get_module_include_path(),
                qml_path,
                app_type='qt')

        self.assertThat(self.get_qml_view().visible, Eventually(Equals(True)))


    def get_qml_view(self):
        """Get the main QML view"""

        return self.app.select_single("QQuickView")

    def get_mainview(self):
        """Get the QML MainView"""

        mainView = self.app.select_single("MainView")
        self.assertThat(mainView, Not(Is(None)))
        return mainView


    def get_object(self,objectName):
        """Get a object based on the objectName"""

        obj = self.app.select_single(objectName=objectName)
        self.assertThat(obj, Not(Is(None)))
        return obj


    def mouse_click(self,objectName):
        """Move mouse on top of the object and click on it"""

        obj = self.get_object(objectName)
        self.pointing_device.move_to_object(obj)
        self.pointing_device.click()


    def mouse_press(self,objectName):
        """Move mouse on top of the object and press mouse button (without releasing it)"""

        obj = self.get_object(objectName)
        self.pointing_device.move_to_object(obj)
        self.pointing_device.press()


    def mouse_release(self):
        """Release mouse button"""

        self.pointing_device.release()     


    def type_string(self, string):
        """Type a string with keyboard"""

        self.keyboard.type(string)


#.........这里部分代码省略.........
开发者ID:Anne017,项目名称:OVU,代码行数:103,代码来源:__init__.py

示例6: SaucyBaconTestCase

# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import click [as 别名]
class SaucyBaconTestCase(AutopilotTestCase):
    """A common test case class that provides several useful methods for the tests."""

    if model() == 'Desktop':
        scenarios = [
        ('with mouse', dict(input_device_class=Mouse))
        ]
    else:
        scenarios = [
        ('with touch', dict(input_device_class=Touch))
        ]
    
    local_location = get_qml_location() + "/saucybacon.qml"

    @property
    def main_window(self):
        return MainWindow(self.app)

    def setUp(self):
        self.pointing_device = Pointer(self.input_device_class.create())
        super(SaucyBaconTestCase, self).setUp()
        
        print self.local_location
        print get_module_include_path()
        if os.path.exists(self.local_location):
            self.launch_test_local()
        elif os.path.exists('/usr/share/saucybacon/app/saucybacon.qml'):
            self.launch_test_installed()
        else:
            self.launch_test_click()

    def launch_test_local(self):
        self.app = self.launch_test_application(
            "qmlscene",
            self.local_location,
            "-I",
            get_module_include_path(),
            app_type='qt',
            emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)

    def launch_test_installed(self):
        self.app = self.launch_test_application(
            "qmlscene",
            "/usr/share/postino/postino.qml",
            "--desktop_file_hint=/usr/share/applications/saucybacon.desktop",
            app_type='qt',
            emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)

    def launch_test_click(self):
        self.app = self.launch_click_package(
            'com.ubuntu.developers.gcollura.saucybacon',
            emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)


    def get_qml_view(self):
        """Get the main QML view"""

        return self.app.select_single("QQuickView")

    def get_mainview(self):
        """Get the QML MainView"""

        mainView = self.app.select_single("MainView")
        self.assertThat(mainView, Not(Is(None)))
        return mainView


    def get_object(self,objectName):
        """Get a object based on the objectName"""

        obj = self.app.select_single(objectName=objectName)
        self.assertThat(obj, Not(Is(None)))
        return obj


    def mouse_click(self,objectName):
        """Move mouse on top of the object and click on it"""

        obj = self.get_object(objectName)
        self.pointing_device.move_to_object(obj)
        self.pointing_device.click()


    def mouse_press(self,objectName):
        """Move mouse on top of the object and press mouse button (without releasing it)"""

        obj = self.get_object(objectName)
        self.pointing_device.move_to_object(obj)
        self.pointing_device.press()


    def mouse_release(self):
        """Release mouse button"""

        self.pointing_device.release()     


    def type_string(self, string):
        """Type a string with keyboard"""

#.........这里部分代码省略.........
开发者ID:gcollura,项目名称:saucybacon,代码行数:103,代码来源:__init__.py

示例7: CustomInstallTests

# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import click [as 别名]
class CustomInstallTests(AutopilotTestCase):

    def setUp(self):
        super(CustomInstallTests, self).setUp()
        self.app = self.launch_application()

        self.pointing_device = Pointer(Mouse.create())

    def launch_application(self):
        my_process = int(os.environ['UBIQUITY_PID'])
        my_dbus = str(os.environ['DBUS_SESSION_BUS_ADDRESS'])
        return get_proxy_object_for_existing_process(
            pid=my_process, dbus_bus=my_dbus)

    def test_custom_install(self):
        '''
            Test install using Custom partition configuration
        '''
        self.keyboard.press_and_release('Super+1')

        main_window = self.app.select_single(
            'GtkWindow', name='live_installer')
        self.assertThat(main_window.title, Equals("Install"))
        # This method runs the ubiquity_ methods to navigate
        # testing through the install pages
        self.run_custom_install_test()

        #Then finally here check that the complete dialog appears

        self.ubiquity_did_install_complete()

    def run_custom_install_test(self):
        '''
            this can be easily used when debugging. If the test exits on a
            particular page, you can comment out the pages prior to the exit point
            and reset current page to its default state, then run test again.
            The test will start from the page it exited on. This can save alot of
            hassle having to setup the whole test again, just to fix a small error.
        '''
        #Page 1
        self.ubiquity_welcome_page_test()
        #Page 2
        self.ubiquity_preparing_page_test()
        ##Page 3
        self.ubiquity_install_type_page_test()
        ##Page 3 extended
        self.ubiquity_advanced_partition_page()
        #Page 4
        self.ubiquity_where_are_you_page_test()
        #Page 5
        self.ubiquity_keyboard_page_test()
        #Page 6
        self.ubiquity_who_are_you_page_test()
        #page 7
        self.ubiquity_progress_bar_test()

    def ubiquity_welcome_page_test(self):
        '''
            Tests that all needed objects on the Welcome page are accessible    
            And can also be navigated to.            
            Once confirmed continue with install accepting all defaults
        '''
        self.get_ubiquity_objects()

        self.assertThat(self.headerlabel.label, Eventually(Contains('Welcome')))
        #Can we navigate to the quit button? This fails the test if object
        # has no position attribs
        self.pointing_device.move_to_object(self.quit_button)
        self.assertThat(self.continue_button.label, Equals('Continue'))
        #Can we navigate to the continue button?
        self.pointing_device.move_to_object(self.continue_button)
        #Finally lets move on to the next page
        self.pointing_device.click()

    def ubiquity_preparing_page_test(self):

        self.wait_for_button_state_changed()
        #Check the next page title
        self.assertThat(self.headerlabel.label,
                        Eventually(Contains('Preparing to install')))
        #lets get all the page objects

        self.get_ubiquity_objects()
        '''
            Lets test we can go back to the welcome page and come back here
        '''
        #Click back
        self.pointing_device.move_to_object(self.back_button)
        self.pointing_device.click()

        self.wait_for_button_state_changed()
        #check we went back
        self.assertThat(self.headerlabel.label, Eventually(Contains('Welcome')))
        #go back to the page we were on
        self.get_ubiquity_objects()

        self.assertThat(self.continue_button.label, Equals('Continue'))
        self.pointing_device.move_to_object(self.continue_button)
        self.pointing_device.click()

#.........这里部分代码省略.........
开发者ID:queer1,项目名称:ubiquity,代码行数:103,代码来源:test_ubiquity_custom.py


注:本文中的autopilot.input.Pointer.click方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。