Search in sources :

Example 1 with MobileDevice

use of com.seleniumtests.browserfactory.mobile.MobileDevice in project seleniumRobot by bhecquet.

the class TestAdbWrapper method testDeviceList.

@Test(groups = { "ut" })
public void testDeviceList() {
    PowerMockito.mockStatic(OSCommand.class);
    PowerMockito.mockStatic(System.class);
    when(System.getenv("ANDROID_HOME")).thenReturn(null);
    when(System.getenv("ANDROID_SDK_ROOT")).thenReturn(null);
    when(OSCommand.executeCommandAndWait("adb version")).thenReturn("Android Debug Bridge version 1.0.32\nRevision 09a0d98bebce-android");
    when(OSCommand.executeCommandAndWait("adb -s emulator-5554 shell \"dumpsys package com.android.browser | grep versionName\"")).thenReturn("  versionName=6.0-123.4");
    when(OSCommand.executeCommandAndWait("adb -s emulator-5554 shell \"dumpsys package com.android.chrome | grep versionName\"")).thenReturn("  versionName=56.0.123.4");
    when(OSCommand.executeCommandAndWait("adb devices")).thenReturn("List of devices attached\n" + "emulator-5554   device");
    when(OSCommand.executeCommandAndWait("adb -s emulator-5554 shell getprop")).thenReturn("[dalvik.vm.dex2oat-Xms]: [64m]\n" + "[dalvik.vm.dex2oat-Xmx]: [512m]\n" + "[dalvik.vm.heapsize]: [512m]\n" + "[dalvik.vm.image-dex2oat-Xms]: [64m]\n" + "[dalvik.vm.image-dex2oat-Xmx]: [64m]\n" + "[dalvik.vm.isa.arm.features]: [default]\n" + "[dalvik.vm.stack-trace-file]: [/data/anr/traces.txt]\n" + "[debug.force_rtl]: [0]\n" + "[dev.bootcomplete]: [1]\n" + "[gsm.current.phone-type]: [1]\n" + "[gsm.defaultpdpcontext.active]: [true]\n" + "[gsm.network.type]: [UMTS]\n" + "[gsm.nitz.time]: [1478705557978]\n" + "[gsm.operator.alpha]: [Android]\n" + "[gsm.operator.iso-country]: [us]\n" + "[gsm.operator.isroaming]: [false]\n" + "[gsm.operator.numeric]: [310260]\n" + "[gsm.sim.operator.alpha]: [Android]\n" + "[gsm.sim.operator.iso-country]: [us]\n" + "[gsm.sim.operator.numeric]: [310260]\n" + "[gsm.sim.state]: [READY]\n" + "[gsm.version.ril-impl]: [android reference-ril 1.0]\n" + "[init.svc.adbd]: [running]\n" + "[init.svc.bootanim]: [stopped]\n" + "[init.svc.console]: [running]\n" + "[init.svc.debuggerd]: [running]\n" + "[init.svc.drm]: [running]\n" + "[init.svc.fuse_sdcard]: [running]\n" + "[init.svc.goldfish-logcat]: [stopped]\n" + "[init.svc.goldfish-setup]: [stopped]\n" + "[init.svc.healthd]: [running]\n" + "[init.svc.installd]: [running]\n" + "[init.svc.keystore]: [running]\n" + "[init.svc.lmkd]: [running]\n" + "[init.svc.logd]: [running]\n" + "[init.svc.media]: [running]\n" + "[init.svc.netd]: [running]\n" + "[init.svc.qemu-props]: [stopped]\n" + "[init.svc.qemud]: [running]\n" + "[init.svc.ril-daemon]: [running]\n" + "[init.svc.servicemanager]: [running]\n" + "[init.svc.surfaceflinger]: [running]\n" + "[init.svc.ueventd]: [running]\n" + "[init.svc.vold]: [running]\n" + "[init.svc.zygote]: [running]\n" + "[net.bt.name]: [Android]\n" + "[net.change]: [net.dns3]\n" + "[net.dns1]: [10.0.2.3]\n" + "[net.dns2]: [10.0.2.4]\n" + "[net.dns3]: [10.0.2.5]\n" + "[net.eth0.dns1]: [10.0.2.3]\n" + "[net.eth0.dns2]: [10.0.2.4]\n" + "[net.eth0.dns3]: [10.0.2.5]\n" + "[net.eth0.gw]: [10.0.2.2]\n" + "[net.gprs.local-ip]: [10.0.2.15]\n" + "[net.hostname]: [android-ac19bf2a38442f23]\n" + "[net.qtaguid_enabled]: [1]\n" + "[net.tcp.default_init_rwnd]: [60]\n" + "[persist.sys.country]: [US]\n" + "[persist.sys.dalvik.vm.lib.2]: [libart.so]\n" + "[persist.sys.language]: [en]\n" + "[persist.sys.localevar]: []\n" + "[persist.sys.profiler_ms]: [0]\n" + "[persist.sys.timezone]: [GMT]\n" + "[persist.sys.usb.config]: [adb]\n" + "[qemu.hw.mainkeys]: [0]\n" + "[qemu.sf.fake_camera]: [none]\n" + "[qemu.sf.lcd_density]: [480]\n" + "[rild.libargs]: [-d /dev/ttyS0]\n" + "[rild.libpath]: [/system/lib/libreference-ril.so]\n" + "[ro.allow.mock.location]: [1]\n" + "[ro.baseband]: [unknown]\n" + "[ro.board.platform]: []\n" + "[ro.boot.hardware]: [goldfish]\n" + "[ro.bootloader]: [unknown]\n" + "[ro.bootmode]: [unknown]\n" + "[ro.build.characteristics]: [default]\n" + "[ro.build.date.utc]: [1423923410]\n" + "[ro.build.date]: [Sat Feb 14 14:16:50 UTC 2015]\n" + "[ro.build.description]: [sdk_phone_armv7-eng 5.1 LKY45 1737576 test-keys]\n" + "[ro.build.display.id]: [sdk_phone_armv7-eng 5.1 LKY45 1737576 test-keys]\n" + "[ro.build.fingerprint]: [generic/sdk_phone_armv7/generic:5.1/LKY45/1737576:eng/test-keys]\n" + "[ro.build.flavor]: [sdk_phone_armv7-eng]\n" + "[ro.build.host]: [vpbs4.mtv.corp.google.com]\n" + "[ro.build.id]: [LKY45]\n" + "[ro.build.product]: [generic]\n" + "[ro.build.tags]: [test-keys]\n" + "[ro.build.type]: [eng]\n" + "[ro.build.user]: [android-build]\n" + "[ro.build.version.all_codenames]: [REL]\n" + "[ro.build.version.codename]: [REL]\n" + "[ro.build.version.incremental]: [1737576]\n" + "[ro.build.version.release]: [5.1]\n" + "[ro.build.version.sdk]: [22]\n" + "[ro.com.google.locationfeatures]: [1]\n" + "[ro.config.alarm_alert]: [Alarm_Classic.ogg]\n" + "[ro.config.nocheckin]: [yes]\n" + "[ro.config.notification_sound]: [OnTheHunt.ogg]\n" + "[ro.crypto.state]: [unencrypted]\n" + "[ro.dalvik.vm.native.bridge]: [0]\n" + "[ro.debuggable]: [1]\n" + "[ro.factorytest]: [0]\n" + "[ro.hardware]: [goldfish]\n" + "[ro.kernel.android.checkjni]: [1]\n" + "[ro.kernel.android.qemud]: [ttyS1]\n" + "[ro.kernel.androidboot.hardware]: [goldfish]\n" + "[ro.kernel.console]: [ttyS0]\n" + "[ro.kernel.ndns]: [3]\n" + "[ro.kernel.qemu.gles]: [1]\n" + "[ro.kernel.qemu]: [1]\n" + "[ro.opengles.version]: [131072]\n" + "[ro.product.board]: []\n" + "[ro.product.brand]: [generic]\n" + "[ro.product.cpu.abi2]: [armeabi]\n" + "[ro.product.cpu.abi]: [armeabi-v7a]\n" + "[ro.product.cpu.abilist32]: [armeabi-v7a,armeabi]\n" + "[ro.product.cpu.abilist64]: []\n" + "[ro.product.cpu.abilist]: [armeabi-v7a,armeabi]\n" + "[ro.product.device]: [generic]\n" + "[ro.product.locale.language]: [en]\n" + "[ro.product.locale.region]: [US]\n" + "[ro.product.manufacturer]: [unknown]\n" + "[ro.product.model]: [sdk_phone_armv7]\n" + "[ro.product.name]: [sdk_phone_armv7]\n" + "[ro.radio.use-ppp]: [no]\n" + "[ro.revision]: [0]\n" + "[ro.runtime.firstboot]: [1478705722255]\n" + "[ro.secure]: [0]\n" + "[ro.serialno]: []\n" + "[ro.setupwizard.mode]: [EMULATOR]\n" + "[ro.wifi.channels]: []\n" + "[ro.zygote]: [zygote32]\n" + "[selinux.reload_policy]: [1]\n" + "[service.bootanim.exit]: [1]\n" + "[status.battery.level]: [5]\n" + "[status.battery.level_raw]: [50]\n" + "[status.battery.level_scale]: [9]\n" + "[status.battery.state]: [Slow]\n" + "[sys.boot_completed]: [1]\n" + "[sys.settings_global_version]: [2]\n" + "[sys.settings_system_version]: [4]\n" + "[sys.sysctl.extra_free_kbytes]: [24300]\n" + "[sys.sysctl.tcp_def_init_rwnd]: [60]\n" + "[sys.usb.config]: [adb]\n" + "[sys.usb.state]: [adb]\n" + "[wlan.driver.status]: [unloaded]\n" + "[xmpp.auto-presence]: [true]\n");
    when(OSCommand.executeCommandAndWait("adb -s emulator-5554 shell \"pm list packages\"")).thenReturn("package:com.example.android.livecubes\n" + "package:com.android.providers.telephony\n" + "package:com.android.providers.calendar\n" + "package:com.android.providers.media\n" + "package:com.google.android.onetimeinitializer\n" + "package:com.android.wallpapercropper\n" + "package:com.android.documentsui\n" + "package:com.android.galaxy4\n" + "package:com.android.externalstorage\n" + "package:com.android.htmlviewer\n" + "package:com.android.mms.service\n" + "package:com.android.providers.downloads\n" + "package:com.android.messaging\n" + "package:com.android.browser\n" + "package:com.google.android.configupdater\n" + "package:com.android.soundrecorder\n" + "package:com.android.defcontainer\n" + "package:com.android.providers.downloads.ui\n" + "package:com.android.vending\n" + "package:com.android.pacprocessor\n" + "package:com.android.certinstaller\n" + "package:com.android.carrierconfig\n" + "package:com.google.android.launcher.layouts.genymotion\n" + "package:android\n" + "package:com.android.contacts\n" + "package:com.android.camera2\n" + "package:com.android.launcher3\n" + "package:com.android.backupconfirm\n" + "package:com.android.statementservice\n" + "package:com.android.wallpaper.holospiral\n" + "package:com.android.calendar\n" + "package:com.android.phasebeam\n" + "package:com.google.android.setupwizard\n" + "package:com.android.providers.settings\n" + "package:com.android.sharedstoragebackup\n" + "package:com.android.printspooler\n" + "package:com.android.dreams.basic\n" + "package:com.android.webview\n" + "package:com.android.inputdevices\n" + "package:com.android.providers.calllogbackup\n" + "package:com.android.musicfx\n" + "package:com.android.development_settings\n" + "package:com.android.server.telecom\n" + "package:com.google.android.syncadapters.contacts\n" + "package:com.android.keychain\n" + "package:com.android.chrome\n" + "package:com.android.dialer\n" + "package:com.android.gallery3d\n" + "package:com.google.android.gms\n" + "package:com.google.android.gsf\n" + "package:com.google.android.tts\n" + "package:com.google.android.partnersetup\n" + "package:com.android.packageinstaller\n" + "package:com.svox.pico\n" + "package:com.example.android.apis\n" + "package:com.android.proxyhandler\n" + "package:com.android.inputmethod.latin\n" + "package:com.google.android.feedback\n" + "package:com.google.android.syncadapters.calendar\n" + "package:com.android.managedprovisioning\n" + "package:com.android.dreams.phototable\n" + "package:com.android.noisefield\n" + "package:com.google.android.gsf.login\n" + "package:com.android.smspush\n" + "package:com.android.wallpaper.livepicker\n" + "package:com.amaze.filemanager\n" + "package:com.google.android.backuptransport\n" + "package:jp.co.omronsoft.openwnn\n" + "package:com.android.settings\n" + "package:com.android.calculator2\n" + "package:com.android.gesture.builder\n" + "package:com.android.wallpaper\n" + "package:com.android.vpndialogs\n" + "package:com.android.email\n" + "package:com.android.music\n" + "package:com.android.phone\n" + "package:com.android.shell\n" + "package:com.android.providers.userdictionary\n" + "package:com.android.location.fused\n" + "package:com.android.deskclock\n" + "package:com.android.systemui\n" + "package:com.android.exchange\n" + "package:com.android.bluetoothmidiservice\n" + "package:com.android.customlocale2\n" + "package:io.appium.unlock\n" + "package:com.android.bluetooth\n" + "package:com.android.development\n" + "package:com.android.providers.contacts\n" + "package:com.android.captiveportallogin\n");
    AdbWrapper adb = new AdbWrapper();
    List<MobileDevice> mobiles = adb.getDeviceList();
    Assert.assertEquals(mobiles.size(), 1);
    Assert.assertEquals(mobiles.get(0).getId(), "emulator-5554");
    Assert.assertEquals(mobiles.get(0).getName(), "sdk_phone_armv7");
    Assert.assertEquals(mobiles.get(0).getPlatform(), "android");
    Assert.assertEquals(mobiles.get(0).getVersion(), "5.1");
    Assert.assertEquals(mobiles.get(0).getBrowsers().size(), 2);
    Assert.assertEquals(mobiles.get(0).getBrowsers().get(0).getBrowser(), BrowserType.BROWSER);
    Assert.assertEquals(mobiles.get(0).getBrowsers().get(0).getVersion(), "6.0");
    Assert.assertEquals(mobiles.get(0).getBrowsers().get(1).getBrowser(), BrowserType.CHROME);
    Assert.assertEquals(mobiles.get(0).getBrowsers().get(1).getVersion(), "56.0");
}
Also used : AdbWrapper(com.seleniumtests.browserfactory.mobile.AdbWrapper) MobileDevice(com.seleniumtests.browserfactory.mobile.MobileDevice) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with MobileDevice

use of com.seleniumtests.browserfactory.mobile.MobileDevice in project seleniumRobot by bhecquet.

the class TestInstrumentsWrapper method testiOSDeviceRetrieving.

@Test(groups = { "ut" })
public void testiOSDeviceRetrieving() {
    PowerMockito.mockStatic(OSCommand.class);
    PowerMockito.mockStatic(OSUtility.class);
    when(OSCommand.executeCommandAndWait("instruments")).thenReturn("instruments, version 8.3.2 (62124)");
    when(OSUtility.getCurrentPlatorm()).thenReturn(Platform.MAC);
    when(OSCommand.executeCommandAndWait("instruments -s devices")).thenReturn("Mac mini de Thoraval [CBFA063D-2535-5FD8-BA05-CE8D3683D6BA]\n" + "Apple TV 1080p (10.2) [6444F65D-DA15-4505-8307-4520FD346ACE] (Simulator)\n" + "iPad Air (10.3) [77FCE24A-EC11-490B-AFA6-D5950EACD33D] (Simulator)\n" + "iPad Air 2 (10.3) [EF9D4D32-285D-4D08-B145-1B704A6E1B14] (Simulator)\n" + "iPad Pro (12.9 inch) (10.3) [D723D123-C176-4CDD-937E-34060F9AC31A] (Simulator)\n" + "iPhone 5 (10.3) [5621105C-180C-438D-9AC4-1361F9BFA553] (Simulator)\n" + "iPhone 6 (10.3) [8CAD959E-4AD2-4CA1-9072-300E1A738027] (Simulator)\n" + "iPhone 6 Plus (10.3) [FEB56FF6-5705-45F6-8D0F-4958ACA91FF5] (Simulator)\n" + "iPhone 7 (10.3) [D11D74FE-A620-403C-BAAA-1E0FF4486238] (Simulator)\n" + "iPhone 7 (10.3) + Apple Watch Series 2 - 38mm (3.2) [84DA8FFA-F743-4EA6-8E98-DC38165B9ACB] (Simulator)\n" + "iPhone SE (10.3.1) [2FD40F1E-45A2-4580-95D4-5B850E438953] (Simulator)");
    InstrumentsWrapper wrapper = new InstrumentsWrapper();
    List<MobileDevice> devs = wrapper.parseIosDevices();
    Assert.assertEquals(devs.size(), 10);
    Assert.assertEquals(devs.get(8).getName(), "iPhone 7");
    Assert.assertEquals(devs.get(3).getName(), "iPad Pro");
    Assert.assertEquals(devs.get(8).getVersion(), "10.3");
    Assert.assertEquals(devs.get(8).getId(), "84DA8FFA-F743-4EA6-8E98-DC38165B9ACB");
    Assert.assertEquals(devs.get(8).getPlatform(), "iOS");
    Assert.assertEquals(devs.get(8).getBrowsers().get(0).getBrowser(), BrowserType.SAFARI);
    Assert.assertEquals(devs.get(9).getVersion(), "10.3.1");
}
Also used : InstrumentsWrapper(com.seleniumtests.browserfactory.mobile.InstrumentsWrapper) MobileDevice(com.seleniumtests.browserfactory.mobile.MobileDevice) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with MobileDevice

