upload android base code part6

This commit is contained in:
August 2018-08-08 17:48:24 +08:00
parent 421e214c7d
commit 4e516ec6ed
35396 changed files with 9188716 additions and 0 deletions

View file

@ -0,0 +1,24 @@
#
# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := handheld-app-helper-base
LOCAL_STATIC_JAVA_LIBRARIES := app-helpers-common
LOCAL_JAVA_LIBRARIES := ub-uiautomator android-support-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
include $(BUILD_STATIC_JAVA_LIBRARY)

View file

@ -0,0 +1,90 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.platform.test.helpers;
import android.app.Instrumentation;
public abstract class AbstractDownloadsHelper extends AbstractStandardAppHelper {
public static enum Category {
AUDIO,
IMAGES,
RECENT,
VIDEOS
}
public AbstractDownloadsHelper(Instrumentation instr) {
super(instr);
}
/**
* Setup expectation: Downloads app's Navigation Drawer is open
* <p>
* This method will select an item from the navigation drawer's list
*
* @param category - menu item to select (click)
*/
public abstract void selectMenuCategory(Category category);
/**
* Setup expectation: Item has been selected from Navigation Drawer's list
* <p>
* This method opens a directory from the directories list
*
* @param directoryName - name of directory to open
*/
public abstract void selectDirectory(String directoryName);
/**
* Setup expectation: Navigated to the right folder
* <p>
* This method clicks a specific file with name 'filename'
*
* @param filename - name of file to open
*/
public abstract void openFile(String filename);
/**
* Setup expectation: Video is playing
* <p>
* This method will wait for the video to stop playing or until timeoutInSeconds occur,
* whichever comes first. Function will just exit, no test failure in either case.
*
* @param timeoutInSeconds - timeout value in seconds the test will wait for video to end
*/
public abstract void waitForVideoToStopPlaying(long timeoutInSeconds);
/**
* Setup expectation: Audio is playing
* <p>
* This method will wait for the audio to stop playing or until timeoutInSeconds occur,
* whichever comes first. Function will just exit, no test failure in either case.
*
* @param timeoutInSeconds - timeout value in seconds the test will wait for audio to end
*/
public abstract void waitForAudioToStopPlaying(long timeoutInSeconds);
/**
* Setup expectation: Video is playing
* <p>
* This method will enable or disable video looping. It will bring up the options menu and
* check the "Loop video" option
*
* @param enableVideoLooping - true for continuous looping video, false for not looping video
*/
public abstract void enableVideoLooping(boolean enableVideoLooping);
}

View file

@ -0,0 +1,217 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.platform.test.helpers;
import android.app.Instrumentation;
import android.support.test.uiautomator.Direction;
import java.util.List;
public abstract class AbstractGmailHelper extends AbstractStandardAppHelper {
public AbstractGmailHelper(Instrumentation instr) {
super(instr);
}
/**
* Setup expectations: Gmail is open and the navigation bar is visible.
*
* This method will navigate to the Inbox or Primary, depending on the name.
*/
public abstract void goToInbox();
/**
* Alias method for AbstractGmailHelper#goToInbox
*/
public void goToPrimary() {
goToInbox();
}
/**
* Setup expectations: Gmail is open on the Inbox or Primary page.
*
* This method will open a new e-mail to compose and block until complete.
*/
public abstract void goToComposeEmail();
/**
* Checks if the current view is the compose email view.
*
* @return true if the current view is the compose email view, false otherwise.
*/
public abstract boolean isInComposeEmail();
/**
* Checks if the app is open on the Inbox or Primary page.
*
* @return true if the current view is the Inbox or Primary page, false otherwise.
*/
public abstract boolean isInPrimaryOrInbox();
/**
* Setup expectations: Gmail is open and on the Inbox or Primary page.
*
* This method will open the (index)'th visible e-mail in the list and block until the e-mail is
* visible in the foreground. The top-most visible e-mail will always be labeled 0. To get the
* number of visible e-mails, consult the getVisibleEmailCount() function.
*/
public abstract void openEmailByIndex(int index);
/**
* Setup expectations: Gmail is open and on the Inbox or Primary page.
*
* This method will return the number of visible e-mails for use with the #openEmailByIndex
* method.
*/
public abstract int getVisibleEmailCount();
/**
* Setup expectations: Gmail is open and an e-mail is open in the foreground.
*
* This method will press reply, send a reply e-mail with the given parameters, and block until
* the original message is in the foreground again.
*/
public abstract void sendReplyEmail(String address, String body);
/**
* Setup expectations: Gmail is open and composing an e-mail.
*
* This method will set the e-mail's To address and block until complete.
*/
public abstract void setEmailToAddress(String address);
/**
* Setup expectations: Gmail is open and composing an e-mail.
*
* This method will set the e-mail's subject and block until complete.
*/
public abstract void setEmailSubject(String subject);
/**
* Setup expectations: Gmail is open and composing an e-mail.
*
* This method will set the e-mail's Body and block until complete. Focus will remain on the
* e-mail body after completion.
*/
public abstract void setEmailBody(String body);
/**
* Setup expectations: Gmail is open and composing an e-mail.
*
* This method will press send and block until the device is idle on the original e-mail.
*/
public abstract void clickSendButton();
/**
* Setup expectations: Gmail is open and composing an e-mail.
*
* This method will get the e-mail's composition's body and block until complete.
*
* @return {String} the text contained in the email composition's body.
*/
public abstract String getComposeEmailBody();
/**
* Setup expectations: Gmail is open and the navigation drawer is visible.
*
* This method will open the navigation drawer and block until complete.
*/
public abstract void openNavigationDrawer();
/**
* Setup expectations: Gmail is open and the navigation drawer is open.
*
* This method will close the navigation drawer and returns true otherwise false
*/
public abstract boolean closeNavigationDrawer();
/**
* Setup expectations: Gmail is open and the navigation drawer is open.
*
* This method will scroll the navigation drawer and block until idle. Only accepts UP and DOWN.
*/
public abstract void scrollNavigationDrawer(Direction dir);
/**
* Setup expectations: Gmail is open and a mailbox is open.
*
* This method will scroll the mailbox view.
*
* @param direction The direction to scroll, only accepts UP and DOWN.
* @param amount The amount to scroll
* @param scrollToEnd Whether or not to scroll to the end
*/
public abstract void scrollMailbox(Direction direction, float amount, boolean scrollToEnd);
/**
* Setup expectations: Gmail is open and an email is open.
*
* This method will scroll the current email.
*
* @param direction The direction to scroll, only accepts UP and DOWN.
* @param amount The amount to scroll
* @param scrollToEnd Whether or not to scroll to the end
*/
public abstract void scrollEmail(Direction direction, float amount, boolean scrollToEnd);
/**
* Setup expectations: Gmail is open and the navigation drawer is open.
*
* This method will open the mailbox with the given name and block until emails in
* that mailbox have loaded.
*
* @param mailboxName The case insensitive name of the mailbox to open
*/
public abstract void openMailbox(String mailboxName);
/**
* Setup expectations: Gmail is open and an email is open.
*
* This method will return to the mailbox the current email was opened from.
*/
public abstract void returnToMailbox();
/**
* Setup expectations: Gmail is open and an email is open.
*
* This method starts downloading the attachment at the specified index in the current email.
* The download happens in the background. This method returns immediately after starting
* the download and does not wait for the download to complete.
*
* @param index The index of the attachment to download
*/
public abstract void downloadAttachment(int index);
/**
* Setup expectations: Gmail is open and an email is open.
*
* This method gets every link target in an open email by traversing the UI tree of the body
* of the open message.
*
* @return an iterator over the links in the message
*/
public abstract List<String> getEmailLinks();
/**
* Setup expectations: Gmail is open and an email is open.
*
* This method clicks the link in the open email with the given target.
*
* @param target the target of the link to click
*/
public abstract void openEmailLink(String target);
}

View file

@ -0,0 +1,30 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.platform.test.helpers;
import android.app.Instrumentation;
import android.support.test.uiautomator.Direction;
/**
* This class should no longer be extended. Instead, use the {@code IGoogleCameraHelper} interface.
*/
@Deprecated public abstract class AbstractGoogleCameraHelper extends AbstractStandardAppHelper
implements IGoogleCameraHelper{
public AbstractGoogleCameraHelper(Instrumentation instr) {
super(instr);
}
}

