mobile/android/base/tests/testUITelemetry.java

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 package org.mozilla.gecko.tests;
michael@0 2
michael@0 3 import org.mozilla.gecko.AppConstants;
michael@0 4 import org.mozilla.gecko.PrefsHelper;
michael@0 5 import org.mozilla.gecko.Telemetry;
michael@0 6
michael@0 7 import android.util.Log;
michael@0 8
michael@0 9 public class testUITelemetry extends JavascriptTest {
michael@0 10 // Prefix used to distinguish test events and sessions from
michael@0 11 // real ones. Used by the javascript part of the test.
michael@0 12 static final String TEST_PREFIX = "TEST-";
michael@0 13
michael@0 14 public testUITelemetry() {
michael@0 15 super("testUITelemetry.js");
michael@0 16 }
michael@0 17
michael@0 18 @Override
michael@0 19 public void testJavascript() throws Exception {
michael@0 20 blockForGeckoReady();
michael@0 21
michael@0 22 // We can't run these tests unless telemetry is turned on --
michael@0 23 // the events will be dropped on the floor.
michael@0 24 Log.i("GeckoTest", "Enabling telemetry.");
michael@0 25 PrefsHelper.setPref(AppConstants.TELEMETRY_PREF_NAME, true);
michael@0 26
michael@0 27 Log.i("GeckoTest", "Adding telemetry events.");
michael@0 28 try {
michael@0 29 Telemetry.sendUIEvent(TEST_PREFIX + "enone", "method0");
michael@0 30 Telemetry.startUISession(TEST_PREFIX + "foo");
michael@0 31 Telemetry.sendUIEvent(TEST_PREFIX + "efoo", "method1");
michael@0 32 Telemetry.startUISession(TEST_PREFIX + "foo");
michael@0 33 Telemetry.sendUIEvent(TEST_PREFIX + "efoo", "method2");
michael@0 34 Telemetry.startUISession(TEST_PREFIX + "bar");
michael@0 35 Telemetry.sendUIEvent(TEST_PREFIX + "efoobar", "method3", "foobarextras");
michael@0 36 Telemetry.stopUISession(TEST_PREFIX + "foo", "reasonfoo");
michael@0 37 Telemetry.sendUIEvent(TEST_PREFIX + "ebar", "method4", "barextras");
michael@0 38 Telemetry.stopUISession(TEST_PREFIX + "bar", "reasonbar");
michael@0 39 Telemetry.stopUISession(TEST_PREFIX + "bar", "reasonbar2");
michael@0 40 Telemetry.sendUIEvent(TEST_PREFIX + "enone", "method5");
michael@0 41 } catch (Exception e) {
michael@0 42 Log.e("GeckoTest", "Oops.", e);
michael@0 43 }
michael@0 44
michael@0 45 Log.i("GeckoTest", "Running remaining JS test code.");
michael@0 46 super.testJavascript();
michael@0 47 }
michael@0 48 }
michael@0 49

mercurial