Beispiel #1
0
def set_screen_landscape():
    """
    set screen landscape
    :return:
    """
    solo = get_solo()
    call(solo, "setActivityOrientation", SCREEN_ORIENTATION_LANDSCAPE)
 def take_screenshot(self, name):
     """
     Takes a screenshot and saves it with the specified name in the {@link Config} objects save path (default set to: /sdcard/Robotium-Screenshots/).
     Requires write permission (android.permission.WRITE_EXTERNAL_STORAGE) in AndroidManifest.xml of the application under test.
     :param name: the name to give the screenshot
     """
     call(self, "takeScreenshot", name)
 def set_progress_bar(self, index, progress):
     """
     Sets the progress of a ProgressBar matching the specified index. Examples of ProgressBars are: {@link android.widget.SeekBar} and {@link android.widget.RatingBar}.
     :param index: the index of the {@link ProgressBar}
     :param progress: the progress to set the {@link ProgressBar}
     """
     call(self, "setProgressBar", index, progress)
Beispiel #4
0
 def take_screenshot(self, name):
     """
     Takes a screenshot and saves it with the specified name in the {@link Config} objects save path (default set to: /sdcard/Robotium-Screenshots/).
     Requires write permission (android.permission.WRITE_EXTERNAL_STORAGE) in AndroidManifest.xml of the application under test.
     :param name: the name to give the screenshot
     """
     call(self, "takeScreenshot", name)
Beispiel #5
0
 def set_progress_bar(self, index, progress):
     """
     Sets the progress of a ProgressBar matching the specified index. Examples of ProgressBars are: {@link android.widget.SeekBar} and {@link android.widget.RatingBar}.
     :param index: the index of the {@link ProgressBar}
     :param progress: the progress to set the {@link ProgressBar}
     """
     call(self, "setProgressBar", index, progress)
Beispiel #6
0
def set_screen_landscape():
    """
    set screen landscape
    :return:
    """
    solo = get_solo()
    call(solo, "setActivityOrientation", SCREEN_ORIENTATION_LANDSCAPE)
Beispiel #7
0
def set_screen_portrait():
    """
    set screen portrait
    :return:
    """
    solo = get_solo()
    current_activity = solo.get_current_activity()
    call(current_activity, "setRequestedOrientation", SCREEN_ORIENTATION_PORTRAIT)
Beispiel #8
0
 def get_view(self, res_id=None, class_name=None, index=None):
     if res_id:
         if index:
             return call(self, "getView", res_id, index)
         return call(self, "getView", res_id)
     if class_name:
         if index:
             return call(self, "getView", RemoteObject.from_class_name(class_name), index)
         return call(self, "getView", RemoteObject.from_class_name(class_name))
 def get_view(self, res_id=None, class_name=None, index=None):
     if res_id:
         if index:
             return call(self, "getView", res_id, index)
         return call(self, "getView", res_id)
     if class_name:
         if index:
             return call(self, "getView", RemoteObject.from_class_name(class_name), index)
         return call(self, "getView", RemoteObject.from_class_name(class_name))
Beispiel #10
0
def get_soft_input_state(edit_text_view):
    """
    get textView soft input state
    :param edit_text_view: type of textView
    :return: false or true;false means soft input is not active  ;true means soft input is active
    """
    context = call(edit_text_view, "getContext")
    input_manager = call(context, "getSystemService", "input_method")
    return call(input_manager, "isActive")
Beispiel #11
0
def set_screen_portrait():
    """
    set screen portrait
    :return:
    """
    solo = get_solo()
    current_activity = solo.get_current_activity()
    call(current_activity, "setRequestedOrientation",
         SCREEN_ORIENTATION_PORTRAIT)
Beispiel #12
0
def get_soft_input_state(edit_text_view):
    """
    get textView soft input state
    :param edit_text_view: type of textView
    :return: false or true;false means soft input is not active  ;true means soft input is active
    """
    context = call(edit_text_view, "getContext")
    input_manager = call(context, "getSystemService", "input_method")
    return call(input_manager, "isActive")
