Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bilal-alsharifi committed May 27, 2021
1 parent 5fa1bdd commit 2145267
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.smartdevicelink.managers.lockscreen;

import android.content.Context;
import android.content.Intent;
import android.os.Looper;

import androidx.test.ext.junit.runners.AndroidJUnit4;

Expand Down Expand Up @@ -170,4 +172,34 @@ public void testLockScreenDismissibleWithEnableFalseAndDismissibilityTrue() {
assertTrue(lockScreenManager.isLockscreenDismissible);
}

@Test
public void testShowingLockscreenAfterDismissibleFalse() {
if (Looper.myLooper() == null) {
Looper.prepare();
}
lockScreenManager.enableDismissGesture = true;
lockScreenManager.displayMode = LockScreenConfig.DISPLAY_MODE_ALWAYS;

// Send first notification (DD=OFF, Dismissible=true)
OnDriverDistraction onDriverDistraction = new OnDriverDistraction();
onDriverDistraction.setLockscreenDismissibility(true);
onDriverDistraction.setState(DriverDistractionState.DD_OFF);
onDDListener.onNotified(onDriverDistraction);

// Dismiss lock screen activity
lockScreenManager.mLockscreenDismissedReceiver.onReceive(null, new Intent(SDLLockScreenActivity.KEY_LOCKSCREEN_DISMISSED, null));

// Lock screen should be set to auto dismiss in future
assertTrue(lockScreenManager.mLockScreenShouldBeAutoDismissed);

// Send second notification (DD=On, Dismissible=false)
onDriverDistraction = new OnDriverDistraction();
onDriverDistraction.setLockscreenDismissibility(false);
onDriverDistraction.setState(DriverDistractionState.DD_ON);
onDDListener.onNotified(onDriverDistraction);

// Lock screen should be set to NOT auto dismiss in future
assertFalse(lockScreenManager.mLockScreenShouldBeAutoDismissed);
}

}

0 comments on commit 2145267

Please sign in to comment.