def test_create_package_release_without_argument_check_locale(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir('org.xwalk.test') comm.unzip_dir(comm.XwalkPath + comm.windowsCrosswalk, comm.XwalkPath) cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-pkg --platforms=windows --crosswalk=" + comm.XwalkPath + comm.windowsCrosswalk.replace('.zip', '') + " -r " + comm.ConstPath + "/../testapp/create_package_basic/" (return_code, output) = comm.getstatusoutput(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 for i in range(len(apks)): if apks[i].endswith(".msi"): apkLength = apkLength + 1 self.assertEquals(return_code, 0) self.assertEquals(apkLength, 1) cmd = "msiexec /a %s TARGETDIR=%s" % ( apks[0], os.path.join(os.path.abspath(comm.XwalkPath), "test-app")) (return_code, output) = comm.getstatusoutput(cmd) self.assertEquals(return_code, 0) self.assertTrue( os.path.isdir( os.path.join(os.path.abspath(comm.XwalkPath), "test-app", "org.xwalk.test", "locales"))) comm.clear("org.xwalk.test") comm.clear("test-app")
def test_target_build(self): comm.setUp() comm.clear("org.xwalk.test") os.chdir(comm.XwalkPath) comm.create(self) if comm.SHELL_FLAG == "False": cmd = "where android" else: cmd = "which android" (return_code, androidpath) = comm.getstatusoutput(cmd) targetversionpath = os.path.dirname(os.path.dirname(androidpath[0])) os.chdir(targetversionpath) if os.path.exists(os.path.dirname(os.path.dirname(targetversionpath)) + "/platforms/"): shutil.rmtree(os.path.dirname(os.path.dirname(targetversionpath)) + "/platforms/") os.mkdir(os.path.dirname(os.path.dirname(targetversionpath)) + "/platforms/") movepath = os.path.dirname(os.path.dirname(targetversionpath)) if comm.SHELL_FLAG == "False": os.system("xcopy /s /e /i /y platforms\* " + movepath + "\platforms") else: os.system("mv platforms/* " + movepath + "/platforms/") shutil.rmtree("platforms") os.chdir(comm.XwalkPath) os.chdir('org.xwalk.test') buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" (return_build_code, buildstatus) = comm.getstatusoutput(buildcmd) os.chdir(movepath) os.mkdir(targetversionpath + "/platforms") if comm.SHELL_FLAG == "False": os.system("xcopy /s /e /i /y platforms\* " + targetversionpath + "\platforms") else: os.system("mv platforms/* " + targetversionpath + "/platforms/") shutil.rmtree("platforms") comm.clear("org.xwalk.test") self.assertNotEquals(return_build_code, 0) self.assertIn("project target", buildstatus[0])
def test_target_create(self): comm.setUp() if comm.SHELL_FLAG == "False": cmd = "where android" else: cmd = "which android" (return_code, androidpath) = comm.getstatusoutput(cmd) targetversionpath = os.path.dirname(os.path.dirname(androidpath[0])) os.chdir(targetversionpath) if os.path.exists(os.path.dirname(os.path.dirname(targetversionpath)) + "/platforms/"): shutil.rmtree(os.path.dirname(os.path.dirname(targetversionpath)) + "/platforms/") os.mkdir(os.path.dirname(os.path.dirname(targetversionpath)) + "/platforms/") movepath = os.path.dirname(os.path.dirname(targetversionpath)) if comm.SHELL_FLAG == "False": os.system("xcopy /s /e /i /y platforms\* " + movepath + "\platforms") else: os.system("mv platforms/* " + movepath + "/platforms/") shutil.rmtree("platforms") comm.clear("org.xwalk.test") os.chdir(comm.XwalkPath) createcmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-app create org.xwalk.test" + comm.MODE + " --android-crosswalk=" + \ comm.crosswalkzip (return_create_code, output) = comm.getstatusoutput(createcmd) os.chdir(movepath) os.mkdir(targetversionpath + "/platforms") if comm.SHELL_FLAG == "False": os.system("xcopy /s /e /i /y platforms\* " + targetversionpath + "\platforms") else: os.system("mv platforms/* " + targetversionpath + "/platforms/") shutil.rmtree("platforms") comm.clear("org.xwalk.test") self.assertNotEquals(return_create_code, 0)
def test_tools_version(self): comm.setUp() os.chdir(comm.XwalkPath) cmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-pkg --version" (return_code, output) = comm.getstatusoutput(cmd) cmd_1 = comm.HOST_PREFIX + comm.PackTools + "crosswalk-pkg -v" (return_code_1, output_1) = comm.getstatusoutput(cmd_1) with open(comm.PackTools + "../package.json") as json_file: data = json.load(json_file) self.assertEquals(data['version'].strip(os.linesep), output[0].strip(os.linesep)) self.assertEquals(data['version'].strip(os.linesep), output_1[0].strip(os.linesep))
def test_create_package_default_non_interactive(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/ > 1.log 2>&1" (return_code, output) = comm.getstatusoutput(cmd) cmd = "cat 1.log" (return_code, output) = comm.getstatusoutput(cmd) comm.clear("org.xwalk.test") comm.clear("1.log") self.assertEquals(return_code, 0) self.assertIn("Skipping host setup check", output[0])
def test_without_platforms(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 ../../testapp/create_package_basic/" (return_code, output) = comm.getstatusoutput(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 msiLength = 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(".msi"): msiLength = msiLength + 1 comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertEquals(apkLength, 2) self.assertEquals(msiLength, 0) self.assertNotIn("Loading 'windows' platform backend", output[0]) self.assertIn("Loading 'android' platform backend", output[0])
def test_no_sdk(self): comm.setUp() comm.clear("org.xwalk.test") android_home = os.getenv("ANDROID_HOME") android_home2 = android_home + "/sdkk" allpath = os.getenv("PATH") paths = allpath.split(os.linesep) new_path = "" for i in range(len(paths)): print paths[i] if android_home in paths[i]: paths[i] = paths[i].replace(android_home, android_home2) new_path = os.linesep.join(paths).strip() os.environ["PATH"] = new_path os.chdir(comm.XwalkPath) cmd = ( comm.HOST_PREFIX + comm.PackTools + "crosswalk-app create org.xwalk.test" + comm.MODE + " --android-crosswalk=" + comm.crosswalkVersion ) (return_create_code, packstatus) = comm.getstatusoutput(cmd) os.environ["ANDROID_HOME"] = android_home os.environ["PATH"] = allpath comm.clear("org.xwalk.test") self.assertIn("ERROR", packstatus[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_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_file_exist(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir('org.xwalk.test') shutil.copyfile( comm.ConstPath + "/../testapp/manifest_hooks/XWalkExtensionHooks.js", comm.ConstPath + "/../testapp/xwalk_echo_extension/extension/echo_extension/XWalkExtensionHooks.js" ) cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-pkg --platforms=windows --crosswalk=" + comm.XwalkPath + comm.windowsCrosswalk + " --keep " + comm.ConstPath + "/../testapp/xwalk_echo_extension/" (return_code, output) = comm.getstatusoutput(cmd) os.remove( comm.ConstPath + "/../testapp/xwalk_echo_extension/extension/echo_extension/XWalkExtensionHooks.js" ) projectDir = output[0].split(" * " + os.linesep)[-1].split(' ')[-1].strip( os.linesep) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertIn("org.xwalk.test-0.1.0.0.wxs", os.listdir(projectDir))
def test_check_host_android(self): comm.setUp() os.chdir(comm.XwalkPath) cmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app check android" (return_code, output) = comm.getstatusoutput(cmd) self.assertEquals(return_code, 0) self.assertNotIn("ERROR:", output[0])
def test_pre_post_package(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir('org.xwalk.test') shutil.copyfile( comm.ConstPath + "/../testapp/manifest_hooks/XWalkExtensionHooks.js", comm.ConstPath + "/../testapp/extension_permission/contactextension/XWalkExtensionHooks.js" ) cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-pkg --platforms=android --android=" + comm.ANDROID_MODE + " --crosswalk=canary " + comm.ConstPath + "/../testapp/extension_permission/" (return_code, output) = comm.getstatusoutput(cmd) os.remove( comm.ConstPath + "/../testapp/extension_permission/contactextension/XWalkExtensionHooks.js" ) comm.clear("org.xwalk.test") preline = output[0].index('prePackage android') pkgline = output[0].index('Package:') postline = output[0].index('postPackage android') self.assertEquals(return_code, 0) self.assertIn("prePackage android", output[0]) self.assertIn("postPackage android", output[0]) self.assertTrue(postline > pkgline) self.assertTrue(pkgline > preline)
def test_create_package_default_non_interactive(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=windows --crosswalk=" + comm.XwalkPath + comm.windowsCrosswalk.replace('.zip', '') + " -r " + comm.ConstPath + "/../testapp/create_package_basic/ > 1.log 2>&1" (return_code, output) = comm.getstatusoutput(cmd) self.assertEquals(return_code, 0) cmd = "type 1.log" (return_code, output) = comm.getstatusoutput(cmd) comm.clear("org.xwalk.test") comm.clear("1.log") self.assertEquals(return_code, 0) self.assertIn("Skipping host setup check", output[0])
def test_check_host_without_platforms(self): comm.setUp() os.chdir(comm.XwalkPath) cmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app check" (return_code, output) = comm.getstatusoutput(cmd) self.assertEquals(return_code, 0) self.assertNotIn("ERROR:", output[0].split('target windows')[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_invalid_channel(self): comm.setUp() comm.create(self) updatecmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app update channel org.xwalk.test --windows-crosswalk=" + comm.XwalkPath + comm.windowsCrosswalk (return_update_code, update_output) = comm.getstatusoutput(updatecmd) comm.clear("org.xwalk.test") self.assertIn("ERROR:", update_output[0])
def test_without_platforms(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 --android=" + comm.ANDROID_MODE + " --crosswalk=" + comm.crosswalkzip + " ../../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) comm.run(self) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertIn("Loading 'android' platform backend", output[0])
def test_crosswalk_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=windows --crosswalk=canary " + comm.ConstPath + "/../testapp/create_package_basic/" (return_code, output) = comm.getstatusoutput(cmd) version = comm.check_crosswalk_version(self, "canary") crosswalk = 'crosswalk-{}.zip'.format(version) apks = os.listdir(os.getcwd()) apkLength = 0 for i in range(len(apks)): if apks[i].endswith(".msi"): apkLength = apkLength + 1 comm.clear("org.xwalk.test") if not comm.cachedir: namelist = os.listdir(os.getcwd()) else: newcachedir = os.environ.get('CROSSWALK_APP_TOOLS_CACHE_DIR') os.chdir(newcachedir) namelist = os.listdir(os.getcwd()) self.assertEquals(return_code, 0) self.assertIn("canary", output[0]) self.assertIn(version, output[0]) self.assertIn(crosswalk, namelist) self.assertEquals(apkLength, 1)
def test_check_host_windows(self): comm.setUp() os.chdir(comm.XwalkPath) cmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app check windows" (return_code, output) = comm.getstatusoutput(cmd) self.assertEquals(return_code, 0) self.assertNotIn("ERROR:", output[0])
def test_file_exist(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir("org.xwalk.test") shutil.copyfile( comm.ConstPath + "/../testapp/manifest_hooks/XWalkExtensionHooks.js", comm.ConstPath + "/../testapp/xwalk_echo_extension/extension/echo_extension/XWalkExtensionHooks.js", ) cmd = ( comm.HOST_PREFIX + comm.PackTools + "crosswalk-pkg --platforms=windows --crosswalk=" + comm.XwalkPath + comm.windowsCrosswalk + " --keep " + comm.ConstPath + "/../testapp/xwalk_echo_extension/" ) (return_code, output) = comm.getstatusoutput(cmd) os.remove(comm.ConstPath + "/../testapp/xwalk_echo_extension/extension/echo_extension/XWalkExtensionHooks.js") projectDir = output[0].split(" * " + os.linesep)[-1].split(" ")[-1].strip(os.linesep) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertIn("org.xwalk.test-0.1.0.0.wxs", os.listdir(projectDir))
def test_create_package_c(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=windows -c canary " + comm.ConstPath + "/../testapp/create_package_basic/" (return_code, output) = comm.getstatusoutput(cmd) version = comm.check_crosswalk_version(self, "canary") crosswalk = 'crosswalk-{}.zip'.format(version) crosswalk64 = 'crosswalk64-{}.zip'.format(version) apks = os.listdir(os.getcwd()) apkLength = 0 for i in range(len(apks)): if apks[i].endswith(".msi"): apkLength = apkLength + 1 if not comm.cachedir: namelist = os.listdir(os.getcwd()) else: newcachedir = os.environ.get('CROSSWALK_APP_TOOLS_CACHE_DIR') os.chdir(newcachedir) namelist = os.listdir(os.getcwd()) crosswalkexist = 1 if crosswalk not in namelist and crosswalk64 not in namelist: crosswalkexist = 0 comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertIn("canary", output[0]) self.assertIn(version, output[0]) self.assertEquals(crosswalkexist, 1) self.assertEquals(apkLength, 1)
def test_update_invalid_version(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') updatecmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app update 0.0.0.0" (return_update_code, update_output) = comm.getstatusoutput(updatecmd) comm.clear("org.xwalk.test") self.assertIn("ERROR:", update_output[0])
def test_update_toplevel_dir(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test/app') updatecmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app update" (return_update_code, update_output) = comm.getstatusoutput(updatecmd) print update_output[0] comm.clear("org.xwalk.test") self.assertNotEquals(return_update_code, 0)
def test_target_create(self): comm.setUp() if comm.SHELL_FLAG == "False": cmd = "where android" else: cmd = "which android" (return_code, androidpath) = comm.getstatusoutput(cmd) targetversionpath = os.path.dirname(os.path.dirname(androidpath[0])) os.rename(targetversionpath + "/platforms/", targetversionpath + "/backup/") comm.clear("org.xwalk.test") os.chdir(comm.XwalkPath) createcmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-app create org.xwalk.test" + comm.MODE + " --android-crosswalk=" + \ comm.crosswalkzip (return_create_code, output) = comm.getstatusoutput(createcmd) os.rename(targetversionpath + "/backup/", targetversionpath + "/platforms/") comm.clear("org.xwalk.test") self.assertNotEquals(return_create_code, 0)
def test_version_normal(self): comm.setUp() os.chdir(comm.XwalkPath) cmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-pkg --version" (return_code, output) = comm.getstatusoutput(cmd) with open(comm.ConstPath + "/../tools/crosswalk-app-tools/package.json") as json_file: data = json.load(json_file) self.assertEquals( data['version'].strip(os.linesep), output[0].strip(os.linesep))
def test_target_build(self): comm.setUp() comm.clear("org.xwalk.test") os.chdir(comm.XwalkPath) comm.create(self) if comm.SHELL_FLAG == "False": cmd = "where android" else: cmd = "which android" (return_code, androidpath) = comm.getstatusoutput(cmd) targetversionpath = os.path.dirname(os.path.dirname(androidpath[0])) os.rename(targetversionpath + "/platforms/", targetversionpath + "/backup/") os.chdir(comm.XwalkPath + "org.xwalk.test") buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" (return_build_code, buildstatus) = comm.getstatusoutput(buildcmd) os.rename(targetversionpath + "/backup/", targetversionpath + "/platforms/") comm.clear("org.xwalk.test") self.assertNotEquals(return_build_code, 0) self.assertIn("project target", buildstatus[0])
def test_target_create(self): comm.setUp() comm.clear("org.xwalk.test") cmd = "which android" (return_code, androidpath) = comm.getstatusoutput(cmd) targetversionpath = os.path.dirname(os.path.dirname(androidpath[0])) os.chdir(targetversionpath) movepath = os.path.dirname(os.path.dirname(targetversionpath)) + "/new-platforms/" os.system("mv platforms/ " + movepath) os.chdir(comm.XwalkPath) createcmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-app create org.xwalk.test" + comm.MODE + " --android-crosswalk=" + \ comm.crosswalkVersion (return_create_code, output) = comm.getstatusoutput(createcmd) os.chdir(movepath + "../") os.system("mv new-platforms/ " + targetversionpath + "/platforms/") comm.clear("org.xwalk.test") self.assertNotEquals(return_create_code, 0) self.assertIn("android list targets", output[0])
def test_normal_with_downloadCrosswalk(self): comm.setUp() comm.clear("org.xwalk.test") os.chdir(comm.XwalkPath) createcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app create org.xwalk.test" + comm.MODE + comm.ANDROID_TARGETS (return_code, output) = comm.getstatusoutput(createcmd) version = comm.check_crosswalk_version(self, "stable") comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertIn(version, output[0])
def test_version_normal(self): comm.setUp() os.chdir(comm.XwalkPath) cmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-pkg --version" (return_code, output) = comm.getstatusoutput(cmd) with open(comm.ConstPath + "/../tools/crosswalk-app-tools/package.json") as json_file: data = json.load(json_file) self.assertEquals(data['version'].strip(os.linesep), output[0].strip(os.linesep))
def test_target_create(self): comm.setUp() comm.clear("org.xwalk.test") cmd = "which android" (return_code, androidpath) = comm.getstatusoutput(cmd) targetversionpath = os.path.dirname(os.path.dirname(androidpath[0])) os.chdir(targetversionpath) movepath = os.path.dirname( os.path.dirname(targetversionpath)) + "/new-platforms/" os.system("mv platforms/ " + movepath) os.chdir(comm.XwalkPath) createcmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-app create org.xwalk.test" + comm.MODE + " --android-crosswalk=" + \ comm.crosswalkVersion (return_create_code, output) = comm.getstatusoutput(createcmd) os.chdir(movepath + "../") os.system("mv new-platforms/ " + targetversionpath + "/platforms/") comm.clear("org.xwalk.test") self.assertNotEquals(return_create_code, 0) self.assertIn("android list targets", output[0])
def test_target_build(self): comm.setUp() comm.clear("org.xwalk.test") os.chdir(comm.XwalkPath) comm.create(self) cmd = "which android" (return_code, androidpath) = comm.getstatusoutput(cmd) targetversionpath = os.path.dirname(os.path.dirname(androidpath[0])) os.chdir(targetversionpath) movepath = os.path.dirname(os.path.dirname(targetversionpath)) + "/new-platforms/" os.system("mv platforms/ " + movepath) os.chdir(comm.XwalkPath) os.chdir('org.xwalk.test') buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" (return_build_code, buildstatus) = comm.getstatusoutput(buildcmd) os.chdir(movepath + "../") os.system("mv new-platforms/ " + targetversionpath + "/platforms/") comm.clear("org.xwalk.test") self.assertNotEquals(return_build_code, 0) self.assertIn("project target", buildstatus[0])
def test_update_currentVersion(self): comm.setUp() comm.create(self) os.chdir('org.xwalk.test') updatecmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app update 13.42.319.7" comm.update(self, updatecmd) newupdatecmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app update 13.42.319.7" (return_update_code, update_output) = comm.getstatusoutput(newupdatecmd) comm.clear("org.xwalk.test") self.assertIn("Using cached", update_output[0])
def test_target_build(self): comm.setUp() comm.clear("org.xwalk.test") os.chdir(comm.XwalkPath) comm.create(self) cmd = "which android" (return_code, androidpath) = comm.getstatusoutput(cmd) targetversionpath = os.path.dirname(os.path.dirname(androidpath[0])) os.chdir(targetversionpath) movepath = os.path.dirname( os.path.dirname(targetversionpath)) + "/new-platforms/" os.system("mv platforms/ " + movepath) os.chdir(comm.XwalkPath) os.chdir('org.xwalk.test') buildcmd = comm.HOST_PREFIX + comm.PackTools + "crosswalk-app build" (return_build_code, buildstatus) = comm.getstatusoutput(buildcmd) os.chdir(movepath + "../") os.system("mv new-platforms/ " + targetversionpath + "/platforms/") comm.clear("org.xwalk.test") self.assertNotEquals(return_build_code, 0) self.assertIn("project target", buildstatus[0])
def test_create_package_skip_dummy_no(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 + " -s no --crosswalk=" + comm.crosswalkzip + " " + comm.ConstPath + "/../testapp/create_package_basic/" (return_code, output) = comm.getstatusoutput(cmd) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertIn("Checking host setup", output[0])
def test_create_package_skip_dummy_no(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=windows -s no --crosswalk=" + comm.XwalkPath + comm.windowsCrosswalk.replace('.zip', '') + " -r " + comm.ConstPath + "/../testapp/create_package_basic/" (return_code, output) = comm.getstatusoutput(cmd) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertIn("Checking host setup", output[0])
def test_create_version(self): comm.setUp() comm.clear("org.xwalk.test") os.chdir(comm.XwalkPath) createcmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-app create org.xwalk.test" + comm.MODE + " --android-crosswalk=" + comm.crosswalkVersion + comm.ANDROID_TARGETS (return_code, output) = comm.getstatusoutput(createcmd) crosswalk = 'crosswalk-{}.zip'.format(comm.crosswalkVersion) namelist = os.listdir(os.getcwd()) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertIn(comm.crosswalkVersion, output[0]) self.assertIn(crosswalk, namelist)
def test_create_version(self): comm.setUp() comm.clear("org.xwalk.test") os.chdir(comm.XwalkPath) createcmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-app create org.xwalk.test --android-crosswalk=13.42.319.7" (return_code, output) = comm.getstatusoutput(createcmd) crosswalk = 'crosswalk-13.42.319.7.zip' namelist = os.listdir(os.getcwd()) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertIn("13.42.319.7", output[0]) self.assertIn(crosswalk, namelist)
def test_create_version(self): comm.setUp() comm.clear("org.xwalk.test") os.chdir(comm.XwalkPath) createcmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-app create org.xwalk.test" + comm.MODE + " --android-crosswalk=15.44.384.7" (return_code, output) = comm.getstatusoutput(createcmd) crosswalk = 'crosswalk-15.44.384.7.zip' namelist = os.listdir(os.getcwd()) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertIn("15.44.384.7", output[0]) self.assertIn(crosswalk, namelist)
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_create_package_release_without_argument_check_locale(self): comm.setUp() os.chdir(comm.XwalkPath) comm.clear("org.xwalk.test") os.mkdir("org.xwalk.test") os.chdir('org.xwalk.test') comm.unzip_dir(comm.XwalkPath + comm.windowsCrosswalk, comm.XwalkPath) cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-pkg --platforms=windows --crosswalk=" + comm.XwalkPath + comm.windowsCrosswalk.replace('.zip', '') + " -r " + comm.ConstPath + "/../testapp/create_package_basic/" (return_code, output) = comm.getstatusoutput(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 for i in range(len(apks)): if apks[i].endswith(".msi"): apkLength = apkLength + 1 self.assertEquals(return_code, 0) self.assertEquals(apkLength, 1) cmd = "msiexec /a %s TARGETDIR=%s" % (apks[0], os.path.join(os.path.abspath(comm.XwalkPath), "test-app")) (return_code, output) = comm.getstatusoutput(cmd) self.assertEquals(return_code, 0) self.assertTrue(os.path.isdir(os.path.join(os.path.abspath(comm.XwalkPath), "test-app", "org.xwalk.test", "locales"))) comm.clear("org.xwalk.test") comm.clear("test-app")
def test_external_extensions_way(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=canary " + comm.ConstPath + "/../testapp/extension_permission/" (return_code, output) = comm.getstatusoutput(cmd) projectDir = output[0].split(" * " + os.linesep)[-1].split(' ')[-1].strip(os.linesep) comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertNotIn("extensions-config.json", os.listdir(projectDir + "/prj/android/assets/")) self.assertIn("contactextension", os.listdir(projectDir + "/prj/android/assets/xwalk-extensions/")) self.assertIn("contactextension.js", os.listdir(projectDir + "/prj/android/assets/xwalk-extensions/contactextension/")) self.assertIn("contactextension.json", os.listdir(projectDir + "/prj/android/assets/xwalk-extensions/contactextension/"))
def test_create_offline(self): comm.setUp() os.chdir(comm.XwalkPath) for i in range(len(os.listdir(comm.XwalkPath))): if os.listdir(comm.XwalkPath)[i].endswith(".zip"): androidCrosswalk = os.listdir(comm.XwalkPath)[i] comm.clear("org.xwalk.test") cmd = comm.HOST_PREFIX + comm.PackTools + \ "crosswalk-app create org.xwalk.test" + comm.MODE + " --android-crosswalk=" + \ androidCrosswalk (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_create_package_release_without_argument(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=windows --crosswalk=" + comm.XwalkPath + comm.windowsCrosswalk + " -r " + comm.ConstPath + "/../testapp/create_package_basic/" (return_code, output) = comm.getstatusoutput(cmd) apks = os.listdir(os.getcwd()) apkLength = 0 for i in range(len(apks)): if apks[i].endswith(".msi"): apkLength = apkLength + 1 comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertEquals(apkLength, 1)
def test_create_pkg_basic(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 -p android -a " + comm.ANDROID_MODE + ' -t "' + comm.BIT + '" ' + comm.ConstPath + "/../testapp/create_package_basic/" ) (return_code, output) = comm.getstatusoutput(cmd) 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.assertEquals(return_code, 0) self.assertIn("Loading 'android' platform backend", output[0]) self.assertNotIn("candle", output[0]) self.assertNotIn("light", output[0]) self.assertIn(version, output[0])
def test_update_target_platforms(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=windows --crosswalk=" + comm.XwalkPath + comm.windowsCrosswalk + " ../../testapp/manifest_xwalk_target_platforms/android_platform/" (return_code, output) = comm.getstatusoutput(cmd) apks = os.listdir(os.getcwd()) msiLength = 0 for i in range(len(apks)): if apks[i].endswith(".msi"): msiLength = msiLength + 1 comm.clear("org.xwalk.test") self.assertEquals(return_code, 0) self.assertEquals(msiLength, 1) self.assertIn("Loading 'windows' platform backend", output[0]) self.assertNotIn("Loading 'android' platform backend", output[0])