Is there anyone has an idea about this please?

On May 26, 6:06 pm, Johnny Lee <johnnylee...@gmail.com> wrote:
> Hi,
>
> When I'm using theTouchUtils.tapView in my instrumentation tests, it
> doesn't work. Here is the code snip:
> """
>         final TextView popupText = new TextView(mActivity);
>         popupText.setText("Popup Text");
>         popupText.setBackgroundColor(0xff0000ff);
>         popupText.setFocusableInTouchMode(true);
>         popupText.setOnTouchListener(new OnTouchListener() {
>
>                         public boolean onTouch(View v, MotionEvent event) {
>                                 Log.d("PopupWindowTest", 
> "popupText::onTouch>> event: " + event);
>
>                                 return false;
>                         }
>
>         });
>
>         mPopupWindow = new PopupWindow(mActivity);
>         mPopupWindow.setContentView(popupText);
>         mPopupWindow.setWidth(50);
>         mPopupWindow.setHeight(50);
>         mPopupWindow.setOutsideTouchable(true);
>         // FIXME:
>         //   This is weird, but the touch interceptor only works when
>         //       the background drawable is not null.
>         mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
>
>         MockOnTouchListener onTouchListener = new MockOnTouchListener();
>         mPopupWindow.setTouchInterceptor(onTouchListener);
>
>         runTestOnUiThread(new Runnable() {
>             public void run() {
>                 if (mPopupWindow == null || mPopupWindow.isShowing()) {
>                     return;
>                 }
>
>                 mPopupWindow.showAsDropDown(mActivity.getUpperView());
>                 assertTrue(mPopupWindow.isShowing());
>             }
>         });
>
>        TouchUtils.tapView(this, popupText);
>         mInstrumentation.waitForIdleSync();
>         Thread.sleep(3000);
>         assertEquals(1, onTouchListener.getOnTouchCalledCount());
> """
>
> I've already declared the android.permission.INJECT_EVENTS in my
> manifest, and this permission has been granted sucessfully. But it
> seems the tapView didn't work at all.
>
> I've also tried to touch the poped out window manually, and it works.
>
> Do you have any idea about this? Thanks for your help and consideration.
>
> Regards,
> Johnny
> --
> we all have our crosses to bear
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to