Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2661)

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/AwVariationsSeedFetchServiceTest.java

Issue 2975693002: Add AwVariationsSeedFetchService and refactory VariationsSeedFetcher (Closed)
Patch Set: Fix typo in comments Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/javatests/DEPS ('k') | android_webview/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/javatests/src/org/chromium/android_webview/test/AwVariationsSeedFetchServiceTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwVariationsSeedFetchServiceTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwVariationsSeedFetchServiceTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..ae2b44e24c6459773c7cf2b34513f22e37d6b87f
--- /dev/null
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwVariationsSeedFetchServiceTest.java
@@ -0,0 +1,58 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.android_webview.test;
+
+import android.annotation.TargetApi;
+import android.os.Build;
+import android.support.test.filters.MediumTest;
+import android.test.InstrumentationTestCase;
+
+import org.chromium.android_webview.AwVariationsSeedFetchService;
+import org.chromium.android_webview.AwVariationsSeedFetchService.SeedPreference;
+import org.chromium.base.ContextUtils;
+import org.chromium.base.test.util.MinAndroidSdkLevel;
+import org.chromium.components.variations.firstrun.VariationsSeedFetcher.SeedInfo;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+/**
+ * Instrumentation tests for AwVariationsSeedFetchService.
+ */
+@MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP) // Android versions under L don't have JobService.
+@TargetApi(Build.VERSION_CODES.LOLLIPOP) // JobService requires API level 21.
+public class AwVariationsSeedFetchServiceTest extends InstrumentationTestCase {
+ protected void setUp() throws Exception {
+ ContextUtils.initApplicationContextForTests(
+ getInstrumentation().getTargetContext().getApplicationContext());
+ }
+
+ protected void tearDown() throws Exception {
+ AwVariationsSeedFetchService.clearDataForTesting();
+ }
+
+ /**
+ * Ensure reading and writing seed data and pref works correctly.
+ */
+ @MediumTest
+ public void testReadAndWriteVariationsSeed() throws IOException, ClassNotFoundException {
+ SeedInfo seedInfo = new SeedInfo();
+ seedInfo.seedData = "SeedData".getBytes();
+ seedInfo.signature = "SeedSignature";
+ seedInfo.country = "SeedCountry";
+ seedInfo.date = "SeedDate";
+ seedInfo.isGzipCompressed = true;
+ AwVariationsSeedFetchService.storeVariationsSeed(seedInfo);
+
+ byte[] seedData = AwVariationsSeedFetchService.getVariationsSeedData();
+ assertTrue(Arrays.equals(seedData, seedInfo.seedData));
+
+ SeedPreference seedPreference = AwVariationsSeedFetchService.getVariationsSeedPreference();
+ assertEquals(seedPreference.signature, seedInfo.signature);
+ assertEquals(seedPreference.country, seedInfo.country);
+ assertEquals(seedPreference.date, seedInfo.date);
+ assertEquals(seedPreference.isGzipCompressed, seedInfo.isGzipCompressed);
+ }
+}
« no previous file with comments | « android_webview/javatests/DEPS ('k') | android_webview/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698