Beispiel #13
0
 def drag_in_view(self, view, start_x, start_y, end_x, end_y, step_count):
     """
     Drag in view rect.
     :param start_x: start position on x, input percent value. e.g. 40 --> 40%
     :param start_y:
     :param end_x:
     :param end_y:
     :param step_count:
     :return:
     """
     view.class_name = android_view
     call(self, "dragInView", view, start_x, start_y, end_x, end_y, step_count)
 def drag_in_view(self, view, start_x, start_y, end_x, end_y, step_count):
     """
     Drag in view rect.
     :param start_x: start position on x, input percent value. e.g. 40 --> 40%
     :param start_y:
     :param end_x:
     :param end_y:
     :param step_count:
     :return:
     """
     view.class_name = android_view
     call(self, "dragInView", view, start_x, start_y, end_x, end_y, step_count)
Beispiel #15
0
 def get_button(self, text):
     """
     Returns a Button displaying the specified text.
     :param text: the text that is displayed, specified as a regular expression
     :return: the {@link Button} displaying the specified text
     """
     return call(self, "getButton", text)
Beispiel #16
0
 def set_activity_orientation(self, orientation):
     """
     Sets the Orientation (Landscape/Portrait) for the current Activity.
     :param orientation: the orientation to set. <code>Solo.</code>{@link #LANDSCAPE} for landscape or <code>Solo.</code>{@link #PORTRAIT} for portrait.
     :return:
     """
     return call(self, "setActivityOrientation", orientation)
Beispiel #17
0
 def get_displayed_views(self, res_id):
     """
     get views in window rect by view id str
     :param res_id:
     :return:
     """
     return call(self, "getDisplayedViews", res_id)
Beispiel #18
0
def get_text_view_line_count(view):
    """
    get textView line count
    :param view:the type of textView
    :return:
    """
    return call(view, "getLineCount")
Beispiel #19
0
 def wait_for_fragment_by_tag(self, tag):
     """
     Waits for a Fragment matching the specified tag.
     :param tag: the name of the tag
     :return {@code true}: if fragment appears and {@code false} if it does not appear before the timeout
     """
     return call(self, " waitForFragmentByTag", tag)
Beispiel #20
0
 def click_long_on_screen(self, x, y):
     """
     Long clicks the specified coordinates.
     :param x: the x coordinate
     :param y: the y coordinate
     """
     return call(self, "clickLongOnScreen", RemoteObject.from_float(x), RemoteObject.from_float(y))
Beispiel #21
0
 def wait_for_text(self, text):
     """
     Waits for the specified text to appear. Default timeout is 20 seconds.
     @param text the text to wait for, specified as a regular expression
     @return {@code true} if text is displayed and {@code false} if it is not displayed before the timeout
     """
     return call(self, "waitForText", text)
Beispiel #22
0
 def wait_for_activity(self, name):
     """
     Waits for an Activity matching the specified name. Default timeout is 20 seconds.
     :param name: the name of the {@code Activity} to wait for. Example is: {@code "MyActivity"}
     :return: {@code true} if {@code Activity} appears before the timeout and {@code false} if it does not
     """
     return call(self, "waitForActivity", name)
Beispiel #23
0
 def get_text(self, text):
     """
     Returns a TextView displaying the specified text.
     :param text: the text that is displayed, specified as a regular expression
     :return: the {@link TextView} displaying the specified text
     """
     return call(self, "getText", text)
Beispiel #24
0
 def clear_edit_text(self, edit_text_view):
     """
     Clears the value of an EditText.
     :param edit_text_view: the {@link EditText} to clear
     """
     edit_text_view.class_name = android_edit_text
     return call(self, "clearEditText", edit_text_view)
Beispiel #25
0
 def get_current_activity(self):
     """
     Returns the current Activity.
     :return: the current Activity.
     """
     obj = call(self, "getCurrentActivity")
     return Activity.from_object(obj)
Beispiel #26
0
def get_group_child_count(view_group):
    """
    功能:获取viewGroup child 数量
    :param view_group:
    :return:
    """
    return call(view_group, "getChildCount")
Beispiel #27
0
 def get_count(self):
     """
     :return: The number of items owned by the Adapter associated with this
     AdapterView. (This is the number of data items, which may be
     larger than the number of visible views.)
     """
     return call(self, 'getCount')
Beispiel #28
0
 def get_last_visible_position(self):
     """
     Returns the position within the adapter's data set for the last item
     displayed on screen.
     :return: The position within the adapter's data set
     """
     return call(self, 'getLastVisiblePosition')
