CTS: wakeup alarm occurred
Added cts tests for wakeup alarm
Also cleaned up code a bit and reduced the default sleep time to improve
runtime
Test: cts test
Change-Id: I0ab1e4d4924918a7d6bec45dc2931321e9eea28b
diff --git a/hostsidetests/statsd/apps/statsdapp/src/com/android/server/cts/device/statsd/AtomTests.java b/hostsidetests/statsd/apps/statsdapp/src/com/android/server/cts/device/statsd/AtomTests.java
index 56f072e..825a2c4 100644
--- a/hostsidetests/statsd/apps/statsdapp/src/com/android/server/cts/device/statsd/AtomTests.java
+++ b/hostsidetests/statsd/apps/statsdapp/src/com/android/server/cts/device/statsd/AtomTests.java
@@ -16,6 +16,8 @@
package com.android.server.cts.device.statsd;
+import android.app.AlarmManager;
+import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.le.BluetoothLeScanner;
import android.bluetooth.le.ScanCallback;
@@ -38,6 +40,7 @@
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
+import android.os.SystemClock;
import android.util.Log;
import org.junit.Test;
@@ -167,6 +170,27 @@
}
@Test
+ public void testFlashlight() throws Exception {
+ Context context = InstrumentationRegistry.getContext();
+ CameraManager cam = context.getSystemService(CameraManager.class);
+ String[] cameraIds = cam.getCameraIdList();
+ boolean foundFlash = false;
+ for (int i = 0; i < cameraIds.length; i++) {
+ String id = cameraIds[i];
+ if(cam.getCameraCharacteristics(id).get(CameraCharacteristics.FLASH_INFO_AVAILABLE)) {
+ cam.setTorchMode(id, true);
+ sleep(500);
+ cam.setTorchMode(id, false);
+ foundFlash = true;
+ break;
+ }
+ }
+ if(!foundFlash) {
+ Log.e(TAG, "No flashlight found on device");
+ }
+ }
+
+ @Test
public void testGpsScan() {
Context context = InstrumentationRegistry.getContext();
final LocationManager locManager = context.getSystemService(LocationManager.class);
@@ -208,6 +232,20 @@
}
@Test
+ public void testWakeupAlarm() {
+ Context context = InstrumentationRegistry.getContext();
+ String name = "android.cts.statsd.testWakeupAlarm";
+ CountDownLatch onReceiveLatch = new CountDownLatch(1);
+ BroadcastReceiver receiver =
+ registerReceiver(context, onReceiveLatch, new IntentFilter(name));
+ AlarmManager manager = (AlarmManager) (context.getSystemService(AlarmManager.class));
+ PendingIntent pintent = PendingIntent.getBroadcast(context, 0, new Intent(name), 0);
+ manager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP,
+ SystemClock.elapsedRealtime() + 2_000, pintent);
+ waitForReceiver(context, 10_000, onReceiveLatch, receiver);
+ }
+
+ @Test
/** Does two wifi scans. */
// TODO: Copied this from BatterystatsValidation but we probably don't need to wait for results.
public void testWifiScan() {
@@ -225,26 +263,6 @@
}
}
- @Test
- public void testFlashlight() throws Exception {
- Context context = InstrumentationRegistry.getContext();
- CameraManager cam = context.getSystemService(CameraManager.class);
- String[] cameraIds = cam.getCameraIdList();
- boolean foundFlash = false;
- for (int i = 0; i < cameraIds.length; i++) {
- String id = cameraIds[i];
- if(cam.getCameraCharacteristics(id).get(CameraCharacteristics.FLASH_INFO_AVAILABLE)) {
- cam.setTorchMode(id, true);
- sleep(2_000);
- cam.setTorchMode(id, false);
- foundFlash = true;
- break;
- }
- }
- if(!foundFlash) {
- Log.e(TAG, "No flashlight found on device");
- }
- }
// ------- Helper methods
/** Puts the current thread to sleep. */
diff --git a/hostsidetests/statsd/src/android/cts/statsd/AtomTestCase.java b/hostsidetests/statsd/src/android/cts/statsd/AtomTestCase.java
index 729dbb5..dbb64ff 100644
--- a/hostsidetests/statsd/src/android/cts/statsd/AtomTestCase.java
+++ b/hostsidetests/statsd/src/android/cts/statsd/AtomTestCase.java
@@ -60,6 +60,9 @@
protected static final String CONFIG_UID = "1000";
protected static final long CONFIG_ID = "cts_config".hashCode();
+ protected static final int WAIT_TIME_SHORT = 500;
+ protected static final int WAIT_TIME_LONG = 2_000;
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -279,7 +282,7 @@
* @param getStateFromAtom expression that takes in an Atom and returns the state it contains
*/
public void assertStatesOccurred(List<Set<Integer>> stateSets, List<EventMetricData> data,
- Function<Atom, Integer> getStateFromAtom) {
+ int wait, Function<Atom, Integer> getStateFromAtom) {
// Sometimes, there are more events than there are states.
// Eg: When the screen turns off, it may go into OFF and then DOZE immediately.
assertTrue(data.size() >= stateSets.size());
@@ -298,7 +301,7 @@
assertTrue(stateSetIndex < stateSets.size()); // Out of bounds check.
assertTrue(stateSets.get(stateSetIndex).contains(state));
assertTrue(isTimeDiffBetween(data.get(dataIndex - 1), data.get(dataIndex),
- 1_000, 10_000));
+ wait / 2, wait * 5));
}
}
assertTrue(stateSetIndex == stateSets.size() - 1); // We saw each state set.
diff --git a/hostsidetests/statsd/src/android/cts/statsd/DeviceAtomTestCase.java b/hostsidetests/statsd/src/android/cts/statsd/DeviceAtomTestCase.java
index 95e5d5b..7c49407 100644
--- a/hostsidetests/statsd/src/android/cts/statsd/DeviceAtomTestCase.java
+++ b/hostsidetests/statsd/src/android/cts/statsd/DeviceAtomTestCase.java
@@ -114,6 +114,18 @@
}
/**
+ * Adds an event to the config for an atom that matches the app's uid.
+ * @param conf configuration
+ * @param atomTag atom tag (from atoms.proto)
+ */
+ @Override
+ protected void addAtomEvent(StatsdConfig.Builder conf, int atomTag) throws Exception {
+ final int UID_KEY = 1;
+ FieldValueMatcher.Builder kvmUid = createKvm(UID_KEY).setEqInt(getUid());
+ addAtomEvent(conf, atomTag, Arrays.asList(kvmUid));
+ }
+
+ /**
* Gets the uid of the test app.
*/
protected int getUid() throws Exception {
diff --git a/hostsidetests/statsd/src/android/cts/statsd/HostAtomTests.java b/hostsidetests/statsd/src/android/cts/statsd/HostAtomTests.java
index 281ed51..8360452 100644
--- a/hostsidetests/statsd/src/android/cts/statsd/HostAtomTests.java
+++ b/hostsidetests/statsd/src/android/cts/statsd/HostAtomTests.java
@@ -65,10 +65,10 @@
// Setup, make sure the screen is off.
turnScreenOff();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
final int atomTag = Atom.SCREEN_STATE_CHANGED_FIELD_NUMBER;
- final int key = ScreenStateChanged.DISPLAY_STATE_FIELD_NUMBER;
+
Set<Integer> screenOnStates = new HashSet<>(
Arrays.asList(ScreenStateChanged.State.STATE_ON_VALUE,
ScreenStateChanged.State.STATE_ON_SUSPEND_VALUE,
@@ -83,20 +83,20 @@
List<Set<Integer>> stateSet = Arrays.asList(screenOnStates, screenOffStates);
createAndUploadConfig(atomTag);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Trigger events in same order.
turnScreenOn();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_LONG);
turnScreenOff();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_LONG);
// Sorted list of events in order in which they occurred.
List<EventMetricData> data = getEventMetricDataList();
// Assert that the events happened in the expected order.
- assertStatesOccurred(
- stateSet, data, atom -> atom.getScreenStateChanged().getDisplayState().getNumber());
+ assertStatesOccurred(stateSet, data, WAIT_TIME_LONG,
+ atom -> atom.getScreenStateChanged().getDisplayState().getNumber());
}
public void testChargingStateChangedAtom() throws Exception {
@@ -104,10 +104,10 @@
// Setup, set charging state to full.
setChargingState(5);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
final int atomTag = Atom.CHARGING_STATE_CHANGED_FIELD_NUMBER;
- final int key = ChargingStateChanged.CHARGING_STATE_FIELD_NUMBER;
+
Set<Integer> batteryUnknownStates = new HashSet<>(
Arrays.asList(ChargingStateChanged.State.BATTERY_STATUS_UNKNOWN_VALUE));
Set<Integer> batteryChargingStates = new HashSet<>(
@@ -124,29 +124,29 @@
batteryDischargingStates, batteryNotChargingStates, batteryFullStates);
createAndUploadConfig(atomTag);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Trigger events in same order.
setChargingState(1);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
setChargingState(2);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
setChargingState(3);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
setChargingState(4);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
setChargingState(5);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Sorted list of events in order in which they occurred.
List<EventMetricData> data = getEventMetricDataList();
// Unfreeze battery state after test
resetBatteryStatus();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Assert that the events happened in the expected order.
- assertStatesOccurred(stateSet, data,
+ assertStatesOccurred(stateSet, data, WAIT_TIME_SHORT,
atom -> atom.getChargingStateChanged().getChargingState().getNumber());
}
@@ -155,10 +155,10 @@
// Setup, unplug device.
unplugDevice();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
final int atomTag = Atom.PLUGGED_STATE_CHANGED_FIELD_NUMBER;
- final int key = PluggedStateChanged.PLUGGED_STATE_FIELD_NUMBER;
+
Set<Integer> unpluggedStates = new HashSet<>(
Arrays.asList(PluggedStateChanged.State.BATTERY_PLUGGED_NONE_VALUE));
Set<Integer> acStates = new HashSet<>(
@@ -173,31 +173,31 @@
unpluggedStates, wirelessStates, unpluggedStates);
createAndUploadConfig(atomTag);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Trigger events in same order.
plugInAc();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
unplugDevice();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
plugInUsb();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
unplugDevice();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
plugInWireless();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
unplugDevice();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Sorted list of events in order in which they occurred.
List<EventMetricData> data = getEventMetricDataList();
// Unfreeze battery state after test
resetBatteryStatus();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Assert that the events happened in the expected order.
- assertStatesOccurred(stateSet, data,
+ assertStatesOccurred(stateSet, data, WAIT_TIME_SHORT,
atom -> atom.getPluggedStateChanged().getPluggedState().getNumber());
}
@@ -206,10 +206,10 @@
// Setup, set battery level to full.
setBatteryLevel(100);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
final int atomTag = Atom.BATTERY_LEVEL_CHANGED_FIELD_NUMBER;
- final int key = BatteryLevelChanged.BATTERY_LEVEL_FIELD_NUMBER;
+
Set<Integer> batteryDead = new HashSet<>(Arrays.asList(0));
Set<Integer> battery25p = new HashSet<>(Arrays.asList(25));
Set<Integer> battery50p = new HashSet<>(Arrays.asList(50));
@@ -221,29 +221,29 @@
battery75p, batteryFull);
createAndUploadConfig(atomTag);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Trigger events in same order.
setBatteryLevel(0);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
setBatteryLevel(25);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
setBatteryLevel(50);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
setBatteryLevel(75);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
setBatteryLevel(100);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Sorted list of events in order in which they occurred.
List<EventMetricData> data = getEventMetricDataList();
// Unfreeze battery state after test
resetBatteryStatus();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Assert that the events happened in the expected order.
- assertStatesOccurred(stateSet, data,
+ assertStatesOccurred(stateSet, data, WAIT_TIME_SHORT,
atom -> atom.getBatteryLevelChanged().getBatteryLevel());
}
@@ -258,10 +258,10 @@
turnScreenOn();
setScreenBrightnessMode(true);
setScreenBrightness(255);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
final int atomTag = Atom.SCREEN_BRIGHTNESS_CHANGED_FIELD_NUMBER;
- final int key = ScreenBrightnessChanged.LEVEL_FIELD_NUMBER;
+
Set<Integer> screenMin = new HashSet<>(Arrays.asList(25));
Set<Integer> screen100 = new HashSet<>(Arrays.asList(100));
Set<Integer> screen200 = new HashSet<>(Arrays.asList(200));
@@ -271,17 +271,17 @@
List<Set<Integer>> stateSet = Arrays.asList(screenMin, screen100, screen200, screenMax);
createAndUploadConfig(atomTag);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Trigger events in same order.
setScreenBrightness(25);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
setScreenBrightness(100);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
setScreenBrightness(200);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
setScreenBrightness(255);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Sorted list of events in order in which they occurred.
@@ -292,10 +292,11 @@
setScreenBrightnessMode(isInitialManual);
setScreenTimeoutMs(initialTimeout);
turnScreenOff();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Assert that the events happened in the expected order.
- assertStatesOccurred(stateSet, data, atom -> atom.getScreenBrightnessChanged().getLevel());
+ assertStatesOccurred(stateSet, data, WAIT_TIME_SHORT,
+ atom -> atom.getScreenBrightnessChanged().getLevel());
}
public void testDeviceIdleModeStateChangedAtom() throws Exception {
@@ -303,10 +304,10 @@
// Setup, leave doze mode.
leaveDozeMode();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
final int atomTag = Atom.DEVICE_IDLE_MODE_STATE_CHANGED_FIELD_NUMBER;
- final int key = DeviceIdleModeStateChanged.STATE_FIELD_NUMBER;
+
Set<Integer> dozeOff = new HashSet<>(
Arrays.asList(DeviceIdleModeStateChanged.State.DEVICE_IDLE_MODE_OFF_VALUE));
Set<Integer> dozeLight = new HashSet<>(
@@ -318,21 +319,21 @@
List<Set<Integer>> stateSet = Arrays.asList(dozeLight, dozeDeep, dozeOff);
createAndUploadConfig(atomTag);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Trigger events in same order.
enterDozeModeLight();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
enterDozeModeDeep();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
leaveDozeMode();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Sorted list of events in order in which they occurred.
List<EventMetricData> data = getEventMetricDataList();;
// Assert that the events happened in the expected order.
- assertStatesOccurred(stateSet, data,
+ assertStatesOccurred(stateSet, data, WAIT_TIME_SHORT,
atom -> atom.getDeviceIdleModeStateChanged().getState().getNumber());
}
@@ -341,10 +342,10 @@
// Setup, turn off battery saver.
turnBatterySaverOff();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
final int atomTag = Atom.BATTERY_SAVER_MODE_STATE_CHANGED_FIELD_NUMBER;
- final int key = BatterySaverModeStateChanged.STATE_FIELD_NUMBER;
+
Set<Integer> batterySaverOn = new HashSet<>(
Arrays.asList(BatterySaverModeStateChanged.State.ON_VALUE));
Set<Integer> batterySaverOff = new HashSet<>(
@@ -354,19 +355,19 @@
List<Set<Integer>> stateSet = Arrays.asList(batterySaverOn, batterySaverOff);
createAndUploadConfig(atomTag);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Trigger events in same order.
turnBatterySaverOn();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
turnBatterySaverOff();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_SHORT);
// Sorted list of events in order in which they occurred.
List<EventMetricData> data = getEventMetricDataList();
// Assert that the events happened in the expected order.
- assertStatesOccurred(stateSet, data,
+ assertStatesOccurred(stateSet, data, WAIT_TIME_SHORT,
atom -> atom.getBatterySaverModeStateChanged().getState().getNumber());
}
@@ -582,9 +583,9 @@
uploadConfig(config);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_LONG);
turnScreenOn();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_LONG);
List<Atom> data = getGaugeMetricDataList();
@@ -609,9 +610,9 @@
uploadConfig(config);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_LONG);
turnScreenOn();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_LONG);
List<Atom> data = getGaugeMetricDataList();
@@ -634,9 +635,9 @@
uploadConfig(config);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_LONG);
turnScreenOn();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_LONG);
List<Atom> data = getGaugeMetricDataList();
@@ -659,9 +660,9 @@
uploadConfig(config);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_LONG);
turnScreenOn();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_LONG);
List<Atom> data = getGaugeMetricDataList();
@@ -682,9 +683,9 @@
uploadConfig(config);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_LONG);
turnScreenOn();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_LONG);
List<Atom> data = getGaugeMetricDataList();
@@ -706,9 +707,9 @@
uploadConfig(config);
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_LONG);
turnScreenOn();
- Thread.sleep(2000);
+ Thread.sleep(WAIT_TIME_LONG);
List<Atom> data = getGaugeMetricDataList();
diff --git a/hostsidetests/statsd/src/android/cts/statsd/UidAtomTests.java b/hostsidetests/statsd/src/android/cts/statsd/UidAtomTests.java
index 4a14de2..c02e8bd 100644
--- a/hostsidetests/statsd/src/android/cts/statsd/UidAtomTests.java
+++ b/hostsidetests/statsd/src/android/cts/statsd/UidAtomTests.java
@@ -23,8 +23,10 @@
import com.android.os.AtomsProto.CameraStateChanged;
import com.android.os.AtomsProto.FlashlightStateChanged;
import com.android.os.AtomsProto.GpsScanStateChanged;
+import com.android.os.AtomsProto.WakeupAlarmOccurred;
import com.android.os.AtomsProto.WifiScanStateChanged;
import com.android.os.StatsLog.EventMetricData;
+import com.android.tradefed.log.LogUtil;
import java.util.ArrayList;
import java.util.Arrays;
@@ -133,8 +135,38 @@
List<EventMetricData> data = getEventMetricDataList();
// Assert that the events happened in the expected order.
- assertStatesOccurred(stateSet, data,
- atom -> atom.getCameraStateChanged().getState().getNumber());
+ assertStatesOccurred(stateSet, data, WAIT_TIME_LONG,
+ atom -> atom.getCameraStateChanged().getState().getNumber());
+ }
+
+ public void testFlashlightState() throws Exception {
+ if (!TESTS_ENABLED)
+ return;
+ if (!hasFeature(FEATURE_CAMERA_FLASH, true))
+ return;
+
+ final int atomTag = Atom.FLASHLIGHT_STATE_CHANGED_FIELD_NUMBER;
+ final String name = "testFlashlight";
+
+ Set<Integer> flashlightOn = new HashSet<>(
+ Arrays.asList(FlashlightStateChanged.State.ON_VALUE));
+ Set<Integer> flashlightOff = new HashSet<>(
+ Arrays.asList(FlashlightStateChanged.State.OFF_VALUE));
+
+ // Add state sets to the list in order.
+ List<Set<Integer>> stateSet = Arrays.asList(flashlightOn, flashlightOff);
+
+ createAndUploadConfig(atomTag);
+ Thread.sleep(WAIT_TIME_SHORT);
+
+ runDeviceTests(DEVICE_SIDE_TEST_PACKAGE, ".AtomTests", name);
+
+ // Sorted list of events in order in which they occurred.
+ List<EventMetricData> data = getEventMetricDataList();
+
+ // Assert that the events happened in the expected order.
+ assertStatesOccurred(stateSet, data, WAIT_TIME_SHORT,
+ atom -> atom.getFlashlightStateChanged().getState().getNumber());
}
public void testGpsScan() throws Exception {
@@ -161,6 +193,22 @@
assertTrue(a1.getState().getNumber() == stateOff);
}
+ public void testWakeupAlarm() throws Exception {
+ if (!TESTS_ENABLED) return;
+
+ final int atomTag = Atom.WAKEUP_ALARM_OCCURRED_FIELD_NUMBER;
+
+ StatsdConfig.Builder config = createConfigBuilder();
+ addAtomEvent(config, atomTag);
+
+ List<EventMetricData> data = doDeviceMethod("testWakeupAlarm", config);
+ assertTrue(data.size() >= 1);
+ for (int i = 0; i < data.size(); i++) {
+ String tag = data.get(i).getAtom().getWakeupAlarmOccurred().getTag();
+ assertTrue(tag.equals("*walarm*:android.cts.statsd.testWakeupAlarm"));
+ }
+ }
+
public void testWifiScan() throws Exception {
if (!TESTS_ENABLED) return;
if (!hasFeature(FEATURE_WIFI, true)) return;
@@ -183,34 +231,4 @@
assertTrue(a0.getState().getNumber() == stateOn);
assertTrue(a1.getState().getNumber() == stateOff);
}
-
- public void testFlashlightState() throws Exception {
- if (!TESTS_ENABLED) return;
- if (!hasFeature(FEATURE_CAMERA_FLASH, true)) return;
-
- final int atomTag = Atom.FLASHLIGHT_STATE_CHANGED_FIELD_NUMBER;
- final int key = FlashlightStateChanged.STATE_FIELD_NUMBER;
- final String name = "testFlashlight";
- int appUid = getUid();
-
- Set<Integer> flashlightOn = new HashSet<>(
- Arrays.asList(FlashlightStateChanged.State.ON_VALUE));
- Set<Integer> flashlightOff = new HashSet<>(
- Arrays.asList(FlashlightStateChanged.State.OFF_VALUE));
-
- // Add state sets to the list in order.
- List<Set<Integer>> stateSet = Arrays.asList(flashlightOn, flashlightOff);
-
- createAndUploadConfig(atomTag);
- Thread.sleep(2000);
-
- runDeviceTests(DEVICE_SIDE_TEST_PACKAGE, ".AtomTests", name);
-
- // Sorted list of events in order in which they occurred.
- List<EventMetricData> data = getEventMetricDataList();;
-
- // Assert that the events happened in the expected order.
- assertStatesOccurred(stateSet, data,
- atom -> atom.getFlashlightStateChanged().getState().getNumber());
- }
}