mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestPowerManager.java
public void testGetWakeLocksAny()
    {
        PowerManager powerManager = ServiceUtils.getService(m_Context, PowerManager.class);
        assertThat(powerManager, is(notNullValue()));
             
        // Create active wake lock
        WakeLock testLockActive = powerManager.createWakeLock(TestPowerManager.class, "TestAnyWakeLockActive");        
        testLockActive.activate();  
        
        // Create scheduled wake lock
        WakeLock testLockScheduled = powerManager.createWakeLock(TestPowerManager.class, "TestAnyWakeLockSchdeuled");
        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, "TestAnyWakeLockInactive");
        testLockInactive.activate();
        testLockInactive.cancel();
        
        // Check that all lock are returned
        Set<WakeLock> currentLocks = powerManager.getWakeLocks(WakeLockState.Any);    
        printWakeLocks(currentLocks);
        assertThat(currentLocks, hasItem(testLockActive));
        assertThat(currentLocks, hasItem(testLockScheduled));
        assertThat(currentLocks, hasItem(testLockInactive));            
    }
/**
     * Verifies that all WakeLocks are returned by the PowerManager
     */
Verifies that all WakeLocks are returned by the PowerManager
Verifies that all WakeLocks are returned by the PowerManager
public void testGetWakeLocksAny()
    {
        PowerManager powerManager = ServiceUtils.getService(m_Context, PowerManager.class);
        assertThat(powerManager, is(notNullValue()));
        WakeLock testLockActive = powerManager.createWakeLock(TestPowerManager.class, "TestAnyWakeLockActive");        
        testLockActive.activate();  
        WakeLock testLockScheduled = powerManager.createWakeLock(TestPowerManager.class, "TestAnyWakeLockSchdeuled");
        Date wakeTime = new Date(m_Calendar.getTimeInMillis() + (10 * 60 * 1000)); 
        testLockScheduled.scheduleWakeTime(wakeTime);
        WakeLock testLockInactive = powerManager.createWakeLock(TestPowerManager.class, "TestAnyWakeLockInactive");
        testLockInactive.activate();
        testLockInactive.cancel();
        Set<WakeLock> currentLocks = powerManager.getWakeLocks(WakeLockState.Any);    
        printWakeLocks(currentLocks);
        assertThat(currentLocks, hasItem(testLockActive));
        assertThat(currentLocks, hasItem(testLockScheduled));
        assertThat(currentLocks, hasItem(testLockInactive));            
    }
public void testGetWakeLocksAny ( ) { PowerManager powerManager = ServiceUtils . getService ( m_Context , PowerManager . class ) ; assertThat ( powerManager , is ( notNullValue ( ) ) ) ; WakeLock testLockActive = powerManager . createWakeLock ( TestPowerManager . class , "TestAnyWakeLockActive" ) ; testLockActive . activate ( ) ; WakeLock testLockScheduled = powerManager . createWakeLock ( TestPowerManager . class , "TestAnyWakeLockSchdeuled" ) ; Date wakeTime = new Date ( m_Calendar . getTimeInMillis ( ) + ( 10 * 60 * 1000 ) ) ; testLockScheduled . scheduleWakeTime ( wakeTime ) ; WakeLock testLockInactive = powerManager . createWakeLock ( TestPowerManager . class , "TestAnyWakeLockInactive" ) ; testLockInactive . activate ( ) ; testLockInactive . cancel ( ) ; Set < WakeLock > currentLocks = powerManager . getWakeLocks ( WakeLockState . Any ) ; printWakeLocks ( currentLocks ) ; assertThat ( currentLocks , hasItem ( testLockActive ) ) ; assertThat ( currentLocks , hasItem ( testLockScheduled ) ) ; assertThat ( currentLocks , hasItem ( testLockInactive ) ) ; }
Verifies that all WakeLocks are returned by the PowerManager
Verifies that all WakeLocks are returned by the PowerManager
// Create active wake lock // Create scheduled wake lock // schedule for 10min in future // Create Inactive wake lock // Check that all lock are returned