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


Java UiScrollable类代码示例

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


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

示例1: selectSettingsFor

import com.android.uiautomator.core.UiScrollable; //导入依赖的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.UiScrollable; //导入依赖的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: testDownloadInfoDescription

import com.android.uiautomator.core.UiScrollable; //导入依赖的package包/类
/**
 * Tests whether the download info screen contains a non-empty description
 * TextView
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
public void testDownloadInfoDescription() throws RemoteException,
		UiObjectNotFoundException {
	openDownloadInfoScreen();

	// scroll down
	UiScrollable scrollview = new UiScrollable(
			new UiSelector().className("android.widget.ScrollView"));
	scrollview.scrollToEnd(20);

	UiObject description = new UiObject(
			new UiSelector().description("Video description"));

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

示例4: testVideoInfoDescription

import com.android.uiautomator.core.UiScrollable; //导入依赖的package包/类
/**
 * Tests whether the video info screen contains a non-empty description
 * TextView
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
public void testVideoInfoDescription() throws RemoteException,
		UiObjectNotFoundException {
	openVideoInfoScreen();

	// scroll down
	UiScrollable scrollview = new UiScrollable(
			new UiSelector().className("android.widget.ScrollView"));
	scrollview.scrollToEnd(20);

	UiObject description = new UiObject(
			new UiSelector().description("Video description"));

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

示例5: testLaunch

import com.android.uiautomator.core.UiScrollable; //导入依赖的package包/类
/**
 * Play Store launch test.
 *
 * @throws UiObjectNotFoundException
 */
public void testLaunch() throws UiObjectNotFoundException {

    getUiDevice().pressHome();
    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 settingsApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),
            "Play Store");
    settingsApp.clickAndWaitForNewWindow();

    UiObject settingsValidation = new UiObject(new UiSelector().packageName("com.android.vending"));
    assertTrue("Unable to detect Play Store", settingsValidation.exists());
}
 
开发者ID:croute,项目名称:UiAutomatorExample,代码行数:25,代码来源:LaunchSettings.java

示例6: findAndRunApp

import com.android.uiautomator.core.UiScrollable; //导入依赖的package包/类
private void findAndRunApp() throws UiObjectNotFoundException {
    // Go to main screen
    getUiDevice().pressHome();
    // Find menu button
    UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
    // Click on menu button and wait new window
    allAppsButton.clickAndWaitForNewWindow();
    // Find App tab
    UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
    // Click on app tab
    appsTab.click();
    // Find scroll object (menu scroll)
    UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
    // Set the swiping mode to horizontal (the default is vertical)
    appViews.setAsHorizontalList();
    // Find Messaging application
    UiObject settingsApp = appViews.getChildByText(new UiSelector().className("android.widget.TextView"), "My Files");
    // Open Messaging application
    settingsApp.clickAndWaitForNewWindow();

    // Validate that the package name is the expected one
    UiObject settingsValidation = new UiObject(new UiSelector().packageName("com.sec.android.app.myfiles"));
    assertTrue("Unable to detect MyFiles", settingsValidation.exists());
}
 
开发者ID:amazpyel,项目名称:uiautomator_sample,代码行数:25,代码来源:CopyFile.java

示例7: testDemo

import com.android.uiautomator.core.UiScrollable; //导入依赖的package包/类
/**
 * Script starts here
 * @throws UiObjectNotFoundException
 */
