Bug 1612527 - Refactor browser calls in deletion-request ping test; r=raphael

Differential Revision: https://phabricator.services.mozilla.com/D69572

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ankita 2020-04-09 16:24:41 +00:00
Родитель 8d21444c67
Коммит 04fa714df4
2 изменённых файлов: 22 добавлений и 12 удалений

Просмотреть файл

@ -45,6 +45,18 @@ class TelemetryTestCase(WindowManagerMixin, MarionetteTestCase):
self.ping_server.start()
def disable_telemetry(self):
"""Disable the Firefox Data Collection and Use in the current browser."""
self.marionette.instance.profile.set_persistent_preferences(
{"datareporting.healthreport.uploadEnabled": False})
self.marionette.set_pref("datareporting.healthreport.uploadEnabled", False)
def enable_telemetry(self):
"""Enable the Firefox Data Collection and Use in the current browser."""
self.marionette.instance.profile.set_persistent_preferences(
{"datareporting.healthreport.uploadEnabled": True})
self.marionette.set_pref("datareporting.healthreport.uploadEnabled", True)
@contextlib.contextmanager
def new_tab(self):
"""Perform operations in a new tab and then close the new tab."""
@ -141,6 +153,14 @@ class TelemetryTestCase(WindowManagerMixin, MarionetteTestCase):
"""Restarts browser while maintaining the same profile."""
return self.marionette.restart(clean=False, in_app=True)
def start_browser(self):
"""Start the browser."""
return self.marionette.start_session()
def quit_browser(self):
"""Quit the browser."""
return self.marionette.quit(in_app=True)
def install_addon(self):
"""Install a minimal addon and add its ID to self.addon_ids."""

Просмотреть файл

@ -9,16 +9,6 @@ from telemetry_harness.ping_filters import ANY_PING, DELETION_REQUEST_PING, MAIN
class TestDeletionRequestPing(TelemetryTestCase):
"""Tests for "deletion-request" ping."""
def disable_telemetry(self):
self.marionette.instance.profile.set_persistent_preferences(
{"datareporting.healthreport.uploadEnabled": False})
self.marionette.set_pref("datareporting.healthreport.uploadEnabled", False)
def enable_telemetry(self):
self.marionette.instance.profile.set_persistent_preferences(
{"datareporting.healthreport.uploadEnabled": True})
self.marionette.set_pref("datareporting.healthreport.uploadEnabled", True)
def test_optout_ping_across_sessions(self):
"""Test the "deletion-request" ping behaviour across sessions."""
@ -34,12 +24,12 @@ class TestDeletionRequestPing(TelemetryTestCase):
self.assertNotIn("environment", ping["payload"])
# Close Firefox cleanly.
self.marionette.quit(in_app=True)
self.quit_browser()
# TODO: Check pending pings aren't persisted
# Start Firefox.
self.marionette.start_session()
self.start_browser()
# Trigger an environment change, which isn't allowed to send a ping.
self.install_addon()