Skip to content

Commit

Permalink
Test time to load for login screen
Browse files Browse the repository at this point in the history
Signed-off-by: Serhy <sergii@status.im>
  • Loading branch information
antdanchenko authored and Serhy committed Jul 10, 2019
1 parent 368eaf1 commit 253c8c8
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/appium/tests/base_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def implicitly_wait(self):

def verify_no_errors(self):
if self.errors:
pytest.fail('. '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))

def is_alert_present(self, driver):
try:
Expand All @@ -136,7 +136,7 @@ def get_alert_text(self, driver):

def add_alert_text_to_report(self, driver):
if self.is_alert_present(driver):
test_suite_data.current_test.testruns[-1].error += ", also Unexpected Alert is shown: '%s'" \
test_suite_data.current_test.testruns[-1].error += "; also Unexpected Alert is shown: '%s'" \
% self.get_alert_text(driver)


Expand Down
1 change: 1 addition & 0 deletions test/appium/tests/marks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
sign_in = pytest.mark.sign_in
skip = pytest.mark.skip
logcat = pytest.mark.logcat
performance = pytest.mark.performance


battery_consumption = pytest.mark.battery_consumption
65 changes: 65 additions & 0 deletions test/appium/tests/test_performance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
from tests import marks
from tests.base_test_case import SingleDeviceTestCase
from views.sign_in_view import SignInView
from datetime import datetime
import time


class TestPerformance(SingleDeviceTestCase):

def get_timestamps_by_event(self, *args):
# earlier event will be overwritten by latest in case of multiple events in a logcat!

timestamps_by_event = dict()
logcat = self.driver.get_log('logcat')
for event in args:
for line in logcat:
if event in line['message']:
timestamps_by_event[event] = line['timestamp']
return timestamps_by_event

@marks.testrail_id(6216)
@marks.high
@marks.performance
def test_time_to_load_sign_in_screen(self):

app_started = ':init/app-started'
login_shown = ':on-will-focus :login'
password_submitted = ':accounts.login.ui/password-input-submitted'
login_success = ':accounts.login.callback/login-success'

sign_in = SignInView(self.driver)
sign_in.create_user()
profile = sign_in.profile_button.click()
profile.logout()
home = sign_in.sign_in()
home.plus_button.click()
self.driver.info("Close app")
self.driver.close_app()
self.driver.info("Launch app")
self.driver.launch_app()
time.sleep(5)

timestamps_by_event = self.get_timestamps_by_event(app_started, login_shown, password_submitted, login_success)
for event in app_started, login_shown, password_submitted, login_success:
self.driver.info("event: '%s' | timestamp: '%s' | time: '%s'" % (event, timestamps_by_event[event],
datetime.utcfromtimestamp(timestamps_by_event[event] / 1000)))

time_to_login= (timestamps_by_event[login_success] - timestamps_by_event[password_submitted]) / 1000
self.driver.info("Time to login is '%s'" % time_to_login)

time_to_start_app = (timestamps_by_event[login_shown] - timestamps_by_event[app_started]) / 1000
self.driver.info("Time to start the app is '%s'" % time_to_start_app)

baseline_start_app = 0.8
baseline_login = 1.2

if time_to_start_app > baseline_start_app:
self.errors.append(
"time between starting the app and login screen is '%s' seconds, while baseline is '%s'!"
% (time_to_start_app, baseline_start_app))
if time_to_login > baseline_login:
self.errors.append(
"time between submitting a password and successful login is '%s' seconds, while baseline is '%s'!"
% (time_to_login, baseline_login))
self.verify_no_errors()

0 comments on commit 253c8c8

Please sign in to comment.