public void testDemo() throws UiObjectNotFoundException {
    // The following code is documented in the LaunchSettings demo. For detailed description
    // of how this code works, look at the demo LaunchSettings

    // Good to start from here
    getUiDevice().pressHome();

    // open the All Apps view
    UiObject allAppsButton = new UiObject(LauncherHelper.ALL_APPS_BUTTON);
    allAppsButton.click();

    // clicking the APPS tab
    UiSelector appsTabSelector =
            new UiSelector().className(android.widget.TabWidget.class.getName())
                .childSelector(new UiSelector().text("Apps"));
    UiObject appsTab = new UiObject(appsTabSelector);
    appsTab.click();

    // Clicking the Settings
    UiScrollable allAppsScreen = new UiScrollable(LauncherHelper.LAUNCHER_CONTAINER);
    allAppsScreen.setAsHorizontalList();
    UiObject settingsApp =
            allAppsScreen.getChildByText(LauncherHelper.LAUNCHER_ITEM, "Settings");
    settingsApp.click();

    // Now we will select the settings we need to work with. To make this operation a little
    // more generic we will put it in a function. We will try it as a phone first then as a
    // tablet if phone is not our device type
    if (!selectSettingsFor("About phone"))
        selectSettingsFor("About tablet");

    // Now we need to read the Build number text and return it
    String buildNum = getAboutItem("Build number");

    // Log it - Use adb logcat to view the results
    Log.i(LOG_TAG, "Build = " + buildNum);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:42,代码来源:LogBuildNumber.java

示例8: testDemo

import com.android.uiautomator.core.UiScrollable; //导入依赖的package包/类
/**
 * Set an alarm 2 minutes from now and verify it goes off. Also check the notification
 * shades for an alarm. (Crude test but it demos the use of Android resources)
 * @throws UiObjectNotFoundException
 */
public void testDemo() throws UiObjectNotFoundException {
    // The following code is documented in the LaunchSettings demo. For detailed description
    // of how this code works, look at the demo LaunchSettings

    // Good to start from here
    getUiDevice().pressHome();

    // open the All Apps view
    UiObject allAppsButton = new UiObject(LauncherHelper.ALL_APPS_BUTTON);
    allAppsButton.click();

    // clicking the APPS tab
    UiSelector appsTabSelector =
            new UiSelector().className(android.widget.TabWidget.class.getName())
                .childSelector(new UiSelector().text("Apps"));
    UiObject appsTab = new UiObject(appsTabSelector);
    appsTab.click();

    // Clicking the Settings
    UiScrollable allAppsScreen = new UiScrollable(LauncherHelper.LAUNCHER_CONTAINER);
    allAppsScreen.setAsHorizontalList();
    UiObject clockApp =
            allAppsScreen.getChildByText(LauncherHelper.LAUNCHER_ITEM, "Clock");
    clockApp.click();

    // Set an alarm to go off in about 2 minutes
    setAlarm(2);

    // wait for the alarm alert dialog
    UiObject alarmAlert =
            new UiObject(new UiSelector().packageName("com.google.android.deskclock")
                    .className(TextView.class.getName()).text("Alarm"));

    assertTrue("Timeout while waiting for alarm to go off",
            alarmAlert.waitForExists(2 * 60 * 1000));

    clickByText("Dismiss");
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:44,代码来源:SetTwoMinuteAlarm.java

示例9: scrollView

import com.android.uiautomator.core.UiScrollable; //导入依赖的package包/类
/**
 * 向前滚动
 */
private void scrollView() {
	UiScrollable ui = new UiScrollable(new UiSelector().className(ListView.class));
	try {
		ui.scrollForward(60);
	} catch (UiObjectNotFoundException e) {
		e.printStackTrace();
	}
	sleep(1000l);
}
 
开发者ID:Xiangxingqian,项目名称:WeiXinGroupSend,代码行数:13,代码来源:LaunchSettings.java

示例10: start_target_app

import com.android.uiautomator.core.UiScrollable; //导入依赖的package包/类
private void start_target_app(String appName) throws UiObjectNotFoundException {
		// 0. Start fromIndex HOME
		dev.pressHome();

		// 1. Find and click "Apps" button
		//NO Need to use that
//		UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
//
//		allAppsButton.clickAndWaitForNewWindow();

		// 2. Find and click “Apps” tab
		UiObject appsTab = new UiObject(new UiSelector().description("Apps"));
		if (launcherPackName == null) {
			launcherPackName = appsTab.getPackageName(); // remember the launcher package
		}
		appsTab.click();

		// 3. Select scrollable "container view" 
		UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
		// Set the swiping mode to horizontal (the default is vertical)
		appViews.setAsHorizontalList();

		// 4. This API does not work properly in 4.2.2 
		appViews.scrollTextIntoView(appName);

		// 5. Click target app
		UiObject targetApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()), appName, true);

		boolean done = targetApp.clickAndWaitForNewWindow();

		waitForNetworkUpdate();
		// AccessibilityEventProcessor.waitForLastEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED, WINDOW_CONTENT_UPDATE_TIMEOUT);
	}
 
