mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestPowerManager.java
public void testGetWakeLocksWithContext()
    {
        PowerManager powerManager = ServiceUtils.getService(m_Context, PowerManager.class);
        assertThat(powerManager, is(notNullValue()));
        
        // Create active wake lock
        WakeLock testLock1 = powerManager.createWakeLock(TestPowerManager.class, "TestCurrentContext");        
        testLock1.activate();
        
        // Create second active wake lock
        WakeLock testLock2 = powerManager.createWakeLock(ExamplePlatformPowerManager.class, "TestOtherContext");        
        testLock2.activate(); 
               
        // Check that only the lock with context TestPowerManager is returned
        Set<WakeLock> currentLocksInContext = powerManager.getWakeLocks(TestPowerManager.class, WakeLockState.Any);
        printWakeLocks(currentLocksInContext);
        assertThat(currentLocksInContext, hasItem(testLock1));
        assertThat(currentLocksInContext, not(hasItem(testLock2)));   
        
        removeOtherLocks();
    }
/**
     * Verifies that only WakeLocks of a given context are returned by the PowerManager
     */
Verifies that only WakeLocks of a given context are returned by the PowerManager
Verifies that only WakeLocks of a given context are returned by the PowerManager
public void testGetWakeLocksWithContext()
    {
        PowerManager powerManager = ServiceUtils.getService(m_Context, PowerManager.class);
        assertThat(powerManager, is(notNullValue()));
        WakeLock testLock1 = powerManager.createWakeLock(TestPowerManager.class, "TestCurrentContext");        
        testLock1.activate();
        WakeLock testLock2 = powerManager.createWakeLock(ExamplePlatformPowerManager.class, "TestOtherContext");        
        testLock2.activate(); 
        Set<WakeLock> currentLocksInContext = powerManager.getWakeLocks(TestPowerManager.class, WakeLockState.Any);
        printWakeLocks(currentLocksInContext);
        assertThat(currentLocksInContext, hasItem(testLock1));
        assertThat(currentLocksInContext, not(hasItem(testLock2)));   
        removeOtherLocks();
    }
public void testGetWakeLocksWithContext ( ) { PowerManager powerManager = ServiceUtils . getService ( m_Context , PowerManager . class ) ; assertThat ( powerManager , is ( notNullValue ( ) ) ) ; WakeLock testLock1 = powerManager . createWakeLock ( TestPowerManager . class , "TestCurrentContext" ) ; testLock1 . activate ( ) ; WakeLock testLock2 = powerManager . createWakeLock ( ExamplePlatformPowerManager . class , "TestOtherContext" ) ; testLock2 . activate ( ) ; Set < WakeLock > currentLocksInContext = powerManager . getWakeLocks ( TestPowerManager . class , WakeLockState . Any ) ; printWakeLocks ( currentLocksInContext ) ; assertThat ( currentLocksInContext , hasItem ( testLock1 ) ) ; assertThat ( currentLocksInContext , not ( hasItem ( testLock2 ) ) ) ; removeOtherLocks ( ) ; }
Verifies that only WakeLocks of a given context are returned by the PowerManager
Verifies that only WakeLocks of a given context are returned by the PowerManager
// Create active wake lock // Create second active wake lock // Check that only the lock with context TestPowerManager is returned