Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / xwalk / app / tools / android / make_apk_test.py
index cf349a5..80254cf 100755 (executable)
@@ -131,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):
@@ -146,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):
@@ -458,7 +458,7 @@ class TestMakeApk(unittest.TestCase):
            '-f', self._mode]
     RunCommand(cmd)
     self.addCleanup(Clean, 'Example', '1.0.0')
-    theme = 'Example/res/values-v17/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))
@@ -498,7 +498,8 @@ class TestMakeApk(unittest.TestCase):
     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]
+           '--keystore-passcode=xwalk-test',
+           '--keystore-alias-passcode=xwalk-test', self._mode]
     RunCommand(cmd)
     self.addCleanup(Clean, 'Example', '1.0.0')
     self.assertTrue(os.path.exists('Example'))
@@ -530,7 +531,7 @@ class TestMakeApk(unittest.TestCase):
     self.assertTrue(content.find('android.permission.SEND_SMS') != -1)
     self.assertTrue(content.find('android.permission.WRITE_SMS') != -1)
     self.assertTrue(content.find('landscape') != -1)
-    theme = 'Example/res/values-v17/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))
@@ -781,7 +782,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 = ''
@@ -826,7 +827,7 @@ class TestMakeApk(unittest.TestCase):
     # Test orientation option.
     self.assertTrue(content.find('landscape') != -1)
     # Test fullscreen option
-    theme = 'Example/res/values-v17/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))
@@ -892,7 +893,7 @@ class TestMakeApk(unittest.TestCase):
            '--manifest=%s' % manifest_path, self._mode]
     RunCommand(cmd)
     # Check theme.xml.
-    theme_path = os.path.join('Example', 'res', 'values-v17', '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()
@@ -1021,28 +1022,47 @@ class TestMakeApk(unittest.TestCase):
     Clean(name, '1.0.0')
 
 
-  def verifyResultForAppName(self, app_name):
-    android_manifest = 'Example/AndroidManifest.xml'
-    self.assertTrue(os.path.exists(android_manifest))
-    with open(android_manifest, 'r') as content_file:
+  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()
-    label_name = 'android:label="%s"' % app_name
-    self.assertIn(label_name, content)
+
+    self.assertIn(piece_content, content)
     Clean('Example', '1.0.0')
 
 
-  def testAppNameWithNonASCII (self):
+  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.verifyResultForAppName('你好')
+    self.VerifyResultInXMLFile(xml_path, piece_content)
 
     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.verifyResultForAppName('你好')
+    self.VerifyResultInXMLFile(xml_path, piece_content)
+
+
+  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)
+
+    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():
@@ -1085,6 +1105,7 @@ def SuiteWithEmptyModeOption():
   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'))