View file

@ -0,0 +1,51 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.platform.test.helpers;
import android.app.Instrumentation;
public abstract class AbstractGoogleDocsHelper extends AbstractStandardAppHelper {
public AbstractGoogleDocsHelper(Instrumentation instr) {
super(instr);
}
/**
* Setup expectation: Google Docs is open and the Recent Docs Tab can be reached by
* pressing back button multiple times, i.e. the test procedure has been on the Recent
* Docs tab.
*
* Returns to the Recent Docs Tab.
*/
public abstract void goToRecentDocsTab();
/**
* Setup expectation: Google Docs is on the Recent Docs tab.
*
* Opens the document.
*
* @param title The title (case sensitive) of the document as is displayed in the app.
*/
public abstract void openDoc(String title);
/**
* Setup expectation: Google Docs is on a document page.
*
* Scrolls down the document.
*/
public abstract void scrollDownDocument();
}

View file

@ -0,0 +1,79 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.platform.test.helpers;
import android.app.Instrumentation;
import android.support.test.uiautomator.Direction;
public abstract class AbstractGoogleMessengerHelper extends AbstractStandardAppHelper {
public AbstractGoogleMessengerHelper(Instrumentation instr) {
super(instr);
}
/*
* Setup expectations: Google Messenger app is open.
*
* This method brings the Messenger app to the home page.
*/
public abstract void goToHomePage();
/*
* Setup expectation: Google Messenger app is on the home page.
*
* This method brings up the new conversation page.
*/
public abstract void goToNewConversationPage();
/*
* Setup expectations: Google Messenger app is on the new conversation page.
*
* This method moves the Google Messenger app to messages page with the specified contacts.
*/
public abstract void goToMessagesPage();
/**
* Setup expectations: Google Messenger app is on the messages page.
*
* This method scrolls through the messages on the messages page.
*
* @param direction Direction to scroll, must be UP or DOWN.
*/
public abstract void scrollMessages(Direction direction);
/**
* Setup expectations: Google Messenger app is on the messages page.
*
* This method clicks the "send message" textbox on the messages page.
*/
public abstract void clickComposeMessageText();
/**
* Setup expectations:
* 1. Google Messenger app is on the messages page
* 2. New message textbox is not empty.
*/
public abstract void clickSendMessageButton();
/**
* Setup expectations: Google Messenger app is on the messages page.
*
* This method clicks the "attach media" button and attaches the media file with the given
* index in the device media gallery view.
*/
public abstract void attachMediaFromDevice(int index);
}

View file

@ -0,0 +1,128 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.platform.test.helpers;
import android.app.Instrumentation;
import android.support.test.uiautomator.Direction;
public abstract class AbstractPhotosHelper extends AbstractStandardAppHelper {
public AbstractPhotosHelper(Instrumentation instr) {
super(instr);
}
/**
* Setup expectations: Photos is open and on the main or a device folder's screen.
*
* This method will check if there are videos that can be opened on current screen
* by looking for any view objects with content-desc that starts with "Video"
*
* @return true if video clips are found, false otherwise
*/
public abstract boolean searchForVideoClip();
/**
* Setup expectations: Photos is open and on the main or a device folder's screen.
*
* This method will select the first clip to open and play. This will block until the clip
* begins to plays.
*/
public abstract void openFirstClip();
/**
* Setup expectations: Photos is open and a clip is currently playing.
*
* This method will pause the current clip and block until paused.
*/
public abstract void pauseClip();
/**
* Setup expectations: Photos is open and a clip is currently paused in the foreground.
*
* This method will play the current clip and block until it is playing.
*/
public abstract void playClip();
/**
* Setup expectations: Photos is open.
*
* This method will go to the main screen.
*/
public abstract void goToMainScreen();
/**
* Setup expectations: Photos is open.
*
* This method will go to device folder screen.
*/
public abstract void goToDeviceFolderScreen();
/**
* Setup expectations:
* 1. Photos is open
* 2. on device folder screen
* 3. the first device folder is shown on the screen
*
* This method will search for user-specified device folder in device folders.
* If the device folder is found, the function will return with the device
* folder on current screen.
*
* @param folderName User-specified device folder name
* @return true if device folder is found, false otherwise
*/
public abstract boolean searchForDeviceFolder(String folderName);
/**
* Setup expectations:
* 1. Photos is open
* 2. on device folder screen
* 3. user-specified device folder is currently on screen
*
* This method will open the user-specified device folder.
*
* @param folderName User-specified device folder name
*/
public abstract void openDeviceFolder(String folderName);
/**
* Setup expectations: Photos is open and on the main or a device folder's screen.
*
* This method will check if there are pictures that can be opened on current screen
* by looking for any view objects with content-desc that starts with "Photo"
*
* @return true if pictures are found
*/
public abstract boolean searchForPicture();
/**
* Setup expectations: Photos is open and on the main or a device folder's screen.
*
* This method will open the picture at the specified index.
*
* @param index The index of the picture to open
*/
public abstract void openPicture(int index);
/**
* Setup expectations: Photos is open and a picture album is open.
*
* This method will scroll the picture album in the specified direction.
*
* @param direction The direction to scroll, must be LEFT or RIGHT.
*/
public abstract void scrollAlbum(Direction direction);
}

