-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from WasiqB/issue-60
Issue 60
- Loading branch information
Showing
10 changed files
with
164 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/com/github/wasiqb/coteafs/appium/error/NotEnoughBatteryChargeError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* 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.error; | ||
|
||
/** | ||
* @author wasiqb | ||
* @since Oct 2, 2018 | ||
*/ | ||
public class NotEnoughBatteryChargeError extends CoteafsAppiumError { | ||
private static final long serialVersionUID = -4401868812886874760L; | ||
|
||
/** | ||
* @author wasiqb | ||
* @since Oct 2, 2018 | ||
* @param message | ||
*/ | ||
public NotEnoughBatteryChargeError (final String message) { | ||
super (message); | ||
} | ||
|
||
/** | ||
* @author wasiqb | ||
* @since Oct 2, 2018 | ||
* @param message | ||
* @param cause | ||
*/ | ||
public NotEnoughBatteryChargeError (final String message, final Throwable cause) { | ||
super (message, cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/com/github/wasiqb/coteafs/appium/utils/BatteryHealth.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* 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.appium.utils.ErrorUtils.fail; | ||
import static java.text.MessageFormat.format; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import com.github.wasiqb.coteafs.appium.error.NotEnoughBatteryChargeError; | ||
|
||
/** | ||
* @author wasiqb | ||
* @since Oct 2, 2018 | ||
*/ | ||
public final class BatteryHealth { | ||
private static final Logger log = LogManager.getLogger (BatteryHealth.class); | ||
|
||
/** | ||
* @author wasiqb | ||
* @since Oct 2, 2018 | ||
* @param state | ||
* @param level | ||
*/ | ||
public static void check (final String state, final double level) { | ||
log.trace (format ("Current Battery status is [{0}] with charge level as [{1}%]...", 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 () { | ||
// TODO Auto-generated constructor stub | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.