• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java UiElementSelector类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.musala.atmosphere.commons.ui.selector.UiElementSelector的典型用法代码示例。如果您正苦于以下问题:Java UiElementSelector类的具体用法?Java UiElementSelector怎么用?Java UiElementSelector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

UiElementSelector类属于com.musala.atmosphere.commons.ui.selector包,在下文中一共展示了UiElementSelector类的39个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: uiElementSelectorDeserializatinTest

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void uiElementSelectorDeserializatinTest() {
    String jsonMessage = readFile(jsonPath + "uiElementSelectorDeserializatinTest.txt");

    RequestMessage requestMessage = jsonUtil.deserializeRequest(jsonMessage);

    UiElementSelector uiElementSelector = (UiElementSelector) (requestMessage.getArguments()[0]);

    Assert.assertEquals(uiElementSelector.getClassName(), "android.widget.NumberPicker");
    Assert.assertEquals(uiElementSelector.getStringValue(CssAttribute.CLASS_NAME), "android.widget.NumberPicker");
    Assert.assertEquals(uiElementSelector.getStringValueWithSelectionOption(CssAttribute.CLASS_NAME).getKey(),
                        "android.widget.NumberPicker");
    Assert.assertEquals(uiElementSelector.getStringValueWithSelectionOption(CssAttribute.CLASS_NAME)
                                         .getValue()
                                         .name(),
                        "EQUALS");
    Assert.assertEquals(uiElementSelector.getIndex(), new Integer(1));
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-commons,
代码行数:19,
代码来源:UiElementSelectorDeserializationTest.java

示例2: getTimePicker

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Gets an instance for android TimePicker widgets.
 *
 * @return a {@link TimePicker} object representing the only time picker widget on screen.
 * @throws UiElementFetchingException
 *         if no active time pickers are found in the screen
 * @throws MultipleElementsFoundException
 *         if there are more than one time pickers
 */
public TimePicker getTimePicker() throws MultipleElementsFoundException, UiElementFetchingException {
    String message = String.format(PICKERS_MESSAGE, "time");
    UiElementSelector timePickerSelector = new UiElementSelector();
    timePickerSelector.addSelectionAttribute(CssAttribute.CLASS_NAME, TIME_PICKER_WIDGET);

    try {
        getElement(timePickerSelector);
    } catch (MultipleElementsFoundException e) {
        message = String.format(MULTIPLE_PICKERS_AVAILABLE_MESSAGE, "time");
        LOGGER.error(message, e);
        throw new MultipleElementsFoundException(message, e);
    }

    return new TimePicker(this);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-client,
代码行数:25,
代码来源:Screen.java

示例3: nodeAttributeMapConstructorTest

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void nodeAttributeMapConstructorTest() {
    Map<String, String> nodeAttributeMap = new HashMap<>();
    nodeAttributeMap.put("bounds", "[10,15][200,100]");
    nodeAttributeMap.put("index", "5");
    nodeAttributeMap.put("content-desc", "my-content");
    nodeAttributeMap.put("text", "my-text");
    nodeAttributeMap.put("long-clickable", "true");
    nodeAttributeMap.put("password", "false");
    // Empty strings should be skipped
    nodeAttributeMap.put("package", "");
    String[] expectedExpressions = {"[bounds=[10,15][200,100]]", "[index=5]", "[content-desc=my-content]",
            "[text=my-text]", "[long-clickable=true]", "[password=false]"};
    uiElementSelector = new UiElementSelector(nodeAttributeMap);
    String query = uiElementSelector.buildCssQuery();
    assertCssQuery(query, expectedExpressions);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-client,
代码行数:18,
代码来源:UiElementSelectorTest.java

示例4: getNumberPickerField

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Gets the editText field of a picker with a given index.
 * 
 * @param index
 *        - the index of the picker, we are interested in.
 * @return The editText field of the given picker.
 * @throws UiElementFetchingException
 *         if no elements are found for the passed query
 * @throws MultipleElementsFoundException
 *         if multiple elements are found for the passed query
 */
public UiElement getNumberPickerField(int index) throws MultipleElementsFoundException, UiElementFetchingException {
    UiElement numberPicker = getNumberPicker(index);

    UiElementSelector textFieldSelector = new UiElementSelector();
    textFieldSelector.addSelectionAttribute(CssAttribute.CLASS_NAME, TEXT_WIDGET);

    List<UiElement> children = numberPicker.getChildren(textFieldSelector);

    if (children.isEmpty()) {
        throw new UiElementFetchingException("Cannot retrieve number picker field.");
    }

    UiElement numberPickerField = children.get(0);

    return numberPickerField;
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-client,
代码行数:28,
代码来源:PickerHelper.java

示例5: extract

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Extracts the attributes from a {@link UiElementPropertiesContainer} instance to a {@link UiElementSelector}.
 * 
 * @param propertiesContainer
 *        - {@link UiElementPropertiesContainer} instance from which we get the attributes
 * @return a {@link UiElementSelector} instance containing the {@link UiElementPropertiesContainer} attributes
 */
public static UiElementSelector extract(UiElementPropertiesContainer propertiesContainer) {
    UiElementSelector elementSelector = new UiElementSelector();
    elementSelector.addSelectionAttribute(CssAttribute.CHECKED, propertiesContainer.isChecked());
    elementSelector.addSelectionAttribute(CssAttribute.CHECKABLE, propertiesContainer.isCheckable());
    elementSelector.addSelectionAttribute(CssAttribute.CLASS_NAME, propertiesContainer.getClassName());
    elementSelector.addSelectionAttribute(CssAttribute.CLICKABLE, propertiesContainer.isClickable());
    elementSelector.addSelectionAttribute(CssAttribute.CONTENT_DESCRIPTION, propertiesContainer.getContentDescriptor());
    elementSelector.addSelectionAttribute(CssAttribute.ENABLED, propertiesContainer.isEnabled());
    elementSelector.addSelectionAttribute(CssAttribute.FOCUSABLE, propertiesContainer.isFocusable());
    elementSelector.addSelectionAttribute(CssAttribute.FOCUSED, propertiesContainer.isFocused());
    elementSelector.addSelectionAttribute(CssAttribute.INDEX, propertiesContainer.getIndex());
    elementSelector.addSelectionAttribute(CssAttribute.CLICKABLE, propertiesContainer.isLongClickable());
    elementSelector.addSelectionAttribute(CssAttribute.PACKAGE_NAME, propertiesContainer.getPackageName());
    elementSelector.addSelectionAttribute(CssAttribute.SCROLLABLE, propertiesContainer.isScrollable());
    elementSelector.addSelectionAttribute(CssAttribute.SELECTED, propertiesContainer.isSelected());
    elementSelector.addSelectionAttribute(CssAttribute.TEXT, propertiesContainer.getText());
    elementSelector.addSelectionAttribute(CssAttribute.RESOURCE_ID, propertiesContainer.getResourceId());

    return elementSelector;
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-client,
代码行数:28,
代码来源:UiElementAttributeExtractor.java

示例6: testGetListOfVisibleUiElements

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void testGetListOfVisibleUiElements() throws Exception {
    int expectedFoundElements = 3;
    UiElementSelector elementSelector = new UiElementSelector();
    elementSelector.addSelectionAttribute(CssAttribute.CLASS_NAME, BUTTON_CLASS_NAME);

    List<UiElement> foundElements = screen.getElements(elementSelector);

    assertEquals("The number of found elements is different than expected.",
                 expectedFoundElements,
                 foundElements.size());

    for (UiElement element : foundElements) {
        assertEquals("The found element has different field values than the selector.",
                     BUTTON_CLASS_NAME,
                     element.getProperties().getClassName());
    }
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:19,
代码来源:GetAccessibilityUiElementsTest.java

示例7: testMockLocationSameProviderSeveralTimes

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void testMockLocationSameProviderSeveralTimes() throws Exception {
    assertLocation(LOCATION_MOCK_UNSUCCESSFUL, defaultMonitoredProviderLocation);

    GeoLocation secondMockLocation = new GeoLocation(SAN_FRANCISCO_LATITUDE,
                                                     SAN_FRANCISCO_LONGITUDE,
                                                     MONITORED_PROVIDER_NAME);
    secondMockLocation.setAltitude(SAN_FRANCISCO_ALTITUDE);

    boolean isMockSuccessful = testDevice.mockLocation(secondMockLocation);
    assertTrue(FAILURE_INDICATED_ERROR_MESSAGE, isMockSuccessful);

    UiElementSelector coordinatesSelector = new UiElementSelector();
    coordinatesSelector.addSelectionAttribute(CssAttribute.TEXT, EXPECTED_GPS_COORDINATES);
    screen.waitForElementExists(coordinatesSelector, WAIT_FOR_EXPECTED_COORDINATES_TIMEOUT);

    assertLocation(LOCATION_MOCK_UNSUCCESSFUL, secondMockLocation);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:19,
代码来源:MockLocationTest.java

示例8: tapElementWithText

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Tap on {@link UiElement}, displaying exactly the supplied search text.
 *
 * @param text
 *        - search text.
 * @param match
 *        - determines which element to tap if multiple matches exist; zero based index.
 * @return <code>true</code> if the tapping of element is successful, <code>false</code> if it fails.
 * @throws UiElementFetchingException
 *         if no elements or more than 1 are found for the passed query
 */
public boolean tapElementWithText(String text, int match) throws UiElementFetchingException {
    UiElementSelector selector = new UiElementSelector();
    selector.addSelectionAttribute(CssAttribute.TEXT, UiElementSelectionOption.EQUALS, text);
    List<UiElement> elementList = getElements(selector);
    int listSize = elementList.size();
    if (listSize <= match) {
        String message = String.format("Tapping match with index %s requested, but only %s elements matching the criteria found.",
                                       match,
                                       listSize);
        LOGGER.error(message);
        throw new UiElementFetchingException(message);
    }
    UiElement element = elementList.get(match);
    return element.tap();
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-client,
代码行数:27,
代码来源:Screen.java

示例9: find

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Finds all elements in the hierarchy of {@link AccessibilityNodeInfo accessibility nodes} that are matching the
 * given {@link UiElementSelector selector} and {@link UiElementMatcher matcher}.
 *
 * @param matcher
 *        - defines the strategy for matching the given {@link UiElementSelector selector} and node from the
 *        hierarchy
 * @param selector
 *        - contains the properties which accessibility nodes should match
 * @param visibleOnly
 *        - if <code>true</code> only the visible nodes will be used; if <code>false</code> all nodes will be used
 * @return list of {@link AccessibilityElement} that matches the given element {@link UiElementSelector properties}
 */
public List<AccessibilityElement> find(UiElementMatcher<UiElementSelector> matcher,
                                       UiElementSelector selector,
                                       boolean visibleOnly) {
    List<AccessibilityElement> matchingElements = new ArrayList<AccessibilityElement>();

    if (isMatchFound(localRootNodeInfo, selector, matcher, ROOT_NODE_INDEX)) {
        Stack<Integer> pathIndexes = new Stack<Integer>();
        AccessibilityElementBuilder accessibilityElementBuilder = AccessibilityFactory.getAccessibilityElementBuilder();
        AccessibilityElement rootAccessibilityElement = accessibilityElementBuilder.build(localRootNodeInfo,
                                                                                          pathIndexes,
                                                                                          pathToLocalRoot,
                                                                                          ROOT_NODE_INDEX);
        matchingElements.add(rootAccessibilityElement);
    }

    matchingElements.addAll(getChildren(matcher, selector, false, visibleOnly));

    return matchingElements;
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-uiautomator-bridge,
代码行数:33,
代码来源:AccessibilityNodeTraverser.java

示例10: testGetChildrenThatMatchSelectorAttributes

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void testGetChildrenThatMatchSelectorAttributes() throws Exception {
    int expectedChildrenCount = 3;
    UiElementSelector parentSelector = new UiElementSelector();
    parentSelector.addSelectionAttribute(CssAttribute.CLASS_NAME, ANDROID_WIDGET_RELATIVE_LAYOUT);
    UiElement parent = screen.getElement(parentSelector);

    UiElementSelector childSelector = new UiElementSelector();
    childSelector.addSelectionAttribute(CssAttribute.CLASS_NAME, ANDROID_WIDGET_BUTTON);
    List<UiElement> children = parent.getChildren(childSelector);

    assertEquals(MISSMATCH_CHILDREN_COUNT_ERROR_MESSAGE, expectedChildrenCount, children.size());

    for (UiElement child : children) {
        assertEquals(ELEMENT_PROPERTY_MISSMATCH_MESSAGE,
                     ANDROID_WIDGET_BUTTON,
                     child.getProperties().getClassName());
    }
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:20,
代码来源:GetAccessibilityUiElementChildrenTest.java

示例11: getChangeStateWidget

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Override
protected UiElementPropertiesContainer getChangeStateWidget() throws UiElementFetchingException, CommandFailedException {
    UiElementSelector checkBoxWidgetSelector = new UiElementSelector();
    checkBoxWidgetSelector.addSelectionAttribute(CssAttribute.CLASS_NAME, ANDROID_WIDGET_CHECK_BOX_CLASS_NAME);

    automatorCommunicator.waitForExists(checkBoxWidgetSelector, CHANGE_STATE_WIDGET_TIMEOUT);

    List<AccessibilityElement> widgetList = automatorCommunicator.getUiElements(checkBoxWidgetSelector, true);

    if (!widgetList.isEmpty()) {
        // There are more than one check box on the screen, but only the first one is for setting the GPS location
        // state.
        return widgetList.get(0);
    }

    return null;
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-agent,
代码行数:18,
代码来源:GpsLocationCheckBoxEntity.java

示例12: testDisableMockLocation

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void testDisableMockLocation() throws Exception {
    GeoLocation mockLocation = new GeoLocation(DEFAULT_LATITUDE, DEFAULT_LONGITUDE, TEST_PROVIDER);
    testDevice.mockLocation(mockLocation);
    startLocationActivity();
    Thread.sleep(PROVIDER_CONNECT_TIMEOUT);

    testDevice.disableMockLocation(TEST_PROVIDER);
    UiElementSelector disabledProviderIndicatorSelector = new UiElementSelector();
    disabledProviderIndicatorSelector.addSelectionAttribute(CssAttribute.CONTENT_DESCRIPTION,
                                                            ContentDescriptor.PROVIDER_DISCONNECT_MONITOR.toString());
    disabledProviderIndicatorSelector.addSelectionAttribute(CssAttribute.TEXT, DISABLED_TEXT);

    Screen deviceActiveScreen = testDevice.getActiveScreen();
    boolean isProviderDisalbed = deviceActiveScreen.waitForElementExists(disabledProviderIndicatorSelector,
                                                                         DISABLE_WAIT_TIMEOUT);
    assertTrue("Provider monitor did not indicate that the test provider is disabled.", isProviderDisalbed);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:19,
代码来源:DisableMockLocationTest.java

示例13: testOpenNotification

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void testOpenNotification() throws Exception {
    assumeNotNull(testDevice);

    setTestDevice(testDevice);

    UiElementSelector notificationBarSelector = new UiElementSelector();
    notificationBarSelector.addSelectionAttribute(CssAttribute.RESOURCE_ID, NOTIFICATION_BAR_RESOURCE_ID);

    Screen deviceActiveScreen = testDevice.getActiveScreen();
    try {
        deviceActiveScreen.getElement(notificationBarSelector);
        fail("The notification bar was already opened");
    } catch (UiElementFetchingException e) {
        testDevice.openNotificationBar();
        try {
            deviceActiveScreen.waitForElementExists(notificationBarSelector, NOTIFICATION_BAR_TIMEOUT);
            deviceActiveScreen.getElement(notificationBarSelector);
        } catch (UiElementFetchingException exception) {
            fail("The notification bar was not opened.");
        }
    }
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:24,
代码来源:OpenNotificationTest.java

示例14: testGetFreeDiskSpace

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void testGetFreeDiskSpace() throws Exception {
    Screen screen = testDevice.getActiveScreen();

    UiElementSelector showFreeSpaceButtonSelector = new UiElementSelector();
    showFreeSpaceButtonSelector.addSelectionAttribute(CssAttribute.RESOURCE_ID, SHOW_FREE_SPACE_BUTTON_RESOURCE_ID);
    UiElement showFreeSpaceButtonElement = screen.getElement(showFreeSpaceButtonSelector);
    showFreeSpaceButtonElement.tap();

    UiElementSelector freeSpaceTextBoxSelector = new UiElementSelector();
    freeSpaceTextBoxSelector.addSelectionAttribute(CssAttribute.RESOURCE_ID, FREE_SPACE_RESULT_RESOURCE_ID);
    UiElement freeSpaceTextBox = screen.getElement(freeSpaceTextBoxSelector);
    Long expectedFreeSpace = Long.valueOf(freeSpaceTextBox.getText());
    Long freeSpace = testDevice.getAvailableDiskSpace();

    assertEquals("The actual free disk space does not match the expected one.", expectedFreeSpace, freeSpace);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:18,
代码来源:DiskSpaceTest.java

示例15: testDragToPoint

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void testDragToPoint() throws Exception {
    Screen deviceScreen = testDevice.getActiveScreen();

    UiElementSelector imageElementSelector = new UiElementSelector();
    imageElementSelector.addSelectionAttribute(CssAttribute.RESOURCE_ID, IMAGE_ELEMENT_ID);
    UiElement imageElement = deviceScreen.getElement(imageElementSelector);

    UiElementSelector textElementSelector = new UiElementSelector();
    textElementSelector.addSelectionAttribute(CssAttribute.RESOURCE_ID, TEXT_ELEMENT_ID);
    UiElement texElement = deviceScreen.getElement(textElementSelector);

    Point destinationPoint = texElement.getProperties().getBounds().getCenter();
    imageElement.drag(destinationPoint);

    deviceScreen.updateScreen();
    imageElement = deviceScreen.getElement(imageElementSelector);
    Point actualPoint = imageElement.getProperties().getBounds().getCenter();
    assertEquals(MESSAGE_TEST_FAIL, destinationPoint, actualPoint);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:21,
代码来源:DragTest.java

示例16: getDatePicker

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Gets the date picker currently on screen.
 *
 * @return a {@link DatePicker} object representing the time picker widget on screen.
 * @throws UiElementFetchingException
 *         if there is no date picker available on the screen
 * @throws MultipleElementsFoundException
 *         if multiple date pickers are present on the screen
 */
public DatePicker getDatePicker() throws UiElementFetchingException, MultipleElementsFoundException {
    String message = String.format(PICKERS_MESSAGE, "date");
    UiElementSelector timePickerSelector = new UiElementSelector();
    timePickerSelector.addSelectionAttribute(CssAttribute.CLASS_NAME, DATE_PICKER_WIDGET);

    try {
        getElement(timePickerSelector);
    } catch (MultipleElementsFoundException e) {
        message = String.format(MULTIPLE_PICKERS_AVAILABLE_MESSAGE, "date");
        LOGGER.error(message, e);
        throw new MultipleElementsFoundException();
    }

    return new DatePicker(this);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-client,
代码行数:25,
代码来源:Screen.java

示例17: setUp

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().deviceType(DeviceType.DEVICE_PREFERRED);
    DeviceSelector testDeviceSelector = selectorBuilder.build();
    initTestDevice(testDeviceSelector);
    setTestDevice(testDevice);

    startLogCatActivity();

    Screen screen = testDevice.getActiveScreen();
    UiElementSelector logsButtonSelector = new UiElementSelector();
    logsButtonSelector.addSelectionAttribute(CssAttribute.CONTENT_DESCRIPTION, LOG_CAT_BUTTON_CONTENT_DECRIPTOR);

    screen.waitForElementExists(logsButtonSelector, WAIT_FOR_ELEMENT_TIMEOUT);
    generateLogsButton = screen.getElement(logsButtonSelector);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:17,
代码来源:LogCatFiltersTest.java

示例18: testScrollToElementBySelector

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void testScrollToElementBySelector() throws Exception {
    ScrollableView scrollableView = getScrollableView(ContentDescriptor.HORIZONTAL_SCROLL_VIEW_VALIDATOR.toString());
    scrollableView.setAsHorizontalScrollableView();
    UiElement scrollToEndButton = getElementByContentDescriptor(ContentDescriptor.SCROLL_TO_END_BUTTON.toString());
    scrollToEndButton.tap();

    assertScrollToEnd("Failure detected, could not scroll to end.");

    UiElementSelector innerViewSelector = new UiElementSelector();
    innerViewSelector.addSelectionAttribute(CssAttribute.TEXT, SCROLL_TO_TEXT);

    assertUIElementNotOnScreen("Element is already visible", innerViewSelector);
    Boolean hasScrolled = scrollableView.scrollToElementBySelector(MAX_SWIPES, innerViewSelector);

    assertTrue("Failure detected, scroll to element by selector returned false.", hasScrolled);
    assertUIElementOnScreen("Failure detected, the UiElement is not on screen", innerViewSelector);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:19,
代码来源:HorizontalScrollTest.java

示例19: testRevalidateTemporaryExistingElement

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void testRevalidateTemporaryExistingElement() throws Exception {
    UiElementSelector selector = new UiElementSelector();
    selector.addSelectionAttribute(CssAttribute.CONTENT_DESCRIPTION,
                                   ContentDescriptor.CHANGING_TEXT_BUTTON_DESCRIPTOR.toString());
    Screen activeScreen = testDevice.getActiveScreen();
    boolean isPresent = activeScreen.waitForElementExists(selector, ELEMENT_WAIT_TIMEOUT);
    assertTrue("Wait for element existance returned false.", isPresent);

    UiElement changingTextButton = activeScreen.getElement(selector);
    assertTrue("Element revalidation returned false, but the element is present on the screen.",
               changingTextButton.revalidate());

    changingTextButton.tap();
    selector.addSelectionAttribute(CssAttribute.TEXT, CHANGING_TEXT_BUTTON_ORIGINAL_TEXT);
    boolean isGone = activeScreen.waitUntilElementGone(selector, ELEMENT_WAIT_TIMEOUT);

    assertTrue("Wait until element gone returned false.", isGone);

    assertFalse("Element revalidation returned true, but the element is not present on the screen.",
                changingTextButton.revalidate());
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:23,
代码来源:UiElementRevalidationTest.java

示例20: testScrollToElementBySelector

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void testScrollToElementBySelector() throws Exception {
    ScrollableView scrollableView = getScrollableView(ContentDescriptor.SCROLL_VIEW_VALIDATOR.toString());
    UiElement scrollToEndButton = getElementByContentDescriptor(ContentDescriptor.SCROLL_TO_END_BUTTON.toString());
    scrollToEndButton.tap();

    assertScrollToEnd("Could not scroll to end.");

    UiElementSelector innerViewSelector = new UiElementSelector();
    innerViewSelector.addSelectionAttribute(CssAttribute.TEXT, SCROLL_TO_TEXT);

    assertUIElementNotOnScreen("Element is already visible", innerViewSelector);
    Boolean hasScrolled = scrollableView.scrollToElementBySelector(MAX_SWIPES, innerViewSelector);

    assertTrue("Tap element to selector with scrolling returned false.", hasScrolled);
    assertUIElementOnScreen("The UiElement is not on screen", innerViewSelector);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:18,
代码来源:ScrollTest.java

示例21: testTapElementBySelectorWithScrolling

点赞 3

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void testTapElementBySelectorWithScrolling() throws Exception {
    ScrollableView scrollableView = getScrollableView(ContentDescriptor.SCROLL_VIEW_VALIDATOR.toString());
    UiElement scrollToEndButton = getElementByContentDescriptor(ContentDescriptor.SCROLL_TO_END_BUTTON.toString());
    scrollToEndButton.tap();

    assertScrollToEnd("Could not scroll to end.");

    UiElementSelector innerViewSelector = new UiElementSelector();
    innerViewSelector.addSelectionAttribute(CssAttribute.TEXT, SCROLL_TO_TEXT);

    assertUIElementNotOnScreen("Element is already visible", innerViewSelector);
    Boolean hasTapped = scrollableView.tapElementBySelectorWithScrolling(MAX_SWIPES, innerViewSelector);

    assertTrue("Tap element to selector with scrolling returned false.", hasTapped);
    assertUIElementOnScreen("The UiElement is not on screen", innerViewSelector);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:18,
代码来源:ScrollTest.java

示例22: GsonUtil

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
public GsonUtil() {
    gsonBuilder = new GsonBuilder().enableComplexMapKeySerialization();
    gsonBuilder.registerTypeHierarchyAdapter(Pack.class, new PackDeserializer());
    gsonBuilder.registerTypeHierarchyAdapter(UiElementSelector.class, new UiElementSelectorDeserializer());
    gsonBuilder.registerTypeHierarchyAdapter(RequestMessage.class, new RequestMessageSerializer());
    gsonBuilder.registerTypeHierarchyAdapter(RequestMessage.class, new RequestMessageDeserializer());
    gsonBuilder.registerTypeHierarchyAdapter(ResponseMessage.class, new ResponseMessageSerializer());
    gsonBuilder.registerTypeHierarchyAdapter(ResponseMessage.class, new ResponseMessageDeserializer());
    g = gsonBuilder.create();
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-commons,
代码行数:11,
代码来源:GsonUtil.java

示例23: match

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Override
public boolean match(UiElementSelector selector, AccessibilityNodeInfo nodeInformation) {
    String selectorResourceId = selector.getStringValue(CssAttribute.RESOURCE_ID);

    if (selectorResourceId != null && !selectorResourceId.equals(nodeInformation.getViewIdResourceName())) {
        return false;
    }

    return super.match(selector, nodeInformation);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-commons,
代码行数:11,
代码来源:UiElementSelectorMatcherImpl.java

示例24: emptyUiElementSelectorDeserializationTest

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void emptyUiElementSelectorDeserializationTest() {
    UiElementSelector selector = new UiElementSelector();

    UiElementSelector result = (UiElementSelector) getExpectedResponseData(RoutingAction.SEND_BROADCAST, selector);

    Assert.assertTrue(result.isEmpty());
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-commons,
代码行数:9,
代码来源:UiElementSelectorDeserializationTest.java

示例25: emptyUiElementSelectorAttributeDeserializationTest

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void emptyUiElementSelectorAttributeDeserializationTest() {
    String jsonRequest = readFile(jsonPath + "emptyUiElementSelectorAttributeDeserializationTest.txt");

    RequestMessage requestMessage = jsonUtil.deserializeRequest(jsonRequest);

    UiElementSelector selector = (UiElementSelector) requestMessage.getArguments()[0];

    Assert.assertNull(selector.getText());
    Assert.assertTrue((Boolean) requestMessage.getArguments()[1]);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-commons,
代码行数:12,
代码来源:UiElementSelectorDeserializationTest.java

示例26: assertAutoRotationOff

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Asserts that the auto rotation of the test device is turned off.
 *
 * @param message
 *        - message to be displayed if assertion fails.
 * @throws UiElementFetchingException
 */
public static void assertAutoRotationOff(String message) throws UiElementFetchingException {
    UiElementSelector autoRotationOffSelector = new UiElementSelector();
    autoRotationOffSelector.addSelectionAttribute(CssAttribute.CONTENT_DESCRIPTION,
                                                  ContentDescriptor.AUTO_ROTATION_BUTTON.toString());
    autoRotationOffSelector.addSelectionAttribute(CssAttribute.ENABLED, false);

    assertElementExists(message, autoRotationOffSelector);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:16,
代码来源:OnDeviceValidatorAssert.java

示例27: handle

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Override
public Object handle(Object[] args) throws Exception {
    AccessibilityElement parentElement = (AccessibilityElement) args[0];
    UiElementSelector successorSelector = (UiElementSelector) args[1];
    Boolean directChildrenOnly = (Boolean) args[2];
    Boolean visibleOnly = (Boolean) args[3];

    AccessibilityHelper accessibilityHelper = AccessibilityFactory.getAccessibilityHelper();
    AccessibilityNodeInfo accessibilityRootNode = accessibilityHelper.getRootInActiveWindow();

    AccessibilityNodeTraverser traverser = new AccessibilityNodeTraverser(accessibilityRootNode, "");
    UiElementMatcher<UiElementPropertiesContainer> propertiesMatcher = AccessibilityFactory.getUiElementPropertiesContainerMatcher();

    AccessibilityNodeInfo parentAccessibilityNode = traverser.getCorrespondingAccessibilityNodeInfo(parentElement,
                                                                                                    propertiesMatcher,
                                                                                                    visibleOnly);

    if (parentAccessibilityNode == null) {
        throw new UiElementFetchingException("Element, for which retrieving children is requested, is not present on the screen.");
    }

    AccessibilityNodeTraverser successorsTraverser = new AccessibilityNodeTraverser(parentAccessibilityNode,
                                                                                    parentElement.getPath());

    UiElementMatcher<UiElementSelector> successorSelectorMatcher = AccessibilityFactory.getUiElementSelectorMatcher();

    return successorsTraverser.getChildren(successorSelectorMatcher,
                                           successorSelector,
                                           directChildrenOnly,
                                           visibleOnly);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-uiautomator-bridge,
代码行数:32,
代码来源:UiElementSuccessorRetriever.java

示例28: waitForUnexistingElement

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void waitForUnexistingElement()
    throws InterruptedException,
        ActivityStartingException,
        UiElementFetchingException {

    UiElementSelector selector = new UiElementSelector();
    selector.addSelectionAttribute(CssAttribute.CONTENT_DESCRIPTION, UNEXISTING_BUTTON_DESCRIPTOR);
    Screen activeScreen = testDevice.getActiveScreen();
    boolean result = activeScreen.waitForElementExists(selector, ELEMENT_WAIT_TIMEOUT);

    assertFalse("Wait for element exists returned true.", result);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:14,
代码来源:WaitForExistsTest.java

示例29: getChildren

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Finds all children of the root in the hierarchy of {@link AccessibilityNodeInfo accessibility nodes} that are
 * matching the given {@link UiElementSelector selector} and {@link UiElementMatcher matcher}.
 *
 * @param matcher
 *        - defines the strategy for matching the given {@link UiElementSelector selector} and node from the
 *        hierarchy
 * @param selector
 *        - contains the properties which accessibility nodes should match
 * @param directOnly
 *        - if <code>true</code> only direct children are traversed, otherwise all children are traversed
 * @param visibleOnly
 *        - if <code>true</code> only the visible nodes will be used; if <code>false</code> all nodes will be used
 * @return list of {@link AccessibilityElement} that are children of the root
 */
public List<AccessibilityElement> getChildren(UiElementMatcher<UiElementSelector> matcher,
                                              UiElementSelector selector,
                                              boolean directOnly,
                                              boolean visibleOnly) {
    List<AccessibilityElement> childrenList = new ArrayList<AccessibilityElement>();

    Queue<AccessibilityNodeInfo> nextNodes = new LinkedList<AccessibilityNodeInfo>();
    Map<AccessibilityNodeInfo, Integer> nodeToindex = new HashMap<AccessibilityNodeInfo, Integer>();

    processDirectChildren(localRootNodeInfo, nextNodes, nodeToindex, visibleOnly);

    while (!nextNodes.isEmpty()) {
        AccessibilityNodeInfo currentNodeInformation = nextNodes.poll();
        Integer currentNodeIndex = nodeToindex.get(currentNodeInformation);

        if (isMatchFound(currentNodeInformation, selector, matcher, currentNodeIndex)) {
            Stack<Integer> pathIndexes = extractPath(nodeToindex, currentNodeInformation);
            AccessibilityElementBuilder accessibilityElementBuilder = AccessibilityFactory.getAccessibilityElementBuilder();
            AccessibilityElement accessibilityElement = accessibilityElementBuilder.build(currentNodeInformation,
                                                                                          pathIndexes,
                                                                                          pathToLocalRoot,
                                                                                          currentNodeIndex);
            childrenList.add(accessibilityElement);
        }

        if (!directOnly) {
            processDirectChildren(currentNodeInformation, nextNodes, nodeToindex, visibleOnly);
        }
    }

    return childrenList;
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-uiautomator-bridge,
代码行数:48,
代码来源:AccessibilityNodeTraverser.java

示例30: assertDeviceProximity

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Asserts that proximity value of a device corresponds to the given selector string.
 *
 * @param message
 *        - message to be displayed if the assertion fails
 * @param proximityTextSelector
 *        - a text selector for the attribute field containing the proximity value
 */
public static void assertDeviceProximity(String message, String proximityTextSelector) {
    UiElementSelector deviceProximitySelector = new UiElementSelector();
    deviceProximitySelector.addSelectionAttribute(CssAttribute.TEXT, proximityTextSelector);
    deviceProximitySelector.addSelectionAttribute(CssAttribute.CONTENT_DESCRIPTION,
                                                  ContentDescriptor.PROXIMITY_FIELD_BOX.toString());

    assertUIElementOnScreen(message, deviceProximitySelector);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:17,
代码来源:OnDeviceValidatorAssert.java

示例31: assertInAirplaneMode

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Asserts that the the test device is in airplane mode.
 *
 * @param message
 *        - message to be displayed if assertion fails.
 * @throws UiElementFetchingException
 */
public static void assertInAirplaneMode(String message) throws UiElementFetchingException {
    UiElementSelector airplaneModeSelector = new UiElementSelector();

    airplaneModeSelector.addSelectionAttribute(CssAttribute.CONTENT_DESCRIPTION,
                                               ContentDescriptor.AIRPLANE_MODE_FLAG.toString());
    airplaneModeSelector.addSelectionAttribute(CssAttribute.ENABLED, true);

    assertElementExists(message, airplaneModeSelector);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:17,
代码来源:OnDeviceValidatorAssert.java

示例32: testGetMultipleUiElements

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test(expected = MultipleElementsFoundException.class)
public void testGetMultipleUiElements() throws Exception {
    UiElementSelector elementSelector = new UiElementSelector();
    elementSelector.addSelectionAttribute(CssAttribute.CLASS_NAME, BUTTON_CLASS_NAME);

    screen.getElement(elementSelector);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:8,
代码来源:GetAccessibilityUiElementTest.java

示例33: assertInputTextBoxIsFocused

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Asserts that the battery status box is focused.
 *
 * @param message
 *        - message to be displayed if assertion fails.
 * @throws UiElementFetchingException
 */
public static void assertInputTextBoxIsFocused(String message) throws UiElementFetchingException {
    UiElementSelector inputTextSelector = new UiElementSelector();

    inputTextSelector.addSelectionAttribute(CssAttribute.CONTENT_DESCRIPTION,
                                            ContentDescriptor.EMPTY_TEXT_BOX.toString());
    inputTextSelector.addSelectionAttribute(CssAttribute.FOCUSED, true);

    assertElementExists(message, inputTextSelector);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:17,
代码来源:OnDeviceValidatorAssert.java

示例34: isMatchFound

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
private boolean isMatchFound(AccessibilityNodeInfo nodeInfo,
                             UiElementSelector selector,
                             UiElementMatcher<UiElementSelector> matcher,
                             int index) {
    Integer selectorIndex = selector.getIntegerValue(CssAttribute.INDEX);

    if (selectorIndex == null) {
        return matcher.match(selector, nodeInfo);
    }

    return selectorIndex.intValue() == index && matcher.match(selector, nodeInfo);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-uiautomator-bridge,
代码行数:13,
代码来源:AccessibilityNodeTraverser.java

示例35: assertValidatorIsStarted

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Asserts the the OnDeviceValidator has been started.
 *
 * @throws UiElementFetchingException
 */
public static void assertValidatorIsStarted() throws UiElementFetchingException {
    // If the validator app activity is not started, this element fetching
    // will fail.
    UiElementSelector validationViewSelector = new UiElementSelector();

    validationViewSelector.addSelectionAttribute(CssAttribute.CONTENT_DESCRIPTION,
                                                 VALIDATOR_APP_CONTROL_ELEMENT_CONTENTDESC);
    validationViewSelector.addSelectionAttribute(CssAttribute.ENABLED, true);
    assertElementExists(VALIDATOR_IS_NOT_STARTED_MESSAGE, validationViewSelector, APP_STARTUP_WAIT_TIME);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:16,
代码来源:OnDeviceValidatorAssert.java

示例36: assertValidatorIsNotStarted

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Asserts that the OnDeviceValidator application is not started.
 *
 * @param message
 *        - the message to be displayed in case the assertion fails
 * @throws UiElementFetchingException
 *         - thrown if the validation element of the OnDeviceValidator application cannot be fetched
 */
public static void assertValidatorIsNotStarted(String message) throws UiElementFetchingException {
    // If the validator app activity is not started, this element fetching
    // will fail.
    UiElementSelector validationViewSelector = new UiElementSelector();

    validationViewSelector.addSelectionAttribute(CssAttribute.CONTENT_DESCRIPTION,
                                                 VALIDATOR_APP_CONTROL_ELEMENT_CONTENTDESC);
    validationViewSelector.addSelectionAttribute(CssAttribute.ENABLED, true);

    assertElementGone(message, validationViewSelector);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:20,
代码来源:OnDeviceValidatorAssert.java

示例37: assertWiFiIsOff

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Asserts that the WiFi button is disabled.
 *
 * @param message
 *        - message to be displayed if assertion fails.
 * @throws UiElementFetchingException
 */
public static void assertWiFiIsOff(String message) throws UiElementFetchingException {
    UiElementSelector wifiButtonSelector = new UiElementSelector();

    wifiButtonSelector.addSelectionAttribute(CssAttribute.CONTENT_DESCRIPTION,
                                             ContentDescriptor.WIFI_FLAG.toString());

    wifiButtonSelector.addSelectionAttribute(CssAttribute.ENABLED, false);

    assertElementExists(message, wifiButtonSelector);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:18,
代码来源:OnDeviceValidatorAssert.java

示例38: assertWiFiIsOn

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
/**
 * Asserts that the WiFi button is enabled.
 *
 * @param message
 *        - message to be displayed if assertion fails.
 * @throws UiElementFetchingException
 */
public static void assertWiFiIsOn(String message) throws UiElementFetchingException {
    UiElementSelector wifiButtonSelector = new UiElementSelector();

    wifiButtonSelector.addSelectionAttribute(CssAttribute.CONTENT_DESCRIPTION,
                                             ContentDescriptor.WIFI_FLAG.toString());

    wifiButtonSelector.addSelectionAttribute(CssAttribute.ENABLED, true);

    assertElementExists(message, wifiButtonSelector);
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:18,
代码来源:OnDeviceValidatorAssert.java

示例39: testGetVisibleUiElement

点赞 2

import com.musala.atmosphere.commons.ui.selector.UiElementSelector; //导入依赖的package包/类
@Test
public void testGetVisibleUiElement() throws Exception {
    UiElementSelector elementSelector = new UiElementSelector();
    elementSelector.addSelectionAttribute(CssAttribute.CLASS_NAME, BUTTON_CLASS_NAME);
    elementSelector.addSelectionAttribute(CssAttribute.TEXT, FIRST_BUTTON_TEXT);

    UiElement foundElement = screen.getElement(elementSelector);

    assertEquals(SELECTOR_PROPERTIES_MISSMATCH_MESSAGE,
                 BUTTON_CLASS_NAME,
                 foundElement.getProperties().getClassName());
    assertEquals(SELECTOR_PROPERTIES_MISSMATCH_MESSAGE, FIRST_BUTTON_TEXT, foundElement.getText());
}
 

开发者ID:MusalaSoft,
项目名称:atmosphere-integration-tests,
代码行数:14,
代码来源:GetAccessibilityUiElementTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)