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


Java UiObject类代码示例

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


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

示例1: selectSettingsFor

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
/**
 * Select a settings items and perform scroll if needed to find it.
 * @param name
 */
private boolean selectSettingsFor(String name)  {
    try {
        UiScrollable appsSettingsList = new UiScrollable(SettingsHelper.LIST_VIEW);
        UiObject obj = appsSettingsList.getChildByText(SettingsHelper.LIST_VIEW_ITEM, name);
        obj.click();
    } catch (UiObjectNotFoundException e) {
        return false;
    }
    return true;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:15,代码来源:LogBuildNumber.java

示例2: testDemo

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
public void testDemo() throws UiObjectNotFoundException {

        // Press on the HOME button.
        getUiDevice().pressHome();

        // Launch the "Google" apps via the All Apps screen.
        UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
        allAppsButton.clickAndWaitForNewWindow();
        UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
        appsTab.click();
        UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
        appViews.setAsHorizontalList();
        UiObject testApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),
                "Google");
        testApp.clickAndWaitForNewWindow();

        // Get the google search text box
        UiObject searchBox = new UiObject(
                new UiSelector().className("com.google.android.search.shared.ui.SimpleSearchText"));

        // do Japanese Input!
        searchBox.setText(Utf7ImeHelper.e("こんにちは!UiAutomatorで入力しています。"));
    }
 
开发者ID:Xiangxingqian,项目名称:WeiXinGroupSend,代码行数:24,代码来源:UiAutomatorInputTest.java