Beispiel #29
0
 def click_on_text(self, text):
     """
     Clicks a View or WebElement displaying the specified
     text. Will automatically scroll when needed.
     :param text: the text to click. The parameter will be interpreted as a regular expression
     """
     return call(self, "clickOnText", text)
 def get_last_visible_position(self):
     """
     Returns the position within the adapter's data set for the last item
     displayed on screen.
     :return: The position within the adapter's data set
     """
     return call(self, 'getLastVisiblePosition')
 def clear_edit_text(self, edit_text_view):
     """
     Clears the value of an EditText.
     :param edit_text_view: the {@link EditText} to clear
     """
     edit_text_view.class_name = android_edit_text
     return call(self, "clearEditText", edit_text_view)
Beispiel #32
0
def get_group_child_count(view_group):
    """
    功能:获取viewGroup child 数量
    :param view_group:
    :return:
    """
    return call(view_group, "getChildCount")
 def get_displayed_views(self, res_id):
     """
     get views in window rect by view id str
     :param res_id:
     :return:
     """
     return call(self, "getDisplayedViews", res_id)
 def get_text(self, text):
     """
     Returns a TextView displaying the specified text.
     :param text: the text that is displayed, specified as a regular expression
     :return: the {@link TextView} displaying the specified text
     """
     return call(self, "getText", text)
 def get_button(self, text):
     """
     Returns a Button displaying the specified text.
     :param text: the text that is displayed, specified as a regular expression
     :return: the {@link Button} displaying the specified text
     """
     return call(self, "getButton", text)
 def wait_for_activity(self, name):
     """
     Waits for an Activity matching the specified name. Default timeout is 20 seconds.
     :param name: the name of the {@code Activity} to wait for. Example is: {@code "MyActivity"}
     :return: {@code true} if {@code Activity} appears before the timeout and {@code false} if it does not
     """
     return call(self, "waitForActivity", name)
 def set_activity_orientation(self, orientation):
     """
     Sets the Orientation (Landscape/Portrait) for the current Activity.
     :param orientation: the orientation to set. <code>Solo.</code>{@link #LANDSCAPE} for landscape or <code>Solo.</code>{@link #PORTRAIT} for portrait.
     :return:
     """
     return call(self, "setActivityOrientation", orientation)
 def get_count(self):
     """
     :return: The number of items owned by the Adapter associated with this
     AdapterView. (This is the number of data items, which may be
     larger than the number of visible views.)
     """
     return call(self, 'getCount')
 def click_long_on_screen(self, x, y):
     """
     Long clicks the specified coordinates.
     :param x: the x coordinate
     :param y: the y coordinate
     """
     return call(self, "clickLongOnScreen", RemoteObject.from_float(x), RemoteObject.from_float(y))
 def wait_for_text(self, text):
     """
     Waits for the specified text to appear. Default timeout is 20 seconds.
     @param text the text to wait for, specified as a regular expression
     @return {@code true} if text is displayed and {@code false} if it is not displayed before the timeout
     """
     return call(self, "waitForText", text)
 def get_current_activity(self):
     """
     Returns the current Activity.
     :return: the current Activity.
     """
     obj = call(self, "getCurrentActivity")
     return Activity.from_object(obj)
Beispiel #42
0
def get_text_view_line_count(view):
    """
    get textView line count
    :param view:the type of textView
    :return:
    """
    return call(view, "getLineCount")
 def wait_for_fragment_by_tag(self, tag):
     """
     Waits for a Fragment matching the specified tag.
     :param tag: the name of the tag
     :return {@code true}: if fragment appears and {@code false} if it does not appear before the timeout
     """
     return call(self, " waitForFragmentByTag", tag)
 def click_on_text(self, text):
     """
     Clicks a View or WebElement displaying the specified
     text. Will automatically scroll when needed.
     :param text: the text to click. The parameter will be interpreted as a regular expression
     """
     return call(self, "clickOnText", text)
Beispiel #45
0
 def enter_text(self, edit_text_view, text):
     """
     Enters text in the specified EditText.
     :param edit_text_view: the {@link EditText} to enter text in
     :param text: the text to enter in the {@link EditText} field
     """
     edit_text_view.class_name = android_edit_text
     return call(self, "enterText", edit_text_view, text)
 def enter_text(self, edit_text_view, text):
     """
     Enters text in the specified EditText.
     :param edit_text_view: the {@link EditText} to enter text in
     :param text: the text to enter in the {@link EditText} field
     """
     edit_text_view.class_name = android_edit_text
     return call(self, "enterText", edit_text_view, text)
Beispiel #47
0
    def wait_for_view(self, class_name):
        """
        Waits for a View matching the specified class. Default timeout is 20 seconds.
        :param class_name:viewClass the {@link View} class to wait for
        :return:{@code true} if the {@link View} is displayed and {@code false} if it is not displayed before the timeout
        """

        return call(self, "waitForView", RemoteObject.from_class_name(class_name))
    def wait_for_view(self, class_name):
        """
        Waits for a View matching the specified class. Default timeout is 20 seconds.
        :param class_name:viewClass the {@link View} class to wait for
        :return:{@code true} if the {@link View} is displayed and {@code false} if it is not displayed before the timeout
        """

        return call(self, "waitForView", RemoteObject.from_class_name(class_name))
Beispiel #49
0
 def click_long_on_view(self, view):
     """
     Long clicks the specified View.
     :param view: the {@link View} to long click
     :return:
     """
     view.class_name = android_view
     return call(self, "clickLongOnView", view)
 def wait_for_log_message(self, message):
     """
     Waits for the specified log message to appear. Default timeout is 20 seconds.
     Requires read logs permission (android.permission.READ_LOGS) in AndroidManifest.xml of the application under test.
     :param message: the log message to wait for
     :return: {@code true} if log message appears and {@code false} if it does not appear before the timeout
     """
     return call(self, "waitForLogMessage", message)
Beispiel #51
0
def get_child_view(parent_view, index=1):
    """
    通过parent_view 获取 index 位置的view
    :param parent_view: 父级view,view继承ViewGroup
    :param index:第index位置
    :return:
    """
    return call(parent_view, "getChildAt", index - 1)
 def click_long_on_view(self, view):
     """
     Long clicks the specified View.
     :param view: the {@link View} to long click
     :return:
     """
     view.class_name = android_view
     return call(self, "clickLongOnView", view)
Beispiel #53
0
def get_child_view(parent_view, index=1):
    """
    通过parent_view 获取 index 位置的view
    :param parent_view: 父级view,view继承ViewGroup
    :param index:第index位置
    :return:
    """
    return call(parent_view, "getChildAt", index - 1)
Beispiel #54
0
 def scroll_list_to_top(self, list_view):
     """
     Scrolls to the top of the specified AbsListView.
     :param list_view: the {@link AbsListView} to scroll
     :return: {@code true} if more scrolling can be performed
     """
     list_view.class_name = android_abs_list_view
     return call(self, "scrollListToTop", list_view)
Beispiel #55
0
 def wait_for_log_message(self, message):
     """
     Waits for the specified log message to appear. Default timeout is 20 seconds.
     Requires read logs permission (android.permission.READ_LOGS) in AndroidManifest.xml of the application under test.
     :param message: the log message to wait for
     :return: {@code true} if log message appears and {@code false} if it does not appear before the timeout
     """
     return call(self, "waitForLogMessage", message)
 def scroll_list_to_top(self, list_view):
     """
     Scrolls to the top of the specified AbsListView.
     :param list_view: the {@link AbsListView} to scroll
     :return: {@code true} if more scrolling can be performed
     """
     list_view.class_name = android_abs_list_view
     return call(self, "scrollListToTop", list_view)
Beispiel #57
0
def get_view_text(view_id, index=0):
    """
    Returns a TextView matching the specified index.
    :param view_id:the view_id of the {@link View}
    :param index:the index of the {@link TextView}. {@code 0} if only one is available
    :return:a {@link TextView} matching the specified index
    """
    view = get_solo().get_view(res_id=view_id, index=index)
    return call(view, "getText")
 def wait_text_in_list(self, list_view, text):
     """
     Scroll list one screen by one. Not scroll line by line
     :param list_view:
     :param text:
     :return:
     """
     list_view.class_name = android_abs_list_view
     return call(self, "waitTextInList", list_view, text)
Beispiel #59
0
def assert_view_not_show(view):
    """
    assert view is hidden
    :param view:
    :return:
    """
    is_shown = call(view, "isShown")
    if is_shown:
        raise AssertionError('%s is show' % view)
Beispiel #60
0
def get_view_text(view_id, index=0):
    """
    Returns a TextView matching the specified index.
    :param view_id:the view_id of the {@link View}
    :param index:the index of the {@link TextView}. {@code 0} if only one is available
    :return:a {@link TextView} matching the specified index
    """
    view = get_solo().get_view(res_id=view_id, index=index)
    return call(view, "getText")