Test time to load for login screen

Signed-off-by: Serhy <sergii@status.im>
This commit is contained in:
Anton Danchenko 2019-06-03 22:44:06 +03:00 committed by Serhy
parent 368eaf1944
commit 253c8c8e7a
No known key found for this signature in database
GPG Key ID: 5D7C4B9E2B6F500B
3 changed files with 68 additions and 2 deletions

View File

@ -123,7 +123,7 @@ class AbstractTestCase:
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:
@ -136,7 +136,7 @@ class AbstractTestCase:
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)

View File

@ -21,6 +21,7 @@ wallet = pytest.mark.wallet
sign_in = pytest.mark.sign_in
skip = pytest.mark.skip
logcat = pytest.mark.logcat
performance = pytest.mark.performance
battery_consumption = pytest.mark.battery_consumption

View File

@ -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()