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
parent 8d21444c67
commit 04fa714df4
2 changed files with 22 additions and 12 deletions

View File

@ -45,6 +45,18 @@ class TelemetryTestCase(WindowManagerMixin, MarionetteTestCase):
self.ping_server.start() 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 @contextlib.contextmanager
def new_tab(self): def new_tab(self):
"""Perform operations in a new tab and then close the new tab.""" """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.""" """Restarts browser while maintaining the same profile."""
return self.marionette.restart(clean=False, in_app=True) 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): def install_addon(self):
"""Install a minimal addon and add its ID to self.addon_ids.""" """Install a minimal addon and add its ID to self.addon_ids."""

View File

@ -9,16 +9,6 @@ from telemetry_harness.ping_filters import ANY_PING, DELETION_REQUEST_PING, MAIN
class TestDeletionRequestPing(TelemetryTestCase): class TestDeletionRequestPing(TelemetryTestCase):
"""Tests for "deletion-request" ping.""" """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): def test_optout_ping_across_sessions(self):
"""Test the "deletion-request" ping behaviour across sessions.""" """Test the "deletion-request" ping behaviour across sessions."""
@ -34,12 +24,12 @@ class TestDeletionRequestPing(TelemetryTestCase):
self.assertNotIn("environment", ping["payload"]) self.assertNotIn("environment", ping["payload"])
# Close Firefox cleanly. # Close Firefox cleanly.
self.marionette.quit(in_app=True) self.quit_browser()
# TODO: Check pending pings aren't persisted # TODO: Check pending pings aren't persisted
# Start Firefox. # Start Firefox.
self.marionette.start_session() self.start_browser()
# Trigger an environment change, which isn't allowed to send a ping. # Trigger an environment change, which isn't allowed to send a ping.
self.install_addon() self.install_addon()