Skip to content

Commit 821d26d

Browse files
committed
Switch to detect test mode automatically
1 parent 4605b95 commit 821d26d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,14 @@ class MainActivity : AppCompatActivity(),
120120
EMOJI +
121121
LONG_TEXT
122122

123-
var testMode: Boolean = false
123+
private val isRunningTest : Boolean by lazy {
124+
try {
125+
Class.forName("android.support.test.espresso.Espresso")
126+
true
127+
} catch (e: ClassNotFoundException) {
128+
false
129+
}
130+
}
124131
}
125132

126133
private val MEDIA_CAMERA_PHOTO_PERMISSION_REQUEST_CODE: Int = 1001
@@ -258,7 +265,7 @@ class MainActivity : AppCompatActivity(),
258265
aztec.setToolbar(formattingToolbar)
259266

260267
// initialize the text & HTML
261-
if (!testMode) {
268+
if (!isRunningTest) {
262269
source.displayStyledAndFormattedHtml(EXAMPLE)
263270
}
264271

0 commit comments

Comments
 (0)