def test_multiple_icons(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') jsonfile = open( comm.ConstPath + "/../tools/org.xwalk.test/app/manifest.json", "r") jsons = jsonfile.read() jsonfile.close() jsonDict = json.loads(jsons) jsonDict["icons"] = [{ "src": "icon.png", "sizes": "72x72" }, { "src": "../../../icon/icon.gif", "sizes": "82x82" }, { "src": "../../../icon/icon.jpg", "sizes": "97x97" }, { "src": "../../../icon/icon.bmp", "sizes": "117x117" }] json.dump( jsonDict, open(comm.ConstPath + "/../tools/org.xwalk.test/app/manifest.json", "w")) buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" buildstatus = os.system(buildcmd) comm.run(self) comm.clear("org.xwalk.test") if comm.SHELL_FLAG == "False": os.system('adb start-server') self.assertEquals(buildstatus, 0)
def test_versionCode_normal(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" buildstatus = os.popen(buildcmd).readlines() index = 0 for x in range(len(buildstatus), 0, -1): index = x - 1 if buildstatus[index].find("Using android:versionCode") != -1: break versionCode = buildstatus[index].strip( " *\nUsing android:versionCode")[1:-1] root = ElementTree.parse( comm.ConstPath + "/../tools/org.xwalk.test/prj/android/AndroidManifest.xml" ).getroot() attributes = root.attrib for x in attributes.keys(): if x.find("versionCode") != -1: versionCode_xml = attributes[x] break comm.run(self) comm.clear("org.xwalk.test") if comm.SHELL_FLAG == "False": os.system('adb start-server') self.assertEquals(versionCode, versionCode_xml)
def test_create_package_stable(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir("org.xwalk.test") cmd = ( comm.HOST_PREFIX + comm.PackTools + "crosswalk-pkg --platforms=android --crosswalk=stable " + comm.ConstPath + "/../testapp/create_package_missing_icon_startUrl/" ) return_code = os.system(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: apkLength = apkLength + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: apkLength = apkLength + 1 self.assertEquals(apkLength, 2) comm.run(self) comm.clear("org.xwalk.test") if comm.SHELL_FLAG == "False": os.system("adb start-server") self.assertEquals(return_code, 0)
def test_build_missing_so_file(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') if comm.ARCH == "x86": os.remove( os.getcwd() + '/prj/android/xwalk_core_library/libs/armeabi-v7a/libxwalkcore.so') buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" buildstatus = os.system(buildcmd) self.assertEquals(buildstatus, 0) pkgs = os.listdir(os.getcwd()) armLength = 0 for i in range(len(pkgs)): if pkgs[i].endswith(".apk") and "arm" in pkgs[i]: armLength = armLength + 1 self.assertEquals(armLength, 0) else: os.remove( os.getcwd() + '/prj/android/xwalk_core_library/libs/x86/libxwalkcore.so') buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" buildstatus = os.system(buildcmd) self.assertEquals(buildstatus, 0) pkgs = os.listdir(os.getcwd()) x86Length = 0 for i in range(len(pkgs)): if pkgs[i].endswith(".apk") and "x86" in pkgs[i]: x86Length = x86Length + 1 self.assertEquals(x86Length, 0) comm.run(self) comm.clear("org.xwalk.test") os.system('adb start-server')
def handle_sp_list(self, url): # serial play list urls = [] # http://www.bilibili.com/sp/维京传奇 # base.special.js line 25, loadBgmPage # http://www.bilibili.com/sppage/bangumi-21542-913-1.html # first find 21542 hutf = self.get_hutf(url) #echo(hutf) spid = search_first(hutf, 'var spid = "(\d+)";').group(1) echo("spid=", spid) for li in SelStr('ul#season_selector li', hutf): data = self.get_hutf("http://www.bilibili.com/sppage/bangumi-%s-%s-1.html" % ( spid, li['season_id'])) for n in SelStr('div.season_list li a.t', data): urls.append((n['title'].strip(), 'http://www.bilibili.com' + n['href'])) args = copy(self.parsed_args) sk = args.playlist_skip args.playlist_skip = -1315 tp = args.playlist_top args.playlist_top = 0 cnt = 0 for t, u in urls: cnt = cnt + 1 if cnt > tp > 0: break if cnt < sk: continue echo(t, u) b = BILIBILI() b.title = t args.url = u run(b, args) sys.exit(1)
def test_extensions_without_jsFile(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir('org.xwalk.test') shutil.copytree(comm.ConstPath + "/../testapp/extension_permission/", comm.XwalkPath + "/org.xwalk.test/extension_permission/") os.remove(comm.XwalkPath + "/org.xwalk.test/extension_permission/contactextension/contactextension.js") cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-pkg --platforms=android --android=" + comm.ANDROID_MODE + " --crosswalk=" + comm.crosswalkzip + " " + comm.XwalkPath + "/org.xwalk.test/extension_permission/" return_code = os.system(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 if comm.MODE != " --android-shared": for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 self.assertEquals(apkLength, 2) else: for i in range(len(apks)): if apks[i].endswith(".apk") and "shared" in apks[i]: apkLength = apkLength + 1 appVersion = apks[i].split('-')[1] self.assertEquals(apkLength, 1) comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0)
def test_create_package_canary(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir('org.xwalk.test') cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-pkg --platforms=android --android=" + comm.ANDROID_MODE + ' --crosswalk=canary --targets="' + comm.BIT + '" ' + comm.ConstPath + "/../testapp/create_package_basic/" (return_code, output) = comm.getstatusoutput(cmd) version = comm.check_crosswalk_version(self, "canary") apks = os.listdir(os.getcwd()) apkLength = 0 if comm.MODE != " --android-shared": for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 self.assertEquals(apkLength, 2) else: for i in range(len(apks)): if apks[i].endswith(".apk") and "shared" in apks[i]: apkLength = apkLength + 1 appVersion = apks[i].split('-')[1] self.assertEquals(apkLength, 1) comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertIn(version, output[0])
def test_create_package_reading_manifest(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") if os.path.exists(comm.ConstPath + "/../testapp/start_url/manifest.json"): os.remove(comm.ConstPath + "/../testapp/start_url/manifest.json") os.chdir('org.xwalk.test') cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-pkg --platforms=android" + comm.ANDROID_MODE + " --crosswalk=" + comm.crosswalkzip + " --manifest '{ \"xwalk_package_id\": \"org.xwalk.test\", \"start_url\": \"start.html\" }' " + comm.ConstPath + "/../testapp/start_url/" return_code = os.system(cmd) with open(comm.ConstPath + "/../testapp/start_url/manifest.json") as json_file: data = json.load(json_file) apks = os.listdir(os.getcwd()) apkLength = 0 if comm.MODE != " --android-shared": for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: apkLength = apkLength + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: apkLength = apkLength + 1 self.assertEquals(apkLength, 2) else: for i in range(len(apks)): if apks[i].endswith(".apk") and "shared" in apks[i]: apkLength = apkLength + 1 appVersion = apks[i].split('-')[1] self.assertEquals(apkLength, 1) comm.run(self) comm.clear("org.xwalk.test") os.remove(comm.ConstPath + "/../testapp/start_url/manifest.json") self.assertEquals(return_code, 0) self.assertEquals(data['xwalk_package_id'].strip(os.linesep), "org.xwalk.test")
def test_create_package_crosswalkdir(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") crosswalkdir = zipfile.ZipFile(comm.crosswalkzip,'r') for file in crosswalkdir.namelist(): crosswalkdir.extract(file, r'.') crosswalkdir.close() os.chdir('org.xwalk.test') cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-pkg --platforms=android" + comm.ANDROID_MODE + " --crosswalk=" + comm.crosswalkzip[:comm.crosswalkzip.index(".zip")] + "/ " + comm.ConstPath + "/../testapp/create_package_basic/" return_code = os.system(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 if comm.MODE != " --android-shared": for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: apkLength = apkLength + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: apkLength = apkLength + 1 self.assertEquals(apkLength, 2) else: for i in range(len(apks)): if apks[i].endswith(".apk") and "shared" in apks[i]: apkLength = apkLength + 1 appVersion = apks[i].split('-')[1] self.assertEquals(apkLength, 1) comm.run(self) comm.clear("org.xwalk.test") shutil.rmtree(comm.crosswalkzip[:comm.crosswalkzip.index(".zip")]) self.assertEquals(return_code, 0)
def test_keep_project(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir('org.xwalk.test') cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-pkg --platforms=android --android=" + comm.ANDROID_MODE + " --keep --crosswalk=" + comm.crosswalkzip + " " + comm.ConstPath + "/../testapp/create_package_basic/" (return_code, output) = comm.getstatusoutput(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 if comm.MODE != " --android-shared": for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 self.assertEquals(apkLength, 2) else: for i in range(len(apks)): if apks[i].endswith(".apk") and "shared" in apks[i]: apkLength = apkLength + 1 appVersion = apks[i].split('-')[1] self.assertEquals(apkLength, 1) projectDir = output[0].split(" * " + os.linesep)[-1].split(' ')[-1].strip(os.linesep) comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertIn("app", os.listdir(projectDir)) self.assertIn("prj", os.listdir(projectDir))
def test_without_platforms(self): comm.setUp() os.chdir(comm.TEMP_DATA_PATH) comm.cleanTempData(comm.TEST_PROJECT_COMM) os.mkdir(comm.TEST_PROJECT_COMM) os.chdir(comm.TEST_PROJECT_COMM) cmd = 'crosswalk-pkg ' + comm.SCRIPT_DIR_NAME + "/../testapp/create_package_basic/" packstatus = commands.getstatusoutput(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 debLength = 0 for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: apkLength = apkLength + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: apkLength = apkLength + 1 if apks[i].endswith(".deb"): debLength = debLength + 1 comm.run(self) comm.cleanTempData(comm.TEST_PROJECT_COMM) self.assertEquals(packstatus[0], 0) self.assertEquals(apkLength, 2) self.assertEquals(debLength, 0) self.assertNotIn("target deb", packstatus[1]) self.assertIn("target android", packstatus[1])
def test_build_package_release(self): comm.setUp() for i in range(len(os.listdir(comm.XwalkPath))): if os.listdir(comm.XwalkPath)[i].endswith(".zip"): androidCrosswalk = os.listdir(comm.XwalkPath)[i] os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir('org.xwalk.test') cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-pkg --platforms=android --release=true " + comm.ConstPath + "/../testapp/create_package_missing_icon_startUrl/" return_code = os.system(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: apkLength = apkLength + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: apkLength = apkLength + 1 self.assertEquals(apkLength, 2) comm.run(self) comm.clear("org.xwalk.test") if comm.SHELL_FLAG == "False": os.system('adb start-server') self.assertEquals(return_code, 0)
def test_build_missing_so_file(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') if comm.ARCH == "x86": os.remove( os.getcwd() + '/prj/android/xwalk_core_library/libs/armeabi-v7a/libxwalkcore.so') buildcmd = comm.PackTools + "crosswalk-app build" buildstatus = commands.getstatusoutput(buildcmd) self.assertEquals(buildstatus[0], 0) os.chdir('pkg') pkgs = os.listdir(os.getcwd()) self.assertNotIn("test-debug.armeabi-v7a.apk", pkgs) else: os.remove( os.getcwd() + '/prj/android/xwalk_core_library/libs/x86/libxwalkcore.so') buildcmd = comm.PackTools + "crosswalk-app build" buildstatus = commands.getstatusoutput(buildcmd) self.assertEquals(buildstatus[0], 0) os.chdir('pkg') pkgs = os.listdir(os.getcwd()) self.assertNotIn("test-debug.x86.apk", pkgs) comm.run(self) comm.clear("org.xwalk.test")
def test_crosswalk_release(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir('org.xwalk.test') cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-pkg --platforms=android --android=" + comm.ANDROID_MODE + " --crosswalk=" + comm.crosswalkzip + " " + comm.ConstPath + "/../testapp/create_package_basic/" return_code = os.system(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 if comm.MODE != " --android-shared": for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 self.assertEquals(apkLength, 2) else: for i in range(len(apks)): if apks[i].endswith(".apk") and "shared" in apks[i]: apkLength = apkLength + 1 appVersion = apks[i].split('-')[1] self.assertEquals(apkLength, 1) comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0)
def test_default_channel(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir('org.xwalk.test') output = self.invokeCrosswalkPkg([ '--platforms=android', '--android=' + comm.ANDROID_MODE, '--targets=' + comm.BIT, comm.ConstPath + '/../testapp/create_package_basic/', ]) version = comm.check_crosswalk_version(self, "stable") apks = os.listdir(os.getcwd()) apkLength = 0 if comm.MODE != " --android-shared": for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 self.assertEquals(apkLength, 2) else: for i in range(len(apks)): if apks[i].endswith(".apk") and "shared" in apks[i]: apkLength = apkLength + 1 appVersion = apks[i].split('-')[1] self.assertEquals(apkLength, 1) comm.run(self) comm.clear("org.xwalk.test") self.assertIn(version, output)
def test_build_debug_path_webp(self): comm.setUp() comm.create(self) jsonfile = open( comm.ConstPath + "/../tools/org.xwalk.test/app/manifest.json", "r") jsons = jsonfile.read() jsonfile.close() jsonDict = json.loads(jsons) jsonDict["xwalk_android_webp"] = "80 80 100" json.dump( jsonDict, open(comm.ConstPath + "/../tools/org.xwalk.test/app/manifest.json", "w")) if os.path.exists("pkg"): shutil.rmtree("pkg") os.mkdir("pkg") os.chdir('pkg') buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build " + comm.XwalkPath + "org.xwalk.test" comm.build(self, buildcmd) comm.run(self) os.chdir('../') shutil.rmtree("pkg") comm.clear("org.xwalk.test") if comm.SHELL_FLAG == "False": os.system('adb start-server')
def test_create_package_relative_path(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir('org.xwalk.test') cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-pkg --platforms=android --android=" + comm.ANDROID_MODE + " --crosswalk=" + comm.crosswalkzip + " ../../testapp/create_package_basic/" return_code = os.system(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 if comm.MODE != " --android-shared": for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 self.assertEquals(apkLength, 2) else: for i in range(len(apks)): if apks[i].endswith(".apk") and "shared" in apks[i]: apkLength = apkLength + 1 appVersion = apks[i].split('-')[1] self.assertEquals(apkLength, 1) comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0)
def test_update_app_version(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') jsonfile = open(comm.ConstPath + "/../tools/org.xwalk.test/app/manifest.json", "r") jsons = jsonfile.read() jsonfile.close() jsonDict = json.loads(jsons) jsonDict["xwalk_app_version"] = "0.0.1" json.dump(jsonDict, open(comm.ConstPath + "/../tools/org.xwalk.test/app/manifest.json", "w")) with open(comm.ConstPath + "/../tools/org.xwalk.test/app/manifest.json") as json_file: data = json.load(json_file) buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" buildstatus = os.system(buildcmd) root = ElementTree.parse(comm.ConstPath + "/../tools/org.xwalk.test/prj/android/AndroidManifest.xml").getroot() attributes = root.attrib for x in attributes.keys(): if x.find("versionName") != -1: versionName_xml = attributes[x] break comm.run(self) comm.clear("org.xwalk.test") if comm.SHELL_FLAG == "False": os.system('adb start-server') self.assertEquals(data['xwalk_app_version'].strip("\n\t"), "0.0.1") self.assertEquals(buildstatus, 0) self.assertEquals(data['xwalk_app_version'].strip("\n\t"), versionName_xml)
def test_without_platforms(self): comm.setUp() os.chdir(comm.TEMP_DATA_PATH) comm.cleanTempData(comm.TEST_PROJECT_COMM) os.mkdir(comm.TEST_PROJECT_COMM) os.chdir(comm.TEST_PROJECT_COMM) cmd = 'crosswalk-pkg ' + comm.SCRIPT_DIR_NAME + "/../testapp/create_package_basic/" packstatus = commands.getstatusoutput(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 debLength = 0 for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: apkLength = apkLength + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: apkLength = apkLength + 1 if apks[i].endswith(".deb"): debLength = debLength + 1 comm.run(self) comm.cleanTempData(comm.TEST_PROJECT_COMM) self.assertEquals(packstatus[0], 0) self.assertEquals(apkLength, 2) self.assertEquals(debLength, 0) self.assertNotIn("target deb", packstatus[1]) self.assertIn("Loading 'android' platform backend", packstatus[1])
def test_setting_value(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir('org.xwalk.test') cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-pkg --platforms=android --android=" + comm.ANDROID_MODE + " --crosswalk=" + comm.crosswalkzip + " ../../testapp/manifest_xwalk_target_platforms/windows_platform/" (return_code, output) = comm.getstatusoutput(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 if comm.MODE != " --android-shared": for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 self.assertEquals(apkLength, 2) else: for i in range(len(apks)): if apks[i].endswith(".apk") and "shared" in apks[i]: apkLength = apkLength + 1 appVersion = apks[i].split('-')[1] self.assertEquals(apkLength, 1) comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertIn("Loading 'android' platform backend", output[0]) self.assertNotIn("Loading 'windows' platform backend", output[0])
def test_create_package_target_bit_crosswalkdir(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") crosswalkdir = zipfile.ZipFile(comm.crosswalkzip, "r") for file in crosswalkdir.namelist(): crosswalkdir.extract(file, r".") crosswalkdir.close() os.chdir("org.xwalk.test") cmd = ( comm.HOST_PREFIX + comm.PackTools + "crosswalk-pkg --platforms=android --android=" + comm.ANDROID_MODE + " --crosswalk=" + comm.crosswalkzip[: comm.crosswalkzip.index(".zip")] + ' --targets="32 64" ' + comm.ConstPath + "/../testapp/create_package_basic/" ) return_code = os.system(cmd) apks = os.listdir(os.getcwd()) x86Length = 0 x86_64Length = 0 armLength = 0 arm_64Length = 0 apkLength = 0 if comm.MODE != " --android-shared": for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: if "64" in apks[i]: x86_64Length = x86_64Length + 1 else: x86Length = x86Length + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: if "64" in apks[i]: arm_64Length = arm_64Length + 1 else: armLength = armLength + 1 if comm.BIT == "64": self.assertEquals(x86_64Length, 1) self.assertEquals(arm_64Length, 1) self.assertEquals(x86Length, 0) self.assertEquals(armLength, 0) else: self.assertEquals(x86_64Length, 0) self.assertEquals(arm_64Length, 0) self.assertEquals(x86Length, 1) self.assertEquals(armLength, 1) else: for i in range(len(apks)): if apks[i].endswith(".apk") and "shared" in apks[i]: apkLength = apkLength + 1 appVersion = apks[i].split("-")[1] self.assertEquals(apkLength, 1) comm.run(self) comm.clear("org.xwalk.test") shutil.rmtree(comm.crosswalkzip[: comm.crosswalkzip.index(".zip")]) self.assertEquals(return_code, 0)
def test_setting_value(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir('org.xwalk.test') cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-pkg --platforms=android --android=" + comm.ANDROID_MODE + " --crosswalk=" + comm.crosswalkzip + " ../../testapp/manifest_xwalk_target_platforms/" (return_code, output) = comm.getstatusoutput(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 if comm.MODE != " --android-shared": for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: if comm.BIT == "64": self.assertIn("64", apks[i]) apkLength = apkLength + 1 self.assertEquals(apkLength, 2) else: for i in range(len(apks)): if apks[i].endswith(".apk") and "shared" in apks[i]: apkLength = apkLength + 1 appVersion = apks[i].split('-')[1] self.assertEquals(apkLength, 1) comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertIn("target android", output[0]) self.assertNotIn("target windows", output[0])
def test_update_app_version_twodot(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') jsonfile = open(comm.ConstPath + "/../tools/org.xwalk.test/app/manifest.json", "r") jsons = jsonfile.read() jsonfile.close() jsonDict = json.loads(jsons) jsonDict["xwalk_app_version"] = "0.0.1" json.dump(jsonDict, open(comm.ConstPath + "/../tools/org.xwalk.test/app/manifest.json", "w")) with open(comm.ConstPath + "/../tools/org.xwalk.test/app/manifest.json") as json_file: data = json.load(json_file) buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" buildstatus = os.popen(buildcmd).readlines() index = 0 for x in range(len(buildstatus),0,-1): index = x -1 if buildstatus[index].find("Using android:versionCode") != -1: break versionCode = buildstatus[index].strip(" *\nUsing android:versionCode")[1:-1] root = ElementTree.parse(comm.ConstPath + "/../tools/org.xwalk.test/prj/android/AndroidManifest.xml").getroot() attributes = root.attrib for x in attributes.keys(): if x.find("versionCode") != -1: versionCode_xml = attributes[x] break comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(data['xwalk_app_version'].strip(os.linesep), "0.0.1") self.assertEquals(versionCode, versionCode_xml)
def test_build_release(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') buildcmd = comm.PackTools + "crosswalk-app build release" comm.build(self, buildcmd) comm.run(self) comm.clear("org.xwalk.test")
def test_update_version(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') updatecmd = comm.PackTools + "crosswalk-app update 13.42.319.7" comm.update(self, updatecmd) comm.run(self) comm.clear("org.xwalk.test")
def test_build_debug(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" comm.build(self, buildcmd) comm.run(self) comm.clear("org.xwalk.test")
def test_target_arch(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir('org.xwalk.test') if comm.BIT == "64": self.invokeCrosswalkPkg([ '--platforms=android', '--android=' + comm.ANDROID_MODE, '--crosswalk=' + comm.crosswalkzip, '--targets=arm64-v8a x86_64', comm.ConstPath + '/../testapp/create_package_basic/', ]) else: self.invokeCrosswalkPkg([ '--platforms=android', '--android=' + comm.ANDROID_MODE, '--crosswalk=' + comm.crosswalkzip, '--targets=armeabi-v7a x86', comm.ConstPath + '/../testapp/create_package_basic/', ]) apks = os.listdir(os.getcwd()) x86Length = 0 x86_64Length = 0 armLength = 0 arm_64Length = 0 apkLength = 0 if comm.MODE != " --android-shared": for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: if "64" in apks[i]: x86_64Length = x86_64Length + 1 else: x86Length = x86Length + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: if "64" in apks[i]: arm_64Length = arm_64Length + 1 else: armLength = armLength + 1 if comm.BIT == "64": self.assertEquals(x86_64Length, 1) self.assertEquals(arm_64Length, 1) self.assertEquals(x86Length, 0) self.assertEquals(armLength, 0) else: self.assertEquals(x86_64Length, 0) self.assertEquals(arm_64Length, 0) self.assertEquals(x86Length, 1) self.assertEquals(armLength, 1) else: for i in range(len(apks)): if apks[i].endswith(".apk") and "shared" in apks[i]: apkLength = apkLength + 1 appVersion = apks[i].split('-')[1] self.assertEquals(apkLength, 1) comm.run(self) comm.clear("org.xwalk.test")
def test_build_normal(self): comm.setUp() comm.create(self) os.chdir(comm.TEST_PROJECT_COMM) buildcmd = "crosswalk-app build" comm.build(self, buildcmd) comm.run(self) comm.cleanTempData(comm.TEST_PROJECT_COMM) comm.delete()
def test_update_invalid_version(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') updatecmd = comm.PackTools + "crosswalk-app update 0.0.0.0" updatestatus = commands.getstatusoutput(updatecmd) comm.run(self) comm.clear("org.xwalk.test") self.assertIn("ERROR:", updatestatus[1])
def test_build_release(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build release" comm.build(self, buildcmd) comm.run(self) comm.clear("org.xwalk.test") os.system('adb start-server')
def test_name_chinese(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') shutil.copyfile(comm.ConstPath + "/../testapp/manifest_name_chinese/manifest.json", comm.ConstPath + "/../tools/org.xwalk.test/app/manifest.json") buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" buildstatus = os.system(buildcmd) comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(buildstatus, 0)
def test_build_normal(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" comm.build(self, buildcmd) comm.run(self) comm.clear("org.xwalk.test") if comm.SHELL_FLAG == "False": os.system('adb start-server')
def test_name_chinese(self): comm.setUp() comm.create(self) os.chdir(comm.TEST_PROJECT_COMM) shutil.copyfile(comm.TEMP_DATA_PATH + "/../testapp/manifest_name_chinese/manifest.json", comm.TEMP_DATA_PATH + comm.TEST_PROJECT_COMM + "/app/manifest.json") buildcmd = "crosswalk-app build" buildstatus = os.system(buildcmd) comm.run(self) comm.cleanTempData(comm.TEST_PROJECT_COMM) self.assertEquals(buildstatus, 0)
def test_update_toplevel_dir(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test/pkg') updatecmd = comm.PackTools + "crosswalk-app update" updatestatus = commands.getstatusoutput(updatecmd) print updatestatus[1] comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(updatestatus[0], 2048)
def test_create_package_target_bit(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir("org.xwalk.test") cmd = ( comm.HOST_PREFIX + comm.PackTools + "crosswalk-pkg --platforms=android --android=" + comm.ANDROID_MODE + ' --targets="' + comm.BIT + '" -c canary ' + comm.ConstPath + "/../testapp/create_package_basic/" ) return_code = os.system(cmd) apks = os.listdir(os.getcwd()) x86Length = 0 x86_64Length = 0 armLength = 0 arm_64Length = 0 apkLength = 0 if comm.MODE != " --android-shared": for i in range(len(apks)): if apks[i].endswith(".apk") and "x86" in apks[i]: if "64" in apks[i]: x86_64Length = x86_64Length + 1 else: x86Length = x86Length + 1 if apks[i].endswith(".apk") and "arm" in apks[i]: if "64" in apks[i]: arm_64Length = arm_64Length + 1 else: armLength = armLength + 1 if comm.BIT == "64": self.assertEquals(x86_64Length, 1) self.assertEquals(arm_64Length, 1) self.assertEquals(x86Length, 0) self.assertEquals(armLength, 0) else: self.assertEquals(x86_64Length, 0) self.assertEquals(arm_64Length, 0) self.assertEquals(x86Length, 1) self.assertEquals(armLength, 1) else: for i in range(len(apks)): if apks[i].endswith(".apk") and "shared" in apks[i]: apkLength = apkLength + 1 appVersion = apks[i].split("-")[1] self.assertEquals(apkLength, 1) comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0)
def test_create_with_platform_android(self): comm.setUp() os.chdir(comm.XwalkPath) cmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app create org.xwalk.test" + comm.MODE + " --platforms=android" packstatus = os.system(cmd) self.assertEquals(packstatus, 0) os.chdir('org.xwalk.test') buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" comm.build(self, buildcmd) comm.run(self) comm.clear("org.xwalk.test")
def test_build_missing_both_so_file(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') os.remove(os.getcwd() + '/prj/android/xwalk_core_library/libs/armeabi-v7a/libxwalkcore.so') os.remove(os.getcwd() + '/prj/android/xwalk_core_library/libs/x86/libxwalkcore.so') buildcmd = comm.PackTools + "crosswalk-app build" buildstatus = commands.getstatusoutput(buildcmd) comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(buildstatus[0], 1)
def test_create_with_platform_android(self): comm.setUp() os.chdir(comm.TEMP_DATA_PATH) comm.cleanTempData(comm.TEST_PROJECT_COMM) cmd = "crosswalk-app create " + comm.TEST_PROJECT_COMM + " --platform=android" packstatus = commands.getstatusoutput(cmd) os.chdir(comm.TEST_PROJECT_COMM) buildcmd = "crosswalk-app build" comm.build(self, buildcmd) comm.run(self) comm.cleanTempData(comm.TEST_PROJECT_COMM) self.assertEquals(packstatus[0], 0)
def test_name_chinese(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') shutil.copyfile( comm.ConstPath + "/../testapp/manifest_name_chinese/manifest.json", comm.ConstPath + "/../tools/org.xwalk.test/app/manifest.json") buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" buildstatus = os.system(buildcmd) comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(buildstatus, 0)
def test_apkName_contains_appVersion(self): comm.setUp() comm.create(self) os.chdir("org.xwalk.test") with open(comm.ConstPath + "/../tools/org.xwalk.test/app/manifest.json") as json_file: data = json.load(json_file) buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" appVersion = comm.build(self, buildcmd) comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(data["xwalk_app_version"].strip(os.linesep), "0.1") self.assertEquals(data["xwalk_app_version"].strip(os.linesep), appVersion)
def test_build_path_release(self): comm.setUp() comm.create(self) if os.path.exists("pkg"): shutil.rmtree("pkg") os.mkdir("pkg") os.chdir('pkg') buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build release " + comm.XwalkPath + "org.xwalk.test" comm.build(self, buildcmd) comm.run(self) os.chdir('../') shutil.rmtree("pkg") comm.clear("org.xwalk.test")
def test_run(self): comm.setUp() app_name = "helloworld" pkg_name = "com.example." + app_name.lower() cmd_create = "bin/create " + app_name + " com.example." + app_name + " " + app_name comm.create(cmd_create, app_name, self) if not comm.replace_key(os.path.join(comm.pack_tool, app_name, "assets", "www", "index.html"), "<a href='http://www.intel.com'>Intel</a>\n</body>", "</body>"): return False cmd_run = "./cordova/run" if comm.check_app_installed(pkg_name, self): comm.app_uninstall(pkg_name, self) comm.run(cmd_run, app_name, self)
def test_create_offline(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-app create org.xwalk.test" + comm.MODE + " --android-crosswalk=" + \ comm.crosswalkzip (return_create_code, create_output) = comm.getstatusoutput(cmd) os.chdir('org.xwalk.test') buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" comm.build(self, buildcmd) comm.run(self) comm.clear("org.xwalk.test") self.assertNotIn("Looking for", create_output)
def test_build_path_normal(self): comm.setUp() comm.create(self) if os.path.exists("pkg"): shutil.rmtree("pkg") os.mkdir("pkg") os.chdir('pkg') buildcmd = "crosswalk-app build " + comm.TEMP_DATA_PATH + comm.TEST_PROJECT_COMM comm.build(self, buildcmd) comm.run(self) os.chdir('../') shutil.rmtree("pkg") comm.cleanTempData(comm.TEST_PROJECT_COMM) comm.delete()
def test_apkName_contains_appVersion(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') with open(comm.ConstPath + "/../tools/org.xwalk.test/app/manifest.json") as json_file: data = json.load(json_file) buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" appVersion = comm.build(self, buildcmd) comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(data['xwalk_app_version'].strip(os.linesep), "0.1") self.assertEquals(data['xwalk_app_version'].strip(os.linesep), appVersion)
def test_display_browser(self): comm.setUp() comm.create(self) os.chdir(comm.TEST_PROJECT_COMM) jsonfile = open(comm.TEMP_DATA_PATH + comm.TEST_PROJECT_COMM + "/app/manifest.json", "r") jsons = jsonfile.read() jsonfile.close() jsonDict = json.loads(jsons) jsonDict["display"] = "browser" json.dump(jsonDict, open(comm.TEMP_DATA_PATH + comm.TEST_PROJECT_COMM + "/app/manifest.json", "w")) buildcmd = "crosswalk-app build" buildstatus = os.system(buildcmd) comm.run(self) comm.cleanTempData(comm.TEST_PROJECT_COMM) self.assertEquals(buildstatus, 0)
def test_build_path_normal(self): comm.setUp() comm.create(self) if os.path.exists("pkg"): shutil.rmtree("pkg") os.mkdir("pkg") os.chdir('pkg') buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build " + comm.XwalkPath + "org.xwalk.test" comm.build(self, buildcmd) comm.run(self) os.chdir('../') shutil.rmtree("pkg") comm.clear("org.xwalk.test") if comm.SHELL_FLAG == "False": os.system('adb start-server')