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

Unified Diff: third_party/WebKit/LayoutTests/battery-status/promise-with-eventlisteners.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/promise-with-eventlisteners.html
diff --git a/third_party/WebKit/LayoutTests/battery-status/promise-with-eventlisteners.html b/third_party/WebKit/LayoutTests/battery-status/promise-with-eventlisteners.html
index b2f77161054e001fb561ade668effa888bb549b6..4e13f952a73f8090c34e4c4e44a7160952c8a468 100644
--- a/third_party/WebKit/LayoutTests/battery-status/promise-with-eventlisteners.html
+++ b/third_party/WebKit/LayoutTests/battery-status/promise-with-eventlisteners.html
@@ -2,6 +2,8 @@
<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 promise resolution and event listeners callbacks.");
@@ -15,26 +17,6 @@ gc();
jsTestIsAsync = true;
testRunner.waitUntilDone();
-var mockBatteryInfo;
-function setAndFireMockBatteryInfo(charging, chargingTime, dischargingTime, level) {
- mockBatteryInfo = { charging: charging,
- chargingTime: chargingTime,
- dischargingTime: dischargingTime,
- level: level };
- window.internals.updateBatteryStatus(charging, chargingTime, dischargingTime, level);
-}
-
-// compare obtained battery values with the mock values
-function checkBatteryInfo(batteryManager) {
- batteryInfo = batteryManager;
- shouldBeDefined("batteryInfo");
- shouldBeDefined("mockBatteryInfo");
- shouldBe('batteryInfo.charging', 'mockBatteryInfo.charging');
- shouldBe('batteryInfo.chargingTime', 'mockBatteryInfo.chargingTime');
- shouldBe('batteryInfo.dischargingTime', 'mockBatteryInfo.dischargingTime');
- shouldBe('batteryInfo.level', 'mockBatteryInfo.level');
-}
-
var battery;
function batteryStatusSuccess(batteryManager) {
debug('batteryStatusSuccess invoked');
@@ -100,13 +82,10 @@ function finishIfReady() {
}
}
-function batteryStatusFailure() {
- testFailed('failed to successfully resolve the promise');
- setTimeout(finishJSTest, 0);
-}
-
-navigator.getBattery().then(batteryStatusSuccess, batteryStatusFailure);
-setAndFireMockBatteryInfo(false, 10, 20, 0.5);
+ready.then(() => {
+ navigator.getBattery().then(batteryStatusSuccess, batteryStatusFailure);
+ setAndFireMockBatteryInfo(false, 10, 20, 0.5);
+});
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698