package net.northking.cctp.se.device.bean;

import io.appium.java_client.android.AndroidDriver;
import lombok.extern.slf4j.Slf4j;
import net.northking.cctp.element.core.DeviceDriver;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebElement;

import java.net.URL;
import java.util.concurrent.Future;

@Slf4j
public class AndroidMobileDeviceDriver extends AndroidDriver<WebElement> implements DeviceDriver {

    private Future future;

    public AndroidMobileDeviceDriver(URL remoteAddress, Capabilities desiredCapabilities) {
        super(remoteAddress,desiredCapabilities);
        log.info("Mobile androidDriver created --> [address:{},capability:{}]", remoteAddress, desiredCapabilities);
    }

    @Override
    public void destroy() {
        try {
            this.quit();
        } catch (Exception e) {
           log.warn("driver有问题。。。。。");
        }
        if (null != this.future) {
            future.cancel(true);
            this.future = null;
        }
        log.info("androidDriver driver destroyed. ");
    }

    @Override
    public void setFuture(Future future) {
        this.future = future;
    }

    @Override
    public Future getFuture() {
        return this.future;
    }


}
