Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
appium-uiautomator2-server/app/src/androidTestServer/java/io/appium/uiautomator2/server/test/AppiumUiAutomator2Server.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
40 lines (33 sloc)
1.29 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.appium.uiautomator2.server.test; | |
import android.os.SystemClock; | |
import androidx.test.runner.AndroidJUnit4; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import io.appium.uiautomator2.common.exceptions.SessionRemovedException; | |
import io.appium.uiautomator2.server.ServerInstrumentation; | |
import io.appium.uiautomator2.utils.Logger; | |
@RunWith(AndroidJUnit4.class) | |
public class AppiumUiAutomator2Server { | |
private static ServerInstrumentation serverInstrumentation; | |
/** | |
* Starts the server on the device. | |
* !!! This class is the main entry point for UIA2 driver package. | |
* !!! Do not rename or move it unless you know what you are doing. | |
*/ | |
@Test | |
public void startServer() { | |
if (serverInstrumentation == null) { | |
serverInstrumentation = ServerInstrumentation.getInstance(); | |
Logger.info("[AppiumUiAutomator2Server]", " Starting Server"); | |
try { | |
while (!serverInstrumentation.isServerStopped()) { | |
SystemClock.sleep(1000); | |
serverInstrumentation.startMjpegServer(); | |
serverInstrumentation.startServer(); | |
} | |
} catch (SessionRemovedException e) { | |
//Ignoring SessionRemovedException | |
} | |
} | |
} | |
} | |