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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/omaha/MockExponentialBackoffScheduler.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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
Index: chrome/android/javatests/src/org/chromium/chrome/browser/omaha/MockExponentialBackoffScheduler.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/omaha/MockExponentialBackoffScheduler.java b/chrome/android/javatests/src/org/chromium/chrome/browser/omaha/MockExponentialBackoffScheduler.java
new file mode 100644
index 0000000000000000000000000000000000000000..fda5c6b699f98f8860a134577364c3de890ea98b
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/omaha/MockExponentialBackoffScheduler.java
@@ -0,0 +1,52 @@
+// Copyright 2015 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.chrome.browser.omaha;
+
+import static junit.framework.Assert.assertNotNull;
+
+import android.app.AlarmManager;
+import android.app.PendingIntent;
+import android.content.Context;
+
+/**
+ * Overrides the setAlarm function and allows changing the clock.
+ */
+public class MockExponentialBackoffScheduler extends ExponentialBackoffScheduler {
+ private boolean mAlarmWasSet;
+ private long mAlarmTimestamp;
+ private long mCurrentTimestamp;
+
+ public MockExponentialBackoffScheduler(String packageName, Context context,
+ long baseMilliseconds, long maxMilliseconds) {
+ super(packageName, context, baseMilliseconds, maxMilliseconds);
+ }
+
+ @Override
+ protected void setAlarm(AlarmManager am, long timestamp, PendingIntent retryPIntent) {
+ // Getting the Intent from the PendingIntent is not straightforward.
+ // The delay is checked by another unit test.
+ assertNotNull(am);
+ assertNotNull(retryPIntent);
+ mAlarmWasSet = true;
+ mAlarmTimestamp = timestamp;
+ }
+
+ @Override
+ public long getCurrentTime() {
+ return mCurrentTimestamp;
+ }
+
+ public void setCurrentTime(long timestamp) {
+ mCurrentTimestamp = timestamp;
+ }
+
+ public boolean getAlarmWasSet() {
+ return mAlarmWasSet;
+ }
+
+ public long getAlarmTimestamp() {
+ return mAlarmTimestamp;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698