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