Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create automated tests for android google map? [duplicate]

I have an android application that uses a google map to display markers and I am looking to create automated user acceptance test for the map functions. I will have to grab a marker and click on it to open another activity for example. So I have been looking for the automated test framework like Robotium, Espresso and UIautomator but I could not find any detailed material such as code examples or tutorial on how to create automated GUI tests for a android google map.

Can anyone tell me which framework is the best to realize this kind of automated user acceptance tests and provide with detailed information on it?

Thanks in advance.

like image 752
ChrisUser2627250 Avatar asked Mar 22 '26 06:03

ChrisUser2627250


1 Answers

I am having to do the same thing at uni, I have been using Espresso to apply testing to other UI components. I have not started the map yet, but I found something that might work? I am unsure due to not trying it myself yet (revising). I had to try and access the android actionbar and to do this I had to refer to the content describtion. "Navigate Up" is apparently the name of the Home(enabled) function.

  onView(withContentDescription("Navigate up")).perform(click());  //appbar home icon

When a fail occurs due to espresso not reaching a component, it lists all the names and content description of the activity/fragment you are testing within the error output. (See Below example) Because thats the way i found the name for the android action bar components I enabled. So this might help with your markers etc.

 View Hierarchy:
+>DecorView{id=-1, visibility=VISIBLE, width=540, height=960, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=3}
|
+->LinearLayout{id=-1, visibility=VISIBLE, width=540, height=888, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
|
+-->ViewStub{id=16909173, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
|
+-->FrameLayout{id=-1, visibility=VISIBLE, width=540, height=850, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=38.0, child-count=1}
|
+--->ActionBarOverlayLayout{id=2131492927, res-name=decor_content_parent, visibility=VISIBLE, width=540, height=850, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
|
+---->ContentFrameLayout{id=16908290, res-name=content, visibility=VISIBLE, width=540, height=766, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=84.0, child-count=1}
|
+----->FrameLayout{id=2131492989, res-name=frame_container, visibility=VISIBLE, width=540, height=766, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}
|
+------>LinearLayout{id=-1, visibility=VISIBLE, width=540, height=766, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=0}
|
+---->ActionBarContainer{id=2131492928, res-name=action_bar_container, visibility=VISIBLE, width=540, height=84, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}   ...

+------>ImageButton{id=-1, desc=Navigate up, visibility=VISIBLE, width=84, height=84, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}

Can you let me know if it works?

like image 140
Boo Avatar answered Mar 24 '26 20:03

Boo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!