summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjdesprez <jdesprez@google.com>2017-12-05 05:46:53 -0800
committerjdesprez <jdesprez@google.com>2017-12-05 05:48:18 -0800
commitc33644cff2a68dbcf3e65cd2877405a866ee38f9 (patch)
treebd501f5580fb12de32b9a3b7300770d89006a322
parentfbe6dbe67854e6b157f70c07fdc1810b24e1f284 (diff)
downloadloganalysis-c33644cff2a68dbcf3e65cd2877405a866ee38f9.tar.gz
Update unit tests to work in other timezone
Particular unit tests always expected PST timezone for the time generated. Updated to use the current timezone. Test: run unit tests when in GMT timezone (london) Bug: None Change-Id: Id7c5f12aabadf07373945a974a5791b092a63311
-rw-r--r--tests/src/com/android/loganalysis/parser/BatteryStatsSummaryInfoParserTest.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/src/com/android/loganalysis/parser/BatteryStatsSummaryInfoParserTest.java b/tests/src/com/android/loganalysis/parser/BatteryStatsSummaryInfoParserTest.java
index ad0c999..c6ba381 100644
--- a/tests/src/com/android/loganalysis/parser/BatteryStatsSummaryInfoParserTest.java
+++ b/tests/src/com/android/loganalysis/parser/BatteryStatsSummaryInfoParserTest.java
@@ -20,7 +20,9 @@ import com.android.loganalysis.item.BatteryStatsSummaryInfoItem;
import junit.framework.TestCase;
import java.util.Arrays;
+import java.util.GregorianCalendar;
import java.util.List;
+import java.util.TimeZone;
/**
* Unit tests for {@link BatteryStatsSummaryInfoParser}
@@ -83,8 +85,14 @@ public class BatteryStatsSummaryInfoParserTest extends TestCase {
assertEquals("The battery dropped a level 24 mins on average",
summary.getBatteryDischargeRate());
- assertEquals("The peak discharge time was during Tue Dec 09 16:31:07 PST 2014 to "
- + "Tue Dec 09 19:35:52 PST 2014 where battery dropped from 89 to 80",
+ // Get the current timezone short name (PST, GMT) to properly output the time as expected.
+ String timezone =
+ new GregorianCalendar().getTimeZone().getDisplayName(false, TimeZone.SHORT);
+ assertEquals(
+ String.format(
+ "The peak discharge time was during Tue Dec 09 16:31:07 %s 2014 to "
+ + "Tue Dec 09 19:35:52 %s 2014 where battery dropped from 89 to 80",
+ timezone, timezone),
summary.getPeakDischargeTime());
}