Issue
Is there any method built in to Robotium Solo 4.0 to change the system clock time?
I understand that I could probably write some code to open the Settings app, navigate to the clock and change the time, but if something was built in to Robotium to do this, it would be very useful. The Settings menu varies so much depending on the OS version, so it would be a lot of work to write a method that does this properly on all Android OSes.
I have a few date pickers in my app that only allow you to select dates during business hours, so I need to fake that my phone's system time is within normal business hours for the date pickers to allow me to select anything.
If there's nothing built in and someone has written their own robotium script to navigate to the settings app, I'd appreciate you sharing your approach.
Thanks in advance.
Solution
There are a few solutions.
Programatically you could
Just because you cannot change the phones clock easily does not preclude you being able to change what you consider business hours easily, this way you can change your business hours to be based on the current time, e.g. change it to allow or disallow the current time range and then use that as the basis of your test. It is not perfect but it will allow you to test that your code to include/exclude works even if you are not testing the exact time range (although you should be able to right a test to check the data is normally the correct values so combined with the previous tests this will probably give you enough assurance.
or...
you can set the date on non rooted phones using a command from your pc, how you go about integrating this into your test is up to you though (you will have to set the date run a test set a date run a test etc). To do this use the 'adb shell date' command (you can search for its usage here on stackoverflow).
Answered By - Paul Harris
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.