示例3: handle

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
@Override
public Object handle(Object[] args) throws UiObjectNotFoundException {
    UiElementPropertiesContainer propertiesContainer = (UiElementPropertiesContainer) args[0];
    SwipeDirection direction = (SwipeDirection) args[1];

    UiSelector selector = UiSelectorParser.convertSelector(propertiesContainer);

    UiObject element = new UiObject(selector);
    switch (direction) {
        case DOWN:
            element.swipeDown(SWIPE_STEPS_COUNT);
            break;
        case UP:
            element.swipeUp(SWIPE_STEPS_COUNT);
            break;
        case LEFT:
            element.swipeLeft(SWIPE_STEPS_COUNT);
            break;
        case RIGHT:
            element.swipeRight(SWIPE_STEPS_COUNT);
            break;
    }

    return UIAutomatorRequest.VOID_RESPONSE;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-uiautomator-bridge,代码行数:26,代码来源:ElementSwiper.java

示例4: handle

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
@Override
public Object handle(Object[] args) throws UiObjectNotFoundException {
    UiElementPropertiesContainer propertiesContainer = (UiElementPropertiesContainer) args[0];

    UiSelector selector = UiSelectorParser.convertSelector(propertiesContainer);

    UiObject field = new UiObject(selector);

    field.clearTextField();

    for (int i = 0; i < ACTION_TIMEOUT_SECONDS / (ACTION_TIMEOUT_STEP / 1000); i++) {
        String text = field.getText();
        if (!text.isEmpty()) {
            try {
                Thread.sleep(ACTION_TIMEOUT_STEP);
            } catch (InterruptedException e) {
                // Nothing to do here
            }
        } else {
            break;
        }
    }

    return UIAutomatorRequest.VOID_RESPONSE;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-uiautomator-bridge,代码行数:26,代码来源:TextFieldEraser.java

示例5: testPress

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
@Test
public void testPress() throws Exception {
    Action action;

    // Mocking
    UiObject uiObject = mock(UiObject.class);
    mockStatic(PressAction.class);
    when(PressAction.getUiObject("Press Me")).thenReturn(uiObject);
    when(PressAction.getUiObject("Not Found")).thenReturn(null);

    // Test Success
    action = new PressAction();
    action.setValues(new Object[]{"Press Me"});
    Assert.assertNull(action.run(null, null));

    // Test Failure
    action = new PressAction();
    action.setValues(new Object[]{"Not Found"});
    Assert.assertEquals("UI Object 'Not Found' not found", action.run(null, null));
}
 
开发者ID:fabricereix,项目名称:AndroidFunctionalTester,代码行数:21,代码来源:ActionImplTest.java

示例6: setSystemTime

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
@Override
public void setSystemTime(Calendar calendar) throws UiObjectNotFoundException, IOException {
	ShellCommandUtils
    		.executeShellCommand("/system/bin/am start -a android.settings.DATE_SETTINGS");

    UiObject dateAndTimeToggle = new UiObject(new UiSelector().text("Automatic date & time"));
    UiObject setDate = new UiObject(new UiSelector().text("Set date"));

    if (!setDate.isEnabled()) {
        dateAndTimeToggle.click();
    }

    new UiObject(
            new UiSelector().text("Set time")).click();

    AsusNexus72012sdk21TimePickerHelper.setTime(calendar);
    AsusNexus72012sdk21TimePickerHelper.clickOK();
}
 
开发者ID:SeaDroids,项目名称:CIWorkshopProjects,代码行数:19,代码来源:AsusNexus72012sdk21SystemDateTimeViewHelper.java

示例7: setSystemTime

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
@Override
public void setSystemTime(Calendar calendar) throws UiObjectNotFoundException, IOException {
	ShellCommandUtils
			.executeShellCommand("/system/bin/am start -a android.settings.DATE_SETTINGS");

    UiObject dateAndTimeToggle = new UiObject(new UiSelector().text("Automatic date and time"));
    UiObject setDate = new UiObject(new UiSelector().text("Set date"));

    if (!setDate.isEnabled()) {
        dateAndTimeToggle.click();
    }

    new UiObject(
            new UiSelector().text("Set time")).click();

    SamsungGalaxyS5sdk19TimePickerHelper.setTime(calendar);
    SamsungGalaxyS5sdk19TimePickerHelper.clickSet();
}
 
开发者ID:SeaDroids,项目名称:CIWorkshopProjects,代码行数:19,代码来源:SamsungGalaxyS5sdk19SystemDateTimeViewHelper.java

示例8: testGridItemHealth

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
/**
 * Tests whether the first item contains an existing and enabled health
 * ProgressBar
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
public void testGridItemHealth() throws RemoteException,
		UiObjectNotFoundException {
	openThumbGrid();

	UiCollection grid = new UiCollection(
			new UiSelector().className("android.widget.GridView"));
	UiObject firstItem = grid.getChild(new UiSelector().index(0));
	UiObject health = firstItem.getChild(new UiSelector().index(2))
			.getChild(new UiSelector().index(1));

	assertTrue("Health view doesn't exist", health.exists());
	assertTrue("Health view isn't enabled", health.isEnabled());
	assertEquals("Health view isn't a ProgressBar",
			"android.widget.ProgressBar", health.getClassName());
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:23,代码来源:ThumbGridUiTest.java

示例9: setSystemDate

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
@Override
public void setSystemDate(Calendar calendar) throws UiObjectNotFoundException, IOException {
	ShellCommandUtils
			.executeShellCommand("/system/bin/am start -a android.settings.DATE_SETTINGS");

    UiObject dateAndTimeToggle = new UiObject(new UiSelector().text("Automatic date and time"));
    UiObject setDate = new UiObject(new UiSelector().text("Set date"));

    if (!setDate.isEnabled()) {
        dateAndTimeToggle.click();
    }

    new UiObject(
            new UiSelector().text("Set date")).click();

    SamsungGalaxyS5sdk19DatePickerHelper.setDate(calendar);
    SamsungGalaxyS5sdk19DatePickerHelper.clickSet();
}
 
开发者ID:SeaDroids,项目名称:CIWorkshopProjects,代码行数:19,代码来源:SamsungGalaxyS5sdk19SystemDateTimeViewHelper.java

示例10: testHomeItemClick

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
/**
 * Test whether the drawer opens the thumbgrid fragment when the first list
 * item (home item) is clicked
 * 
 * @throws UiObjectNotFoundException
 * @throws RemoteException
 */
public void testHomeItemClick() throws UiObjectNotFoundException,
		RemoteException {
	openNavigationDrawer();
	UiObject navDrawer = new UiObject(
			new UiSelector().description("navigation_drawer"));

	UiObject homeItem = navDrawer.getChild(new UiSelector().text("Home"));
	assertTrue("Navigation drawer doesn't exist", navDrawer.exists());
	assertTrue("Home item click failed", homeItem.click());

	// check whether nav drawer is closed
	assertFalse("Navigation drawer is still open after clicking home item",
			navDrawer.exists());

	// check if the app title is changed
	UiObject upButton = new UiObject(
			new UiSelector().descriptionContains("navigation drawer"));
	UiObject title = upButton.getChild(new UiSelector()
			.className("android.widget.TextView"));

	assertEquals(
			"App title not correctly changed after clicking home item",
			"Home", title.getText());
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:32,代码来源:NavigationDrawerUiTest.java

示例11: testListItemTitle

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
/**
 * Tests whether the first item contains an existing and enabled title
 * TextView
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
public void testListItemTitle() throws RemoteException,
		UiObjectNotFoundException {
	openDownloadList();

	UiCollection list = new UiCollection(
			new UiSelector().className("android.widget.ListView"));
	UiObject firstItem = list.getChild(new UiSelector().index(0));
	UiObject title = firstItem.getChild(new UiSelector().index(0));

	assertTrue("Title doesn't exist", title.exists());
	assertTrue("Title isn't enabled", title.isEnabled());
	assertEquals("Title isn't a TextView", "android.widget.TextView",
			title.getClassName());
	assertFalse("Title is empty string", title.getText().equals(""));
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:23,代码来源:DownloadListUiTest.java

示例12: testListItemStatus

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
/**
 * Tests whether the first item contains an existing and enabled status
 * TextView
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
public void testListItemStatus() throws RemoteException,
		UiObjectNotFoundException {
	openDownloadList();

	UiCollection list = new UiCollection(
			new UiSelector().className("android.widget.ListView"));
	UiObject firstItem = list.getChild(new UiSelector().index(0));
	UiObject status = firstItem.getChild(new UiSelector().index(1));

	assertTrue("Status doesn't exist", status.exists());
	assertTrue("Status isn't enabled", status.isEnabled());
	assertEquals("Status isn't a TextView", "android.widget.TextView",
			status.getClassName());
	assertFalse("Status is empty string", status.getText().equals(""));
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:23,代码来源:DownloadListUiTest.java

示例13: testListItemDownloadSpeed

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
/**
 * Tests whether the first item contains an existing and enabled download
 * speed TextView
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
public void testListItemDownloadSpeed() throws RemoteException,
		UiObjectNotFoundException {
	openDownloadList();

	UiCollection list = new UiCollection(
			new UiSelector().className("android.widget.ListView"));
	UiObject firstItem = list.getChild(new UiSelector().index(0));
	UiObject downSpeed = firstItem.getChild(new UiSelector().index(2));

	assertTrue("Download speed doesn't exist", downSpeed.exists());
	assertTrue("Download speed isn't enabled", downSpeed.isEnabled());
	assertEquals("Download speed isn't a TextView",
			"android.widget.TextView", downSpeed.getClassName());
	assertFalse("Download speed is empty string", downSpeed.getText()
			.equals(""));
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:24,代码来源:DownloadListUiTest.java

示例14: testListItemUploadSpeed

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
/**
 * Tests whether the first item contains an existing and enabled upload
 * speed TextView
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
public void testListItemUploadSpeed() throws RemoteException,
		UiObjectNotFoundException {
	openDownloadList();

	UiCollection list = new UiCollection(
			new UiSelector().className("android.widget.ListView"));
	UiObject firstItem = list.getChild(new UiSelector().index(0));
	UiObject upSpeed = firstItem.getChild(new UiSelector().index(3));

	assertTrue("Upload speed doesn't exist", upSpeed.exists());
	assertTrue("Upload speed isn't enabled", upSpeed.isEnabled());
	assertEquals("Upload speed isn't a TextView",
			"android.widget.TextView", upSpeed.getClassName());
	assertFalse("Upload speed is empty string", upSpeed.getText()
			.equals(""));
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:24,代码来源:DownloadListUiTest.java

示例15: openDownloadList

import com.android.uiautomator.core.UiObject; //导入依赖的package包/类
/**
 * Launches the app, opens the navigation drawer and clicks the downloads
 * item to load the downloads list
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
private void openDownloadList() throws RemoteException,
		UiObjectNotFoundException {
	startTSAP();

	UiObject navDrawer = new UiObject(
			new UiSelector().description("navigation_drawer"));
	if (!navDrawer.exists()) {
		UiObject upButton = new UiObject(
				new UiSelector().description("Navigate up"));
		upButton.click();
	}

	UiObject downloadsItem = navDrawer.getChild(new UiSelector()
			.text("Downloads"));
	downloadsItem.click();
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:24,代码来源:DownloadListUiTest.java


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