summaryrefslogtreecommitdiffstats
path: root/tests/src/com/cyngn/audiofx/util/BaseAudioFxServiceInstrumentationTest.java
diff options
context:
space:
mode:
authorRoman Birg <roman@cyngn.com>2016-08-25 06:49:57 -0700
committerRoman Birg <roman@cyngn.com>2016-08-25 06:49:57 -0700
commit173320f2fcc50d819a0ed681e12f34e8739ed610 (patch)
tree4c12e256a18eb75aeacfd47ae852a0644598d93d /tests/src/com/cyngn/audiofx/util/BaseAudioFxServiceInstrumentationTest.java
parent47248a06db1abcefd0668bd2dd6d61d2abb3bbb3 (diff)
parente95b0267e571f128d881b9c0881f5e25f725239e (diff)
downloadandroid_packages_apps_AudioFX-173320f2fcc50d819a0ed681e12f34e8739ed610.tar.gz
android_packages_apps_AudioFX-173320f2fcc50d819a0ed681e12f34e8739ed610.tar.bz2
android_packages_apps_AudioFX-173320f2fcc50d819a0ed681e12f34e8739ed610.zip
Merge branch 'cm-13.0-oss' into HEAD
Change-Id: Ie762fdbe5b70dec6843ce489e78d802662e148fb
Diffstat (limited to 'tests/src/com/cyngn/audiofx/util/BaseAudioFxServiceInstrumentationTest.java')
-rw-r--r--tests/src/com/cyngn/audiofx/util/BaseAudioFxServiceInstrumentationTest.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/src/com/cyngn/audiofx/util/BaseAudioFxServiceInstrumentationTest.java b/tests/src/com/cyngn/audiofx/util/BaseAudioFxServiceInstrumentationTest.java
new file mode 100644
index 0000000..e882c9d
--- /dev/null
+++ b/tests/src/com/cyngn/audiofx/util/BaseAudioFxServiceInstrumentationTest.java
@@ -0,0 +1,59 @@
+package com.cyngn.audiofx.util;
+
+import android.content.Context;
+import android.content.Intent;
+import android.media.audiofx.AudioEffect;
+import android.os.IBinder;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.rule.ServiceTestRule;
+import android.support.test.runner.AndroidJUnit4;
+import com.cyngn.audiofx.service.AudioFxService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.concurrent.TimeoutException;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by roman on 3/1/16.
+ */
+@RunWith(AndroidJUnit4.class)
+public abstract class BaseAudioFxServiceInstrumentationTest {
+
+ private static final int MAX_ITERATION = 100;
+
+ protected AudioFxService.LocalBinder mService;
+
+ @Rule
+ public ServiceTestRule mServiceRule = new ServiceTestRule();
+
+ protected void setupService() throws TimeoutException {
+ int it = 0;
+
+ /**
+ * lol
+ * https://code.google.com/p/android/issues/detail?id=180396
+ */
+ IBinder binder;
+ while((binder = mServiceRule.bindService(
+ new Intent(InstrumentationRegistry.getTargetContext(),
+ AudioFxService.class))) == null && it < MAX_ITERATION){
+ it++;
+ }
+ mService = (AudioFxService.LocalBinder) binder;
+ assertNotNull(mService);
+ }
+
+ protected final Context getContext() {
+ return InstrumentationRegistry.getContext();
+ }
+
+ protected final Context getTargetContext() {
+ return InstrumentationRegistry.getTargetContext();
+ }
+
+}