Added x86 apks and enabled x86 arch in run_cts script

This allows running WebView CTS tests on emulators
Bug:922854,923215

Test: Setup and launch an AVD (L-O) with sufficient internal storage (3GB ok),
Test: run_cts.py [-f "<test filter>"] [--fast-local-dev]

Change-Id: I644b3ca40962031f2ec3f495a028c4e5d0994db5
Reviewed-on: https://chromium-review.googlesource.com/c/1461680
Commit-Queue: Andrew Luo <aluo@chromium.org>
Reviewed-by: Changwan Ryu <changwan@chromium.org>
Reviewed-by: Nate Fischer <ntfschr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#631846}
diff --git a/DEPS b/DEPS
index c0cb0a14..b0075fb5 100644
--- a/DEPS
+++ b/DEPS
@@ -314,7 +314,7 @@
       'packages': [
           {
               'package': 'chromium/android_webview/tools/cts_archive',
-              'version': '3JR1LoM5xpNK_jcnwciobRW9H8TM3SUxuSGQJBjt6AUC',
+              'version': 'svYF6kVCr4ZLwvgZjFTwSkw3bv08SQ9DhqYnpwcCCugC',
           },
       ],
       'condition': 'checkout_android',
diff --git a/android_webview/tools/cts_archive/cipd.yaml b/android_webview/tools/cts_archive/cipd.yaml
index 1ba0f5e..9b095a7 100644
--- a/android_webview/tools/cts_archive/cipd.yaml
+++ b/android_webview/tools/cts_archive/cipd.yaml
@@ -11,3 +11,7 @@
   - file: arm64/M/android-cts-arm_64-4607285.zip
   - file: arm64/N/android-cts-arm_64-5075646.zip
   - file: arm64/O/android-cts-arm_64-5075719.zip