View file

@ -0,0 +1,75 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.platform.test.helpers;
import android.app.Instrumentation;
public abstract class AbstractPlayBooksHelper extends AbstractStandardAppHelper {
public AbstractPlayBooksHelper(Instrumentation instr) {
super(instr);
}
/**
* Setup expectations: PlayBooks is open on any screen.
*
* Navigates to "My Library" and selects the "ALL BOOKS" tab.
*/
public abstract void goToAllBooksTab();
/**
* Setup expectations: PlayBooks is open on "My Library - ALL BOOKS" screen.
*
* Selects the first Book and start reading.
*/
public abstract void openBook();
/**
* Setup expectations: PlayBooks is on a page of a book.
*
* Exits reading mode.
*/
public abstract void exitReadingMode();
/**
* Setup expectations: PlayBooks is on a full-screen page of a book.
*
* Goes to the next page by clicking the right side of the page.
*/
public abstract void goToNextPage();
/**
* Setup expectations: PlayBooks is on a full-screen page of a book.
*
* Goes to the previous page by clicking the left side of the page.
*/
public abstract void goToPreviousPage();
/**
* Setup expectations: PlayBooks is on a full-screen page of a book.
*
* Goes to the next page by scrolling leftwards.
*/
public abstract void scrollToNextPage();
/**
* Setup expectations: PlayBooks is on a full-screen page of a book.
*
* Goes to the previous page by scrolling rightwards.
*/
public abstract void scrollToPreviousPage();
}

View file

@ -0,0 +1,25 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.platform.test.helpers;
import android.app.Instrumentation;
public abstract class AbstractQuickSearchBoxHelper extends AbstractStandardAppHelper {
public AbstractQuickSearchBoxHelper(Instrumentation instr) {
super(instr);
}
}

View file

@ -0,0 +1,87 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.platform.test.helpers;
import android.app.Instrumentation;
import android.content.Intent;
public abstract class AbstractSystemUpdateHelper extends AbstractStandardAppHelper {
protected final static String SYSTEM_UPDATE = "android.settings.SYSTEM_UPDATE_SETTINGS";
public AbstractSystemUpdateHelper(Instrumentation instr) {
super(instr);
}
/**
* As System Update is a subcomponent of Settings, it will not appear in the launcher.
* It needs to be opened directly via its activity.
*/
@Override
public void open() {
Intent startIntent = new Intent(SYSTEM_UPDATE);
startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mInstrumentation.getContext().startActivity(
startIntent);
try {
// wait for app to open
Thread.sleep(7000);
} catch (InterruptedException ignored) {
// do nothing
}
}
/**
* Check whether or not an update is available
* @return true if the device has an update available, false otherwise.
*/
public abstract boolean isUpdateAvailable();
/**
* If an update is available, download it. Otherwise, throw {@link IllegalStateException}.
* Precondition: The device is on the System Update screen.
* Postcondition: A system update will be ready to install.
* @return true if the download succeeded
*/
public abstract boolean downloadUpdate();
/**
* Click on an existing OTA notification.
* Precondition: The notification drawer is open and an OTA notification exists.
* Postcondition: The device is on the System Update screen.
*/
public abstract void clickOtaNotification();
/**
* Check whether or not an OTA notification is present
* @return true if an OTA notification is in the notification drawer, false otherwise.
*/
public abstract boolean hasOtaNotification();
/**
* Check whether or not an attempted OTA download is completed
* @return true if an OTA is ready to install, false otherwise
*/
public abstract boolean isOtaDownloadCompleted();
/**
* Install an OTA. This will cause the device to power off.
* Precondition: A system update is ready to install.
* Postcondition: The device will reboot.
* @return true if the "Install" button was successfully clicked, false otherwise
*/
public abstract boolean installOta();
}

