def test_swith_between_webapps(self): setUp() testapp = TestApp(device, ConstPath + "/../iterative.apk", "org.xwalk.iterative", "IterativeActivity") switchapp = TestApp(device, ConstPath + "/../switchapp.apk", "org.xwalk.switchapp", "SwitchappActivity") try: if not testapp.isInstalled(): testapp.install() if not switchapp.isInstalled(): switchapp.install() testapp.launch() # Pause and Resume 50 times for i in range(50): time.sleep(2) # swtich to other webapp self.assertTrue(testapp.switchTo(switchapp)) time.sleep(2) # swtich back self.assertTrue(testapp.switch()) testapp.stop() switchapp.stop() except Exception as e: print "Error: %s" % e testapp.stop() switchapp.stop() self.assertTrue(False)
def test_app_repeatedly_in_lowbattery(self): setUp() testapp = TestApp(device, ConstPath + "/../testapp/lowresourcetest.apk", "org.xwalk.lowresourcetest", "LowresourcetestActivity") if testapp.isInstalled(): testapp.uninstall() for i in range(20): if testapp.install() and testapp.launch(): switchresult = False for i in range(2): time.sleep(1) # swtich app switchresult = testapp.switch() if switchresult: time.sleep(1) if testapp.stop() and testapp.uninstall(): time.sleep(1) else: testapp.uninstall() self.assertTrue(False) else: testapp.uninstall() self.assertTrue(False) else: testapp.uninstall() self.assertTrue(False) testapp.uninstall() self.assertTrue(True)
def test_2_install(self): apk_file = commands.getstatusoutput("ls %s| grep %s" % (app_dir, app_name))[1] if apk_file.endswith(".apk"): global testapp testapp = TestApp(comm.device, app_dir + apk_file, package_name, active_name) if testapp.isInstalled(): testapp.uninstall() self.assertTrue(testapp.install()) else: print("-->> No packed %s apk in %s" % (app_name, app_dir)) self.assertTrue(False)
def test_2_install(self): apk_file = commands.getstatusoutput("ls %s| grep %s" % (comm.build_app_dest, app_name.lower()))[1] if apk_file.endswith(".apk"): global testapp testapp = TestApp(comm.device, comm.build_app_dest + apk_file, package_name, active_name) if testapp.isInstalled(): testapp.uninstall() self.assertTrue(testapp.install()) else: print("-->> No packed %s apk in %s" % (app_name, comm.build_app_dest)) self.assertTrue(False)
def test_2_install(self): # Workaround for XWALK-6016: Build x86 and arm together, add arch filter apk_file = commands.getstatusoutput("ls %s| grep %s| grep %s" % (comm.build_app_dest, app_name.lower(), comm.ARCH))[1] if apk_file.endswith(".apk"): global testapp testapp = TestApp(comm.device, comm.build_app_dest + apk_file, package_name, active_name) if testapp.isInstalled(): testapp.uninstall() self.assertTrue(testapp.install()) else: print("-->> No packed %s apk in %s" % (app_name, comm.build_app_dest)) self.assertTrue(False)
def test_app_repeatedly_in_lowdisk(self): setUp() if makeLowDisk(): testapp = TestApp(device, ConstPath + "/../testapp/lowresourcetest.apk", "org.xwalk.lowresourcetest", "LowresourcetestActivity") if testapp.isInstalled(): testapp.uninstall() for i in range(20): if testapp.install() and testapp.launch(): switchresult = False for i in range(2): time.sleep(1) # swtich app switchresult = testapp.switch() if switchresult: time.sleep(1) if testapp.stop() and testapp.uninstall(): time.sleep(1) else: testapp.uninstall() cleanWork() self.assertTrue(False) else: testapp.uninstall() cleanWork() self.assertTrue(False) else: testapp.uninstall() cleanWork() self.assertTrue(False) testapp.uninstall() cleanWork() self.assertTrue(True) else: print "-->> Test envrionment fail to set up" cleanWork() self.assertTrue(False)
def test_app_repeatedly_in_lowmemory(self): setUp() testapp = TestApp(device, ConstPath + "/../testapp/lowresourcetest.apk", "org.xwalk.lowresourcetest", "LowresourcetestActivity") if testapp.isInstalled(): testapp.uninstall() for i in range(20): self.assertTrue(testapp.install()); self.assertTrue(testapp.launch()); time.sleep(1) # swtich to background self.assertTrue(testapp.switch()); time.sleep(1) # swtich to front self.assertTrue(testapp.switch()); time.sleep(1) self.assertTrue(testapp.stop()); self.assertTrue(testapp.uninstall());
def test_pause_resume_webapp_repeatedly(self): setUp() testapp = TestApp(device, ConstPath + "/../iterative.apk", "org.xwalk.iterative", "IterativeActivity") try: if not testapp.isInstalled(): testapp.install() testapp.launch() # Pause and Resume 50 times for i in range(50): time.sleep(2) # swtich to back self.assertTrue(testapp.switch()) time.sleep(2) # swtich to front self.assertTrue(testapp.switch()) testapp.stop() except Exception as e: print "Error: %s" % e testapp.stop() self.assertTrue(False)
def test_app_repeatedly_in_lowmemory(self): setUp() testapp = TestApp(device, ConstPath + "/../testapp/lowresourcetest.apk", "org.xwalk.lowresourcetest", "LowresourcetestActivity") if testapp.isInstalled(): testapp.uninstall() for i in range(20): self.assertTrue(testapp.install()) self.assertTrue(testapp.launch()) time.sleep(1) # swtich to background self.assertTrue(testapp.switch()) time.sleep(1) # swtich to front self.assertTrue(testapp.switch()) time.sleep(1) self.assertTrue(testapp.stop()) self.assertTrue(testapp.uninstall())
def makeLowDisk(): cleanWork() action_status = False if not os.path.exists(approot): cmd = "mkdir %s" % approot (return_code, output) = doCMD(cmd) vediofile = appsrc + "/video.3gp" vediosize = getFileSize(vediofile) if vediosize <= 0: print "-->> Lack pre-condition resource files" return False tmpreadystate = [False, False, False] global instaled_app_list while not action_status: freesize = getFreeDiskSize(device) if (freesize >= 1024) and not tmpreadystate[0]: # make app size: 500M count = int((500 - vediosize)/vediosize) for i in range(count): cmd = "cp %s %s " % (vediofile, appsrc + "/video" + str(i) +".temp.3gp") (return_code, output) = doCMD(cmd) tmpreadystate[0] = True elif (freesize >= 512) and (freesize < 1024) and not tmpreadystate[1]: # clean appsrc if tmpreadystate[0]: cmd = "rm -rf %s/*.temp.3gp" % (appsrc) (return_code, output) = doCMD(cmd) (return_code, output) = doCMD(cmd) # make app size: 100M count = int((100 - vediosize)/vediosize) for i in range(count): cmd = "cp %s %s " % (vediofile, appsrc + "/video" + str(i) +".temp.3gp") (return_code, output) = doCMD(cmd) tmpreadystate[1] = True elif (freesize < 512) and not tmpreadystate[2]: # clean appsrc cmd = "rm -rf %s/*.temp.3gp" % (appsrc) (return_code, output) = doCMD(cmd) tmpreadystate[2] = True appname = "helloworld%s" % int(time.time()) if createAPK(appname): apkname = appname[0].upper() + appname[1:] apkpath = approot + "/" + apkname + "_" + device_abi + ".apk" testapp = TestApp(device, apkpath, "org.xwalk." + appname, apkname + "Activity") #If app exists, go to next if not testapp.isInstalled(): #if app is not installed successful, delete the package, return True if not testapp.install(): action_status = True deleteAPK(testapp) # tmpreadystate[2] == True, # means free disk is too small to install test app # need to uninstall the last one to keep more free disk if len(instaled_app_list) > 0 and tmpreadystate[2]: testapp = instaled_app_list.pop(-1) testapp.uninstall() deleteAPK(testapp) else: instaled_app_list.append(testapp) else: break return action_status
def makeLowDisk(): cleanWork() action_status = False if not os.path.exists(approot): cmd = "mkdir %s" % approot (return_code, output) = doCMD(cmd) vediofile = appsrc + "/video.3gp" vediosize = getFileSize(vediofile) if vediosize <= 0: print "-->> Lack pre-condition resource files" return False tmpreadystate = [False, False, False] global instaled_app_list while not action_status: freesize = getFreeDiskSize(device) if (freesize >= 1024) and not tmpreadystate[0]: # make app size: 500M count = int((500 - vediosize) / vediosize) for i in range(count): cmd = "cp %s %s " % (vediofile, appsrc + "/video" + str(i) + ".temp.3gp") (return_code, output) = doCMD(cmd) tmpreadystate[0] = True elif (freesize >= 512) and (freesize < 1024) and not tmpreadystate[1]: # clean appsrc if tmpreadystate[0]: cmd = "rm -rf %s/*.temp.3gp" % (appsrc) (return_code, output) = doCMD(cmd) (return_code, output) = doCMD(cmd) # make app size: 100M count = int((100 - vediosize) / vediosize) for i in range(count): cmd = "cp %s %s " % (vediofile, appsrc + "/video" + str(i) + ".temp.3gp") (return_code, output) = doCMD(cmd) tmpreadystate[1] = True elif (freesize < 512) and not tmpreadystate[2]: # clean appsrc cmd = "rm -rf %s/*.temp.3gp" % (appsrc) (return_code, output) = doCMD(cmd) tmpreadystate[2] = True appname = "helloworld%s" % int(time.time()) if createAPK(appname): apkname = appname[0].upper() + appname[1:] apkpath = approot + "/" + appname + ".apk" testapp = TestApp(device, apkpath, "org.xwalk." + appname, apkname + "Activity") #If app exists, go to next if not testapp.isInstalled(): #if app is not installed successful, delete the package, return True if not testapp.install(): action_status = True deleteAPK(testapp) # tmpreadystate[2] == True, # means free disk is too small to install test app # need to uninstall the last one to keep more free disk if len(instaled_app_list) > 0 and tmpreadystate[2]: testapp = instaled_app_list.pop(-1) testapp.uninstall() deleteAPK(testapp) else: instaled_app_list.append(testapp) else: break return action_status