Calabash-ios - Put the device is Airplane Mode - objective-c

Is there any way to interact with an iPhone's settings when testing a device using calabash-ios?
Using calabash for Android (calabash-android) I can make system calls in my step-definitions using adb, Android Device Bridge. For example: system(adb shell am broadcast -a android.intent.action.AIRPLANE_MODE)
This will make a call right into the Android OS.
I don't want to have to manually set up a device and then run tests. I would like to automate it. Is this possible?
Examples: I want to see if all my tests pass with airplane mode on. Then I would like to programmatically set airplane mode to off and see if all my tests pass. I would prefer not to have to change a setting like this manually and then run all tests.
Thanks

It is not possible to put your device into Airplane mode with Calabash iOS.
You could write a backdoor method in your app that simulates Airplane mode.
Be aware however, that Calabash iOS embeds an http server in your application; that is how the client gem communicates with your app.
http://calabashapi.xamarin.com/ios/Calabash/Cucumber/Core.html#backdoor-instance_method
The Xamarin Test Cloud has some options for testing apps in Airplane mode.

Related

How to implement cron jobs in react native?

I am new to react-native and implementing simple app where app will monitor the mobile's clock time and should set some flags so as to notify user to perform some task when he starts the app.
I want to continuously monitor mobile's clock time as a background job in the react native app such that, when user opens the app and if specific time has already passed, it should set some flag to take future decision.
After some research over blogs, I found that react-native-background-task and/or background-timers can be used. But I am finding difficulty in implementing it. Can anyone help me with the implementation example for the same.
Thank you in advance.
So, from your post I'm going to assume a few things. One being you'll develop on Android as well as iOS, you just want to use a plugin (not code a module yourself).
Unfortunately, unless I'm mistaken - there's no simple answer and I'll explain.
As Android and iOS go forward they are starting to limit usage of Apps in the background, specifically Android goes into 'Doze' mode and iOS works in a similar fashion.
For Android, you'll need to consider a few things and I'll concentrate on them, as you'll need to know this before actually creating a RN app.
Doze Mode
Starting from Android 6.0 (API level 23), Android introduces two
power-saving features that extend battery life for users by managing
how apps behave when a device is not connected to a power source. Doze
reduces battery consumption by deferring background CPU and network
activity for apps when the device is unused for long periods of time.
App Standby defers background network activity for apps with which the
user has not recently interacted.
While the device is in Doze, apps' access to certain battery-intensive
resources is deferred until maintenance windows. The specific
restrictions are listed in Power Management Restrictions.
Doze and App Standby manage the behavior of all apps running on
Android 6.0 or higher, regardless whether they are specifically
targeting API level 23. To ensure the best experience for users, test
your app in Doze and App Standby modes and make any necessary
adjustments to your code. The sections below provide details.
Cruically, you'll need to note:
The system does not allow sync adapters to run.
The system does not allow JobScheduler to run.
So firstly for android, you'll (probably) need to ensure your app is in a 'whitelist'. You can check the requirements of the list here:
https://developer.android.com/training/monitoring-device-state/doze-standby
Or, you can access the maintenance window with a plugin like here:
https://github.com/transistorsoft/react-native-background-fetch
Testing
Android give you some tools to do so, mainly running:
$ adb shell dumpsys battery unplug
$ adb shell am set-inactive <packageName> true
Headless JS
You can check out headless tasks, which could suit your situation:
https://facebook.github.io/react-native/docs/headless-js-android
Caveats:
Although Android state that the operating system itself acts like documented, devices themselves can have software built in which essentially kills background processes. Nokia is one of the worst. So be aware of this.

Buildfire: How to use the Barcode Scanner

I have gotten to the point where I can launch the barcode mock mode.
I am trying to figure out how I can start scanning test codes in development.
Or would an app that I am trying to test this on, need to have camera permissions on the app?
In that case, how do you overcome the use of the Camera Hardware on the PWA?
Or is there a way that I can scan QR-Codes using a different javascript API that would work in all cases?
Also, I had to move the camera and barcode service Javascript files into my Widget folder because when I was trying to reference them as you do on the instructions, the files wouldn't load.
Yes when you are in web it will mock the functionality because you're not on a device. There are HTML5 Camera API's see (https://www.html5rocks.com/en/tutorials/getusermedia/intro/)
You can use the BuildFire Previewer App (contact customer support if you havent downloaded it yet)
While you can take a copy of the services into your plugin it is risky. If we issue any updates or bug fixes you will not receive them. Also if it breaks compatibility at any time (rare but possible) your plugin stop working

iOS simulator calling bash system commands via objective-c?

Has anybody had any success calling a system bash command via objective-c from the simulator? I have considered doing this over a SSH connection but this is likely to be a quite laggy, so wondered if there was a more direct method. The idea behind this is to allow fast development of logging features in ruby... These calls would be stripped out of the live deployed app, therefor private calls would be fine for this.
You can do that, it works as you might expect on a UNIX platform.
int status = system("/usr/bin/say hello");
can be called from a simulator app, and will execute the correct binary.

How to automatically test if offline mode is working in web application

I have mobile web application that has offline capabilities (via HTML5).
I'm currently building automatic build & testing for it (ant, JsTestDriver etc.), until I hit a wall. How can I test if the web application has working offline mode? This is specially painful since if tested by hand; iPhone practically needs full reset between tests (it tends to cling on to some parts of the data).
I'm thinking something around these lines (on a idea level):
Setup Java web server with ant
Fire some sort of headless client, that supports HTML5 offline use
Load the application
Validate that everything is loaded
Disable server
Load the application
Validate that everything is loaded, still
Any suggestions how would I proceed doing something like this?
Not sure I understand your question, but what do you think of:
Not using an iPhone, but chrome on PC with the ripple emulator http://ripple.tinyhippos.com/
Setting a fake proxy or editing the .host file in order to be sure that your chrome session does not have access to your server.

Is my app running on the Blackberry Simulator?

I am testing a blackberry app that sends SMS messages. I would like to use the simulator for testing, but since SMS doesn't work on the simulator I would like to have an alternate code path to handle the interaction. What is the right way to detect that the app is being run under a simulator, instead of an actual device?
DeviceInfo.isSimulator()