View file

@ -0,0 +1,96 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package android.platform.test.helpers;
import android.support.test.uiautomator.Direction;
public interface ICalendarHelper extends IStandardAppHelper {
// Enumeration of the available Calendar pages.
public enum Page { DAY, MONTH, SCHEDULE, THREE_DAY, WEEK }
/**
* Setup expectations: Calendar is open with all menus closed.
* <p>
* Opens the navigation drawer.
*/
public void openNavigationDrawer();
/**
* Setup expectations: Calendar is open and the navigation drawer is open.
* <p>
* Closes the navigation drawer.
*/
public void closeNavigationDrawer();
/**
* Setup expectations: Calendar is open on a page other than {@link Page.MONTH} with all menus
* closed.
* <p>
* Opens the month dropdown.
*/
public void openMonthDropdown();
/**
* Setup expectations: Calendar is open on a page other than {@link Page.MONTH} and the month
* dropdown is open.
* <p>
* Closes the month dropdown.
*/
public void closeMonthDropdown();
/**
* Setup expectations: Calendar is open with all menus closed.
* <p>
* Opens the {@link FloatingActionButton} menu.
*/
public void openActionMenu();
/**
* Setup expectations: Calendar is open and the action menu is open.
* <p>
* Closes the {@link FloatingActionButton} menu.
*/
public void closeActionMenu();
/**
* Setup expectations: Calendar is open and the navigation drawer is open.
* <p>
* Flings the navigation drawer in the supplied {@link Direction}.
* <p>
* @param dir the {@link Direction} to fling the drawer.
*/
public void flingNavigationDrawer(Direction dir);
/**
* Setup expectations: Calendar is open and the navigation drawer is open.
* <p>
* Selects the supplied {@link Page} from the navigation drawer.
* <p>
* @param page the {@link Page} or layout to select.
*/
public void selectPage(Page page);
/**
* Setup expectations: Calendar is open on the supplied {@link Page} with all menus closed.
* <p>
* Flings the supplied {@link Page} in the supplied {@link Direction}.
* <p>
* @param page the {@link Page} or layout to select.
* @param dir the {@link Direction} to fling in.
*/
public void flingPage(Page page, Direction dir);
}

View file

