michael@0: package org.mozilla.gecko.tests; michael@0: michael@0: import org.mozilla.gecko.AppConstants; michael@0: import org.mozilla.gecko.PrefsHelper; michael@0: import org.mozilla.gecko.Telemetry; michael@0: michael@0: import android.util.Log; michael@0: michael@0: public class testUITelemetry extends JavascriptTest { michael@0: // Prefix used to distinguish test events and sessions from michael@0: // real ones. Used by the javascript part of the test. michael@0: static final String TEST_PREFIX = "TEST-"; michael@0: michael@0: public testUITelemetry() { michael@0: super("testUITelemetry.js"); michael@0: } michael@0: michael@0: @Override michael@0: public void testJavascript() throws Exception { michael@0: blockForGeckoReady(); michael@0: michael@0: // We can't run these tests unless telemetry is turned on -- michael@0: // the events will be dropped on the floor. michael@0: Log.i("GeckoTest", "Enabling telemetry."); michael@0: PrefsHelper.setPref(AppConstants.TELEMETRY_PREF_NAME, true); michael@0: michael@0: Log.i("GeckoTest", "Adding telemetry events."); michael@0: try { michael@0: Telemetry.sendUIEvent(TEST_PREFIX + "enone", "method0"); michael@0: Telemetry.startUISession(TEST_PREFIX + "foo"); michael@0: Telemetry.sendUIEvent(TEST_PREFIX + "efoo", "method1"); michael@0: Telemetry.startUISession(TEST_PREFIX + "foo"); michael@0: Telemetry.sendUIEvent(TEST_PREFIX + "efoo", "method2"); michael@0: Telemetry.startUISession(TEST_PREFIX + "bar"); michael@0: Telemetry.sendUIEvent(TEST_PREFIX + "efoobar", "method3", "foobarextras"); michael@0: Telemetry.stopUISession(TEST_PREFIX + "foo", "reasonfoo"); michael@0: Telemetry.sendUIEvent(TEST_PREFIX + "ebar", "method4", "barextras"); michael@0: Telemetry.stopUISession(TEST_PREFIX + "bar", "reasonbar"); michael@0: Telemetry.stopUISession(TEST_PREFIX + "bar", "reasonbar2"); michael@0: Telemetry.sendUIEvent(TEST_PREFIX + "enone", "method5"); michael@0: } catch (Exception e) { michael@0: Log.e("GeckoTest", "Oops.", e); michael@0: } michael@0: michael@0: Log.i("GeckoTest", "Running remaining JS test code."); michael@0: super.testJavascript(); michael@0: } michael@0: } michael@0: