Upstream version 9.38.207.0
[platform/framework/web/crosswalk.git] / src / xwalk / app / tools / android / make_apk_test.py
index 0b2c62d..2cc9b22 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# coding: UTF-8
 
 # Copyright (c) 2013, 2014 Intel Corporation. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
@@ -12,6 +13,7 @@ import sys
 import unittest
 import warnings
 
+
 def Clean(name, app_version):
   if os.path.exists(name):
     shutil.rmtree(name)
@@ -58,23 +60,24 @@ def RunCommand(command):
   return proc.communicate()[0]
 
 
-def GetResultWithOption(mode, manifest=None, name=None, package=None):
+def GetResultWithOption(mode=None, manifest=None, name=None, package=None):
   app_url = None
-  if manifest != None:
+  if manifest is not None:
     manifest = '--manifest=' + manifest
   else:
     app_url = '--app-url=http://www.intel.com'
-  if name != None:
+  if name is not None:
     name = '--name=' + name
-  if package != None:
+  if package is not None:
     package = '--package=' + package
+
   cmd = ['python', 'make_apk.py',
          '--app-version=1.0.0',
          '%s' % manifest,
          '%s' % name,
          '%s' % package,
          '%s' % app_url,
-         mode]
+         '%s' % mode]
   return RunCommand(cmd)
 
 
@@ -128,7 +131,7 @@ class TestMakeApk(unittest.TestCase):
     # replace the original native library with an empty library.
     # Because it doesn't affect the result of test.
     if options.mode == 'embedded':
-      native_library_dir = 'native_libs'
+      native_library_dir = os.path.join('xwalk_core_library', 'libs')
       native_library_temp_dir = 'temp'
       shutil.copytree(native_library_dir, native_library_temp_dir)
       for root, _, files in os.walk(native_library_dir):
@@ -143,17 +146,17 @@ class TestMakeApk(unittest.TestCase):
   def restoreNativeLibrary():
     # Restore the original native library for embedded mode.
     if options.mode == 'embedded':
-      native_library_dir = 'native_libs'
+      native_library_dir = os.path.join('xwalk_core_library', 'libs')
       native_library_temp_dir = 'temp'
-      if os.path.exists(native_library_dir):
+      if os.path.isdir(native_library_dir):
         shutil.rmtree(native_library_dir)
       shutil.move(native_library_temp_dir, native_library_dir)
 
   @staticmethod
   def archs():
-    x86_native_lib_path = os.path.join('native_libs', 'x86', 'libs',
+    x86_native_lib_path = os.path.join('xwalk_core_library', 'libs',
                                        'x86', 'libxwalkcore.so')
-    arm_native_lib_path = os.path.join('native_libs', 'armeabi-v7a', 'libs',
+    arm_native_lib_path = os.path.join('xwalk_core_library', 'libs',
                                        'armeabi-v7a', 'libxwalkcore.so')
     arch_list = []
     if os.path.isfile(x86_native_lib_path):
@@ -162,22 +165,25 @@ class TestMakeApk(unittest.TestCase):
       arch_list.append('arm')
     return arch_list
 
-  def checkApks(self, apk_name, app_version):
-    # Check whether some files are contained in the given APK.
+  def checkApks(self, apk_name, app_version, keystore_path=None):
+    apks = []
     if self._mode.find('shared') != -1:
       apk_path = '%s_%s.apk' % (apk_name, app_version)
-      self.checkApk(apk_path, '')
+      apks.append((apk_path, ''))
     elif self._mode.find('embedded') != -1:
       x86_apk_path = '%s_%s_x86.apk' % (apk_name, app_version)
       if os.path.exists(x86_apk_path):
-        self.checkApk(x86_apk_path, 'x86')
+        apks.append((x86_apk_path, 'x86'))
       arm_apk_path = '%s_%s_arm.apk' % (apk_name, app_version)
       if os.path.exists(arm_apk_path):
-        self.checkApk(arm_apk_path, 'arm')
+        apks.append((arm_apk_path, 'arm'))
+
+    for apk, apk_arch in apks:
+      self.checkApk(apk, apk_arch, keystore_path)
 
-  def checkApk(self, apk_path, arch):
-    # Check whether some files are contained in the given apk
-    # for specified arch.
+  def checkApk(self, apk_path, arch, keystore_path=None):
+    """Checks whether some files are contained in the given APK,
+    and optionally verifies its signature."""
     cmd = ['jar', 'tvf', apk_path]
     out = RunCommand(cmd)
     common_files = ['AndroidManifest.xml', 'classes.dex']
@@ -188,8 +194,7 @@ class TestMakeApk(unittest.TestCase):
                                 'xwalk.pak',
                                 'device_capabilities_api.js',
                                 'launch_screen_api.js',
-                                'presentation_api.js',
-                                'screen_orientation_api.js']
+                                'presentation_api.js']
       for res_file in embedded_related_files:
         self.assertTrue(out.find(res_file) != -1)
     if arch == 'x86':
@@ -197,28 +202,26 @@ class TestMakeApk(unittest.TestCase):
     elif arch == 'arm':
       self.assertTrue(out.find('armeabi-v7a/libxwalkcore.so') != -1)
 
+    if keystore_path:
+      cmd = ['jarsigner', '-verify', '-keystore', keystore_path,
+             '-verbose', apk_path]
+      out = RunCommand(cmd)
+      self.assertIn('smk', out)
+
   def testName(self):
     cmd = ['python', 'make_apk.py', '--app-version=1.0.0',
+           '--app-url=http://www.intel.com',
            '--package=org.xwalk.example', self._mode]
     out = RunCommand(cmd)
     Clean('Example', '1.0.0')
-    self.assertTrue(out.find('The APK name is required!') != -1)
+    self.assertIn('An APK name is required', out)
 
     cmd = ['python', 'make_apk.py', '--name=Test_Example',
            '--app-version=1.0.0', '--app-url=http://www.intel.com',
            '--package=org.xwalk.example', self._mode]
     out = RunCommand(cmd)
-    self.assertTrue(out.find('The APK name is required!') == -1)
-    Clean('Test_Example', '1.0.0')
-
-    invalid_chars = '\/:.*?"<>|-'
-    for c in invalid_chars:
-      invalid_name = '--name=Example' + c
-      cmd = ['python', 'make_apk.py', invalid_name,
-             '--app-version=1.0.0', '--package=org.xwalk.example',
-             '--app-url=http://www.intel.com', self._mode]
-      out = RunCommand(cmd)
-      self.assertTrue(out.find('invalid characters') != -1)
+    self.assertNotIn('An APK name is required', out)
+    Clean('Example', '1.0.0')
 
   def testToolVersion(self):
     cmd = ['python', 'make_apk.py', '--version']
@@ -329,23 +332,49 @@ class TestMakeApk(unittest.TestCase):
 
   def testPackage(self):
     cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0',
-           self._mode]
+           '--app-url=http://www.intel.com', self._mode]
     out = RunCommand(cmd)
-    self.addCleanup(Clean, 'Example', '1.0.0')
-    self.assertTrue(out.find('The package name is required!') != -1)
+    self.assertIn('A package name is required', out)
+
+    cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0',
+           '--package=org.xwalk.example',
+           '--app-url=http://www.intel.com', self._mode]
+    out = RunCommand(cmd)
+    self.assertNotIn('A package name is required', out)
     Clean('Example', '1.0.0')
+
+  def testPackageWithInvalidCharacter(self):
+    package_name_error = 'package name should be started with letters'
+
     cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0',
-           '--package=org.xwalk.example', self._mode]
+           '--package=org.xwalk._example',
+           '--app-url=http://www.intel.com', self._mode]
+    out = RunCommand(cmd)
+    self.assertIn(package_name_error, out)
+
+    cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0',
+           '--package=org.xwalk.123example',
+           '--app-url=http://www.intel.com', self._mode]
+    out = RunCommand(cmd)
+    self.assertIn(package_name_error, out)
+
+    cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0',
+           '--package=org.xwalk.example_',
+           '--app-url=http://www.intel.com', self._mode]
     out = RunCommand(cmd)
-    self.assertTrue(out.find('The package name is required!') == -1)
+    self.assertNotIn(package_name_error, out)
+    Clean('Example', '1.0.0')
 
   def testEntry(self):
     cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0',
            '--package=org.xwalk.example', '--app-url=http://www.intel.com',
            self._mode]
     out = RunCommand(cmd)
+    self.assertNotIn('You must pass either "--app-url" or',
+                     out)
+    self.assertNotIn('You must specify both "--app-local-path" and',
+                     out)
     self.addCleanup(Clean, 'Example', '1.0.0')
-    self.assertTrue(out.find('The entry is required.') == -1)
     self.checkApks('Example', '1.0.0')
     Clean('Example', '1.0.0')
 
@@ -354,7 +383,10 @@ class TestMakeApk(unittest.TestCase):
            '--package=org.xwalk.example', '--app-root=%s' % test_entry_root,
            '--app-local-path=index.html', self._mode]
     out = RunCommand(cmd)
-    self.assertTrue(out.find('The entry is required.') == -1)
+    self.assertNotIn('You must pass either "--app-url" or',
+                     out)
+    self.assertNotIn('You must specify both "--app-local-path" and',
+                     out)
     self.checkApks('Example', '1.0.0')
 
   def testEntryWithErrors(self):
@@ -362,7 +394,9 @@ class TestMakeApk(unittest.TestCase):
            '--package=org.xwalk.example', self._mode]
     out = RunCommand(cmd)
     self.addCleanup(Clean, 'Example', '1.0.0')
-    self.assertTrue(out.find('The entry is required.') != -1)
+    self.assertIn('You must pass either "--app-url" or',
+                  out)
+
     self.assertFalse(os.path.exists('Example.apk'))
     Clean('Example', '1.0.0')
 
@@ -370,14 +404,16 @@ class TestMakeApk(unittest.TestCase):
            '--package=org.xwalk.example', '--app-url=http://www.intel.com',
            '--app-root=.', self._mode]
     out = RunCommand(cmd)
-    self.assertTrue(out.find('The entry is required.') != -1)
+    self.assertIn('You must pass either "--app-url" or',
+                  out)
     self.assertFalse(os.path.exists('Example.apk'))
     Clean('Example', '1.0.0')
 
     cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0',
            '--package=org.xwalk.example', '--app-root=./', self._mode]
     out = RunCommand(cmd)
-    self.assertTrue(out.find('The entry is required.') != -1)
+    self.assertIn('You must specify both "--app-local-path" and',
+                  out)
     self.assertFalse(os.path.exists('Example.apk'))
     Clean('Example', '1.0.0')
 
@@ -385,15 +421,18 @@ class TestMakeApk(unittest.TestCase):
            '--package=org.xwalk.example', '--app-local-path=index.html',
            self._mode]
     out = RunCommand(cmd)
-    self.assertTrue(out.find('The entry is required.') != -1)
+    self.assertIn('You must specify both "--app-local-path" and',
+                  out)
     self.assertFalse(os.path.exists('Example.apk'))
     Clean('Example', '1.0.0')
 
     manifest_path = os.path.join('test_data', 'manifest',
                                  'manifest_app_launch_local_path.json')
-    cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path, self._mode]
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, self._mode]
     out = RunCommand(cmd)
-    self.assertTrue(out.find('Please make sure that the local path file') != -1)
+    self.assertTrue(
+        out.find('Please make sure that the local path file') != -1)
     self.assertFalse(os.path.exists('Example.apk'))
 
   def testIconByOption(self):
@@ -428,7 +467,7 @@ class TestMakeApk(unittest.TestCase):
            '-f', self._mode]
     RunCommand(cmd)
     self.addCleanup(Clean, 'Example', '1.0.0')
-    theme = 'Example/res/values/theme.xml'
+    theme = 'Example/res/values-v14/theme.xml'
     with open(theme, 'r') as content_file:
       content = content_file.read()
     self.assertTrue(os.path.exists(theme))
@@ -452,6 +491,7 @@ class TestMakeApk(unittest.TestCase):
     Clean('Example', '1.0.0')
     manifest_path = os.path.join('test_data', 'manifest', 'manifest.json')
     cmd = ['python', 'make_apk.py', '--enable-remote-debugging',
+           '--package=org.xwalk.example',
            '--manifest=%s' % manifest_path, self._mode]
     RunCommand(cmd)
     activity = 'Example/src/org/xwalk/example/ExampleActivity.java'
@@ -461,27 +501,64 @@ class TestMakeApk(unittest.TestCase):
     self.assertTrue(content.find('setRemoteDebugging') != -1)
     self.checkApks('Example', '1.0.0')
 
-  def testKeystore(self):
-    keystore_path = os.path.join('test_data', 'keystore', 'xwalk-test.keystore')
+  def testUseAnimatableView(self):
     cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0',
            '--package=org.xwalk.example', '--app-url=http://www.intel.com',
-           '--keystore-path=%s' % keystore_path, '--keystore-alias=xwalk-test',
-           '--keystore-passcode=xwalk-test', self._mode]
+           '--use-animatable-view', self._mode]
     RunCommand(cmd)
     self.addCleanup(Clean, 'Example', '1.0.0')
