2015-08-22 01:08:46 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.service;
|
|
|
|
|
|
|
|
import android.app.Application;
|
|
|
|
import android.app.NotificationManager;
|
|
|
|
import android.app.Service;
|
|
|
|
import android.content.Context;
|
|
|
|
|
2016-09-10 10:52:02 +02:00
|
|
|
import org.robolectric.RuntimeEnvironment;
|
2015-08-22 01:08:46 +02:00
|
|
|
|
2016-09-10 10:52:02 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
2015-08-22 01:08:46 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.test.MockHelper;
|
2016-09-10 10:52:02 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.test.TestBase;
|
2015-08-22 01:08:46 +02:00
|
|
|
|
2016-09-10 10:52:02 +02:00
|
|
|
public abstract class AbstractServiceTestCase<T extends Service> extends TestBase {
|
2015-08-22 01:08:46 +02:00
|
|
|
private Context mContext;
|
2016-09-10 10:52:02 +02:00
|
|
|
private GBApplication mApplication;
|
2015-08-22 01:08:46 +02:00
|
|
|
private NotificationManager mNotificationManager;
|
|
|
|
private MockHelper mMockHelper;
|
|
|
|
|
2016-09-10 10:52:02 +02:00
|
|
|
protected AbstractServiceTestCase() {
|
2015-08-22 01:08:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Context getContext() {
|
|
|
|
return mContext;
|
|
|
|
}
|
|
|
|
|
2016-04-29 21:49:17 +02:00
|
|
|
protected MockHelper getmMockHelper() {
|
|
|
|
return mMockHelper;
|
|
|
|
}
|
|
|
|
|
2016-09-10 10:52:02 +02:00
|
|
|
@Override
|
2015-08-22 01:08:46 +02:00
|
|
|
public void setUp() throws Exception {
|
2016-09-10 10:52:02 +02:00
|
|
|
super.setUp();
|
2015-08-22 01:08:46 +02:00
|
|
|
mMockHelper = new MockHelper();
|
2016-09-10 10:52:02 +02:00
|
|
|
mApplication = (GBApplication) RuntimeEnvironment.application;
|
|
|
|
mContext = mApplication;
|
2015-08-22 01:08:46 +02:00
|
|
|
mNotificationManager = mMockHelper.createNotificationManager(mContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Application getApplication() {
|
|
|
|
return mApplication;
|
|
|
|
}
|
|
|
|
|
|
|
|
private NotificationManager getNotificationService() {
|
|
|
|
return mNotificationManager;
|
|
|
|
}
|
|
|
|
}
|