@ -0,0 +1,140 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.platform.test.helpers;
import android.app.Instrumentation;
import android.support.test.uiautomator.Direction;
import java.lang.IllegalArgumentException;
public interface IChromeHelper extends IStandardAppHelper {
public enum MenuItem {
NEW_TAB("New tab"),
DOWNLOADS("Downloads"),
HISTORY("History"),
SETTINGS("Settings");
private String mDisplayName;
MenuItem(String displayName) {
mDisplayName = displayName;
}
@Override
public String toString() {
return mDisplayName;
}
}
public enum ClearRange {
PAST_HOUR("past hour"),
PAST_DAY("past day"),
PAST_WEEK("past week"),
LAST_4_WEEKS("last 4 weeks"),
BEGINNING_OF_TIME("beginning of time");
private String mDisplayName;
ClearRange(String displayName) {
mDisplayName = displayName;
}
@Override
public String toString() {
return mDisplayName;
}
}
/**
* Setup expectations: Chrome is open and on a standard page, i.e. a tab is open.
*
* This method will open the URL supplied and block until the page is open.
*/
public abstract void openUrl(String url);
/**
* Setup expectations: Chrome is open on a page.
*
* This method will scroll the page as directed and block until idle.
*/
public abstract void flingPage(Direction dir);
/**
* Setup expectations: Chrome is open on a page.
*
* This method will open the overload menu, indicated by three dots and block until open.
*/
public abstract void openMenu();
/**
* Setup expectations: Chrome is open on a page and menu is opened.
*
* This method will open provided item in the menu.
*/
public abstract void openMenuItem(IChromeHelper.MenuItem menuItem);
/**
* Setup expectations: Chrome is open on a page and the tabs are treated as apps.
*
* This method will change the settings to treat tabs inside of Chrome and block until Chrome is
* open on the original tab.
*/
public abstract void mergeTabs();
/**
* Setup expectations: Chrome is open on a page and the tabs are merged.
*
* This method will change the settings to treat tabs outside of Chrome and block until Chrome
* is open on the original tab.
*/
public abstract void unmergeTabs();
/**
* Setup expectations: Chrome is open on a page.
*
* This method will reload the page by clicking the refresh button, and block until the page
* is reopened.
*/
public abstract void reloadPage();
/**
* Setup expectations: Chrome is open on a page.
*
* This method is getter for contentDescription of Tab elements.
*/
public abstract String getTabDescription();
/**
* Setup expectations: Chrome is open on a History page.
*
* This method clears browser history for provided period of time.
*/
public abstract void clearBrowsingData(IChromeHelper.ClearRange range);
/**
* Setup expectations: Chrome is open on a Downloads page.
*
* This method checks header is displayed on Downloads page.
*/
public abstract void checkIfDownloadsOpened();
/**
* Setup expectations: Chrome is open on a Settings page.
*
* This method clicks on Privacy setting on Settings page.
*/
public abstract void openPrivacySettings();
}

View file

