Skip to content

Instantly share code, notes, and snippets.

View smiklosovic's full-sized avatar

Štefan Miklošovič smiklosovic

View GitHub Profile
@smiklosovic
smiklosovic / ArquillianScreenShooterTestCase.java
Last active December 19, 2015 15:09
Initial idea how to get screenshots in tests, very handy in Arquillian Droidium environment.
@RunWith(Arquillian.class)
// when this annotation is omitted, images will be saved into
// default location, like target/screenshots
@SaveScreenShotsTo("target/my-screenshots/ArquillianScreenShooterTestCase/")
// when no @TakeScreenShots are specified on method, this one will be used by default
@TakeScreenShots(BeforeAsserts.class)
public class ArquillianScreenShooterTestCase {
@Drone WebDriver driver
import java.io.File;
import java.io.IOException;
import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.RawImage;
import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
public void retrieveOTPPath(FragmentActivity activity, Callback<List<OTP>> callback) throws Exception {
AuthenticationModule authModule = authenticator.get("login", activity);
URL url = new URL(baseURL);
Pipeline pipeline = new Pipeline(url);
PipeConfig pipeConfig = new PipeConfig(url, OTP.class);
pipeConfig.setAuthModule(authModule);
pipeConfig.setEndpoint("/auth/otp/secret");
<profile>
<id>jboss-staging-repository-group</id>
<repositories>
<repository>
<id>jboss-staging-repository-group</id>
<name>JBoss Staging Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/staging</url>
<layout>default</layout>
<releases>
@Deployment
@Instrumentable
public statit Archive<?> mobilePhoneDeployment()
{
return some apk you want to test
}
@Deployment
@Targets("jboss")
public void removeAllActivitiesForDrone(@Observes BeforeDroneDestroyed event) {
InjectionPoint<?> injectionPoint = event.getInjectionPoint();
Object drone = droneContext.get().getDrone(injectionPoint);
if (RemoteWebDriver.class.isAssignableFrom(drone.getClass())) {
WebDriverConfiguration configuration = droneContext.get()
.getDroneConfiguration(injectionPoint, WebDriverConfiguration.class);
(E) AfterClass
(I) TestContextHandler.createSuiteContext
(I) TestContextHandler.createClassContext
(E) TestClass
(O) ClientBeforeAfterLifecycleEventExecuter.on
(O) ContainerEventController.execute
(E) ContainerMultiControlEvent
(O) ContainerDeployController.undeployManaged
(E) UnDeployDeployment
(I) ContainerDeploymentContextHandler.createContainerContext
public class AndroidDronePointFilter implements DronePointFilter {
@Override
public boolean accept(DroneContext context, DronePoint<?> dronePoint) {
DronePointContext<?> dronePointContext = context.get(dronePoint);
if (dronePointContext.hasConfiguration() && dronePoint.conformsTo(WebDriver.class)) {
if (dronePointContext.isInstantiated()) {
if (dronePoint.conformsTo(AndroidDriver.class)) {
return true;
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* 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
ProcessInteraction interaction = new ProcessInteractionBuilder().
replyTo("Do you wish to create a custom hardware profile \\[no\\]")
.with("no" + System.getProperty("line.separator"))
.build();
Tasks.prepare(CommandTool.class).interaction(interaction).command(command).execute().await();