use of com.seleniumtests.browserfactory.mobile.MobileDevice in project seleniumRobot by bhecquet.

the class TestMobileDeviceSelector method testSelectiOSNotReady.

@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testSelectiOSNotReady() {
    // available devices
    List<MobileDevice> deviceList = new ArrayList<>();
    deviceList.add(new MobileDevice("IPhone 6", "0000", "iOS", "10.2", new ArrayList<>()));
    when(instrumentsWrapper.parseIosDevices()).thenReturn(deviceList);
    // requested caps
    DesiredCapabilities requestedCaps = new DesiredCapabilities();
    requestedCaps.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
    deviceSelector.setAndroidReady(true);
    deviceSelector.setIosReady(false);
    deviceSelector.getRelevantMobileDevice(requestedCaps);
}
Also used : MobileDevice(com.seleniumtests.browserfactory.mobile.MobileDevice) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with MobileDevice

use of com.seleniumtests.browserfactory.mobile.MobileDevice in project seleniumRobot by bhecquet.

the class TestMobileDeviceSelector method testSelectWithoutMobileCapabilities.

/**
 * Test that an error is raised when no mobile capability is found (DEVICE_NAME, PLATFORM_NAME, PLATFORM_VERSION)
 */
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testSelectWithoutMobileCapabilities() {
    // available devices
    List<MobileDevice> deviceList = new ArrayList<>();
    when(adbWrapper.getDeviceList()).thenReturn(deviceList);
    // requested caps
    DesiredCapabilities requestedCaps = new DesiredCapabilities();
    requestedCaps.setCapability(CapabilityType.BROWSER_NAME, "firefox");
    deviceSelector.setAndroidReady(true);
    deviceSelector.setIosReady(false);
    deviceSelector.getRelevantMobileDevice(requestedCaps);
}
Also used : MobileDevice(com.seleniumtests.browserfactory.mobile.MobileDevice) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with MobileDevice

