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

Unified Diff: LayoutTests/battery-status/restricted-level-precision.html

Issue 1229143006: Enforce restricted precision of the Battery Status API level attribute (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: no-find-copies Created 5 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 | « no previous file | LayoutTests/battery-status/restricted-level-precision-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/battery-status/restricted-level-precision.html
diff --git a/LayoutTests/battery-status/restricted-level-precision.html b/LayoutTests/battery-status/restricted-level-precision.html
new file mode 100644
index 0000000000000000000000000000000000000000..b2706a5d47da4bade21f01c6fe30219e330e3209
--- /dev/null
+++ b/LayoutTests/battery-status/restricted-level-precision.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../resources/js-test.js"></script>
+<script>
+description("Test to ensure level is reported with restricted precision.");
+
+if (!window.testRunner)
+ debug('This test cannot be run without the TestRunner');
+
+// Clean-up any unused battery manager objects from previous tests.
+gc();
+jsTestIsAsync = true;
+testRunner.waitUntilDone();
+
+var levelFullPrecision = 0.556789;
+var levelRounded = 0.56;
+
+function setAndFireMockBatteryInfo(charging, chargingTime, dischargingTime, level) {
+ testRunner.didChangeBatteryStatus(charging, chargingTime, dischargingTime, level);
+}
+
+var battery;
+function batteryStatusSuccess(batteryManager) {
+ debug('batteryStatusSuccess invoked');
+ battery = batteryManager;
+ shouldBe('battery.level', 'levelRounded');
+ setTimeout(finishJSTest, 0);
+}
+
+function batteryStatusFailure() {
+ testFailed('failed to successfully resolve the promise');
+ setTimeout(finishJSTest, 0);
+}
+
+navigator.getBattery().then(batteryStatusSuccess, batteryStatusFailure);
+setAndFireMockBatteryInfo(false, 10, 20, levelFullPrecision);
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/battery-status/restricted-level-precision-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698