summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2017-08-28 09:43:59 -0700
committerMichael Plass <mplass@google.com>2017-08-28 09:43:59 -0700
commit876054396ec8fc5e706e37da0e77297eb8c3cddb (patch)
tree628a54de269677b68aed20b35e1df24eb402d68a /tests
parentf77fca37902331575d779df9754566db471db85f (diff)
[WifiScoreReport] Synthetic time for unit tests
Using the actual wall clock can cause test failures if the clock has never been set, so use a synthetic clock for the unit tests. Bug: 65064946 Test: Unit tests pass Change-Id: I26830c6c113c9cb3186877d0c169b6b3eccf1272
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
index 24d3afa18..6f01c8eb2 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
@@ -48,6 +48,18 @@ public class WifiScoreReportTest {
private static final int CELLULAR_THRESHOLD_SCORE = 50;
+ class FakeClock extends Clock {
+ long mWallClockMillis = 1500000000000L;
+ int mStepMillis = 1001;
+
+ @Override
+ public long getWallClockMillis() {
+ mWallClockMillis += mStepMillis;
+ return mWallClockMillis;
+ }
+ }
+
+ FakeClock mClock;
WifiConfiguration mWifiConfiguration;
WifiScoreReport mWifiScoreReport;
ScanDetailCache mScanDetailCache;
@@ -122,7 +134,8 @@ public class WifiScoreReportTest {
when(mWifiConfigManager.getScanDetailCacheForNetwork(anyInt()))
.thenReturn(mScanDetailCache);
when(mContext.getResources()).thenReturn(mResources);
- mWifiScoreReport = new WifiScoreReport(mContext, mWifiConfigManager, new Clock());
+ mClock = new FakeClock();
+ mWifiScoreReport = new WifiScoreReport(mContext, mWifiConfigManager, mClock);
}
/**