Bug 1488468 - Remove wait.until calls and improve formatting in test_main_tab_scalar; r=davehunt
authorRaphael Pierzina <rpierzina@mozilla.com>
Fri, 05 Oct 2018 19:16:47 +0000
changeset 439964 b6f68f56cc7fa528d4f8a1ac1ca7ce7d84948719
parent 439963 5084bccfd9ac480180a8b512568345ed1de605d6
child 439965 b2a9499e2c3e3673ea1fae85d5e7f19481f11ca4
push id70520
push userdhunt@mozilla.com
push dateMon, 08 Oct 2018 09:17:13 +0000
treeherderautoland@b2a9499e2c3e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavehunt
bugs1488468
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1488468 - Remove wait.until calls and improve formatting in test_main_tab_scalar; r=davehunt Depends on D7904 Differential Revision: https://phabricator.services.mozilla.com/D7905
toolkit/components/telemetry/tests/marionette/tests/client/test_main_tab_scalars.py
--- a/toolkit/components/telemetry/tests/marionette/tests/client/test_main_tab_scalars.py
+++ b/toolkit/components/telemetry/tests/marionette/tests/client/test_main_tab_scalars.py
@@ -1,35 +1,47 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from marionette_driver.wait import Wait
-
 from telemetry_harness.testcase import TelemetryTestCase
 
 
+def check_is_shutdown_ping(ping):
+    """Check for a shutdown ping."""
+
+    if ping["type"] != "main":
+        return False
+
+    if ping["payload"]["info"]["reason"] != "shutdown":
+        return False
+
+    return True
+
+
 class TestMainTabScalars(TelemetryTestCase):
+    """Tests for Telemetry Scalars."""
 
     def test_main_tab_scalars(self):
-        wait = Wait(self.marionette, 10)
+        """Test for Telemetry Scalars."""
 
         with self.marionette.using_context(self.marionette.CONTEXT_CHROME):
             tab1 = self.browser.tabbar.selected_tab
+
             tab2 = self.browser.tabbar.open_tab()
-            wait.until(lambda m: len(self.browser.tabbar.tabs) == 2)
             self.browser.tabbar.switch_to(tab2)
+
             tab3 = self.browser.tabbar.open_tab()
-            wait.until(lambda m: len(self.browser.tabbar.tabs) == 3)
             self.browser.tabbar.switch_to(tab3)
+
             self.browser.tabbar.close_tab(tab3, force=True)
-            wait.until(lambda m: len(self.browser.tabbar.tabs) == 2)
             self.browser.tabbar.close_tab(tab2, force=True)
-            wait.until(lambda m: len(self.browser.tabbar.tabs) == 1)
+
             self.browser.tabbar.switch_to(tab1)
-        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
-        scalars = ping['payload']['processes']['parent']['scalars']
-        assert scalars['browser.engagement.max_concurrent_tab_count'] == 3
-        assert scalars['browser.engagement.tab_open_event_count'] == 2
-        assert scalars['browser.engagement.max_concurrent_window_count'] == 1
+
+        ping = self.wait_for_ping(self.restart_browser, check_is_shutdown_ping)
+        assert ping["type"] == "main"
+        assert ping["clientId"] == self.client_id
+
+        scalars = ping["payload"]["processes"]["parent"]["scalars"]
+        assert scalars["browser.engagement.max_concurrent_tab_count"] == 3
+        assert scalars["browser.engagement.tab_open_event_count"] == 2
+        assert scalars["browser.engagement.max_concurrent_window_count"] == 1