-    self.assertTrue(os.path.exists('Example'))
-    apk_list = ['Example.apk', 'Example_x86.apk', 'Example_arm.apk']
-    for apk in apk_list:
-      if os.path.isfile(apk):
-        cmd = ['jarsigner', '-verify', '-keystore',
-               keystore_path, '-verbose', apk]
-        out = RunCommand(cmd)
-        self.assertTrue(out.find('smk') != -1)
+    activity = 'Example/src/org/xwalk/example/ExampleActivity.java'
+    with open(activity, 'r') as content_file:
+      content = content_file.read()
+    self.assertTrue(os.path.exists(activity))
+    self.assertTrue(content.find('setUseAnimatableView') != -1)
+    self.checkApks('Example', '1.0.0')
+    Clean('Example', '1.0.0')
+    manifest_path = os.path.join('test_data', 'manifest', 'manifest.json')
+    cmd = ['python', 'make_apk.py', '--use-animatable-view',
+           '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, self._mode]
+    RunCommand(cmd)
+    activity = 'Example/src/org/xwalk/example/ExampleActivity.java'
+    with open(activity, 'r') as content_file:
+      content = content_file.read()
+    self.assertTrue(os.path.exists(activity))
+    self.assertTrue(content.find('setUseAnimatableView') != -1)
     self.checkApks('Example', '1.0.0')
 
+  def testKeystore(self):
+    keystore_path = os.path.join('test_data', 'keystore',
+                                 'xwalk-test.keystore')
+    cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0',
+           '--package=org.xwalk.example', '--app-url=http://www.intel.com',
+           '--keystore-path=%s' % keystore_path, '--keystore-alias=xwalk-test',
+           '--keystore-passcode=xwalk-test',
+           '--keystore-alias-passcode=xwalk-test', self._mode]
+    RunCommand(cmd)
+    self.assertTrue(os.path.isdir('Example'))
+    self.checkApks('Example', '1.0.0', keystore_path)
+    Clean('Example', '1.0.0')
+
+    keystore_path_with_space = os.path.join(
+      'test_data', 'keystore', 'test keystore')
+    shutil.copy2(keystore_path, keystore_path_with_space)
+    keystore_path = os.path.join('test_data', 'keystore',
+                                 'xwalk-test.keystore')
+    cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0',
+           '--package=org.xwalk.example', '--app-url=http://www.intel.com',
+           '--keystore-path=%s' % keystore_path_with_space,
+           '--keystore-alias=xwalk test',
+           '--keystore-passcode=xwalk-test',
+           '--keystore-alias-passcode=xwalk test', self._mode]
+    RunCommand(cmd)
+    self.assertTrue(os.path.isdir('Example'))
+    self.checkApks('Example', '1.0.0', keystore_path_with_space)
+    Clean('Example', '1.0.0')
+
   def testManifest(self):
     manifest_path = os.path.join('test_data', 'manifest', 'manifest.json')
-    cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path, self._mode]
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, self._mode]
     RunCommand(cmd)
     self.addCleanup(Clean, 'Example', '1.0.0')
     manifest = 'Example/AndroidManifest.xml'
@@ -496,7 +573,8 @@ class TestMakeApk(unittest.TestCase):
     self.assertTrue(content.find('android.permission.RECEIVE_SMS') != -1)
     self.assertTrue(content.find('android.permission.SEND_SMS') != -1)
     self.assertTrue(content.find('android.permission.WRITE_SMS') != -1)
-    theme = 'Example/res/values/theme.xml'
+    self.assertTrue(content.find('landscape') != -1)
+    theme = 'Example/res/values-v14/theme.xml'
     with open(theme, 'r') as content_file:
       content = content_file.read()
     self.assertTrue(os.path.exists(theme))
@@ -509,47 +587,93 @@ class TestMakeApk(unittest.TestCase):
   def testManifestWithSpecificValue(self):
     manifest_path = os.path.join('test_data', 'manifest',
                                  'manifest_app_launch_local_path.json')
-    cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path, self._mode]
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, self._mode]
     out = RunCommand(cmd)
     self.addCleanup(Clean, 'Example', '1.0.0')
     self.assertTrue(out.find('no app launch path') == -1)
     self.checkApks('Example', '1.0.0')
 
