當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。