当前位置: 首页>>代码示例>>Java>>正文


Java ScreenOrientation类代码示例

本文整理汇总了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));
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-client,代码行数:24,代码来源:GetUiElementImageTest.java

示例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));
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-client,代码行数:24,代码来源:GetUiElementImageTest.java

示例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));
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-client,代码行数:24,代码来源:GetUiElementImageTest.java

示例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));
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-client,代码行数:25,代码来源:GetUiElementImageTest.java

示例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);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:9,代码来源:GetScreenshotTest.java

示例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);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:8,代码来源:ScreenOrientationTest.java

示例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);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:9,代码来源:ScreenOrientationTest.java

示例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);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:8,代码来源:ScreenOrientationTest.java

示例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);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:9,代码来源:ScreenOrientationTest.java

示例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;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:18,代码来源:DeviceSettingsEntity.java

示例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;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:21,代码来源:DeviceSettingsEntity.java

示例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);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-client,代码行数:20,代码来源:UiElement.java

示例13: testThrowsExceptionOnSetScreenOrientation

import com.musala.atmosphere.commons.ScreenOrientation; //导入依赖的package包/类
@Test(expected = ServerConnectionFailedException.class)
public void testThrowsExceptionOnSetScreenOrientation() {
    testDevice.setScreenOrientation(ScreenOrientation.LANDSCAPE);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-client,代码行数:5,代码来源:ReconnectDeviceTest.java

示例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);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:17,代码来源:OnDeviceValidatorAssert.java

示例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);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-client,代码行数:10,代码来源:Device.java


注:本文中的com.musala.atmosphere.commons.ScreenOrientation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。