mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestPowerManager.java
public void testGetWakeLocksActive()
    {
        PowerManager powerManager = ServiceUtils.getService(m_Context, PowerManager.class);
        assertThat(powerManager, is(notNullValue()));
        
        // Create active wake lock
        WakeLock testLockActive = powerManager.createWakeLock(TestPowerManager.class, "TestActiveWakeLockActive");
        testLockActive.activate();  
        
        // Create scheduled wake lock
        WakeLock testLockScheduled = powerManager.createWakeLock(TestPowerManager.class, "TestActiveWakeLockSchdeuled");
        Date wakeTime = new Date(m_Calendar.getTimeInMillis() + (10 * 60 * 1000)); // schedule for 10min in future
        testLockScheduled.scheduleWakeTime(wakeTime);
        
        // Create Inactive wake lock
        WakeLock testLockInactive = powerManager.createWakeLock(TestPowerManager.class, "TestActiveWakeLockInactive");
        testLockInactive.activate();
        testLockInactive.cancel();
        
        // Check that only the active lock is returned
        Set<WakeLock> currentLocks = powerManager.getWakeLocks(WakeLockState.Active);
        assertThat(currentLocks, hasItem(testLockActive));
        assertThat(currentLocks, not(hasItem(testLockScheduled)));
        assertThat(currentLocks, not(hasItem(testLockInactive)));               
    }
/**
     * Verifies that only WakeLocks in the Active state are returned by the PowerManager
     */
Verifies that only WakeLocks in the Active state are returned by the PowerManager
Verifies that only WakeLocks in the Active state are returned by the PowerManager
public void testGetWakeLocksActive()
    {
        PowerManager powerManager = ServiceUtils.getService(m_Context, PowerManager.class);
        assertThat(powerManager, is(notNullValue()));
        WakeLock testLockActive = powerManager.createWakeLock(TestPowerManager.class, "TestActiveWakeLockActive");
        testLockActive.activate();  
        WakeLock testLockScheduled = powerManager.createWakeLock(TestPowerManager.class, "TestActiveWakeLockSchdeuled");
        Date wakeTime = new Date(m_Calendar.getTimeInMillis() + (10 * 60 * 1000)); 
        testLockScheduled.scheduleWakeTime(wakeTime);
        WakeLock testLockInactive = powerManager.createWakeLock(TestPowerManager.class, "TestActiveWakeLockInactive");
        testLockInactive.activate();
        testLockInactive.cancel();
        Set<WakeLock> currentLocks = powerManager.getWakeLocks(WakeLockState.Active);
        assertThat(currentLocks, hasItem(testLockActive));
        assertThat(currentLocks, not(hasItem(testLockScheduled)));
        assertThat(currentLocks, not(hasItem(testLockInactive)));               
    }
public void testGetWakeLocksActive ( ) { PowerManager powerManager = ServiceUtils . getService ( m_Context , PowerManager . class ) ; assertThat ( powerManager , is ( notNullValue ( ) ) ) ; WakeLock testLockActive = powerManager . createWakeLock ( TestPowerManager . class , "TestActiveWakeLockActive" ) ; testLockActive . activate ( ) ; WakeLock testLockScheduled = powerManager . createWakeLock ( TestPowerManager . class , "TestActiveWakeLockSchdeuled" ) ; Date wakeTime = new Date ( m_Calendar . getTimeInMillis ( ) + ( 10 * 60 * 1000 ) ) ; testLockScheduled . scheduleWakeTime ( wakeTime ) ; WakeLock testLockInactive = powerManager . createWakeLock ( TestPowerManager . class , "TestActiveWakeLockInactive" ) ; testLockInactive . activate ( ) ; testLockInactive . cancel ( ) ; Set < WakeLock > currentLocks = powerManager . getWakeLocks ( WakeLockState . Active ) ; assertThat ( currentLocks , hasItem ( testLockActive ) ) ; assertThat ( currentLocks , not ( hasItem ( testLockScheduled ) ) ) ; assertThat ( currentLocks , not ( hasItem ( testLockInactive ) ) ) ; }
Verifies that only WakeLocks in the Active state are returned by the PowerManager
Verifies that only WakeLocks in the Active state are returned by the PowerManager
// Create active wake lock // Create scheduled wake lock // schedule for 10min in future // Create Inactive wake lock // Check that only the active lock is returned