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

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

Issue 1836203002: Change the battery-status layout tests to use JS mocks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
Index: third_party/WebKit/LayoutTests/battery-status/restricted-level-precision.html
diff --git a/third_party/WebKit/LayoutTests/battery-status/restricted-level-precision.html b/third_party/WebKit/LayoutTests/battery-status/restricted-level-precision.html
index 8561b46732184abcfa767798b0baefe0f13f12a4..7b409425eed284cfc9ac0148377d15b6ea7d84d1 100644
--- a/third_party/WebKit/LayoutTests/battery-status/restricted-level-precision.html
+++ b/third_party/WebKit/LayoutTests/battery-status/restricted-level-precision.html
@@ -2,13 +2,13 @@
<html>
<body>
<script src="../resources/js-test.js"></script>
+<script src="../resources/mojo-helpers.js"></script>
+<script src="resources/mock-battery-monitor.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');
-if (!window.internals)
- debug('This test cannot be run without the window.internals');
// Clean-up any unused battery manager objects from previous tests.
gc();
@@ -18,10 +18,6 @@ testRunner.waitUntilDone();
var levelFullPrecision = 0.556789;
var levelRounded = 0.56;
-function setAndFireMockBatteryInfo(charging, chargingTime, dischargingTime, level) {
- window.internals.updateBatteryStatus(charging, chargingTime, dischargingTime, level);
-}
-
var battery;
function batteryStatusSuccess(batteryManager) {
debug('batteryStatusSuccess invoked');
@@ -30,13 +26,10 @@ function batteryStatusSuccess(batteryManager) {
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);
+mockBatteryMonitorReady.then(() => {
+ navigator.getBattery().then(batteryStatusSuccess, batteryStatusFailure);
+ setAndFireMockBatteryInfo(false, 10, 20, levelFullPrecision);
+});
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698