зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1382345 - Use callback in test harness r=chutten
Added callback to testcase.py. Made sure callback is callable. Added callback in test_main_tab_scalars to be the browser restart. Added callback in test_ping_server_received_ping to None because no callback is needed. MozReview-Commit-ID: Jf4YHasCXVg --HG-- extra : rebase_source : f2b54f151d40436598003c009cc8a9b06bb052af
This commit is contained in:
Родитель
b24d631e4c
Коммит
61246931b7
|
@ -51,12 +51,14 @@ class TelemetryTestCase(PuppeteerMixin, MarionetteTestCase):
|
|||
# Wait 5 seconds to ensure that telemetry has reinitialized
|
||||
time.sleep(5)
|
||||
|
||||
def wait_for_ping(self, ping_filter_func):
|
||||
if len(self.ping_list) == 0:
|
||||
try:
|
||||
Wait(self.marionette, 60).until(lambda t: len(self.ping_list) > 0)
|
||||
except Exception as e:
|
||||
self.fail('Error generating ping: {}'.format(e.message))
|
||||
def wait_for_ping(self, action_func, ping_filter_func):
|
||||
current_num_pings = len(self.ping_list)
|
||||
if callable(action_func):
|
||||
action_func()
|
||||
try:
|
||||
Wait(self.marionette, 60).until(lambda _: len(self.ping_list) > current_num_pings)
|
||||
except Exception as e:
|
||||
self.fail('Error generating ping: {}'.format(e.message))
|
||||
# Filter pings based on type and reason to make sure right ping is captured.
|
||||
self.ping_list = [p for p in self.ping_list if ping_filter_func(p)]
|
||||
|
||||
|
|
|
@ -25,8 +25,7 @@ class TestMainTabScalars(TelemetryTestCase):
|
|||
self.browser.tabbar.close_tab(tab2, force=True)
|
||||
wait.until(lambda m: len(self.browser.tabbar.tabs) == 1)
|
||||
self.browser.tabbar.switch_to(tab1)
|
||||
self.restart_browser()
|
||||
ping = self.wait_for_ping(lambda p: p['type'] == 'main'
|
||||
ping = self.wait_for_ping(self.restart_browser, lambda p: p['type'] == 'main'
|
||||
and p['payload']['info']['reason'] == 'shutdown')
|
||||
assert ping['type'] == 'main'
|
||||
assert ping['clientId'] == self.client_id
|
||||
|
|
|
@ -15,7 +15,7 @@ class TestPingServer(TelemetryTestCase):
|
|||
data = {'type': 'server-test-ping', 'reason': 'unit-test'}
|
||||
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||
json_req = requests.post(self.ping_server_url, data=json.dumps(data), headers=headers)
|
||||
ping = self.wait_for_ping(lambda p: p['type'] == 'server-test-ping')
|
||||
ping = self.wait_for_ping(None, lambda p: p['type'] == 'server-test-ping')
|
||||
assert ping is not None
|
||||
assert json_req.status_code == 200
|
||||
assert data['type'] == ping['type'] and data['reason'] == ping['reason']
|
||||
|
|
Загрузка…
Ссылка в новой задаче