Unfortunately, this is a known issue. As far as I know, there is no way to
retrieve a reference to a Dialog through Instrumentation.

My only suggestion is to have MyActivity store a reference to MyDialog when
it is created, which your test can retrieve.

On Thu, May 28, 2009 at 3:22 AM, [email protected] <
[email protected]> wrote:

>
> Hi,
>
> I am writting unit tests on my Android project.
> I would like to test whether a specific dialog window appears when i
> click on a button.
> For example, I have :
> ----------------------------------Begin Code
> ---------------------------------------------
>
> public class MyDialog extends Dialog
>   {
>       ....
>   }
>
>
>
> public class MyActivity extends Activity
>   {
>
>    ....
>
>    myButton.setOnClickListener( new OnClickListener()
>      {
>         @Override
>         public void onClick(View v)
>            {
>               MyDialog window = new MyDialog(...);
>               window.show();
>            }
>      }
>
>    .....
>   }
> ---------------------------------End
> Code-----------------------------------
>
>
>
> It works fine, but how to test it?
>
> I start my test method, but i don't know how to finish it :
>
>
>
>
> --------------------------------Begin Code
> ------------------------------------------------
> @MediumTest
>  public void testMyButtonAction()
>   {
>    startActivity(intent,null, null);
>    Activity currentActivity = getActivity();
>    myButton = (Button) currentActivity.findViewById(R.id.mybutton);
>    myButton.performClick();
>    assertNotNull(........)   // what is the method to get Dialog
>   }
> ------------------------------- End Code
> ----------------------------------------------------
>
>
> Somebody can help me please :D
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to