com.github.wasiqb.coteafs.appium.utils.BatteryHealth Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of appium Show documentation
Show all versions of appium Show documentation
Robust Automation Framework wrapped over Appium.
/*
* Copyright (c) 2017-2020, Wasiq Bhamla.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.wasiqb.coteafs.appium.utils;
import static com.github.wasiqb.coteafs.error.util.ErrorUtil.fail;
import com.github.wasiqb.coteafs.appium.error.NotEnoughBatteryChargeError;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* @author wasiqb
* @since Oct 2, 2018
*/
public final class BatteryHealth {
private static final Logger log = LogManager.getLogger ();
/**
* @param state Battery state
* @param level Battery level
*
* @author wasiqb
* @since Oct 2, 2018
*/
public static void check (final String state, final double level) {
log.trace ("Current Battery status is [{}] with charge level as [{}%]...", state, level * 100);
if (!state.equals ("CHARGING") && !state.equals ("FULL") && level < 0.2) {
fail (NotEnoughBatteryChargeError.class,
"Battery does not have enough charging, to continue, put your device on USB...");
}
}
private BatteryHealth () {
// Utility class.
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy