hellofenghao / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

Feature request - waitForActivity() modification to recognize subclasses #548

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Lets say we have the following classes

Activity
-----------
EditActivity extends Activity
------------
NoteEditActivity extends EditActivity
NotebookEditActivity extends EditActivity
------------

Current functionality
----------------------
In Robotium now calling waitForActivity(EditActivity.class)
will return false for its subclasses (ie. NoteEditActivity and 
NotebookEditActivity).

Desired functionality
----------------------
having waitForActivity(EditActivity.class) return true for all its subclasses 
(ie. NoteEditActivity and NotebookEditActivity).

Current usage/workaround
---------------------
calling
solo.waitForActivity(NoteEditActivity.class, TIME_OUT) || 
solo.waitForActivity(NotebookEditActivity.class, TIME_OUT)

Problems
1) slow due to timing out of first condition before second condition is 
evaluated
2) if a new sub class of EditActivity is added, the above code needs to be 
modified. It is not scaleable.

Suggested modification
---------------------
using the instanceof operator should work. I assume the current code is 
implemented using Class:getClass() comparisons.

Possible issues
---------------------
Cases:

1) Where the current implementation returns true, the proposed 
waitForActivity() functionality will always return true 
2) Where the current functionality returns false sometimes the new 
functionality will return true 
eg.
Current:  waitForClass(ParentActivity.class) -> false
Proposed: waitForClass(ParentActivity.class) -> true

The 2) case looks like it may be an issue for some current projects. If this is 
an issue adding a new method to Solo would be just as helpful. Actually 
thinking about it more, I think it would probably be the better solution.

Maybe call it waitForActivityInstanceOf()

Thanks for Robotium it has been a huge help for me :)

Original issue reported on code.google.com by ianm...@gmail.com on 31 Oct 2013 at 6:48

GoogleCodeExporter commented 9 years ago
I would recommend that if the requested feature is not already present in 
another function, then it should definitely be implemented in a new separate 
function.

I'd see your waitForActivityInstanceOf() and raise you a 
waitForActivitySubclass().

InstanceOf "feels" like it would contradict the required Class parameter 
signature.

Original comment by carl.na...@sas.com on 31 Oct 2013 at 7:08

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. A new method will be included in the next release. 

Original comment by renasr...@gmail.com on 1 Nov 2013 at 5:17

GoogleCodeExporter commented 9 years ago
At this time we've opted to not include this. Will open this issue if that 
changes in the future. 

Original comment by renasr...@gmail.com on 6 Jan 2014 at 7:54