@ -0,0 +1,219 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.platform.test.helpers;
import android.app.Instrumentation;
import android.support.test.uiautomator.Direction;
public interface IGoogleCameraHelper extends IStandardAppHelper {
public static final int HDR_MODE_AUTO = -1;
public static final int HDR_MODE_OFF = 0;
public static final int HDR_MODE_ON = 1;
public static final int VIDEO_SD_480 = -2;
public static final int VIDEO_HD_720 = -1;
public static final int VIDEO_HD_1080 = 0;
public static final int VIDEO_4K_MODE_ON = 1;
public static final int VIDEO_30FPS = 0;
public static final int VIDEO_60FPS = 1;
public static final int HFR_MODE_OFF = 0;
public static final int HFR_MODE_120_FPS = 1;
public static final int HFR_MODE_240_FPS = 2;
public static final int FLASH_AUTO = -1;
public static final int FLASH_OFF = 0;
public static final int FLASH_ON = 1;
public static final int NUM_FLASH_MODES = 3;
/**
* Setup expectations: GoogleCamera is open and idle in video mode.
*
* This method will change to camera mode and block until the transition is complete.
*/
public void goToCameraMode();
/**
* Setup expectations: GoogleCamera is open and idle in camera mode.
*
* This method will change to video mode and block until the transition is complete.
*/
public void goToVideoMode();
/**
* Setup expectations: GoogleCamera is open and idle in either camera/video mode.
*
* This method will change to back camera and block until the transition is complete.
*/
public void goToBackCamera();
/**
* Setup expectations: GoogleCamera is open and idle in either camera/video mode.
*
* This method will change to front camera and block until the transition is complete.
*/
public void goToFrontCamera();
/**
* Setup expectation: in Camera mode with the capture button present.
*
* This method will capture a photo and block until the transaction is complete.
*/
public void capturePhoto();
/**
* Setup expectation: in Video mode with the capture button present.
*
* This method will capture a video of length timeInMs and block until the transaction is
* complete.
* @param time duration of video in milliseconds
*/
public void captureVideo(long time);
/**
* Setup expectation:
* 1. in Video mode with the capture button present.
* 2. videoTime > snapshotStartTime
*
* This method will capture a video of length videoTime, and take a picture at snapshotStartTime.
* It will block until the the video is captured and the device is again idle in video mode.
* @param time duration of video in milliseconds
*/
public void snapshotVideo(long videoTime, long snapshotStartTime);
/**
* Setup expectation: GoogleCamera is open and idle in camera mode.
*
* This method will set HDR to one of the following:
* - on (mode == HDR_MODE_ON)
* - auto (mode == HDR_MODE_AUTO)
* - off (mode == HDR_MODE_OFF)
* @param mode the integer value of the mode denoted above.
*/
public void setHdrMode(int mode);
/**
* Setup expectation: GoogleCamera is open and idle in video mode.
*
* This method will set 4K mode to one of the following:
* - on (mode == VIDEO_4K_MODE_ON)
* - off (mode != VIDEO_4K_MODE_ON)
* @param mode the integer value of the mode denoted above.
*/
public void set4KMode(int mode);
/**
* Setup expectation: GoogleCamera is open and idle in video mode.
*
* This method will set HFR mode to one of the following:
* - off (mode == HFR_MODE_OFF)
* - 120 fps (mode == HFR_MODE_120_FPS)
* - 240 fps (mode == HFR_MODE_240_FPS)
* @param mode the integer value of the mode denoted above.
*/
public void setHFRMode(int mode);
/**
*
* Setup expectations: GoogleCamera is open and idle in either camera/video mode.
*
* This method will set EIS to on(true), or off(false).
* @param mode the boolean value of the mode denoted above.
*/
public void setEIS(boolean mode);
/**
* Setup expectation: GoogleCamera is open and idle in either camera/video mode.
*
* This method will set front video capture resolution to one of the following:
* - SD 480p (mode == VIDEO_SD_480)
* - HD 720p (mode == VIDEO_HD_720)
* - HD 1080p (mode == VIDEO_HD_1080)
* - UHD 4K (mode == VIDEO_4K_MODE_ON)
* @param mode the integer value of the mode denoted above.
*/
public void selectFrontVideoResolution(int mode);
/**
* Setup expectation: GoogleCamera is open and idle in either camera/video mode.
*
* This method will set back video capture resolution to one of the following:
* - SD 480p (mode == VIDEO_SD_480)
* - HD 720p (mode == VIDEO_HD_720)
* - HD 1080p (mode == VIDEO_HD_1080)
* - UHD 4K (mode == VIDEO_4K_MODE_ON)
* @param mode the integer value of the mode denoted above.
*/
public void selectBackVideoResolution(int mode);
/**
*
* Setup expectations: GoogleCamera is open, idle, in video mode,
* using back camera, and not in 4k mode
*
* This method will set video capture framerate to one of the following:
* - 30 fps (mode == VIDEO_30FPS)
* - 60 fps (mode == VIDEO_60FPS)
* @param mode the integer value of the mode denoted above.
*/
public void setFrameRate(int mode);
/**
* Setup expectation: GoogleCamera is open and idle in camera or video mode.
*
* This method will set flash to one of the following:
* - on (mode == FLASH_ON)
* - auto (mode == FLASH_AUTO)
* - off (mode == FLASH_OFF)
* @param mode the integer value of the mode denoted above.
*/
public void setFlashMode(int mode);
/**
* Setup expectation: in Camera mode with the capture button present.
*
* This method will block until the capture button is enabled for pressing.
*/
public void waitForCameraShutterEnabled();
/**
* Setup expectation: in Video mode with the capture button present.
*
* This method will block until the capture button is enabled for pressing.
*/
public void waitForVideoShutterEnabled();
/**
* Temporary function.
*/
public String openWithShutterTimeString();
/**
* Setup expectations: in Camera mode or in Video mode
*/
public void goToAlbum();
/**
* Setup expectations:
* 1. in album view
* 2. scroll direction is either LEFT or RIGHT
*
* @param direction scroll direction, either LEFT or RIGHT
*/
public void scrollAlbum(Direction direction);
}

View file

@ -0,0 +1,33 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.platform.test.helpers.tests;
import android.os.RemoteException;
import android.platform.test.helpers.common.test.HelperTest;
import android.platform.test.helpers.IStandardAppHelper;
public abstract class HandheldHelperTest<T extends IStandardAppHelper> extends HelperTest<T> {
@Override
public void initialize() {
try {
getDevice().setOrientationNatural();
} catch (RemoteException e) {
throw new RuntimeException("Could not set orientation.", e);
}
super.initialize();
}
}