How to modify system settings in Robotium

459 views
Skip to first unread message

Xiaofeng Xu

unread,
Feb 21, 2012, 2:41:31 AM2/21/12
to Robotium Developers
Hi, All,

Is there any way to modify system settings using Robotium?
I would like to turn on setting->Applications-> unknown source
permission.

Or is there other automatic way to do this?


Thank you very much.

Yahor Paulavets

unread,
Feb 22, 2012, 3:24:13 PM2/22/12
to robotium-...@googlegroups.com
Hello,


Best regards,
Yahor


--
You received this message because you are subscribed to the Google Groups "Robotium Developers" group.
To post to this group, send email to robotium-...@googlegroups.com.
To unsubscribe from this group, send email to robotium-develo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotium-developers?hl=en.


Xiaofeng Xu

unread,
Feb 25, 2012, 10:11:26 AM2/25/12
to Robotium Developers
I tried to start setting activity in my test project, using the
following code:

Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
ComponentName cn = new ComponentName("com.android.settings",
"com.android.settings.ApplicationSettings");
i.setComponent(cn);
solo.getCurrentActivity().startActivity(i);
solo.goBack();

The settings is started, after
"solo.getCurrentActivity().startActivity(i);". However, the
"solo.goBack()" cannot go back to my testing app.

Is this the correct way to use "goBack()"?

Thank you.
> >http://groups.google.com/group/robotium-developers?hl=en.- 隐藏被引用文字 -
>
> - 显示引用的文字 -

Yahor Paulavets

unread,
Feb 25, 2012, 11:03:25 AM2/25/12
to robotium-...@googlegroups.com
Hello,

Please try to return to your app, sending your app's Intent, like you open Settings.

Best regards,
Yahor

Xiaofeng Xu

unread,
Feb 26, 2012, 5:05:39 AM2/26/12
to Robotium Developers
Thank you.

Yes, I tried that, it works.
Intent localIntent = new Intent(solo.getCurrentActivity(),
HomeActivity.class);
solo.getCurrentActivity().startActivity(localIntent);

It would go back to HomeActivity.

I have one more question. when I used the following code to start
setting.

Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
ComponentName cn = new ComponentName("com.android.settings",
"com.android.settings.ApplicationSettings");
i.setComponent(cn);
solo.getCurrentActivity().startActivity(i);

Can I use "solo.clickonscreen(x,y)" to modify the setting?
How to decide the value of x, and y in the clickonscreen function?



On 2月26日, 上午12时03分, Yahor Paulavets <ypaulav...@agilefusion.com>
wrote:
> Hello,
>
> > > >http://groups.google.com/group/robotium-developers?hl=en.-隐藏被引用文字 -

Yahor Paulavets

unread,
Feb 26, 2012, 12:20:24 PM2/26/12
to robotium-...@googlegroups.com
Hello,

Regarding interaction with the settings application - without tricks it is not possible due to the security restrictions,
you would get 'event injection' exception, but you can try the following:
1. add EVENT_INJECTIONS permission into the test's manifest file;
2. (perhaps will help) resign settings app, use article for information: robotium for preinstalled apps.

I think you almost have no chance to get Settings app's views to know what are clicking, but you can hardcode some coords for sure for clicking.

Best regards,
Yahor

Xiaofeng Xu

unread,
Feb 26, 2012, 7:54:28 PM2/26/12
to Robotium Developers
Hi, Yahor,

The error I got is "the click can not be completed." I guess this is
because the click is not done on the testing app.
Because robotium only supports one app one time, even if I resign
settings app, I still can not modify settings in my test project, am I
right?
Thank you very much.

Best Regards,
Xiaofeng

On 2月27日, 上午1时20分, Yahor Paulavets <ypaulav...@agilefusion.com> wrote:
> Hello,
>
> Regarding interaction with the settings application - without tricks it is
> not possible due to the security restrictions,
> you would get 'event injection' exception, but you can try the following:
> 1. add EVENT_INJECTIONS permission into the test's manifest file;
> 2. (perhaps will help) resign settings app, use article for information:
> robotium for preinstalled apps.
>
> I think you almost have no chance to get Settings app's views to know what
> are clicking, but you can hardcode some coords for sure for clicking.
>
> Best regards,
> Yahor
>

Yahor Paulavets

unread,
Feb 27, 2012, 2:15:16 AM2/27/12
to robotium-...@googlegroups.com
Hello,

I'm not sure for 100%, but I'm able to do clicks in the different apps, if they are signed with the same cert.
But I'm testing custom Android OS image, so there are could be differencies with the original Android OS
testing.

If you need this click very much, you can root your device and do clicks anywhere you like :)

Best regards,
Yahor

Xiaofeng Xu

unread,
Feb 27, 2012, 4:58:22 AM2/27/12
to Robotium Developers
I see.

Thank you very much. I will try to root it.

On 2月27日, 下午3时15分, Yahor Paulavets <ypaulav...@agilefusion.com> wrote:
> Hello,
>
Reply all
Reply to author
Forward
0 new messages