Skip to content

Instantly share code, notes, and snippets.

@yehjames
Created November 26, 2014 08:55
Show Gist options
  • Save yehjames/b1e345e83702c385d174 to your computer and use it in GitHub Desktop.
Save yehjames/b1e345e83702c385d174 to your computer and use it in GitHub Desktop.
travelSUT(packageName,activityName)
input:packageName,activityName
output:nodeList,edgeList,screenButtonTapped
edgeList
nodeList
begin:
startApp(packageName,activityName)
currentScreenNumber=0
nextScreenNumber=0
step=0
while True do:
ripping(nextScreenNumber)
currentScreenNumber=nextScreenNumber
nextScreenNumber=xmlScreenCompare(screenList) //Compare screen whether it's a new screen or a previous screen.
//construct the travel model
edgeList.append(Edge(currentScreenNumber, nextScreenNumber,button_tapped))
nodeList[nextScreenNumber].add_inEdge((currentScreenNumber,nextScreenNumber))
nodeList[currentScreenNumber].add_outEdge((currentScreenNumber,nextScreenNumber),button_tapped)
//Use ABCA-coverage to caculate the button coverage rate
button_coverage_rate=ABCA_coverage()
screen_button_tap[currentScreenNumber].add({button_tapped:button_coverage_rate})
if step >1:
nextScreenNumber=check_problem(screen_button_tap,currentScreenNumber,nextScreenNumber) //檢查是否所有畫面的按鈕都已被點擊過
endif
step=step+1
endwhile
end
ripping(screenNumber)
input:screenNumber
output:none
begin
Screen_xml_info = Get current screen xml infomation from android uiautomator
get all clickable buttons from Screen_xml_info
click it randomly
if all button has clicked then
label this screen as traveled screen and back to previous parent node
else:
tap the button
endif
end
xmlScreenCompare(screenList)
input:screenList
output:return past same sreen index or new screen index
begin
Screen_xml_info = Get current screen xml infomation from android uiautomator
Screen_xml_abstraction = Extract all attribute class which is contain "layout" in Screen_xml_info
screen_is_same=False
for each pastScreen ∈ screenList:
compare pastScreen to Screen_xml_abstraction
if not same then:
screen_is_same=Ture
break
end for
if screen_is_same then:
return index of the same screen in screenList
else:
screenList.append(Screen_xml_abstraction)
return the last index in screenList
end if
end
check_problem(screen_button_tap,currentScreenNumber,nextScreenNumber): //check the problem that : SUT is executing or return to previous screen without labeled traveled screen
App_is_over=Flase
if the label of screen0 is "traveled screen" then: //travel is over
tapByCoverageRate(nodeList,screen_button_tap)
endif
if app is not executing then
App_is_over=True
endif
if currentScreenNumber!=nextScreenNumber:
if (nextScreenNumber in screenList and screen_button_tap[currentScreenNumber]!="traveled screen" )or App_is_over then
for each tap ∈ nodeList[currentScreenNumber].toScreenInputs:
restartApp()
nextScreenNumber=currentScreenNumber
return nextScreenNumber
endif
return nextScreenNumber
endif
tapByCoverageRate(nodeList,screen_button_tap):
Enter SUT setting interface and reversely check all chackbox buttons
sort screen_button_tap form lower coverage rate to higher coverage rate
for each button ∈ screen_button_tap
get the button's screen number and use nodeList model to arrive that screen number
tap the button on this screen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment