-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2628 from kylecorry31/flashlight-ui-test
Add flashlight tool tests
- Loading branch information
Showing
6 changed files
with
126 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
app/src/androidTest/java/com/kylecorry/trail_sense/tools/flashlight/ToolFlashlightTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.kylecorry.trail_sense.tools.flashlight | ||
|
||
import com.kylecorry.andromeda.torch.Torch | ||
import com.kylecorry.trail_sense.R | ||
import com.kylecorry.trail_sense.test_utils.AutomationLibrary.click | ||
import com.kylecorry.trail_sense.test_utils.AutomationLibrary.doesNotHaveNotification | ||
import com.kylecorry.trail_sense.test_utils.AutomationLibrary.hasNotification | ||
import com.kylecorry.trail_sense.test_utils.AutomationLibrary.isFalse | ||
import com.kylecorry.trail_sense.test_utils.AutomationLibrary.isNotVisible | ||
import com.kylecorry.trail_sense.test_utils.AutomationLibrary.isTrue | ||
import com.kylecorry.trail_sense.test_utils.AutomationLibrary.isVisible | ||
import com.kylecorry.trail_sense.test_utils.AutomationLibrary.string | ||
import com.kylecorry.trail_sense.test_utils.TestUtils | ||
import com.kylecorry.trail_sense.test_utils.TestUtils.context | ||
import com.kylecorry.trail_sense.test_utils.TestUtils.openQuickActions | ||
import com.kylecorry.trail_sense.test_utils.ToolTestBase | ||
import com.kylecorry.trail_sense.test_utils.views.quickAction | ||
import com.kylecorry.trail_sense.tools.flashlight.infrastructure.FlashlightService | ||
import com.kylecorry.trail_sense.tools.tools.infrastructure.Tools | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import org.junit.Test | ||
|
||
@HiltAndroidTest | ||
class ToolFlashlightTest : ToolTestBase(Tools.FLASHLIGHT) { | ||
|
||
@Test | ||
fun verifyBasicFunctionality() { | ||
canToggleFlashlight() | ||
canToggleScreenFlashlight() | ||
verifyQuickAction() | ||
} | ||
|
||
private fun canToggleFlashlight() { | ||
if (!Torch.isAvailable(context)) { | ||
return | ||
} | ||
|
||
click(R.id.flashlight_on_btn) | ||
hasNotification( | ||
FlashlightService.NOTIFICATION_ID, | ||
title = string(R.string.flashlight_title) | ||
) | ||
isTrue { TestUtils.isTorchOn } | ||
|
||
click(R.id.flashlight_on_btn) | ||
doesNotHaveNotification(FlashlightService.NOTIFICATION_ID) | ||
isFalse { TestUtils.isTorchOn } | ||
} | ||
|
||
private fun canToggleScreenFlashlight() { | ||
click(R.id.screen_flashlight_btn) | ||
isNotVisible(R.id.screen_flashlight_btn) | ||
|
||
click(R.id.red_white_switcher) | ||
click(R.id.red_white_switcher) | ||
|
||
isVisible(R.id.brightness_seek) | ||
|
||
click(R.id.off_btn) | ||
|
||
isVisible(R.id.screen_flashlight_btn) | ||
} | ||
|
||
private fun verifyQuickAction() { | ||
openQuickActions() | ||
|
||
if (Torch.isAvailable(context)) { | ||
click(quickAction(Tools.QUICK_ACTION_FLASHLIGHT)) | ||
hasNotification( | ||
FlashlightService.NOTIFICATION_ID, | ||
title = string(R.string.flashlight_title) | ||
) | ||
isTrue { TestUtils.isTorchOn } | ||
|
||
click(quickAction(Tools.QUICK_ACTION_FLASHLIGHT)) | ||
doesNotHaveNotification(FlashlightService.NOTIFICATION_ID) | ||
isFalse { TestUtils.isTorchOn } | ||
} | ||
|
||
click(quickAction(Tools.QUICK_ACTION_SCREEN_FLASHLIGHT)) | ||
isVisible(R.id.screen_flashlight) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters