Add a regression test for Deflate/zlib behavior

Adds a regression test for Deflate and the underlying native libraries.
If any of these tests fail it suggests that tools such as Google Play
Store that rely on deterministic binary output from Deflate; those tools
may behave inefficiently if the output changes.

Bug: 27637914
Test: run cts -m CtsLibcoreTestCases -t libcore.java.util.zip.DeflateRegressionTest
Change-Id: If281f5c1402959d6f959cc4827e912df46b70c57
diff --git a/JavaLibrary.mk b/JavaLibrary.mk
index 5955f27..31836ad 100644
--- a/JavaLibrary.mk
+++ b/JavaLibrary.mk
@@ -228,16 +228,17 @@
 LOCAL_NO_STANDARD_LIBRARIES := true
 LOCAL_JAVA_LIBRARIES := core-oj core-libart okhttp bouncycastle
 LOCAL_STATIC_JAVA_LIBRARIES := \
+	archive-patcher \
 	core-test-rules \
 	core-tests-support \
+	junit-params \
 	mockftpserver \
 	mockito-target \
 	mockwebserver \
 	nist-pkix-tests \
 	slf4j-jdk14 \
 	sqlite-jdbc \
-	tzdata-testing \
-        junit-params
+	tzdata-testing
 LOCAL_JAVACFLAGS := $(local_javac_flags)
 LOCAL_ERROR_PRONE_FLAGS := -Xep:TryFailThrowable:ERROR
 LOCAL_JAVA_LANGUAGE_VERSION := 1.8
@@ -390,14 +391,15 @@
         mockito-api-hostdex \
         okhttp-hostdex
     LOCAL_STATIC_JAVA_LIBRARIES := \
+        archive-patcher-hostdex \
         core-test-rules-hostdex \
+        junit-params-hostdex \
         mockftpserver-hostdex \
         mockwebserver-host \
         nist-pkix-tests-host \
         slf4j-jdk14-hostdex \
         sqlite-jdbc-host \
-        tzdata-testing-hostdex \
-        junit-params-hostdex
+        tzdata-testing-hostdex
     LOCAL_JAVACFLAGS := $(local_javac_flags)
     LOCAL_MODULE_TAGS := optional
     LOCAL_JAVA_LANGUAGE_VERSION := 1.8
diff --git a/luni/src/test/java/libcore/java/util/zip/DeflateRegressionTest.java b/luni/src/test/java/libcore/java/util/zip/DeflateRegressionTest.java
new file mode 100644
index 0000000..1a505fa
--- /dev/null
+++ b/luni/src/test/java/libcore/java/util/zip/DeflateRegressionTest.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.java.util.zip;
+
+import com.google.archivepatcher.shared.DefaultDeflateCompatibilityWindow;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * A regression test for Deflate and the underlying native libraries. If any of these tests fail
+ * it suggests that tools such as Google Play Store that rely on deterministic binary output from
+ * Deflate; those tools may behave inefficiently if the output changes.
+ */
+public class DeflateRegressionTest {
+
+    /*
+     * If this test fails then it implies a change that could regress Android user performance.
+     * Please check that the platform version of Deflate is still used by affected tools and notify
+     * them. See also http://b/27637914.
+     */
+    @Test
+    public void deterministicOutput() throws Exception {
+        assertTrue(new DefaultDeflateCompatibilityWindow().isCompatible());
+    }
+}