示例#1
0
def init_application(plan, app, device):
    Saver.save_crawler_log_both(plan.logPath, device.logPath,
                                "Step : init application")
    if Setting.RunInitNodes:
        appController.start_activity(device, app.packageName,
                                     app.launcherActivity)
        while True:
            launcherPage = pageController.get_page_info(plan, app, device)
            if launcherPage.clickableNodesNum == 0:
                Saver.save_crawler_log_both(plan.logPath, device.logPath,
                                            'scroll to left')
                appController.drag_screen_to_left(device)
            else:
                Saver.save_crawler_log_both(plan.logPath, device.logPath,
                                            'stop scroll')
                break
        Saver.save_crawler_log_both(plan.logPath, device.logPath,
                                    'Step : init nodes run begin')
        crawl_init_nodes(plan, app, device, launcherPage)
        del launcherPage
    if Setting.RunInitCase:
        run_init_cases(plan, app, device)
    # when go in mainActivity, will add the nodes in MainActivity to device.unCrawledNodes
    # if crawl main Nodes , after start mainActivity, these nodes can't be added to the page, will get unCrawlable page
    device.unCrawledNodes = []
    del plan, app, device
示例#2
0
def run_test(plan, app, device):
    Saver.save_crawler_log_both(plan.logPath, device.logPath,
                                "Step : run test ")
    device.update_crawl_statue("Running")

    # init device
    appController.clean_device_logcat(device)

    # uninstall & install apk
    if Setting.UnInstallApk:
        appController.uninstall_app(device, app.packageName)
        appController.uninstall_app(device, app.testPackageName)
    if Setting.InstallApk:
        appController.install_app(device, app.apkPath)
        appController.install_app(device, app.testApkPath)

    # init app
    init_application(plan, app, device)

    # begin crawl
    if Setting.CrawlModel == 'Normal' or Setting.CrawlModel == 'Random':
        Saver.save_crawler_log_both(plan.logPath, device.logPath,
                                    "Step : begin to crawl main nodes")
        appController.start_activity(device, app.packageName, app.mainActivity)
        time.sleep(5)
        page = pageController.get_page_info(plan, app, device)
        device.update_begin_crawl_time()
        crawl_main_nodes(plan, app, device, page)
        del page

    crawl_activities(plan, app, device)
    device.endCrawlTime = datetime.datetime.now()
    Saver.save_logcat(plan, device)
    # clean unusable files
    pageController.remove_uidump_xml_file(device)

    # update & save result
    Saver.save_crawler_log_both(
        plan.logPath, device.logPath, "Step : " + device.id + " has Crawled " +
        str(len(device.hasCrawledNodes)) + " nodes.")
    Saver.save_crawler_log_both(
        plan.logPath, device.logPath, "Step : " + device.id + " there are " +
        str(len(device.unCrawledNodes)) + " unCrawled nodes .")
    Saver.save_crawler_log_both(
        plan.logPath, device.logPath, "Step : " + device.id + " has Crawled " +
        str(len(device.hasCrawledActivities)) + " activities .")
    if device.crawlStatue == 'Running':
        device.update_crawl_statue('Passed')
    if device.crawlStatue == "Passed":
        plan.passedDevice += 1
    else:
        plan.failedDevice += 1
示例#3
0
def crawl_activities(plan, app, device):
    if Setting.CrawlModel == 'Activity':
        for activity in app.activities:
            appController.start_activity(device, app.packageName,
                                         app.launcherActivity)
            time.sleep(3)
            if appController.start_activity(device, app.packageName, activity):
                page = pageController.get_page_info(plan, app, device)
                crawl_nodes_in_an_activity(plan, app, device, activity, page,
                                           page)
                appController.kill_app(app)
                del page
            del activity
    del plan, app, device
示例#4
0
def crawl_activities(plan, app, device):
    if Setting.CrawlModel == 'Activity':
        for activity in app.activities:
            appController.start_activity(device, app.packageName, app.mainActivity)
            time.sleep(3)
            appController.start_activity(device, app.packageName, activity)
            time.sleep(2)
            info = pageController.get_top_activity_info(device)
            if info['activity'] == activity:
                page = pageController.get_page_info(plan, app, device)
                crawl_nodes_in_an_activity(plan, app, device, activity, page, page)
                appController.kill_app(app)
                del page
            del activity, info
    del plan, app, device