+  - file: x86/L/android-cts-x86-5.1_r28.zip
+  - file: x86/M/android-cts-x86-6.0_r32.zip
+  - file: x86/N/android-cts-x86-7.0_r28.zip
+  - file: x86/O/android-cts-x86-8.0_r16.zip
diff --git a/android_webview/tools/cts_archive/version.txt b/android_webview/tools/cts_archive/version.txt
index 9459d4b..5625e59d 100644
--- a/android_webview/tools/cts_archive/version.txt
+++ b/android_webview/tools/cts_archive/version.txt
@@ -1 +1 @@
-1.1
+1.2
diff --git a/android_webview/tools/cts_config/webview_cts_gcs_path.json b/android_webview/tools/cts_config/webview_cts_gcs_path.json
index 29d0906..664b2a1 100644
--- a/android_webview/tools/cts_config/webview_cts_gcs_path.json
+++ b/android_webview/tools/cts_config/webview_cts_gcs_path.json
@@ -3,11 +3,19 @@
   {
     " The format of this file is as follows.  The excludes and includes lists under test_runs are mutually exclusive, if not specified, all tests in apk will run.":
     {
-      "<arch>": {
-        "<android SDK Code, such as L, M, N, ...>": {
-          "filename": "<relative path to cts_archive_dir of cts zip>",
-          "_origin":  "<branch@buildid>",
-          "unzip_dir":   "<relative path to work directory where cts should be unzipped to>",
+      "<android SDK Code, such as L, M, N, ...>": {
+        "arch": {
+	  "<arch1>": {
+            "filename": "<relative path to cts_archive_dir of cts zip>",
+            "_origin":  "<branch@buildid>",
+            "unzip_dir":   "<relative path to work directory where cts should be unzipped to>"
+	  },
+	  "<arch2>": {
+            "filename": "<relative path to cts_archive_dir of cts zip>",
+            "_origin":  "<branch@buildid>",
+            "unzip_dir":   "<relative path to work directory where cts should be unzipped to>"
+	  }
+	},
           "test_runs": [
           {
             "apk": "location of the test apk in the cts zip file",
@@ -26,14 +34,21 @@
           }]
         }
       }
-    }
   },
-  "arm64": {
-    "L": {
-      "filename": "arm64/L/android-cts-arm_64-4607260.zip",
-      "_origin": "aosp-lollipop-mr1-cts-dev@4607260",
-      "unzip_dir": "arm64/L/4607260/",
-      "test_runs": [
+  "L": {
+    "arch": {
+      "arm64": {
+        "filename": "arm64/L/android-cts-arm_64-4607260.zip",
+        "_origin": "aosp-lollipop-mr1-cts-dev@4607260",
+        "unzip_dir": "arm64/L/4607260/"
+      },
+      "x86": {
+        "filename": "x86/L/android-cts-x86-5.1_r28.zip",
+        "_origin": "aosp-lollipop-mr1-cts-release@5.1_r28",
+        "unzip_dir": "x86/L/5.1_r28/"
+      }
+    },
+    "test_runs": [
       {
         "apk": "android-cts/repository/testcases/CtsWebkitTestCases.apk",
         "excludes": [
@@ -94,12 +109,21 @@
           "match": "android.widget.cts.RemoteViewsActivityTest#testWebView"
         }]
       }]
+  },
+  "M": {
+    "arch": {
+      "arm64": {
+        "filename": "arm64/M/android-cts-arm_64-4607285.zip",
+        "_origin": "aosp-marshmallow-cts-dev@4607285",
+        "unzip_dir": "arm64/M/4607285/"
+      },
+      "x86": {
+      "filename": "x86/M/android-cts-x86-6.0_r32.zip",
+      "_origin": "aosp-marshmallow-cts-release@6.0_r32",
+      "unzip_dir": "x86/M/6.0_r32/"
+      }
     },
-    "M": {
-      "filename": "arm64/M/android-cts-arm_64-4607285.zip",
-      "_origin": "aosp-marshmallow-cts-dev@4607285",
-      "unzip_dir": "arm64/M/4607285/",
-      "test_runs": [
+    "test_runs": [
       {
         "apk": "android-cts/repository/testcases/CtsWebkitTestCases.apk",
         "excludes": [
@@ -160,11 +184,20 @@
           "match": "android.widget.cts.RemoteViewsActivityTest#testWebView"
         }]
       }]
+  },
+  "N": {
+    "arch": {
+      "arm64": {
+        "filename": "arm64/N/android-cts-arm_64-5075646.zip",
+        "_origin": "aosp-nougat-cts-dev@5075646",
+        "unzip_dir": "arm64/N/5075646/"
+      },
+      "x86": {
+      "filename": "x86/N/android-cts-x86-7.0_r28.zip",
+      "_origin": "aosp-nougat-cts-release@7.0_r28",
+      "unzip_dir": "x86/N/7.0_r28/"
+      }
     },
-    "N": {
-      "filename": "arm64/N/android-cts-arm_64-5075646.zip",
-      "_origin": "aosp-nougat-cts-dev@5075646",
-      "unzip_dir": "arm64/N/5075646/",
       "test_runs": [
       {
         "apk": "android-cts/testcases/CtsWebkitTestCases.apk",
@@ -182,11 +215,20 @@
           "match": "android.widget.cts.RemoteViewsActivityTest#testWebView"
         }]
       }]
+  },
+  "O": {
+    "arch": {
+      "arm64": {
+        "filename": "arm64/O/android-cts-arm_64-5075719.zip",
+        "_origin": "aosp-oreo-cts-dev@5075719",
+        "unzip_dir": "arm64/O/5075719/"
+      },
+      "x86": {
+      "filename": "x86/O/android-cts-x86-8.0_r16.zip",
+      "_origin": "aosp-oreo-cts-release@8.0_r16",
+      "unzip_dir": "x86/O/8.0_r16/"
+      }
     },
-    "O": {
-      "filename": "arm64/O/android-cts-arm_64-5075719.zip",
-      "_origin": "aosp-oreo-cts-dev@5075719",
-      "unzip_dir": "arm64/O/5075719/",
       "test_runs": [
       {
         "apk": "android-cts/testcases/CtsWebkitTestCases.apk",
@@ -200,6 +242,5 @@
       {
         "apk": "android-cts/testcases/CtsWebViewStartupApp.apk"
       }]
-    }
   }
 }
diff --git a/android_webview/tools/run_cts.py b/android_webview/tools/run_cts.py
index 2a9fff8..11f26be 100755
--- a/android_webview/tools/run_cts.py
+++ b/android_webview/tools/run_cts.py
@@ -35,8 +35,11 @@
 
 _EXPECTED_FAILURES_FILE = os.path.join(
     os.path.dirname(__file__), 'cts_config', 'expected_failure_on_bot.json')
+
 _WEBVIEW_CTS_GCS_PATH_FILE = os.path.join(
     os.path.dirname(__file__), 'cts_config', 'webview_cts_gcs_path.json')
+_ARCH_SPECIFIC_CTS_INFO = ["filename", "unzip_dir", "_origin"]
+
 _CTS_ARCHIVE_DIR = os.path.join(os.path.dirname(__file__), 'cts_archive')
 
 _SDK_PLATFORM_DICT = {
@@ -49,13 +52,22 @@
     version_codes.OREO_MR1: 'O'
 }
 
-# TODO(aluo): support 'x86' and 'x86_64'
+# The test apks are apparently compatible across all architectures, the
+# arm vs x86 split is to match the current cts releases and in case things
+# start to diverge in the future.  Keeping the arm64 (instead of arm) dict
+# key to avoid breaking the bots that specify --arch arm64 to invoke the tests.
 _SUPPORTED_ARCH_DICT = {
-    abis.ARM_64: 'arm64',
+    # TODO(aluo): Investigate how to force WebView abi on platforms supporting
+    # multiple abis.
     # The test apks under 'arm64' support both arm and arm64 devices.
     abis.ARM: 'arm64',
+    abis.ARM_64: 'arm64',
+    # The test apks under 'x86' support both x86 and x86_64 devices.
+    abis.X86: 'x86',
+    abis.X86_64: 'x86'
 }
 
+
 FILE_FILTER_OPT = '--test-launcher-filter-file'
 TEST_FILTER_OPT = '--test-filter'
 ISOLATED_FILTER_OPT = '--isolated-script-test-filter'
@@ -68,7 +80,10 @@
   with open(_WEBVIEW_CTS_GCS_PATH_FILE) as f:
     cts_gcs_path_info = json.load(f)
   try:
-    return cts_gcs_path_info[arch][platform][item]
+    if item in _ARCH_SPECIFIC_CTS_INFO:
+      return cts_gcs_path_info[platform]['arch'][arch][item]
+    else:
+      return cts_gcs_path_info[platform][item]
   except KeyError:
     raise Exception('No %s info available for arch:%s, android:%s' %
                     (item, arch, platform))