+  def testManifestWithDeprecatedField(self):
+    manifest_path = os.path.join('test_data', 'manifest', 'deprecated',
+                                 'manifest_app_local_path.json')
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, self._mode]
+    out = RunCommand(cmd)
+    self.addCleanup(Clean, 'Example', '1.0.0')
+    self.assertIn('WARNING: app.launch.local_path is deprecated for Crosswalk',
+                  out)
+    Clean('Example', '1.0.0')
+
+    manifest_path = os.path.join('test_data', 'manifest', 'deprecated',
+                                 'manifest_launch_path.json')
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, self._mode]
+    out = RunCommand(cmd)
+    self.assertIn('WARNING: launch_path is deprecated for Crosswalk', out)
+    Clean('Example', '1.0.0')
+
+    manifest_path = os.path.join('test_data', 'manifest', 'deprecated',
+                                 'manifest_permissions.json')
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, self._mode]
+    out = RunCommand(cmd)
+    self.assertIn('WARNING: permissions is deprecated for Crosswalk', out)
+    Clean('Example', '1.0.0')
+
+    manifest_path = os.path.join('test_data', 'manifest',
+                                 'manifest_deprecated_icon.json')
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, self._mode]
+    out = RunCommand(cmd)
+    self.assertIn('WARNING: icons defined as dictionary form is deprecated',
+                  out)
+    Clean('Example', '1.0.0')
+
+    manifest_path = os.path.join('test_data', 'manifest', 'deprecated',
+                                 'manifest_description.json')
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, self._mode]
+    out = RunCommand(cmd)
+    self.assertIn('WARNING: description is deprecated for Crosswalk', out)
+    Clean('Example', '1.0.0')
+
+    manifest_path = os.path.join('test_data', 'manifest', 'deprecated',
+                                 'manifest_deprecated_version.json')
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, self._mode]
+    out = RunCommand(cmd)
+    self.assertIn('WARNING: version is deprecated for Crosswalk', out)
+
   def testManifestWithError(self):
     manifest_path = os.path.join('test_data', 'manifest',
                                  'manifest_no_app_launch_path.json')
-    cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path,
-           '--verbose', self._mode]
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, '--verbose', self._mode]
     out = RunCommand(cmd)
     self.assertTrue(out.find('no app launch path') != -1)
     manifest_path = os.path.join('test_data', 'manifest',
                                  'manifest_no_name.json')
-    cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path,
-           '--verbose', self._mode]
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, '--verbose', self._mode]
     out = RunCommand(cmd)
     self.assertTrue(out.find('no \'name\' field') != -1)
     manifest_path = os.path.join('test_data', 'manifest',
-                                 'manifest_no_version.json')
-    cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path,
-           '--verbose', self._mode]
-    out = RunCommand(cmd)
-    self.assertTrue(out.find('no \'version\' field') != -1)
-    manifest_path = os.path.join('test_data', 'manifest',
                                  'manifest_permissions_format_error.json')
-    cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path,
-           '--verbose', self._mode]
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, '--verbose', self._mode]
     out = RunCommand(cmd)
     self.assertTrue(out.find('\'Permissions\' field error') != -1)
     manifest_path = os.path.join('test_data', 'manifest',
                                  'manifest_permissions_field_error.json')
-    cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path,
-           '--verbose', self._mode]
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, '--verbose', self._mode]
     out = RunCommand(cmd)
     self.assertTrue(out.find('\'Permissions\' field error') != -1)
     manifest_path = os.path.join('test_data', 'manifest',
                                  'manifest_not_supported_permission.json')
-    cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path,
-           '--verbose', self._mode]
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, '--verbose', self._mode]
     out = RunCommand(cmd)
     self.assertTrue(
         out.find('\'Telephony\' related API is not supported') != -1)
@@ -567,7 +691,8 @@ class TestMakeApk(unittest.TestCase):
     self.assertTrue(os.path.exists(extensions_config_json))
     with open(extensions_config_json, 'r') as content_file:
       content = content_file.read()
-    self.assertTrue(content.find('xwalk-extensions/myextension/myextension.js'))
+    self.assertTrue(
+        content.find('xwalk-extensions/myextension/myextension.js'))
     self.assertTrue(content.find('com.example.extension.MyExtension'))
     extension_js = 'Example/assets/xwalk-extensions/myextension/myextension.js'
     self.assertTrue(os.path.exists(extension_js))
@@ -607,7 +732,8 @@ class TestMakeApk(unittest.TestCase):
 
   def testXPK(self):
     xpk_file = os.path.join('test_data', 'xpk', 'example.xpk')
-    cmd = ['python', 'make_apk.py', '--xpk=%s' % xpk_file, self._mode]
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--xpk=%s' % xpk_file, self._mode]
     RunCommand(cmd)
     self.addCleanup(Clean, 'Example', '1.0.0')
     self.assertTrue(os.path.exists('Example'))
@@ -615,7 +741,8 @@ class TestMakeApk(unittest.TestCase):
 
   def testXPKWithError(self):
     xpk_file = os.path.join('test_data', 'xpk', 'error.xpk')
-    cmd = ['python', 'make_apk.py', '--xpk=%s' % xpk_file, self._mode]
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--xpk=%s' % xpk_file, self._mode]
     out = RunCommand(cmd)
     error_msg = 'XPK doesn\'t contain manifest file'
     self.assertTrue(out.find(error_msg) != -1)
@@ -661,6 +788,28 @@ class TestMakeApk(unittest.TestCase):
       else:
         self.assertFalse(os.path.isfile('Example_1.0.0._arm.apk'))
       self.assertFalse(os.path.isfile('Example_1.0.0_x86.apk'))
+      Clean('Example', '1.0.0')
+      cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0',
+             '--package=org.xwalk.example', '--app-url=http://www.intel.com',
+             self._mode]
+      RunCommand(cmd)
+      if 'arm' in self.archs():
+        self.assertTrue(os.path.isfile('Example_1.0.0_arm.apk'))
+        self.checkApk('Example_1.0.0_arm.apk', 'arm')
+      else:
+        self.assertFalse(os.path.isfile('Example_1.0.0._arm.apk'))
+      if 'x86' in self.archs():
+        self.assertTrue(os.path.isfile('Example_1.0.0_x86.apk'))
+        self.checkApk('Example_1.0.0_x86.apk', 'x86')
+      else:
+        self.assertFalse(os.path.isfile('Example_1.0.0._x86.apk'))
+      Clean('Example', '1.0.0')
+      cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0',
+             '--package=org.xwalk.example', '--app-url=http://www.intel.com',
+             '--arch=undefined', self._mode]
+      out = RunCommand(cmd)
+      error_msg = 'invalid choice: \'undefined\''
+      self.assertTrue(out.find(error_msg) != -1)
 
   def testVerbose(self):
     cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0',
@@ -676,7 +825,7 @@ class TestMakeApk(unittest.TestCase):
 
   def executeCommandAndVerifyResult(self, exec_file):
     # Test all of supported options with empty 'mode' option.
-    icon_path = './app_src/res/drawable-xhdpi/crosswalk.png'
+    icon_path = './template/res/drawable-xhdpi/crosswalk.png'
     extension_path = 'test_data/extensions/myextension'
     arch = ''
     icon = ''
@@ -721,7 +870,7 @@ class TestMakeApk(unittest.TestCase):
     # Test orientation option.
     self.assertTrue(content.find('landscape') != -1)
     # Test fullscreen option
-    theme = 'Example/res/values/theme.xml'
+    theme = 'Example/res/values-v14/theme.xml'
     with open(theme, 'r') as content_file:
       content = content_file.read()
     self.assertTrue(os.path.exists(theme))
@@ -759,6 +908,81 @@ class TestMakeApk(unittest.TestCase):
 
     self.executeCommandAndVerifyResult('customize.py')
 
+  def testLaunchScreen(self):
+    # Prepare launch screen resources.
+    launch_screen_path = os.path.join('test_data', 'launchScreen')
+    orientations = ['default', 'portrait', 'landscape']
+    dimensions = ['0_75', '1', '1_5', '2']
+    img_types = ['img', 'bg']
+    for orientation in orientations:
+      for dimension in dimensions:
+        for img_type in img_types:
+          name = orientation + '_' + img_type + '_' + dimension
+          path_tmp = os.path.join(launch_screen_path, name)
+          _file = open(path_tmp,'w+')
+          _file.write(name)
+          _file.close()
+    # Run Test.
+    manifest_path = os.path.join('test_data', 'launchScreen',
+                                 'manifest_deprecated_launch_screen.json')
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, self._mode]
+    out = RunCommand(cmd)
+    self.assertTrue(
+        out.find('WARNING: launch_screen is deprecated for Crosswalk') != -1)
+    Clean('Example', '1.0.0')
+    manifest_path = os.path.join('test_data', 'launchScreen', 'manifest.json')
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path, self._mode]
+    RunCommand(cmd)
+    # Check theme.xml.
+    theme_path = os.path.join('Example', 'res', 'values-v14', 'theme.xml')
+    self.assertTrue(os.path.exists(theme_path))
+    with open(theme_path, 'r') as content_file:
+      content = content_file.read()
+    self.assertTrue(content.find('@drawable/launchscreen_bg') != -1)
+    # Check launchscreen_bg.xml
+    launch_screen_bg_path = os.path.join(
+        "Example", 'res', 'drawable', 'launchscreen_bg.xml')
+    self.assertTrue(os.path.exists(launch_screen_bg_path))
+    with open(launch_screen_bg_path, 'r') as content_file:
+      content = content_file.read()
+    self.assertTrue(content.find('@drawable/launchscreen_bg_img') != -1)
+    # Check resource images
+    for orientation in orientations:
+      for dimension in dimensions:
+        drawable = 'drawable'
+        if orientation == 'portrait':
+          drawable = drawable + '-port'
+        elif orientation == 'landscape':
+          drawable = drawable + '-land'
+        if dimension == '0_75':
+          drawable = drawable + '-ldpi'
+        elif dimension == '1':
+          drawable = drawable + '-mdpi'
+        elif dimension == '1_5':
+          drawable = drawable + '-hdpi'
+        elif dimension == '2':
+          drawable = drawable + '-xhdpi'
+        # Check background image
+        bg_drawable = os.path.join(
+            "Example", 'res', drawable, 'launchscreen_bg_img')
+        self.assertTrue(os.path.exists(bg_drawable))
+        with open(bg_drawable, 'r') as content_file:
+          content = content_file.read()
+        name = orientation + '_' + 'bg' + '_' + dimension
+        self.assertTrue(content == name)
+        # Check foreground image
+        fg_drawable = os.path.join(
+            "Example", 'res', drawable, 'launchscreen_img')
+        self.assertTrue(os.path.exists(fg_drawable))
+        with open(fg_drawable, 'r') as content_file:
+          content = content_file.read()
+        name = orientation + '_' + 'img' + '_' + dimension
+        self.assertTrue(content == name)
+    self.checkApks('Example', '1.0.0')
+    Clean('Example', '1.0.0')
+
   def testTargetDir(self):
     test_option = ['./', '../', '~/']
     for option in test_option:
@@ -789,6 +1013,7 @@ class TestMakeApk(unittest.TestCase):
 
     cmd = ['python', 'customize.py',
            '--name=%s' % name,
+           '--package=org.xwalk.example',
            '--compressor',
            '--app-root=%s' % app_root]
     RunCommand(cmd)
@@ -797,6 +1022,7 @@ class TestMakeApk(unittest.TestCase):
 
     cmd = ['python', 'customize.py',
            '--name=%s' % name,
+           '--package=org.xwalk.example',
            '--app-root=%s' % app_root,
            '--compressor']
     RunCommand(cmd)
@@ -805,6 +1031,7 @@ class TestMakeApk(unittest.TestCase):
 
     cmd = ['python', 'customize.py',
            '--name=%s' % name,
+           '--package=org.xwalk.example',
            '--compressor=js',
            '--app-root=%s' % app_root]
     RunCommand(cmd)
@@ -812,6 +1039,7 @@ class TestMakeApk(unittest.TestCase):
 
     cmd = ['python', 'customize.py',
            '--name=%s' % name,
+           '--package=org.xwalk.example',
            '--compressor=css',
            '--app-root=%s' % app_root]
     RunCommand(cmd)
@@ -819,6 +1047,7 @@ class TestMakeApk(unittest.TestCase):
 
     cmd = ['python', 'customize.py',
            '--name=%s' % name,
+           '--package=org.xwalk.example',
            '--app-root=%s' % app_root]
     RunCommand(cmd)
     CompareSizeForCompressor(None, css_file, 'css', name, fun)
@@ -826,6 +1055,7 @@ class TestMakeApk(unittest.TestCase):
 
     cmd = ['python', 'customize.py',
            '--name=%s' % name,
+           '--package=org.xwalk.example',
            '--app-root=%s' % app_root,
            '--compressor=other']
     RunCommand(cmd)
@@ -834,57 +1064,48 @@ class TestMakeApk(unittest.TestCase):
 
     Clean(name, '1.0.0')
 
-  def testInvalidCharacter(self):
-    version = '1.0.0'
-    start_with_letters = ' should be started with letters'
-    app_name_error = 'app name' + start_with_letters
-    package_name_error = 'package name' + start_with_letters
-    parse_error = 'parser error in manifest.json file'
-    directory = os.path.join('test_data', 'manifest', 'invalidchars')
-
-    manifest_path = os.path.join(directory, 'manifest_with_space_name.json')
-    result = GetResultWithOption(self._mode, manifest_path)
-    self.assertTrue(result.find(app_name_error) != -1)
 
-    manifest_path = os.path.join(directory, 'manifest_with_chinese_name.json')
-    result = GetResultWithOption(self._mode, manifest_path)
-    self.assertTrue(result.find(app_name_error) != -1)
-
-    manifest_path = os.path.join(directory, 'manifest_parse_error.json')
-    result = GetResultWithOption(self._mode, manifest_path)
-    self.assertTrue(result.find(parse_error) != -1)
+  def VerifyResultInXMLFile(self, xml_path, piece_content):
+    self.assertTrue(os.path.exists(xml_path))
+    with open(xml_path, 'r') as content_file:
+      content = content_file.read()
 
-    manifest_path = os.path.join(directory, 'manifest_with_invalid_name.json')
-    result = GetResultWithOption(self._mode, manifest_path)
-    self.assertTrue(result.find(app_name_error) != -1)
+    self.assertIn(piece_content, content)
+    Clean('Example', '1.0.0')
 
-    package = 'org.xwalk.example'
-    name = '_hello'
-    result = GetResultWithOption(self._mode, name=name, package=package)
-    self.assertTrue(result.find(app_name_error) != -1)
 
-    name = '123hello'
-    result = GetResultWithOption(self._mode, name=name, package=package)
-    self.assertTrue(result.find(app_name_error) != -1)
+  def testAppNameWithNonASCII(self):
+    xml_path = 'Example/AndroidManifest.xml'
+    piece_content = 'android:label="%s"' % '你好'
+    cmd = ['python', 'make_apk.py', '--name=你好', '--app-version=1.0.0',
+           '--package=org.xwalk.example', '--app-url=http://www.intel.com']
+    RunCommand(cmd)
+    self.VerifyResultInXMLFile(xml_path, piece_content)
 
-    name = 'hello_'
-    result = GetResultWithOption(self._mode, name=name, package=package)
-    self.assertTrue(result.find(app_name_error) == -1)
-    Clean(name, version)
+    manifest_path = os.path.join('test_data', 'manifest', 'invalidchars',
+                                 'manifest_with_chinese_name.json')
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path]
+    RunCommand(cmd)
+    self.VerifyResultInXMLFile(xml_path, piece_content)
 
-    name = 'xwalk'
-    package = 'org.xwalk._example'
-    result = GetResultWithOption(self._mode, name=name, package=package)
-    self.assertTrue(result.find(package_name_error) != -1)
 
-    package = 'org.xwalk.123example'
-    result = GetResultWithOption(self._mode, name=name, package=package)
-    self.assertTrue(result.find(package_name_error) != -1)
+  def testDescriptionWithDBCS(self):
+    xml_path = 'Example/res/values/strings.xml'
+    piece_content = '<string name="description">%s</string>' % '你好'
+    cmd = ['python', 'make_apk.py', '--name=hello', '--app-version=1.0.0',
+           '--package=org.xwalk.example', '--app-url=http://www.intel.com',
+           '--description=你好']
+    RunCommand(cmd)
+    self.VerifyResultInXMLFile(xml_path, piece_content)
 
-    package = 'org.xwalk.example_'
-    result = GetResultWithOption(self._mode, name=name, package=package)
-    self.assertTrue(result.find(package_name_error) == -1)
-    Clean(name, version)
+    manifest_path = os.path.join('test_data', 'manifest',
+                                 'manifest_description_dbcs.json')
+    cmd = ['python', 'make_apk.py', '--package=org.xwalk.example',
+           '--manifest=%s' % manifest_path]
+    RunCommand(cmd)
+    piece_content = '"description">%s</string>' % '你好 a sample description'
+    self.VerifyResultInXMLFile(xml_path, piece_content)
 
 
 def SuiteWithModeOption():
@@ -904,26 +1125,30 @@ def SuiteWithModeOption():
   test_suite.addTest(TestMakeApk('testFullscreen'))
   test_suite.addTest(TestMakeApk('testIconByOption'))
   test_suite.addTest(TestMakeApk('testIconByManifest'))
-  test_suite.addTest(TestMakeApk('testInvalidCharacter'))
   test_suite.addTest(TestMakeApk('testKeystore'))
   test_suite.addTest(TestMakeApk('testManifest'))
+  test_suite.addTest(TestMakeApk('testManifestWithDeprecatedField'))
   test_suite.addTest(TestMakeApk('testManifestWithError'))
   test_suite.addTest(TestMakeApk('testName'))
   test_suite.addTest(TestMakeApk('testOrientation'))
   test_suite.addTest(TestMakeApk('testPackage'))
+  test_suite.addTest(TestMakeApk('testPackageWithInvalidCharacter'))
   test_suite.addTest(TestMakeApk('testPermissions'))
   test_suite.addTest(TestMakeApk('testPermissionsWithError'))
   test_suite.addTest(TestMakeApk('testXPK'))
   test_suite.addTest(TestMakeApk('testXPKWithError'))
   test_suite.addTest(TestMakeApk('testTargetDir'))
+  test_suite.addTest(TestMakeApk('testLaunchScreen'))
   return test_suite
 
 
 def SuiteWithEmptyModeOption():
   # Gather all the tests for empty mode option.
   test_suite = unittest.TestSuite()
+  test_suite.addTest(TestMakeApk('testAppNameWithNonASCII'))
   test_suite.addTest(TestMakeApk('testCompressor'))
   test_suite.addTest(TestMakeApk('testCustomizeFile'))
+  test_suite.addTest(TestMakeApk('testDescriptionWithDBCS'))
   test_suite.addTest(TestMakeApk('testEmptyMode'))
   test_suite.addTest(TestMakeApk('testToolVersion'))
   test_suite.addTest(TestMakeApk('testVerbose'))