use of com.seleniumtests.browserfactory.mobile.MobileDevice in project seleniumRobot by bhecquet.

the class TestMobileDeviceSelector method testSelectAndroidNotReady.

@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testSelectAndroidNotReady() {
    // available devices
    List<MobileDevice> deviceList = new ArrayList<>();
    deviceList.add(new MobileDevice("Nexus 5", "1234", "android", "5.0", new ArrayList<>()));
    when(adbWrapper.getDeviceList()).thenReturn(deviceList);
    // requested caps
    DesiredCapabilities requestedCaps = new DesiredCapabilities();
    requestedCaps.setCapability(MobileCapabilityType.PLATFORM_NAME, "android");
    deviceSelector.setAndroidReady(false);
    deviceSelector.setIosReady(false);
    deviceSelector.getRelevantMobileDevice(requestedCaps);
}
Also used : MobileDevice(com.seleniumtests.browserfactory.mobile.MobileDevice) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

MobileDevice (com.seleniumtests.browserfactory.mobile.MobileDevice)16 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)16 Test (org.testng.annotations.Test)16 ArrayList (java.util.ArrayList)14 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)13 MockitoTest (com.seleniumtests.MockitoTest)12 GenericDriverTest (com.seleniumtests.GenericDriverTest)4 ReporterTest (com.seleniumtests.it.reporter.ReporterTest)4 ExistingAppiumLauncher (com.seleniumtests.browserfactory.mobile.ExistingAppiumLauncher)3 URL (java.net.URL)3 Capabilities (org.openqa.selenium.Capabilities)3 MutableCapabilities (org.openqa.selenium.MutableCapabilities)3 BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)2 AndroidDriver (io.appium.java_client.android.AndroidDriver)2 AdbWrapper (com.seleniumtests.browserfactory.mobile.AdbWrapper)1 InstrumentsWrapper (com.seleniumtests.browserfactory.mobile.InstrumentsWrapper)1 LocalAppiumLauncher (com.seleniumtests.browserfactory.mobile.LocalAppiumLauncher)1 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)1 IOSDriver (io.appium.java_client.ios.IOSDriver)1 SkipException (org.testng.SkipException)1