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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.omaha;
6
7 import static junit.framework.Assert.assertNotNull;
8
9 import android.app.AlarmManager;
10 import android.app.PendingIntent;
11 import android.content.Context;
12
13 /**
14 * Overrides the setAlarm function and allows changing the clock.
15 */
16 public class MockExponentialBackoffScheduler extends ExponentialBackoffScheduler {
17 private boolean mAlarmWasSet;
18 private long mAlarmTimestamp;
19 private long mCurrentTimestamp;
20
21 public MockExponentialBackoffScheduler(String packageName, Context context,
22 long baseMilliseconds, long maxMilliseconds) {
23 super(packageName, context, baseMilliseconds, maxMilliseconds);
24 }
25
26 @Override
27 protected void setAlarm(AlarmManager am, long timestamp, PendingIntent retry PIntent) {
28 // Getting the Intent from the PendingIntent is not straightforward.
29 // The delay is checked by another unit test.
30 assertNotNull(am);
31 assertNotNull(retryPIntent);
32 mAlarmWasSet = true;
33 mAlarmTimestamp = timestamp;
34 }
35
36 @Override
37 public long getCurrentTime() {
38 return mCurrentTimestamp;
39 }
40
41 public void setCurrentTime(long timestamp) {
42 mCurrentTimestamp = timestamp;
43 }
44
45 public boolean getAlarmWasSet() {
46 return mAlarmWasSet;
47 }
48
49 public long getAlarmTimestamp() {
50 return mAlarmTimestamp;
51 }
52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698