Giter VIP home page Giter VIP logo

hatt's Introduction

HATT

__author__ = 'kasi'
#coding=utf-8
#import moudles
from Core.Utils.surface_collector import SurfaceStatsCollector
from Core.Action.action import Action
from Core.Info.element import Element
from Core.Info.performance import PerformanceInfo
from Core.Action.Monkey.monkey import Monkey
import Core.Info.keycode as key
s=SurfaceStatsCollector()
a=Action()
e=Element()
p=PerformanceInfo()
m=Monkey()
"""
Performance Test
"""
#Fps Test
s.DisableWarningAboutEmptyData()
s.Start()
#steps
for x in range(3):
    a.swipeToUp()
s.Stop()
#print result
for x in s.GetResults():
    if "avg_surface_fps" in x.name:
        print x.name,x.value,x.unit

#Cpu Test
#steps
for x in range(3):
    a.swipeToUp()
    #print result
    cpunInfo=p.getCpuFromDump("com.android.launch")
    #or
    cpunInfo=p.getCpuFromTop("com.android.launch")


# Mem Test
#steps
for x in range(3):
    a.swipeToUp()
    #print result
    memInfo=p.getMemFromDump("com.android.launch")
    #or if you install procrank
    menInfo=p.getMemFromProcrank("com.android.launch")


#LaunchTime Test
#steps
for x in range(3):
    a.swipeToUp()
#print result
startInfo=p.getAppStartTotalTime("com.android.launch/.LaunchActivity")


#Flow Test
#steps
flowInfoBefore=p.getCurFlowFromProc("com.android.launch")
#do something
for x in range(3):
    a.swipeToUp()
flowInfoAfter=p.getCurFlowFromProc("com.android.launch")
#print result
flowInfo=flowInfoAfter-flowInfoBefore

#Battery Test
#steps
batteryInfoBefore=p.getBatteryLevel()
#do something
for x in range(3):
    a.swipeToUp()
batteryInfoAfter=p.getBatteryLevel()
#batteryInfo=(batteryInfoBefore-batteryInfoAfter)*batteryCount


"""
Function Test
"""
#click element
#1.get by class
elm=e.findElementByClass("TextView")
#or by id
elm=e.findElementById("dd")
#or by text
elm=e.findElementByName("tt")
#or by content-desc
elm=e.findElementByContent("tt")
#2.then do something
#click
a.touch(elm)
a.touchByElement(elm)
a.touchByRatio(0.5,0.2)
a.touch(300,400)
#long click
a.longPress(elm)
#send text
a.sendText("dd")
#send keyevent
a.sendKeyEvent(key.BACK)
#swipe
a.swipeToDown()
a.swipeToLeft()
a.swipeToRight()
a.swipeToUp()
a.swipe(elm,elm)
a.swipe(100,100,100,100)

#check currentview hava element
#by class
e.searchForByClass("TextView")
#by name
e.searchForByName("dd")
#by id
e.searchForById("dd")
#by content-desc
e.searchForByContent("dd")


"""
Monkey Test
"""
#steps
m.StartOne("com.android.browser",1000,1000,1000)
#wait for monkey stop or new script and run m.Stop()
#if you see monkey stop you can run
m.Stop()

hatt's People

Contributors

pdhxxj avatar

Watchers

James Cloos avatar jayzhen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.