This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
/
activities.py
82 lines (67 loc) · 3.59 KB
/
activities.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from marionette.by import By
from gaiatest.apps.base import Base
from marionette import Wait
from marionette import expected
class Activities(Base):
_actions_menu_locator = (By.CSS_SELECTOR, 'form[data-type="action"]')
_action_option_locator = (By.CSS_SELECTOR, 'form[data-type="action"] button')
_activity_window_locator = (By.CLASS_NAME, 'activityWindow')
_wallpaper_button_locator = (By.XPATH, "//*[text()='Wallpaper']")
_gallery_button_locator = (By.XPATH, '//*[text()="Gallery"]')
_camera_button_locator = (By.XPATH, '//*[text()="Camera"]')
_messages_button_locator = (By.XPATH, '//*[text()="Messages"]')
_cancel_button_locator = (By.CSS_SELECTOR, 'form[data-type="action"] button[data-action="cancel"]')
_save_image_locator = (By.CSS_SELECTOR, 'button[data-id="save-image"]')
def __init__(self, marionette):
Base.__init__(self, marionette)
self.marionette.switch_to_frame()
view = self.marionette.find_element(*self._actions_menu_locator)
Wait(self.marionette).until(lambda m: view.location['y'] == 0)
def tap_wallpaper(self):
self.marionette.find_element(*self._wallpaper_button_locator).tap()
self.wait_for_element_not_displayed(*self._actions_menu_locator)
from gaiatest.apps.wallpaper.app import Wallpaper
wallpaper = Wallpaper(self.marionette)
self.wait_for_condition(lambda m: self.apps.displayed_app.name == wallpaper.name)
self.apps.switch_to_displayed_app()
return wallpaper
def tap_gallery(self):
self.marionette.find_element(*self._gallery_button_locator).tap()
self.wait_for_element_not_displayed(*self._actions_menu_locator)
from gaiatest.apps.gallery.app import Gallery
gallery = Gallery(self.marionette)
self.wait_for_condition(lambda m: self.apps.displayed_app.name == gallery.name)
self.apps.switch_to_displayed_app()
return gallery
def tap_camera(self):
self.marionette.find_element(*self._camera_button_locator).tap()
self.wait_for_element_not_displayed(*self._actions_menu_locator)
from gaiatest.apps.camera.app import Camera
camera = Camera(self.marionette)
self.wait_for_condition(lambda m: self.apps.displayed_app.name == camera.name)
self.apps.switch_to_displayed_app()
camera.wait_for_loading_spinner_hidden()
camera.wait_for_capture_ready()
return camera
def tap_cancel(self):
self.marionette.find_element(*self._cancel_button_locator).tap()
self.wait_for_element_not_displayed(*self._actions_menu_locator)
self.apps.switch_to_displayed_app()
def tap_save_image(self):
Wait(self.marionette).until(expected.element_displayed(
Wait(self.marionette).until(expected.element_present(*self._save_image_locator))))
self.marionette.find_element(*self._save_image_locator).tap()
@property
def options_count(self):
return len(self.marionette.find_elements(*self._action_option_locator))
@property
def is_menu_visible(self):
return self.is_element_displayed(*self._actions_menu_locator)
def share_to_messages(self):
self.marionette.find_element(*self._messages_button_locator).tap()
self.wait_for_element_not_displayed(*self._actions_menu_locator)
from gaiatest.apps.messages.regions.new_message import NewMessage
return NewMessage(self.marionette)