android


Robotium How to test with background Services like conversion?


I am using Robotium Recorder to test my app. My problem is in my app i am doing audio conversions in background which take some time based on how much time user is recording.
Example
If i am running a test which records for 10mins (Converts in background) each time like this 10 times it records so when my last recording that is 10th recording finishes robotium exits and kill the app.
**Problem:- For last recording my file still need to convert its converting in background (Service) but app is killed so converting failed. I cannot use solo.sleep(int) because i dont know how much time it will take to convert **
You can use solo.waitForCondition()
final int TIMEOUT = 5000;
Assert.assertTrue(solo.waitForCondition(new Condition() {
#Override
public boolean isSatisfied() {
// return true if the file has been converted.
}
}, TIMEOUT));
Finally i got the solution
In testRun() function call isServiceRunning() function.
public void testRun() {
.
.
if(isSurviceRunning()) {
solo.sleep(time);
}
}
This method check for background services of your app and return boolean.
public boolean isServiceRunning() {
ActivityManager manager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if ("com.pakage.name.yourcls.your_service_name".equals(service.service.getClassName())) {
Log.d("Running Service is->", "" + service.service.getClassName());
return true;
} else {
Log.d("false", "" + service.service.getClassName());
}
}
return false;
}

Related Links

String (eg. “C”), I got from PreferenceManager, does not equals to “C” [duplicate]
Chrome RE-DIRECT without Opening New Window or Tab
Parent View to show SnackBar for a Layout with Data Binding
How to add new marker without removing previous marker?
Get binded ViewHolder's positions scope
GitLab CI Android SDK not found
unfortunately, *appname* has stopped with MonoGame
Dialog.setOnDismissListener NullpointerException
Flappy bird pause
Alert dialog showing only after second click
Progress Bar does not work
Add one section separator for Navigation Drawer in Android
Using service to continue timer outside of application lifecycle
Mapbox: MyLocationTracking.TRACKING_FOLLOW lagging behind
Bluetooth abstract device ping
Android ExpandableListAdapter hasStableIds, What's meaning “stable” id?

Categories

HOME
batch-file
pagination
mjml
numbers
battery
mstest
composite-primary-key
pclxl
spring-data-mongodb
cublas
alsa
hpc
pkcs#11
character
p2p
google-schemas
categorical-data
plink
http-post
keytool
atlassian-stash
imessage
sigma.js
cgbitmapcontext
object-storage
windows-server-2003
genexus-sd
inversion-of-control
tpm
exchangewebservices
nsurl
corenlp-server
custom-controls
laravel-eloquent
card.io
sammy.js
biztalk-rule-engine
contacts
arduino-ide
baidu-map
openproject
google-earth-engine
news
numberpicker
xv6
stringtokenizer
watchface
vmware-fusion
movilizer
microsoft-metro
oracle-service-bus
file-sharing
dapper-simplecrud
lightning
swingworker
grails-plugin
eigenvector
omniauth-facebook
turbo-prolog
spring-retry
dynamics-nav-2016
custom-errors
xenomai
computer-architecture
vigenere
include-guards
poppler
rpart
aspectj-maven-plugin
mmwormhole
variadic-templates
android-cookiemanager
paw
gii
parallel-testing
grails-plugin-rabbitmq
clickbank
jeromq
printdialog
script#
asdf
flex++
octal
server-administration
resource-management
wcf-configuration
cross-database
infobright
entitydatasource
strsep
collectionviewsource
nhprof
undefined-index
jqueryform
tui
localizable.strings
image-capture

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App