Author Topic: Fake OnPress/OnDrag Event  (Read 6322 times)

rmonteiro

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Fake OnPress/OnDrag Event
« on: April 30, 2015, 01:05:28 PM »
We are trying to automate few test cases of our Unity game. We were able to simulate user tap by sending gameObj.SendMessage("OnClick");

However when trying to send OnPress gameObj.SendMessage("OnPress"); It does not seem to press the object. The object has UI Button, UIDragDropItem and UIEventTrigger script attached.

Any suggestions? It looks like I need to fake the event is being sent from UICamera however not sure how do I go about it.

I tried this suggestion http://www.tasharen.com/forum/index.php?topic=4721.msg22743#msg22743
however I receive an NRE

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fake OnPress/OnDrag Event
« Reply #1 on: April 30, 2015, 08:36:18 PM »
You shouldn't be sending messages yourself. If you want to have custom input events, then do just that -- UICamera.onCustomInput. There are a lot of flags that need to be set in UICamera.

rmonteiro

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Fake OnPress/OnDrag Event
« Reply #2 on: May 05, 2015, 05:13:54 PM »
I am new to Unity and NGUI. The game already does the required actions like drag,drop,press

We(QA) would like to automate some GUI testing. We started a low protocol server within the game which responds to certain request and sends them to Unity thread. For eg if it receives a tap request on an object we do gameObj.SendMessage("OnClick");

We would like to automate the drag functionality too.

As per your suggestion why shouldn't we send messages? So we need to set up all required flags in UICamera to simulate this? How do we simulate a mousetouchevent?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fake OnPress/OnDrag Event
« Reply #3 on: May 05, 2015, 10:46:44 PM »
Depends on whether you check any UICamera's variables inside your callbacks. Drag events in particular are sensitive to that. Drag sets "is dragging" state, click eligibility, what's being dragged, in addition to variables that remember what was pressed (which is by default what's being dragged unless a new object was cloned).