开发者ID:MagicHry,项目名称:EnhancedPUMA,代码行数:34,代码来源:EnhancedPUMALauncher.java

示例11: clickOnText

import com.android.uiautomator.core.UiScrollable; //导入依赖的package包/类
public void clickOnText(String text, boolean scroll, int maxScrol)
		throws UiObjectNotFoundException {
	if (!scroll) {
		clickOnText(text);
	} else {
		UiScrollable selScroll = new UiScrollable(new UiSelector());
		
		try {
			selScroll.setMaxSearchSwipes(maxScrol);
		} catch (Exception e) {
			//Do nothing
		}
		
		selScroll.scrollTextIntoView(text);
		selScroll.waitForExists(DEFAULT_DELAY);

		// Create the object
		UiObject objScrollable = selScroll
				.getChildByText(new UiSelector()
						.className(Constants.TEXT_VIEW_CLASS), text);
		if (objScrollable.exists()) {
			// Click on object into the listView
			objScrollable.click();
		} else {
			throw new UiObjectNotFoundException(
					"There is no object on list or the list do not exists on window");
		}
	}
}
 
开发者ID:thiagoolsilva,项目名称:UiAutomatorFramework,代码行数:30,代码来源:Clicker.java

示例12: getCustomerItem

import com.android.uiautomator.core.UiScrollable; //导入依赖的package包/类
/**
 * 顧客名一覧のListViewの中から、指定された顧客名が表示されているリストアイテムを取得する(スクロール対応版)。
 * 
 * @param customerName 検索したい顧客名
 */
@Override
protected UiObject getCustomerItem(String customerName) throws UiObjectNotFoundException {
    UiScrollable customerList = new UiScrollable(new UiSelector().className(ListView.class.getName()));
    // スクロール方向を指定する
    customerList.setAsVerticalList();
    return customerList.getChildByText(new UiSelector().className(TextView.class.getName()), customerName);
}
 
开发者ID:nowsprinting,项目名称:AndroidAppsTestAutomationSamples,代码行数:13,代码来源:MasterPageScrollSupport.java

示例13: testDisabled

import com.android.uiautomator.core.UiScrollable; //导入依赖的package包/类
public void testDisabled() throws Exception {
    startApp();

    swipeLeft();
    swipeLeft();
    validateCurrentPageTitle("無効化済み");

    UiScrollable listView = new UiScrollable(new UiSelectorBuilder().className(ListView.class).scrollable(true).build());
    listView.scrollToBeginning(10);

    // リストの一つ一つをチェックする前に、現状のスクリーンショットを撮っておく
    // (目的のタブが表示されているかを目視確認するため)
    // (ViewPagerIndicatorはTextViewを使っていないためuiautomatorでは文字列を取得できない)
    TestUtils.takeScreenshot(getUiDevice(), screenshotOutputPath, "LIST.jpg");

    List<String> errorAppList = validateAllItems(listView, new InstalledAppDetailValidator() {
        @Override
        public boolean validate(String packageName) throws UiObjectNotFoundException {
            UiObject uninstallButton = new UiObject(
                    new UiSelectorBuilder()
                            .className(Button.class)
                            .resourceId("com.android.settings:id/right_button")
                            .text("有効にする").build()
            );
            return uninstallButton.exists() && uninstallButton.isEnabled();
        }
    });

    TestUtils.debugLog(errorAppList);
    assertTrue("「無効化済み」に表示されている無効化されていないアプリ " + errorAppList.toString(), errorAppList.isEmpty());
}
 
