Skip to content

Commit

Permalink
feat(java): ✨ added android specific critical actions
Browse files Browse the repository at this point in the history
  • Loading branch information
WasiqB committed Jan 22, 2025
1 parent 02e0c60 commit 3295f25
Show file tree
Hide file tree
Showing 220 changed files with 641 additions and 267 deletions.
2 changes: 1 addition & 1 deletion core-java/checkstyles/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
~ MIT License
~
~ Copyright (c) 2022 Wasiq Bhamla
~ Copyright (c) 2022 Boyka Framework
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions core-java/checkstyles/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
~ MIT License
~
~ Copyright (c) 2022 Wasiq Bhamla
~ Copyright (c) 2022 Boyka Framework
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -145,7 +145,7 @@
</module>
<!-- Validate whitespace around Generics (angle brackets) per typical conventions
http://checkstyle.sourceforge.net/config_whitespace.html#GenericWhitespace -->
<!-- <module name="GenericWhitespace"/>-->
<!-- <module name="GenericWhitespace"/>-->

<!-- ##### Blank line requirements ##### -->
<module name="EmptyLineSeparator">
Expand Down
2 changes: 1 addition & 1 deletion core-java/code-formatter/boyka-formatter.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
~ MIT License
~
~ Copyright (c) 2023, Wasiq Bhamla
~ Copyright (c) 2024, Boyka Framework
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion core-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
~ MIT License
~
~ Copyright (c) 2022 Wasiq Bhamla
~ Copyright (c) 2022 Boyka Framework
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions core-java/setting/settings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
~ MIT License
~
~ Copyright (c) 2022 Wasiq Bhamla
~ Copyright (c) 2022 Boyka Framework
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
Expand All @@ -15,8 +15,8 @@
-->

<settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>central</id>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -16,6 +16,8 @@

package io.github.boykaframework.actions.device;

import static com.google.common.truth.Truth.assertWithMessage;
import static io.github.boykaframework.actions.CommonActions.getDriverAttribute;
import static io.github.boykaframework.actions.CommonActions.performDriverAction;
import static io.github.boykaframework.enums.ListenerType.ANDROID_DEVICE_ACTION;
import static io.github.boykaframework.enums.Message.ACTION_NOT_SUPPORTED_ON_PLATFORM;
Expand All @@ -25,9 +27,15 @@
import static java.util.Optional.ofNullable;
import static org.apache.logging.log4j.LogManager.getLogger;

import java.io.File;
import java.io.IOException;

import com.google.common.truth.StringSubject;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.HasNotifications;
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
import io.appium.java_client.clipboard.HasClipboard;
import io.github.boykaframework.actions.interfaces.device.IAndroidDeviceActions;
import io.github.boykaframework.actions.interfaces.listeners.device.IAndroidDeviceActionsListener;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -57,16 +65,87 @@ private AndroidDeviceActions () {
this.listener = getSession ().getListener (ANDROID_DEVICE_ACTION);
}

@Override
public String getClipboardText () {
LOGGER.traceEntry ();
isActionSupported ();
LOGGER.info ("Getting the Clipboard text from Android device...");
ofNullable (this.listener).ifPresent (IAndroidDeviceActionsListener::onGetClipboardText);
return getClipboard ();
}

@Override
public void openNotification () {
LOGGER.traceEntry ();
isActionSupported ();
LOGGER.info ("Opening Notification panel on the Android device...");
ofNullable (this.listener).ifPresent (IAndroidDeviceActionsListener::onOpenNotification);
performDriverAction (HasNotifications::openNotifications);
LOGGER.traceExit ();
}

@Override
public void pressKey (final AndroidKey key) {
LOGGER.traceEntry ();
final var platform = getSession ().getPlatformType ();
if (platform != ANDROID) {
throwError (ACTION_NOT_SUPPORTED_ON_PLATFORM, "Press key", platform);
}
isActionSupported ();
LOGGER.info ("Pressing key [{}] on Android device...", key);
ofNullable (this.listener).ifPresent (l -> l.onPressKey (key));
performDriverAction ((AndroidDriver d) -> d.pressKey (new KeyEvent ().withKey (key)));
LOGGER.traceExit ();
}

@Override
public byte[] pullFile (final String targetFile) {
LOGGER.traceEntry ();
isActionSupported ();
LOGGER.info ("Pulling file [{}] from Android device...", targetFile);
ofNullable (this.listener).ifPresent (l -> l.onPullFile (targetFile));
return getDriverAttribute ((final AndroidDriver d) -> d.pullFile (targetFile), null);
}

@Override
public boolean putFile (final File sourceFile, final String destinationPath) {
LOGGER.traceEntry ();
isActionSupported ();
LOGGER.info ("Putting file [{}] on Android device path [{}]...", sourceFile.getName (), destinationPath);
ofNullable (this.listener).ifPresent (l -> l.onPutFile (sourceFile, destinationPath));
return getDriverAttribute ((final AndroidDriver d) -> {
try {
d.pushFile (destinationPath, sourceFile);
return true;
} catch (final IOException e) {
return false;
}
}, false);
}

@Override
public void setClipboardText (final String text) {
LOGGER.traceEntry ();
isActionSupported ();
LOGGER.info ("Setting the Clipboard text [{}] on the Android device...", text);
ofNullable (this.listener).ifPresent (l -> l.onSetClipboardText (text));
performDriverAction ((AndroidDriver d) -> d.setClipboardText (text));
LOGGER.traceExit ();
}

@Override
public StringSubject verifyClipboardText () {
LOGGER.traceEntry ();
isActionSupported ();
LOGGER.info ("Verifying the Clipboard text from Android device...");
ofNullable (this.listener).ifPresent (IAndroidDeviceActionsListener::onVerifyClipboardText);
return assertWithMessage ("Clipboard Text").that (getClipboard ());
}

private String getClipboard () {
return getDriverAttribute (HasClipboard::getClipboardText, null);
}

private void isActionSupported () {
final var platform = getSession ().getPlatformType ();
if (platform != ANDROID) {
throwError (ACTION_NOT_SUPPORTED_ON_PLATFORM, "Press key", platform);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024, Wasiq Bhamla
* Copyright (c) 2024, Boyka Framework
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit 3295f25

Please sign in to comment.