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

Side by Side Diff: android_webview/tools/WebViewShell/test/blink-apis/battery-status/battery-callback.html

Issue 1394303007: [WebViewLayoutTest] Fix potential rounding error in testBatteryApi() layout test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix the precision test Created 5 years, 2 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
« no previous file with comments | « no previous file | android_webview/tools/WebViewShell/test/blink-apis/battery-status/battery-callback-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <script src="../../resources/js-test.js"></script> 3 <script src="../../resources/js-test.js"></script>
4 <body> 4 <body>
5 <script type="text/javascript"> 5 <script type="text/javascript">
6 description("Test Battery Status API callback in WebView"); 6 description("Test Battery Status API callback in WebView");
7 window.jsTestIsAsync = true; 7 window.jsTestIsAsync = true;
8 8
9 function isInteger(value) {
10 if ((undefined === value) || (null === value)) {
11 return false;
12 }
13 return value % 1 == 0;
14 }
15
16 var battery; 9 var battery;
17 function batteryStatusSuccess(batteryManager) { 10 function batteryStatusSuccess(batteryManager) {
18 debug('batteryStatusSuccess invoked'); 11 debug('batteryStatusSuccess invoked');
19 battery = batteryManager; 12 battery = batteryManager;
20 13
21 // Validate values 14 // Validate values
22 shouldBeGreaterThanOrEqual('battery.level', '0'); 15 shouldBeGreaterThanOrEqual('battery.level', '0');
23 shouldBeLessThanOrEqual('battery.level', '1'); 16 shouldBeLessThanOrEqual('battery.level', '1');
24 // Check that level has at most 2 significant digits 17 // Check that level has at most 2 significant digits
25 shouldBeTrue('isInteger(battery.level * 100)'); 18 shouldBeTrue('battery.level.toPrecision(2) == battery.level');
26 shouldBeTrue('!battery.charging || battery.dischargingTime === Infinity' ); 19 shouldBeTrue('!battery.charging || battery.dischargingTime === Infinity' );
27 shouldBeTrue('battery.charging || battery.chargingTime === Infinity'); 20 shouldBeTrue('battery.charging || battery.chargingTime === Infinity');
28 finishJSTest(); 21 finishJSTest();
29 } 22 }
30 23
31 function batteryStatusFailure() { 24 function batteryStatusFailure() {
32 testFailed("failed to successfully resolve the promise"); 25 testFailed("failed to successfully resolve the promise");
33 finishJSTest(); 26 finishJSTest();
34 } 27 }
35 28
36 navigator.getBattery().then(batteryStatusSuccess, batteryStatusFailure); 29 navigator.getBattery().then(batteryStatusSuccess, batteryStatusFailure);
37 </script> 30 </script>
38 </body> 31 </body>
39 </html> 32 </html>
OLDNEW
« no previous file with comments | « no previous file | android_webview/tools/WebViewShell/test/blink-apis/battery-status/battery-callback-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698