开发者ID:75py,项目名称:DisableManager,代码行数:32,代码来源:MainActivityTestCase.java

示例14: testUndisableable

import com.android.uiautomator.core.UiScrollable; //导入依赖的package包/类
public void testUndisableable() throws Exception {
    startApp();

    swipeLeft();
    swipeLeft();
    swipeLeft();
    validateCurrentPageTitle("無効化不可");

    UiScrollable listView = new UiScrollable(new UiSelectorBuilder().className(ListView.class).scrollable(true).build());
    listView.scrollToBeginning(10);

    // リストの一つ一つをチェックする前に、現状のスクリーンショットを撮っておく
    // (目的のタブが表示されているかを目視確認するため)
    // (ViewPagerIndicatorはTextViewを使っていないためuiautomatorでは文字列を取得できない)
    TestUtils.takeScreenshot(getUiDevice(), screenshotOutputPath, "LIST.jpg");

    List<String> errorAppList = validateAllItems(listView, new InstalledAppDetailValidator() {
        @Override
        public boolean validate(String packageName) throws UiObjectNotFoundException {
            UiObject disableButton = new UiObject(
                    new UiSelectorBuilder()
                            .className(Button.class)
                            .resourceId("com.android.settings:id/right_button")
                            .text("無効にする").build()
            );
            // 「無効にする」ボタンが存在しないか、無効になっている
            return !disableButton.exists() || !disableButton.isEnabled();
        }
    });

    TestUtils.debugLog(errorAppList);
    assertTrue("「無効化不可」に表示されている無効化可能アプリ " + errorAppList.toString(), errorAppList.isEmpty());
}
 
开发者ID:75py,项目名称:DisableManager,代码行数:34,代码来源:MainActivityTestCase.java

示例15: testUser

import com.android.uiautomator.core.UiScrollable; //导入依赖的package包/类
public void testUser() throws Exception {
    startApp();
    swipeLeft();
    swipeLeft();
    swipeLeft();
    swipeLeft();
    validateCurrentPageTitle("ユーザー");

    UiScrollable listView = new UiScrollable(new UiSelectorBuilder().className(ListView.class).scrollable(true).build());
    listView.scrollToBeginning(10);

    // リストの一つ一つをチェックする前に、現状のスクリーンショットを撮っておく
    // (目的のタブが表示されているかを目視確認するため)
    // (ViewPagerIndicatorはTextViewを使っていないためuiautomatorでは文字列を取得できない)
    TestUtils.takeScreenshot(getUiDevice(), screenshotOutputPath, "LIST.jpg");

    List<String> errorAppList = validateAllItems(listView, new InstalledAppDetailValidator() {
        @Override
        public boolean validate(String packageName) throws UiObjectNotFoundException {
            UiObject uninstallButton = new UiObject(
                    new UiSelectorBuilder()
                            .resourceId("com.android.settings:id/right_button")
                            .className(Button.class)
                            .textContains("アンインストール").build()
            );
            // 「アンインストール」ボタンが存在する
            // (かつ有効である、とすると、Lollipopではホームアプリのアンインストールボタンは無効になっているため適切でない)
            // return uninstallButton.exists() && uninstallButton.isEnabled();
            return uninstallButton.exists();
        }
    });

    TestUtils.debugLog(errorAppList);
    assertTrue("「ユーザー」に表示されているアンインストールできないアプリ " + errorAppList.toString(), errorAppList.isEmpty());
}
 
开发者ID:75py,项目名称:DisableManager,代码行数:36,代码来源:MainActivityTestCase.java


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