本文整理汇总了Java中com.musala.atmosphere.commons.ScreenOrientation类的典型用法代码示例。如果您正苦于以下问题:Java ScreenOrientation类的具体用法?Java ScreenOrientation怎么用?Java ScreenOrientation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScreenOrientation类属于com.musala.atmosphere.commons包,在下文中一共展示了ScreenOrientation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetUiElementImageLandscape
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
@Test
public void testGetUiElementImageLandscape() throws Exception {
Path screenshotLandscapeImagePath = Paths.get(TestResources.SCREENSHOT_LANDSCAPE_PATH);
byte[] screenshotLandscapeData = Files.readAllBytes(screenshotLandscapeImagePath);
deviceInformation.setResolution(resolutionLandscape);
when(mockedDevice.getInformation()).thenReturn(deviceInformation);
when(mockedDevice.getScreenOrientation()).thenReturn(ScreenOrientation.LANDSCAPE);
when(mockedDevice.getScreenshot()).thenReturn(screenshotLandscapeData);
when(propertiesContainer.getBounds()).thenReturn(boundsLandscape);
File expectedImageFile = new File(TestResources.ELEMENT_LANDSCAPE_PATH);
BufferedImage expectedBufferedElementImage = ImageIO.read(expectedImageFile);
Image expectedImage = new Image(expectedBufferedElementImage);
when(element.getElementImage()).thenReturn(expectedImage);
Image elementImage = element.getElementImage();
assertTrue(RECEIVED_DIFFERENT_IMAGES_MESSAGE, expectedImage.equals(elementImage));
assertTrue(RECEIVED_DIFFERENT_IMAGES_MESSAGE, elementImage.equals(expectedImage));
}
示例2: testGetUiElementImageUpsideDownLandscape
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
@Test
public void testGetUiElementImageUpsideDownLandscape() throws Exception {
Path screenshotUpsideDownLandscapeImagePath = Paths.get(TestResources.SCREENSHOT_UPSIDE_DOWN_LANDSCAPE_PATH);
byte[] screenshotUpsideDownLandscapeData = Files.readAllBytes(screenshotUpsideDownLandscapeImagePath);
deviceInformation.setResolution(resolutionLandscape);
when(mockedDevice.getInformation()).thenReturn(deviceInformation);
when(mockedDevice.getScreenOrientation()).thenReturn(ScreenOrientation.UPSIDE_DOWN_LANDSCAPE);
when(mockedDevice.getScreenshot()).thenReturn(screenshotUpsideDownLandscapeData);
when(propertiesContainer.getBounds()).thenReturn(boundsLandscape);
File expectedImageFile = new File(TestResources.ELEMENT_UPSIDE_DOWN_LANDSCAPE_PATH);
BufferedImage expectedBufferedElementImage = ImageIO.read(expectedImageFile);
Image expectedImage = new Image(expectedBufferedElementImage);
when(element.getElementImage()).thenReturn(expectedImage);
Image elementImage = element.getElementImage();
assertTrue(RECEIVED_DIFFERENT_IMAGES_MESSAGE, expectedImage.equals(elementImage));
assertTrue(RECEIVED_DIFFERENT_IMAGES_MESSAGE, elementImage.equals(expectedImage));
}
示例3: testGetUiElementImagePortrait
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
@Test
public void testGetUiElementImagePortrait() throws Exception {
Path screenshotPortraitImagePath = Paths.get(TestResources.SCREENSHOT_PORTRAIT_PATH);
byte[] screenshotPortraitData = Files.readAllBytes(screenshotPortraitImagePath);
deviceInformation.setResolution(resolutionPortrait);
when(mockedDevice.getInformation()).thenReturn(deviceInformation);
when(mockedDevice.getScreenOrientation()).thenReturn(ScreenOrientation.PORTRAIT);
when(mockedDevice.getScreenshot()).thenReturn(screenshotPortraitData);
when(propertiesContainer.getBounds()).thenReturn(boundsPortrait);
File expectedImageFile = new File(TestResources.ELEMENT_PORTRAIT_PATH);
BufferedImage expectedBufferedElementImage = ImageIO.read(expectedImageFile);
Image expectedImage = new Image(expectedBufferedElementImage);
when(element.getElementImage()).thenReturn(expectedImage);
Image elementImage = element.getElementImage();
assertTrue(RECEIVED_DIFFERENT_IMAGES_MESSAGE, expectedImage.equals(elementImage));
assertTrue(RECEIVED_DIFFERENT_IMAGES_MESSAGE, elementImage.equals(expectedImage));
}
示例4: testGetUiElementImageUpsideDownPortrait
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
@Test
public void testGetUiElementImageUpsideDownPortrait() throws Exception {
Path screenshotUpsideDownPortraitImagePath = Paths.get(TestResources.SCREENSHOT_UPSIDE_DOWN_PORTRAIT_PATH);
byte[] screenshotUpsideDownPortraitData = Files.readAllBytes(screenshotUpsideDownPortraitImagePath);
deviceInformation.setResolution(resolutionPortrait);
when(mockedDevice.getInformation()).thenReturn(deviceInformation);
when(mockedDevice.getScreenOrientation()).thenReturn(ScreenOrientation.UPSIDE_DOWN_PORTRAIT);
when(mockedDevice.getScreenshot()).thenReturn(screenshotUpsideDownPortraitData);
when(propertiesContainer.getBounds()).thenReturn(boundsPortrait);
File expectedImageFile = new File(TestResources.ELEMENT_UPSIDE_DOWN_PORTRAIT_PATH);
BufferedImage expectedBufferedElementImage = ImageIO.read(expectedImageFile);
Image expectedImage = new Image(expectedBufferedElementImage);
when(element.getElementImage()).thenReturn(expectedImage);
Image elementImage = element.getElementImage();
assertTrue(RECEIVED_DIFFERENT_IMAGES_MESSAGE, expectedImage.equals(elementImage));
assertTrue(RECEIVED_DIFFERENT_IMAGES_MESSAGE, elementImage.equals(expectedImage));
}
示例5: setUp
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().deviceType(DeviceType.DEVICE_PREFERRED);
DeviceSelector testDeviceSelector = selectorBuilder.build();
initTestDevice(testDeviceSelector);
testDevice.setScreenOrientation(ScreenOrientation.PORTRAIT);
}
示例6: testSettingScreenOrientationPortrait
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
@Test
public void testSettingScreenOrientationPortrait() throws Exception {
assertTrue("Setting screen orientation returned false.",
testDevice.setScreenOrientation(ScreenOrientation.PORTRAIT));
Thread.sleep(OPERATION_TIMEOUT);
assertScreenOrientation("Screen rotation expected to be portrait", ScreenOrientation.PORTRAIT);
}
示例7: testSettingScreenOrientationUpsideDownPortrait
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
@Test
public void testSettingScreenOrientationUpsideDownPortrait() throws Exception {
assertTrue("Setting screen orientation returned false.",
testDevice.setScreenOrientation(ScreenOrientation.UPSIDE_DOWN_PORTRAIT));
Thread.sleep(OPERATION_TIMEOUT);
assertScreenOrientation("Screen rotation expected to be upside down portrait",
ScreenOrientation.UPSIDE_DOWN_PORTRAIT);
}
示例8: testSettingScreenOrientationLandscape
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
@Test
public void testSettingScreenOrientationLandscape() throws Exception {
assertTrue("Setting screen orientation returned false.",
testDevice.setScreenOrientation(ScreenOrientation.LANDSCAPE));
Thread.sleep(OPERATION_TIMEOUT);
assertScreenOrientation("Screen rotation expected to be landscape", ScreenOrientation.LANDSCAPE);
}
示例9: testSettingScreenOrientationUpsideDown
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
@Test
public void testSettingScreenOrientationUpsideDown() throws Exception {
assertTrue("Setting screen orientation returned false.",
testDevice.setScreenOrientation(ScreenOrientation.UPSIDE_DOWN_LANDSCAPE));
Thread.sleep(OPERATION_TIMEOUT);
assertScreenOrientation("Screen rotation expected to be upside down landscape",
ScreenOrientation.UPSIDE_DOWN_LANDSCAPE);
}
示例10: getScreenOrientation
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
/**
* Gets a {@link ScreenOrientation} instance that contains information about the orientation of the screen.
*
* @return {@link ScreenOrientation object} that shows how android elements are rotated on the screen
* @see ScreenOrientation
*/
public ScreenOrientation getScreenOrientation() {
ScreenOrientation screenOrientation = null;
try {
int obtainedScreenOrientationValue = deviceSettingsManager.getInt(AndroidSystemSettings.USER_ROTATION);
screenOrientation = ScreenOrientation.getValueOfInt(obtainedScreenOrientationValue);
} catch (SettingsParsingException e) {
LOGGER.error("Failed to get screen orientation of the device.", e);
}
return screenOrientation;
}
示例11: setScreenOrientation
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
/**
* Sets new screen orientation for this device.<br>
* Implicitly turns off screen auto rotation.
*
* @param screenOrientation
* - new {@link ScreenOrientation ScreenOrientation} to be set
* @return <code>true</code> if the screen orientation setting is successful, <code>false</code> if it fails
*/
public boolean setScreenOrientation(ScreenOrientation screenOrientation) {
if (!disableScreenAutoRotation()) {
String message = "Screen orientation was not set due to setting auto rotation failure.";
LOGGER.error(message);
return false;
}
boolean success = deviceSettingsManager.putInt(AndroidSystemSettings.USER_ROTATION,
screenOrientation.getOrientationNumber());
return success;
}
示例12: getElementImage
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
/**
* Crops this {@link UiElement} as an image, using the bounds of the element.
*
* @return {@link Image} contained in the element's bounds
* @throws IOException
* - if getting screenshot from the device fails
*/
public Image getElementImage() throws IOException {
byte[] imageInByte = (byte[]) communicator.sendAction(RoutingAction.GET_SCREENSHOT);
InputStream inputStream = new ByteArrayInputStream(imageInByte);
BufferedImage bufferedImage = ImageIO.read(inputStream);
Bounds elementBounds = propertiesContainer.getBounds();
Pair<Integer, Integer> resolution = getDeviceResolution();
ScreenOrientation screenOrientation = (ScreenOrientation) communicator.sendAction(RoutingAction.GET_SCREEN_ORIENTATION);
Image newImage = new Image(bufferedImage);
return newImage.getSubimage(elementBounds, screenOrientation, resolution);
}
示例13: testThrowsExceptionOnSetScreenOrientation
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
@Test(expected = ServerConnectionFailedException.class)
public void testThrowsExceptionOnSetScreenOrientation() {
testDevice.setScreenOrientation(ScreenOrientation.LANDSCAPE);
}
示例14: assertScreenOrientation
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
/**
* Asserts that the screen rotation of the test device has been set to the expected value.
*
* @param message
* - message to be displayed if assertion fails.
* @param expected
* - the expected screen orientation.
* @throws UiElementFetchingException
*/
public static void assertScreenOrientation(String message, ScreenOrientation expected)
throws UiElementFetchingException {
UiElementSelector screenOrientationSelector = createSelectorByTextAndContentDescriptor(ContentDescriptor.SCREEN_ORIENTATION_BOX,
String.valueOf(expected.getOrientationNumber()));
assertElementExists(message, screenOrientationSelector);
}
示例15: getScreenOrientation
import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
/**
* Gets a {@link ScreenOrientation} instance that contains information about the orientation of the screen.
*
* @return {@link ScreenOrientation object} that shows how android elements are rotated on the screen.
* @see ScreenOrientation
*/
public ScreenOrientation getScreenOrientation() {
return (ScreenOrientation) communicator.sendAction(RoutingAction.GET_SCREEN_ORIENTATION);
}