Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,9 @@ protected PromptHandlerParameters getDefaultBrokerPromptHandlerParameters(@NonNu
.loginHint(username)
.build();
}

@Override
public void enableScreenCapture() {
// Default implementation, Do nothing.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;

Expand Down Expand Up @@ -272,6 +273,34 @@ private String createPowerLiftIncidentInSharedDeviceMode() {
}
}


public void enableScreenCapture() {
Log.i(TAG, "Enable Screen Capture..");
try {
launch(); // launch Authenticator app
handleFirstRun(); // handle first run experience

// click the 3 dot menu icon in top right
UiAutomatorUtils.handleButtonClick("com.azure.authenticator:id/menu_overflow");

// select Settings from drop down
final UiObject settings = UiAutomatorUtils.obtainUiObjectWithText("Settings");
settings.click();

final UiObject screenCapture = UiAutomatorUtils.obtainChildInScrollable(
"settingsScrollView",
"Screen Capture"
);

screenCapture.click();
Log.i(TAG, "Screen Capture is enabled..");
forceStop();
Log.i(TAG, "App is force stopped..");
} catch (final UiObjectNotFoundException e) {
throw new AssertionError(e);
}
}

@Override
public DeviceAdmin getAdminName() {
Logger.i(TAG, "Get Admin Name..");
Expand All @@ -282,10 +311,10 @@ public DeviceAdmin getAdminName() {
* Open the device registration page in the Authenticator App
*/
public void openDeviceRegistrationPage() {
Logger.i(TAG, "Open the device registration page in the Authenticator App..");
Log.i(TAG, "Open the device registration page in the Authenticator App..");
launch(); // launch Authenticator app

handleFirstRun(); // handle first run experience
//handleFirstRun(); // handle first run experience
goToDeviceRegistrationPage();

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
Expand Down Expand Up @@ -404,6 +433,7 @@ public void handleFirstRun() {
UiAutomatorUtils.handleButtonClick("com.azure.authenticator:id/frx_skip_button");
// This is required for auth app as it has increased the compile sdk version to 34
UiAutomatorUtils.handleButtonClickForObjectWithTextSafely("NOT NOW");

shouldHandleFirstRun = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,6 @@ public interface ITestBroker extends IApp {
* @return the flight information set for this broker app
*/
String getFlights();

void enableScreenCapture();
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;

import android.util.Log;

/**
* This class contains utility methods that can be used to interact with the ADB Shell from within
* code during the execution of a UI Test.
Expand Down Expand Up @@ -146,8 +148,13 @@ public static void clearPackage(@NonNull final String packageName) {
* @param packageName the package to force stop
*/
public static void forceStopPackage(@NonNull final String packageName) {
Logger.i(TAG, "Force stop the " + packageName + " App..");
Log.i(TAG, "Force stop the " + packageName + " App..");
executeShellCommand("am force-stop " + packageName);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}

private static void putGlobalSettings(final String settingName, final String value) {
Expand Down
Loading