[Android] Remove PageController Tests
This CL removes all PageController tests, however, subsequent work to refactor tests to further remove/refactor dependencies on rules and/or utils is left out of scope. Bug: 1141179, 1130617 Change-Id: Ib858e22c53cf04743ab2c38de2b84742057bb9a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4611811 Reviewed-by: Andrew Grieve <agrieve@chromium.org> Reviewed-by: James Lee <ljjlee@google.com> Reviewed-by: Ben Pastene <bpastene@chromium.org> Reviewed-by: Mohamed Heikal <mheikal@chromium.org> Commit-Queue: Fred Mello <fredmello@chromium.org> Cr-Commit-Position: refs/heads/main@{#1158902}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
ec46130b89
commit
bda952bec3
chrome
android
browser
supervised_user
test
android
BUILD.gn
javatests
src
org
chromium
chrome
test
pagecontroller
README.md
codelabsolution
controllers
ElementController.javaPageController.java
android
codelab
first_run
notifications
ntp
ChromeMenu.javaIncognitoNewTabPageController.javaNewTabPageController.javaSuggestionTileController.java
tabswitcher
urlpage
webapk
first_run
rules
tests
infra/config
testing/buildbot
chromium.android.jsonchromium.coverage.jsonchromium.memory.jsongn_isolate_map.pyltest_suite_exceptions.pyltest_suites.pyl
tools/android/pagecontroller
@ -3606,11 +3606,8 @@ chrome_common_shared_library("libchromefortest") {
|
||||
java_targets = [
|
||||
"//chrome/android:chrome_public_unit_test_apk__test_apk",
|
||||
"//chrome/android:chrome_public_test_apk__test_apk",
|
||||
"//chrome/test/android:chrome_java_test_pagecontroller_tests__test_apk",
|
||||
"//chrome/test/android:chrome_java_test_wpr_tests__test_apk",
|
||||
"//chrome/test/android:chrome_java_test_feed_test__test_apk",
|
||||
"//chrome/test/android:chrome_webapk_integration_tests__test_apk",
|
||||
"//chrome/test/android:chrome_java_test_pagecontroller_codelab__test_apk",
|
||||
]
|
||||
if (enable_vr) {
|
||||
java_targets += [ "//chrome/android:chrome_public_test_vr_apk__test_apk" ]
|
||||
|
@ -50,7 +50,7 @@ public class ChromeBundleSmokeTest {
|
||||
ChromeUiApplicationTestRule.PACKAGE_NAME_ARG);
|
||||
Assert.assertNotNull("Must specify bundle under test", mPackageName);
|
||||
try {
|
||||
mChromeUiRule.launchIntoNewTabPageOnFirstRun();
|
||||
UiAutomatorUtils.getInstance().launchApplication(mPackageName);
|
||||
} catch (Exception e) {
|
||||
if (NonInstrumentedCrashDetector.checkDidChromeCrash()) {
|
||||
throw new RuntimeException(mPackageName + " should not have crashed.");
|
||||
|
@ -157,7 +157,7 @@ if (is_android) {
|
||||
"//chrome/browser/supervised_user:supervised_user_metrics_java",
|
||||
"//chrome/browser/supervised_user:website_parent_approval_java",
|
||||
"//chrome/test/android:chrome_java_integration_test_support",
|
||||
"//chrome/test/android:chrome_java_test_pagecontroller",
|
||||
"//chrome/test/android:pagecontroller_utils_java",
|
||||
"//components/browser_ui/bottomsheet/android:java",
|
||||
"//components/browser_ui/bottomsheet/android/test:java",
|
||||
"//components/signin/public/android:java",
|
||||
|
@ -37,57 +37,20 @@ android_library("chrome_java_test_pagecontroller") {
|
||||
testonly = true
|
||||
resources_package = "org.chromium.chrome"
|
||||
sources = [
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/ElementController.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/PageController.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/android/PermissionDialog.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/first_run/SyncConfirmationViewPageController.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/notifications/DownloadNotificationController.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/ntp/ChromeMenu.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/ntp/IncognitoNewTabPageController.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/ntp/NewTabPageController.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/ntp/SuggestionTileController.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/tabswitcher/TabSwitcherController.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/tabswitcher/TabSwitcherMenuController.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/urlpage/UrlPage.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/webapk/first_run/LightWeightTOSController.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/rules/ChromeUiApplicationTestRule.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/rules/ChromeUiAutomatorTestRule.java",
|
||||
]
|
||||
deps = [
|
||||
":chrome_java_integration_test_support",
|
||||
"//base:base_java",
|
||||
"//base:base_java_test_support",
|
||||
"//chrome/android:chrome_app_java_resources",
|
||||
"//chrome/android:chrome_java",
|
||||
"//chrome/android/feed:chrome_feed_java_resources",
|
||||
"//chrome/browser/ui/android/appmenu/test:test_support_java",
|
||||
"//third_party/android_deps:guava_android_java",
|
||||
"//third_party/androidx:androidx_annotation_annotation_java",
|
||||
"//third_party/androidx:androidx_test_core_java",
|
||||
"//third_party/androidx:androidx_test_monitor_java",
|
||||
"//third_party/androidx:androidx_test_uiautomator_uiautomator_java",
|
||||
"//third_party/junit",
|
||||
]
|
||||
public_deps = [ ":pagecontroller_utils_java" ]
|
||||
}
|
||||
|
||||
chrome_public_test_apk_tmpl("chrome_java_test_pagecontroller_tests") {
|
||||
apk_name = "ChromePageControllerTests"
|
||||
sources = [
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/tests/ExampleTest.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/tests/NewTabPageControllerTest.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/tests/TabSwitcherControllerTest.java",
|
||||
]
|
||||
deps = [
|
||||
":chrome_java_test_pagecontroller",
|
||||
"//base:base_java_test_support",
|
||||
"//chrome/browser/flags:java",
|
||||
"//content/public/test/android:content_java_test_support",
|
||||
"//third_party/hamcrest:hamcrest_java",
|
||||
"//third_party/junit",
|
||||
]
|
||||
}
|
||||
|
||||
generate_jni_registration("baseline_profile_test_apk_dummy_jni_registration") {
|
||||
testonly = true
|
||||
java_targets = [ ":baseline_profile_test_apk" ]
|
||||
@ -202,44 +165,6 @@ chrome_public_test_apk_tmpl("chrome_java_test_feed_test") {
|
||||
]
|
||||
}
|
||||
|
||||
# WebAPK tests which require additional_apks should be in this test suite.
|
||||
chrome_public_test_apk_tmpl("chrome_webapk_integration_tests") {
|
||||
apk_name = "ChromeWebApkIntegrationTests"
|
||||
sources = [ "javatests/src/org/chromium/chrome/test/pagecontroller/tests/webapk/MapsGoFirstRunTest.java" ]
|
||||
deps = [
|
||||
":chrome_java_test_pagecontroller",
|
||||
"//base:base_java",
|
||||
"//base:base_java_test_support",
|
||||
"//chrome/android:chrome_java",
|
||||
"//chrome/android/webapk/libs/client:client_java",
|
||||
"//chrome/android/webapk/libs/runtime_library:runtime_library_javatests",
|
||||
"//chrome/android/webapk/shell_apk:shell_apk_javatests",
|
||||
"//chrome/browser/first_run/android:java",
|
||||
"//components/webapk/android/libs/client:java",
|
||||
"//content/public/test/android:content_java_test_support",
|
||||
"//third_party/androidx:androidx_test_core_java",
|
||||
"//third_party/androidx:androidx_test_monitor_java",
|
||||
"//third_party/junit",
|
||||
]
|
||||
|
||||
additional_apks = [
|
||||
"//chrome/android/webapk/libs/runtime_library/javatests/apk_with_webapk_service:apk_with_webapk_service",
|
||||
"//chrome/android/webapk/shell_apk/javatests/dex_optimizer:dex_optimizer_apk",
|
||||
"//chrome/android/webapk/shell_apk:javatests_webapk",
|
||||
"//chrome/android/webapk/shell_apk:uiautomator_maps_go_webapk",
|
||||
]
|
||||
}
|
||||
|
||||
chrome_public_test_apk_tmpl("chrome_java_test_pagecontroller_codelab") {
|
||||
apk_name = "ChromePageControllerCodelab"
|
||||
sources = [ "javatests/src/org/chromium/chrome/test/pagecontroller/tests/codelab/SettingsForCodelabTest.java" ]
|
||||
deps = [
|
||||
":chrome_java_test_pagecontroller",
|
||||
"//base:base_java_test_support",
|
||||
"//third_party/junit",
|
||||
]
|
||||
}
|
||||
|
||||
robolectric_binary("chrome_java_test_pagecontroller_junit_tests") {
|
||||
testonly = true
|
||||
sources = [
|
||||
|
@ -1,160 +0,0 @@
|
||||
# Chrome's Page Controller Test Library
|
||||
|
||||
## Introduction
|
||||
|
||||
Page Controllers simplify the task of writing and maintaining integration tests
|
||||
by organizing the logic to interact with the various application UI components
|
||||
into re-usable classes. Learn how to write and use Page Controllers to solve
|
||||
your testing needs.
|
||||
|
||||
|
||||
## File Organization
|
||||
|
||||
[codelabsolution](codelabsolution]: Solutions for the [code lab](#code-lab).
|
||||
[controllers](https://cs.chromium.org/chromium/src/chrome/test/android/javatests/src/org/chromium/chrome/test/pagecontroller/controllers/): Contains all the Page Controllers.<br/>
|
||||
[rules](https://cs.chromium.org/chromium/src/chrome/test/android/javatests/src/org/chromium/chrome/test/pagecontroller/rules/): Junit Test Rules that provide access to the Page Controllers in a
|
||||
test case.<br/>
|
||||
[tests](https://cs.chromium.org/chromium/src/chrome/test/android/javatests/src/org/chromium/chrome/test/pagecontroller/tests/): Tests for the Page Controllers themselves.<br/>
|
||||
[utils](https://cs.chromium.org/chromium/src/chrome/test/android/javatests/src/org/chromium/chrome/test/pagecontroller/utils/): Utility classes that are useful for writing Page Controllers.<br/>
|
||||
|
||||
|
||||
## Using IDEs
|
||||
IDEs will make writing tests and maintaining Page Controllers much easier with online documentation and code completion. See the [setup
|
||||
guide](https://chromium.googlesource.com/chromium/src/+/HEAD/docs/README.md#integrated-development-environment-ide_set-up-guides).
|
||||
|
||||
|
||||
## Code Lab
|
||||
The code lab is an introduction to writing new Page Controllers and using them in tests.
|
||||
|
||||
1) Create a new branch to go through the exercise, ex:
|
||||
```
|
||||
git checkout -b pagecontroller_codelab
|
||||
```
|
||||
|
||||
2) Add code lab files to the build by adding the following lines to chrome/test/android/BUILD.gn.
|
||||
```
|
||||
...
|
||||
android_library("chrome_java_test_pagecontroller") {
|
||||
testonly = true
|
||||
sources = [
|
||||
...
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/android/PermissionDialog.java",
|
||||
+ "javatests/src/org/chromium/chrome/test/pagecontroller/controllers/codelab/SearchEngineSelectionControllerForCodelab.java",
|
||||
+ "javatests/src/org/chromium/chrome/test/pagecontroller/controllers/codelab/SettingsControllerForCodelab.java",
|
||||
...
|
||||
]
|
||||
```
|
||||
|
||||
3) Modify the following files according to TODO hints contained therein. It's
|
||||
best to build and test frequently iteratively as you complete the TODO items.
|
||||
- Start here: [SettingsForCodelabTest.java](tests/codelab/SettingsForCodelabTest.java)
|
||||
- Complete TODOs in: [controllers/ntp/ChromeMenu.java](controllers/ntp/ChromeMenu.java)
|
||||
(Hint, Read the ["Where to find the resource and string
|
||||
ids"](#where-to-find-the-resource-and-string-ids) section to find resource and
|
||||
string ids to use in locators.)
|
||||
- Complete TODOs to pass SettingsForCodelabTest.testOpenCodelabSettings: [controllers/codelab/SettingsControllerForCodelab.java](controllers/codelab/SettingsControllerForCodelab.java)
|
||||
- Complete TODOs to pass SettingsForCodelabTest.testSwitchSearchEngine:
|
||||
[controllers/codelab/SearchEngineSelectionControllerForCodelab.java](controllers/codelab/SearchEngineSelectionControllerForCodelab.java)
|
||||
|
||||
4) Build the codelab.
|
||||
```
|
||||
autoninja -C out/Debug chrome_java_test_pagecontroller_codelab
|
||||
```
|
||||
|
||||
5) Run codelab tests (repeat from step 3 until all the tests pass).
|
||||
```
|
||||
# Open the html results link to view logcat to debug errors. There will be an
|
||||
# xml hierarchy dump of the UI in case of test failures in the logcat.
|
||||
# Screenshot is also available in the test results page.
|
||||
|
||||
# Run the tests one at a time (to aid in troubleshooting) by using the -f option:
|
||||
out/Debug/bin/run_chrome_java_test_pagecontroller_codelab --num-retries 0 --local-output -f "*SettingsForCodelabTest.testOpenSettings"
|
||||
|
||||
out/Debug/bin/run_chrome_java_test_pagecontroller_codelab --num-retries 0 --local-output -f "*SettingsForCodelabTest.testSwitchSearchEngine"
|
||||
```
|
||||
|
||||
6) Sample answers are [here](codelabsolution/README.md) in case you get stuck.
|
||||
|
||||
|
||||
## Writing Testcases
|
||||
|
||||
See the [ExampleTest](https://cs.chromium.org/chromium/src/chrome/test/android/javatests/src/org/chromium/chrome/test/pagecontroller/tests/ExampleTest.java).
|
||||
|
||||
## Creating + Updating Page Controllers
|
||||
|
||||
Currently the Page Controllers use UIAutomator under-the-hood. But it is
|
||||
entirely possible to write methods or whole page controllers using Espresso or
|
||||
some other driver framework.
|
||||
|
||||
```
|
||||
/**
|
||||
* Page controller for CoolNewPage
|
||||
*/
|
||||
class CoolNewPageController extends PageController {
|
||||
// Locators allow the controller to find UI elements on the page
|
||||
// It is preferred to use Resource Ids to find elements since they are
|
||||
// stable across minor UI changes.
|
||||
private static final IUi2Locator LOCATOR_COOL_PAGE = Ui2Locators.withAnyResEntry(R.id.cool_page);
|
||||
// Any of the resource ids in the list will result in a match.
|
||||
private static final IUi2Locator LOCATOR_COOL_BUTTON = Ui2Locators.withAnyResEntry(R.id.cool_button_v1, R.id.cool_button_v2);
|
||||
|
||||
public CoolerPageController clickButton() {
|
||||
// [UiAutomatorUtils.click](https://cs.chromium.org/chromium/src/chrome/test/android/javatests/src/org/chromium/chrome/test/pagecontroller/utils/UiAutomatorUtils.java?q=click) operates on UI elements via IUi2Locators.
|
||||
// In general, methods that operate on IUi2Locators will throw if that
|
||||
// locator could not find an UI elements on the page.
|
||||
// UiAutomatorUtils has retry functionality with a configurable timeout,
|
||||
// so that flakiness can be drastically reduced.
|
||||
mUtils.click(LOCATOR_SOME_BUTTON);
|
||||
|
||||
// If clicking on cool button should always result in the app going
|
||||
// to the EvenCoolerPage, then the action method should return an
|
||||
// instance of that controller via its assertIsCurrentPage() method.
|
||||
// This ensures the UI state is synced upon the return of the method.
|
||||
return EvenCoolerPageController.getInstance().assertIsCurrentPage();
|
||||
}
|
||||
|
||||
// All page controllers must implement this method.
|
||||
@Override
|
||||
public SomePageController assertIsCurrentPage() {
|
||||
mLocatorHelper.get(LOCATOR_SOME_PAGE); // Throws if not found
|
||||
return this;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Where to find the resource and string ids.
|
||||
|
||||
If you're working on a new UI change or are familiar with the UI that you want
|
||||
to implement a Page Controller for, then you already should know what R.id.* and
|
||||
R.string.* entries to use in the Page Controllers. Prefer to construct locators
|
||||
with these resources, for example:
|
||||
|
||||
```
|
||||
import org.chromium.chrome.R;
|
||||
...
|
||||
IUi2Locator LOCATOR_TAB_SWITCHER_BUTTON = Ui2Locators.withResEntries(R.id.tab_switcher_button);
|
||||
|
||||
IUi2Locator LOCATOR_NEW_TAB_MENU_ITEM =
|
||||
Ui2Locators.withPath(Ui2Locators.withResEntries(R.id.menu_item_text),
|
||||
Ui2Locators.withText(R.string.menu_new_tab));
|
||||
```
|
||||
|
||||
**It is highly recommended that unique R.id entries are present for important UI elements in an activity, add if they're missing.**
|
||||
|
||||
**It is also highly recommended that R.string.\* entries be used in Page Controllers and tests instead of hard-coding them. This will keep tests in sync with the code-base and allow them to work under different language settings.**
|
||||
|
||||
If you are not too sure about the correct resource / string ids to use, see if you can find the developer or maintainer for the UI. If they're not available, here are some tips:
|
||||
|
||||
- [Android Layout inspector](https://developer.android.com/studio/debug/layout-inspector): This is useful to find out the resource ids (click an element, then expand the properties list, under mID). To see strings, expand the text folder, see the mText field. Note that this is the literal string, not the string resource id (see strings grd file below).
|
||||
|
||||
- The res directory: Search in [chrome/android/java/res/](https://cs.chromium.org/chromium/src/chrome/android/java/res/) directory for resource ids and string ids. They are defined there and then auto generated (@+id/xyz -> R.id.xyz)
|
||||
|
||||
- Search the strings grd file with
|
||||
[search_strings.py](https://cs.chromium.org/chromium/src/tools/android/pagecontroller/search_strings.py).
|
||||
|
||||
[android_chrome_strings.grd](https://cs.chromium.org/chromium/src/chrome/browser/ui/android/strings/android_chrome_strings.grd) contains the list of strings used in Clank.
|
||||
The entries are transformed into android strings using the name attribute by dropping the IDS_ prefix and converting the rest into lower case. For example: IDS_MENU_BOOKMARKS -> R.string.menu_bookmarks. There may be several string matching what's displayed but with different ids, be sure to read the "desc" field in the grd file and also the java source code for the UI to pick the right one.
|
||||
|
||||
- The Clank java source code: [src/chrome/android/java/src/org/chromium/chrome/browser/](https://cs.chromium.org/chromium/src/chrome/android/java/src/org/chromium/chrome/browser/)
|
||||
|
||||
Search for ids and strings discovered in the previous steps to see how they are used.
|
274
chrome/test/android/javatests/src/org/chromium/chrome/test/pagecontroller/codelabsolution/README.md
274
chrome/test/android/javatests/src/org/chromium/chrome/test/pagecontroller/codelabsolution/README.md
@ -1,274 +0,0 @@
|
||||
# Solutions for Chrome Page Controller Code Lab
|
||||
|
||||
## These are sample solutions for the Code Lab, but not the only way to do it.
|
||||
|
||||
***Paths in steps 1-4 are relative to src/chrome/test/android/javatests/src/org/chromium/chrome/test/pagecontroller/,
|
||||
steps 5 is relative the chromium/src.***
|
||||
|
||||
1) tests/codelab/SettingsForCodelabTest.java:
|
||||
``` java
|
||||
package org.chromium.chrome.test.pagecontroller.tests.codelab;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.RuleChain;
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.codelab.SearchEngineSelectionControllerForCodelab;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.ntp.ChromeMenu;
|
||||
import org.chromium.chrome.test.pagecontroller.rules.ChromeUiApplicationTestRule;
|
||||
import org.chromium.chrome.test.pagecontroller.rules.ChromeUiAutomatorTestRule;
|
||||
|
||||
/**
|
||||
* Test for Page Controllers created in the code lab.
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class SettingsForCodelabTest {
|
||||
// ChromeUiAutomatorTestRule will capture a screen shot and UI Hierarchy info in the event
|
||||
// of a test failure to aid test debugging.
|
||||
public ChromeUiAutomatorTestRule mUiAutomatorRule = new ChromeUiAutomatorTestRule();
|
||||
|
||||
// ChromeUiApplicationTestRule provides a way to launch the Chrome Application under test
|
||||
// and access to the Page Controllers.
|
||||
public ChromeUiApplicationTestRule mChromeUiRule = new ChromeUiApplicationTestRule();
|
||||
|
||||
// The rule chain allows deterministic ordering of test rules so that the
|
||||
// UiAutomatorRule will print debugging information in case of errors
|
||||
// before the application is shut-down.
|
||||
@Rule
|
||||
public final TestRule mChain = RuleChain.outerRule(mChromeUiRule).around(mUiAutomatorRule);
|
||||
|
||||
private ChromeMenu mChromeMenu;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
// TODO: Obtain a ChromeMenu instance. Hint, start with
|
||||
// mChromeUiRule.launchIntoNewTabPageOnFirstRun().
|
||||
mChromeMenu = mChromeUiRule.launchIntoNewTabPageOnFirstRun().openChromeMenu();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenSettingsControllerForCodelab() {
|
||||
// TODO: Modify ChromeMenu.java to add a method that returns an
|
||||
// instance of CodeLabSettings Page Controller.
|
||||
mChromeMenu.openSettingsForCodelab();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitchSearchEngine() {
|
||||
// TODO: Write a test to verify ability to change the default search
|
||||
// engine.
|
||||
SearchEngineSelectionControllerForCodelab engineSelection =
|
||||
mChromeMenu.openSettingsForCodelab().clickSearchEngine();
|
||||
Assert.assertEquals(engineSelection.getEngineChoice(), "Google");
|
||||
engineSelection.chooseSearchEngine("Bing");
|
||||
Assert.assertEquals(engineSelection.getEngineChoice(), "Bing");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2) controllers/codelab/SettingsControllerForCodelab.java:
|
||||
``` java
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.codelab;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
|
||||
// TODO: Read documentation in the PageController class. Refer to implemented
|
||||
// Page Controllers in the pagecontroller directory for examples.
|
||||
/**
|
||||
* Settings Menu Page Controller for the Code Lab.
|
||||
*/
|
||||
public class SettingsControllerForCodelab extends PageController {
|
||||
// TODO: Replace null with a an actual locator. (Hint, see Ui2Locators.with*.)
|
||||
private static final IUi2Locator LOCATOR_SETTINGS =
|
||||
Ui2Locators.withTextString(R.string.settings);
|
||||
|
||||
// TODO: (Hint, you may need more IUi2Locators than just LOCATOR_SETTINGS,
|
||||
// add them here.
|
||||
private static final IUi2Locator LOCATOR_SEARCH_ENGINE =
|
||||
Ui2Locators.withTextString(R.string.search_engine_settings);
|
||||
|
||||
// The next 5 lines are boilerplate, no need to modify.
|
||||
private static final SettingsControllerForCodelab sInstance =
|
||||
new SettingsControllerForCodelab();
|
||||
private SettingsControllerForCodelab() {}
|
||||
public static SettingsControllerForCodelab getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsControllerForCodelab verifyActive() {
|
||||
// TODO: See PageController.verifyActive documentation on what this
|
||||
// method should do. (Hint, PageController has a mLocatorHelper field.)
|
||||
mLocatorHelper.verifyOnScreen(LOCATOR_SETTINGS);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Click on the Search Engine option.
|
||||
* @returns SearchEngineSelectionControllerForCodelab PageController.
|
||||
*/
|
||||
public SearchEngineSelectionControllerForCodelab clickSearchEngine() {
|
||||
// TODO: Perform a click on the Search engine option
|
||||
// in the Settings menu. (Hint, PageController has a mUtils field.)
|
||||
mUtils.click(LOCATOR_SEARCH_ENGINE);
|
||||
|
||||
// TODO: Replace null with an instance of
|
||||
// SearchEngineSelectionControllerForCodelab. (Hint, all PageController
|
||||
// subclasses have a verifyActive method.)
|
||||
return SearchEngineSelectionControllerForCodelab.getInstance().verifyActive();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3) controllers/codelab/SearchEngineSelectionControllerForCodelab.java:
|
||||
``` java
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.codelab;
|
||||
|
||||
import androidx.test.uiautomator.UiObject2;
|
||||
import android.util.Pair;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.UiLocationException;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.UiLocatorHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Search Engine Selection Page Controller for the Code Lab, corresponds to
|
||||
* {@link org.chromium.chrome.browser.search_engines.settings.SearchEngineSettings}.
|
||||
*/
|
||||
public class SearchEngineSelectionControllerForCodelab extends PageController {
|
||||
// TODO: Put locators here.
|
||||
private static final IUi2Locator LOCATOR_SEARCH_ENGINE =
|
||||
Ui2Locators.withPath(Ui2Locators.withAnyResEntry(R.id.action_bar),
|
||||
Ui2Locators.withTextString(R.string.search_engine_settings));
|
||||
private static final IUi2Locator LOCATOR_ALL_ENGINES = Ui2Locators.withPath(
|
||||
Ui2Locators.withAnyResEntry(R.id.name), Ui2Locators.withTextRegex("^(.+)$"));
|
||||
private class EngineSelectionIndicator
|
||||
implements UiLocatorHelper.CustomElementMaker<Pair<String, Boolean>> {
|
||||
@Override
|
||||
public Pair<String, Boolean> makeElement(UiObject2 root, boolean isLastAttempt) {
|
||||
String engine = mLocatorHelper.getOneTextImmediate(LOCATOR_ALL_ENGINES, root);
|
||||
Boolean isChecked = mLocatorHelper.getOneCheckedImmediate(LOCATOR_ALL_ENGINES, root);
|
||||
if (engine == null) {
|
||||
throw new UiLocationException("Engine not found.", LOCATOR_ALL_ENGINES, root);
|
||||
} else if (isChecked == null) {
|
||||
throw new UiLocationException(
|
||||
"Checked status not found.", LOCATOR_ALL_ENGINES, root);
|
||||
} else {
|
||||
return new Pair<String, Boolean>(engine, isChecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
private EngineSelectionIndicator mEngineSelectionIndicator = new EngineSelectionIndicator();
|
||||
// The next 5 lines are boilerplate, no need to modify.
|
||||
private static final SearchEngineSelectionControllerForCodelab sInstance =
|
||||
new SearchEngineSelectionControllerForCodelab();
|
||||
private SearchEngineSelectionControllerForCodelab() {}
|
||||
public static SearchEngineSelectionControllerForCodelab getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
@Override
|
||||
public SearchEngineSelectionControllerForCodelab verifyActive() {
|
||||
// TODO: Implement this method.
|
||||
mLocatorHelper.verifyOnScreen(LOCATOR_SEARCH_ENGINE);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Choose the Omnibox default search engine.
|
||||
* @param engine The engine to choose.
|
||||
*/
|
||||
public SearchEngineSelectionControllerForCodelab chooseSearchEngine(String engineName) {
|
||||
// TODO: Perform a click on the engine choice.
|
||||
mUtils.click(getEngineLocator(engineName));
|
||||
// Returning this instead of void facilitates chaining.
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @return The current engine choice.
|
||||
*/
|
||||
public String getEngineChoice() {
|
||||
// TODO: Determine which engine option is selected and return it.
|
||||
String engineSelection = null;
|
||||
List<Pair<String, Boolean>> engineSelections =
|
||||
mLocatorHelper.getCustomElements(LOCATOR_ALL_ENGINES, mEngineSelectionIndicator);
|
||||
for (Pair<String, Boolean> pair : engineSelections) {
|
||||
if (pair.second) {
|
||||
if (engineSelection == null) {
|
||||
engineSelection = pair.first;
|
||||
} else {
|
||||
throw new UiLocationException("More than 1 engine chosen: " + engineSelection
|
||||
+ "," + pair.first + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (engineSelection == null) {
|
||||
throw new UiLocationException("No engines chosen!");
|
||||
}
|
||||
return engineSelection;
|
||||
}
|
||||
/**
|
||||
* @return IUi2Locator to find the engine choice. Since the engine name
|
||||
* varies across languages, this couldn't be hard-coded.
|
||||
*/
|
||||
private IUi2Locator getEngineLocator(String engineName) {
|
||||
return Ui2Locators.withPath(LOCATOR_ALL_ENGINES, Ui2Locators.withText(engineName));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
4) controllers/ntp/ChromeMenu.java, add lines marked with "+":
|
||||
``` java
|
||||
...
|
||||
|
||||
+ import org.chromium.chrome.test.pagecontroller.controllers.codelab.SettingsControllerForCodelab;
|
||||
...
|
||||
public class ChromeMenu extends PageController {
|
||||
...
|
||||
+ private static final IUi2Locator LOCATOR_SETTINGS_FOR_CODELAB =
|
||||
+ Ui2Locators.withPath(Ui2Locators.withAnyResEntry(R.id.menu_item_text),
|
||||
+ Ui2Locators.withTextString(R.string.menu_settings));
|
||||
...
|
||||
+ public SettingsControllerForCodelab openSettingsForCodelab() {
|
||||
+ mUtils.click(LOCATOR_SETTINGS_FOR_CODELAB);
|
||||
+ return SettingsControllerForCodelab.getInstance().verifyActive();
|
||||
+ }
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
5) Add lines marked with '+' to chrome/test/android/BUILD.gn:
|
||||
```
|
||||
android_library("chrome_java_test_pagecontroller") {
|
||||
testonly = true
|
||||
sources = [
|
||||
...
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/android/PermissionDialog.java",
|
||||
+ "javatests/src/org/chromium/chrome/test/pagecontroller/controllers/codelab/SettingsControllerForCodelab.java",
|
||||
+ "javatests/src/org/chromium/chrome/test/pagecontroller/controllers/codelab/SearchEngineSelectionControllerForCodelab.java",
|
||||
"javatests/src/org/chromium/chrome/test/pagecontroller/controllers/first_run/TOSController.java",
|
||||
...
|
||||
|
||||
```
|
||||
|
||||
6) Build and run.
|
||||
``` bash
|
||||
autoninja -C out/Debug chrome_java_test_pagecontroller_codelab
|
||||
|
||||
out/Debug/bin/run_chrome_java_test_pagecontroller_codelab --num-retries 0 --local-output
|
||||
```
|
@ -1,30 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers;
|
||||
|
||||
import org.chromium.chrome.test.pagecontroller.utils.UiAutomatorUtils;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.UiLocatorHelper;
|
||||
|
||||
/**
|
||||
* Base class for any controller that needs to perform UI actions and verify UI
|
||||
* state.
|
||||
*
|
||||
* Could represent anything from buttons to a news snippet on the New Tab Page,
|
||||
* although simple elements such as buttons can be controlled by
|
||||
* helper methods such as {@link UiAutomatorUtils#click} so that implementing
|
||||
* ElementControllers for them is usually not necessary.
|
||||
*
|
||||
* For modal UI such as the 3-dot menu, its controller should subclass
|
||||
* PageController.
|
||||
*/
|
||||
public class ElementController {
|
||||
protected final UiAutomatorUtils mUtils;
|
||||
protected final UiLocatorHelper mLocatorHelper;
|
||||
|
||||
public ElementController() {
|
||||
mUtils = UiAutomatorUtils.getInstance();
|
||||
mLocatorHelper = mUtils.getLocatorHelper();
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers;
|
||||
|
||||
import android.os.RemoteException;
|
||||
|
||||
import org.chromium.chrome.test.pagecontroller.utils.UiLocationException;
|
||||
|
||||
/**
|
||||
* Base class for Page Controllers.
|
||||
*
|
||||
* A Page Controller allows tests to interact with a single modal view in the
|
||||
* app-under-test. "Page" here does not mean a web-page, but more like Android
|
||||
* Activity. Although special pages such as "chrome://version" could be
|
||||
* implemented as a distinct PageController which other normal webpages can be
|
||||
* loaded in a more generic UrlPage controller. Modal menus or dialogs
|
||||
* controllers are also appropriate to implement as PageControllers.
|
||||
*
|
||||
* When implementing methods that would otherwise return void, but does not
|
||||
* navigate to another PageController, consider returning "this" to facilitate
|
||||
* chaining.
|
||||
*
|
||||
* When implementing methods that navigates to another PageController, consider
|
||||
* returning a verified instance of that controller by returning the result of
|
||||
* its verifyActive() method to facilitate chaining. An exception to this
|
||||
* would be if experiments could cause navigation to different PageControllers,
|
||||
* then the return value should be void.
|
||||
*/
|
||||
public abstract class PageController extends ElementController {
|
||||
public void pressAndroidBackButton() {
|
||||
mUtils.pressBack();
|
||||
}
|
||||
|
||||
public void pressAndroidHomeButton() {
|
||||
mUtils.pressHome();
|
||||
}
|
||||
|
||||
public void pressAndroidOverviewButton() {
|
||||
try {
|
||||
// UiDevice (used by UiAutomatorUtils) calls this the recent apps button,
|
||||
// Android UI seems to prefer the overview button name (as evidenced by talkback's
|
||||
// readout)
|
||||
mUtils.pressRecentApps();
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current page displayed corresponds to this page controller.
|
||||
* @return True if current page can be controlled by this controller, else false.
|
||||
*/
|
||||
public final boolean isCurrentPageThis() {
|
||||
try {
|
||||
verifyActive();
|
||||
return true;
|
||||
} catch (UiLocationException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the current page belongs to the controller.
|
||||
* @throws UiLocationException if the current page does not belong the controller.
|
||||
*/
|
||||
public abstract PageController verifyActive();
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.android;
|
||||
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
|
||||
/**
|
||||
* Android Permissions Dialog Page Controller.
|
||||
*/
|
||||
public class PermissionDialog extends PageController {
|
||||
private static final IUi2Locator LOCATOR_PERMISSION_DIALOG =
|
||||
Ui2Locators.withResName("com.android.packageinstaller:id/perm_desc_root");
|
||||
private static final IUi2Locator LOCATOR_ALLOW =
|
||||
Ui2Locators.withResName("com.android.packageinstaller:id/permission_allow_button");
|
||||
private static final IUi2Locator LOCATOR_DENY =
|
||||
Ui2Locators.withResName("com.android.packageinstaller:id/permission_deny_button");
|
||||
private static final IUi2Locator LOCATOR_MESSAGE =
|
||||
Ui2Locators.withResName("com.android.packageinstaller:id/permission_message");
|
||||
|
||||
private static final PermissionDialog sInstance = new PermissionDialog();
|
||||
private PermissionDialog() {}
|
||||
public static PermissionDialog getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void clickAllow() {
|
||||
mUtils.click(LOCATOR_ALLOW);
|
||||
}
|
||||
|
||||
public void clickDeny() {
|
||||
mUtils.click(LOCATOR_DENY);
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return mLocatorHelper.getOneText(LOCATOR_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionDialog verifyActive() {
|
||||
mLocatorHelper.verifyOnScreen(LOCATOR_PERMISSION_DIALOG);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.codelab;
|
||||
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
|
||||
// TODO: Implement page controller for SearchEngineSettings.java.
|
||||
|
||||
/**
|
||||
* Search Engine Selection Page Controller for the Code Lab, representing
|
||||
* SearchEnginePreferences.java.
|
||||
*
|
||||
* @see {@link org.chromium.chrome.browser.search_engines.settings.SearchEngineSettings}
|
||||
*/
|
||||
|
||||
public class SearchEngineSelectionControllerForCodelab extends PageController {
|
||||
// The next 5 lines are boilerplate, no need to modify.
|
||||
private static final SearchEngineSelectionControllerForCodelab sInstance =
|
||||
new SearchEngineSelectionControllerForCodelab();
|
||||
private SearchEngineSelectionControllerForCodelab() {}
|
||||
public static SearchEngineSelectionControllerForCodelab getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchEngineSelectionControllerForCodelab verifyActive() {
|
||||
// TODO: Implement this method to verify that the UI is displaying the
|
||||
// search engine selection activity then return this (otherwise throw).
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose the Omnibox default search engine.
|
||||
* @param engine The engine to choose.
|
||||
* @return SearchEngineSelectionControllerForCodelab, after verification that
|
||||
* the page has transitioned to it.
|
||||
*/
|
||||
public SearchEngineSelectionControllerForCodelab chooseSearchEngine(String engineName) {
|
||||
// TODO: Construct a IUi2Locator for the element corresponding to the
|
||||
// given engineName and perform a click on it.
|
||||
// (Hint, the resource id entry for search engine choices along with the
|
||||
// engineName can be used by Ui2Locators.withPath(...).)
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The current engine choice.
|
||||
*/
|
||||
public String getEngineChoice() {
|
||||
// TODO: Determine which engine option is selected and return it.
|
||||
// (Hint, there are various get*Checked methods in UILocatorHelper
|
||||
// to find out if something is checked.)
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.codelab;
|
||||
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
|
||||
// TODO: Implement page controller for MainSettings.java. Read
|
||||
// documentation in the PageController class and refer to implemented Page
|
||||
// Controllers in the pagecontroller directory for examples.
|
||||
|
||||
/**
|
||||
* Settings Menu Page Controller for the Code Lab, representing
|
||||
* {@link org.chromium.chrome.browser.settings.MainSettings}.
|
||||
*/
|
||||
public class SettingsControllerForCodelab extends PageController {
|
||||
// TODO: Replace null with a an actual locator. Hint, see
|
||||
// {@link ../../README.md#where-to-find-the-resource-and-string-ids}, and
|
||||
// {@link ../../utils/Ui2Locators#withTextString}.
|
||||
static final IUi2Locator LOCATOR_SETTINGS = null;
|
||||
|
||||
// TODO: (Hint, you may need more IUi2Locators, add them here.
|
||||
|
||||
// The next 5 lines are boilerplate, no need to modify.
|
||||
private static final SettingsControllerForCodelab sInstance =
|
||||
new SettingsControllerForCodelab();
|
||||
private SettingsControllerForCodelab() {}
|
||||
public static SettingsControllerForCodelab getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsControllerForCodelab verifyActive() {
|
||||
// TODO: See PageController.verifyActive documentation on what this
|
||||
// method should do. (Hint, PageController has a mLocatorHelper field.)
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Click on the Search Engine option.
|
||||
* @returns SearchEngineSelectionControllerForCodelab PageController.
|
||||
*/
|
||||
public SearchEngineSelectionControllerForCodelab clickSearchEngine() {
|
||||
// TODO: Perform a click on the Search engine option
|
||||
// in the Settings menu. (Hint, PageController has a mUtils field.)
|
||||
|
||||
// TODO: Replace null with an instance of CodelabSearchEngine. (Hint,
|
||||
// all PageController subclasses have a verifyActive method.)
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.first_run;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
|
||||
/**
|
||||
* Sync Dialog (part of First Run Experience) Page Controller.
|
||||
*/
|
||||
public class SyncConfirmationViewPageController extends PageController {
|
||||
private static final IUi2Locator LOCATOR_SYNC_CONFIRMATION_VIEW =
|
||||
Ui2Locators.withAnyResEntry(R.id.signin_sync_title);
|
||||
private static final IUi2Locator LOCATOR_NO_THANKS =
|
||||
Ui2Locators.withAnyResEntry(R.id.negative_button);
|
||||
|
||||
private static final SyncConfirmationViewPageController sInstance =
|
||||
new SyncConfirmationViewPageController();
|
||||
private SyncConfirmationViewPageController() {}
|
||||
public static SyncConfirmationViewPageController getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void clickNoThanks() {
|
||||
mUtils.click(LOCATOR_NO_THANKS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SyncConfirmationViewPageController verifyActive() {
|
||||
mLocatorHelper.verifyOnScreen(LOCATOR_SYNC_CONFIRMATION_VIEW);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.notifications;
|
||||
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
|
||||
/**
|
||||
* Download Permissions Dialog (download for offline viewing) Page Controller.
|
||||
*/
|
||||
public class DownloadNotificationController extends PageController {
|
||||
private static final IUi2Locator LOCATOR_DOWNLOAD_NOTIFICATION =
|
||||
Ui2Locators.withTextContaining("needs storage access to download files");
|
||||
private static final IUi2Locator LOCATOR_CONTINUE =
|
||||
Ui2Locators.withAnyResEntry(android.R.id.button1);
|
||||
|
||||
private static final DownloadNotificationController sInstance =
|
||||
new DownloadNotificationController();
|
||||
private DownloadNotificationController() {}
|
||||
public static DownloadNotificationController getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void clickContinue() {
|
||||
mUtils.click(LOCATOR_CONTINUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadNotificationController verifyActive() {
|
||||
mLocatorHelper.verifyOnScreen(LOCATOR_DOWNLOAD_NOTIFICATION);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.ntp;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.ui.appmenu.AppMenuTestSupport;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
|
||||
/**
|
||||
* Chrome Menu (NTP 3-dot menu) Page Controller.
|
||||
*/
|
||||
public class ChromeMenu extends PageController {
|
||||
private static final IUi2Locator LOCATOR_CHROME_MENU_BOX =
|
||||
Ui2Locators.withAnyResEntry(AppMenuTestSupport.getAppMenuLayoutListViewId());
|
||||
|
||||
private static final IUi2Locator LOCATOR_NEW_TAB = Ui2Locators.withPath(
|
||||
Ui2Locators.withAnyResEntry(AppMenuTestSupport.getStandardMenuItemTextViewId()),
|
||||
Ui2Locators.withTextString(R.string.menu_new_tab));
|
||||
private static final IUi2Locator LOCATOR_NEW_INCOGNITO_TAB = Ui2Locators.withPath(
|
||||
Ui2Locators.withAnyResEntry(AppMenuTestSupport.getStandardMenuItemTextViewId()),
|
||||
Ui2Locators.withTextString(R.string.menu_new_incognito_tab));
|
||||
|
||||
private static final ChromeMenu sInstance = new ChromeMenu();
|
||||
private ChromeMenu() {}
|
||||
public static ChromeMenu getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChromeMenu verifyActive() {
|
||||
mLocatorHelper.verifyOnScreen(LOCATOR_CHROME_MENU_BOX);
|
||||
return this;
|
||||
}
|
||||
|
||||
public NewTabPageController openNewTab() {
|
||||
mUtils.click(LOCATOR_NEW_TAB);
|
||||
return NewTabPageController.getInstance().verifyActive();
|
||||
}
|
||||
|
||||
public IncognitoNewTabPageController openNewIncognitoTab() {
|
||||
mUtils.click(LOCATOR_NEW_INCOGNITO_TAB);
|
||||
return IncognitoNewTabPageController.getInstance().verifyActive();
|
||||
}
|
||||
|
||||
public NewTabPageController dismiss() {
|
||||
mUtils.clickOutsideOf(LOCATOR_CHROME_MENU_BOX);
|
||||
return NewTabPageController.getInstance().verifyActive();
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.ntp;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
|
||||
/**
|
||||
* Incognito NTP Page Controller.
|
||||
*/
|
||||
public class IncognitoNewTabPageController extends PageController {
|
||||
private static final IUi2Locator LOCATOR_INCOGNITO_PAGE =
|
||||
Ui2Locators.withAnyResEntry(R.id.new_tab_incognito_container);
|
||||
|
||||
private static final IncognitoNewTabPageController sInstance =
|
||||
new IncognitoNewTabPageController();
|
||||
private IncognitoNewTabPageController() {}
|
||||
public static IncognitoNewTabPageController getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IncognitoNewTabPageController verifyActive() {
|
||||
mLocatorHelper.verifyOnScreen(LOCATOR_INCOGNITO_PAGE);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.ntp;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.tabswitcher.TabSwitcherController;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.urlpage.UrlPage;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
|
||||
/**
|
||||
* New Tab Page Page Controller, handles either Feed or Zine implementations.
|
||||
*/
|
||||
public class NewTabPageController extends PageController {
|
||||
private static final float SCROLL_SWIPE_FRACTION = 0.6f;
|
||||
// The test will timeout for Small and Medium sizes before 50 swipes is
|
||||
// reached. This number is set so that it should not be hit if everything
|
||||
// is working fine. Please bump it up if test cases exceeding 50 swipes
|
||||
// becomes common.
|
||||
private static final int MAX_SCROLL_SWIPES = 50;
|
||||
|
||||
private static final IUi2Locator LOCATOR_SEARCH_BOX_TEXT =
|
||||
Ui2Locators.withAnyResEntry(R.id.search_box_text);
|
||||
private static final IUi2Locator LOCATOR_URL_BAR = Ui2Locators.withAnyResEntry(R.id.url_bar);
|
||||
private static final IUi2Locator LOCATOR_SEARCH_PROVIDER_LOGO =
|
||||
Ui2Locators.withAnyResEntry(R.id.search_provider_logo);
|
||||
private static final IUi2Locator LOCATOR_MORE_BUTTON =
|
||||
Ui2Locators.withAnyResEntry(R.id.action_button);
|
||||
private static final IUi2Locator LOCATOR_MENU_BUTTON =
|
||||
Ui2Locators.withAnyResEntry(R.id.menu_button);
|
||||
private static final IUi2Locator LOCATOR_FEED_STREAM_RECYCLER_VIEW =
|
||||
Ui2Locators.withAnyResEntry(R.id.feed_stream_recycler_view);
|
||||
|
||||
private static final IUi2Locator LOCATOR_TAB_SWITCHER =
|
||||
Ui2Locators.withAnyResEntry(R.id.tab_switcher_button);
|
||||
|
||||
private static final IUi2Locator LOCATOR_NEW_TAB_PAGE = Ui2Locators.withAnyResEntry(
|
||||
R.id.ntp_content, R.id.feed_stream_recycler_view, R.id.feed_content_card);
|
||||
|
||||
private static final NewTabPageController sInstance = new NewTabPageController();
|
||||
private NewTabPageController() {}
|
||||
public static NewTabPageController getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void scrollTowardsTop(float screenHeightPercentage) {
|
||||
mUtils.swipeDownVertically(screenHeightPercentage);
|
||||
}
|
||||
|
||||
public void scrollTowardsBottom(float screenHeightPercentage) {
|
||||
mUtils.swipeUpVertically(screenHeightPercentage);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasScrolledToTop() {
|
||||
return mLocatorHelper.isOnScreen(LOCATOR_SEARCH_PROVIDER_LOGO);
|
||||
}
|
||||
|
||||
public void scrollToTop() {
|
||||
scrollToTop(MAX_SCROLL_SWIPES);
|
||||
}
|
||||
|
||||
public void scrollToTop(int maxSwipes) {
|
||||
for (int swipes = 0; swipes < maxSwipes && !hasScrolledToTop(); swipes++) {
|
||||
scrollTowardsTop(SCROLL_SWIPE_FRACTION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the tab switcher at the top. This will cause the page to scroll to the top.
|
||||
* @return The TabSwitcher Page Controller.
|
||||
*/
|
||||
public TabSwitcherController openTabSwitcher() {
|
||||
scrollToTop();
|
||||
mUtils.click(LOCATOR_TAB_SWITCHER);
|
||||
return TabSwitcherController.getInstance().verifyActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the 3-dot menu at the top. This will cause the page to scroll to the top.
|
||||
* @return The ChromeMenu Page Controller.
|
||||
*/
|
||||
public ChromeMenu openChromeMenu() {
|
||||
scrollToTop();
|
||||
mUtils.click(LOCATOR_MENU_BUTTON);
|
||||
return ChromeMenu.getInstance().verifyActive();
|
||||
}
|
||||
|
||||
public UrlPage omniboxSearch(String url) {
|
||||
mUtils.click(LOCATOR_SEARCH_BOX_TEXT);
|
||||
mUtils.setTextAndEnter(LOCATOR_URL_BAR, url);
|
||||
return UrlPage.getInstance().verifyActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewTabPageController verifyActive() {
|
||||
mLocatorHelper.verifyOnScreen(LOCATOR_NEW_TAB_PAGE);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.ntp;
|
||||
|
||||
import static org.chromium.chrome.test.pagecontroller.utils.Ui2Locators.withText;
|
||||
|
||||
import androidx.test.uiautomator.UiObject2;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.ElementController;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.UiLocationException;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.UiLocatorHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Suggestions Tile (below the Omnibox) Element Controller.
|
||||
*/
|
||||
public class SuggestionTileController extends ElementController {
|
||||
/**
|
||||
* Represents a single tile, can be used by the NewTabPageController
|
||||
* to perform actions.
|
||||
*/
|
||||
public static class Info {
|
||||
private String mTitle;
|
||||
|
||||
public Info(String title) {
|
||||
mTitle = title;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Info)) return false;
|
||||
Info info = (Info) o;
|
||||
return mTitle.equals(info.mTitle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return mTitle.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Info{"
|
||||
+ "mTitle='" + mTitle + '\'' + '}';
|
||||
}
|
||||
}
|
||||
|
||||
private static final IUi2Locator LOCATOR_TILE_TITLES =
|
||||
Ui2Locators.withPath(Ui2Locators.withAnyResEntry(R.id.mv_tiles_layout),
|
||||
Ui2Locators.withAnyResEntry(R.id.tile_view_title));
|
||||
private static final IUi2Locator LOCATOR_TILE_TITLE_TEXT = Ui2Locators.withTextRegex(".+");
|
||||
|
||||
private static final SuggestionTileController sInstance = new SuggestionTileController();
|
||||
private SuggestionTileController() {}
|
||||
public static SuggestionTileController getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of tiles.
|
||||
* @return List of Infos representing each tile on the screen, or empty list if non are found.
|
||||
*/
|
||||
public List<Info> parseScreen() {
|
||||
List<String> titles = mLocatorHelper.getAllTexts(LOCATOR_TILE_TITLES);
|
||||
List<Info> infos = mLocatorHelper.getCustomElements(
|
||||
LOCATOR_TILE_TITLES, new UiLocatorHelper.CustomElementMaker<Info>() {
|
||||
@Override
|
||||
public Info makeElement(UiObject2 root, boolean isLastAttempt) {
|
||||
String title =
|
||||
mLocatorHelper.getOneTextImmediate(LOCATOR_TILE_TITLE_TEXT, root);
|
||||
if (title != null) {
|
||||
return new Info(title);
|
||||
} else if (!isLastAttempt) {
|
||||
// Not the last attempt yet, so makeElement will be
|
||||
// called again if we throw an exception. This
|
||||
// gives a chance for the title UI of the tile to
|
||||
// load.
|
||||
throw new UiLocationException(
|
||||
"Title not found.", LOCATOR_TILE_TITLES, root);
|
||||
} else {
|
||||
// This is the last attempt. It is possible that
|
||||
// no complete tiles are found on the screen, just
|
||||
// return null to signal that no tile was found.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return infos;
|
||||
}
|
||||
|
||||
public IUi2Locator getLocator(Info tileInfo) {
|
||||
return Ui2Locators.withPath(LOCATOR_TILE_TITLES, withText(tileInfo.getTitle()));
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.tabswitcher;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.ntp.NewTabPageController;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.UiLocationException;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Tab Switcher Page Controller.
|
||||
*/
|
||||
public class TabSwitcherController extends PageController {
|
||||
private static final Pattern PATTERN_NUMBER_OF_OPEN_TABS = Pattern.compile("^(\\d+) .*");
|
||||
private static final IUi2Locator LOCATOR_NEW_TAB =
|
||||
Ui2Locators.withAnyResEntry(R.id.new_tab_button);
|
||||
private static final IUi2Locator LOCATOR_TAB_SWITCHER_BUTTON =
|
||||
Ui2Locators.withAnyResEntry(R.id.tab_switcher_button, R.id.incognito_toggle_tabs);
|
||||
private static final IUi2Locator LOCATOR_MENU = Ui2Locators.withAnyResEntry(R.id.menu_button);
|
||||
|
||||
private static final TabSwitcherController sInstance = new TabSwitcherController();
|
||||
|
||||
public static TabSwitcherController getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private TabSwitcherController() {}
|
||||
|
||||
public void clickCloseAllTabs() {
|
||||
clickMenu().clickCloseAllTabs();
|
||||
}
|
||||
|
||||
public void clickTabSwitcher() {
|
||||
mUtils.click(LOCATOR_TAB_SWITCHER_BUTTON);
|
||||
}
|
||||
|
||||
public int getNumberOfOpenTabs() {
|
||||
String text = mLocatorHelper.getOneDescription(LOCATOR_TAB_SWITCHER_BUTTON);
|
||||
Matcher matcher = PATTERN_NUMBER_OF_OPEN_TABS.matcher(text);
|
||||
if (matcher.matches()) {
|
||||
return Integer.valueOf(matcher.group(1));
|
||||
} else {
|
||||
throw new UiLocationException(
|
||||
"Could not get number of open tabs in Tab Switcher button.",
|
||||
LOCATOR_TAB_SWITCHER_BUTTON);
|
||||
}
|
||||
}
|
||||
public NewTabPageController clickNewTab() {
|
||||
mUtils.click(LOCATOR_NEW_TAB);
|
||||
return NewTabPageController.getInstance().verifyActive();
|
||||
}
|
||||
|
||||
public TabSwitcherMenuController clickMenu() {
|
||||
mUtils.click(LOCATOR_MENU);
|
||||
return TabSwitcherMenuController.getInstance().verifyActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabSwitcherController verifyActive() {
|
||||
mLocatorHelper.verifyOnScreen(LOCATOR_NEW_TAB);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.tabswitcher;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
|
||||
/**
|
||||
* Tab Switcher Menu Dialog Page Controller.
|
||||
*/
|
||||
public class TabSwitcherMenuController extends PageController {
|
||||
private static final IUi2Locator LOCATOR_MENU_BOX =
|
||||
Ui2Locators.withAnyResEntry(R.id.app_menu_list);
|
||||
|
||||
// TODO(aluo): Add resource ids for menus, using text will break when switching languages
|
||||
private static final IUi2Locator LOCATOR_MENU =
|
||||
Ui2Locators.withPath(LOCATOR_MENU_BOX, Ui2Locators.withText("Close all tabs"));
|
||||
|
||||
private static final IUi2Locator LOCATOR_NEW_TAB =
|
||||
Ui2Locators.withPath(Ui2Locators.withAnyResEntry(R.id.menu_item_text),
|
||||
Ui2Locators.withTextString(R.string.button_new_tab));
|
||||
private static final IUi2Locator LOCATOR_NEW_INCOGNITO_TAB =
|
||||
Ui2Locators.withPath(Ui2Locators.withAnyResEntry(R.id.menu_item_text),
|
||||
Ui2Locators.withTextString(R.string.button_new_incognito_tab));
|
||||
private static final IUi2Locator LOCATOR_CLOSE_ALL_TABS =
|
||||
Ui2Locators.withPath(Ui2Locators.withAnyResEntry(R.id.menu_item_text),
|
||||
Ui2Locators.withTextString(R.string.menu_close_all_tabs));
|
||||
private static final IUi2Locator LOCATOR_SETTINGS =
|
||||
Ui2Locators.withPath(Ui2Locators.withAnyResEntry(R.id.menu_item_text),
|
||||
Ui2Locators.withTextString(R.string.menu_settings));
|
||||
|
||||
private static final TabSwitcherMenuController sInstance = new TabSwitcherMenuController();
|
||||
public static TabSwitcherMenuController getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabSwitcherMenuController verifyActive() {
|
||||
mLocatorHelper.verifyOnScreen(LOCATOR_MENU);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void clickNewTab() {
|
||||
mUtils.click(LOCATOR_NEW_TAB);
|
||||
}
|
||||
|
||||
public void clickNewIncognitoTab() {
|
||||
mUtils.click(LOCATOR_NEW_INCOGNITO_TAB);
|
||||
}
|
||||
|
||||
public void clickCloseAllTabs() {
|
||||
mUtils.click(LOCATOR_CLOSE_ALL_TABS);
|
||||
}
|
||||
|
||||
public void clickSettings() {
|
||||
mUtils.click(LOCATOR_SETTINGS);
|
||||
}
|
||||
|
||||
public TabSwitcherController dismiss() {
|
||||
mUtils.clickOutsideOf(LOCATOR_MENU_BOX);
|
||||
return TabSwitcherController.getInstance().verifyActive();
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.urlpage;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.tabswitcher.TabSwitcherController;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.UiLocatorHelper;
|
||||
|
||||
/**
|
||||
* Url Page (showing a loaded URL) Page Controller.
|
||||
*/
|
||||
// TODO(aluo): merge incognito page into this.
|
||||
public class UrlPage extends PageController {
|
||||
private static final long PAGE_LOAD_TIMEOUT = 10000L;
|
||||
private static final IUi2Locator LOCATOR_WEB_VIEW =
|
||||
Ui2Locators.withPath(Ui2Locators.withAnyResEntry(R.id.content),
|
||||
Ui2Locators.withClassRegex("android\\.webkit\\.WebView"));
|
||||
private static final IUi2Locator LOCATOR_URL_BAR = Ui2Locators.withAnyResEntry(R.id.url_bar);
|
||||
private static final IUi2Locator LOCATOR_TAB_SWITCHER =
|
||||
Ui2Locators.withAnyResEntry(R.id.tab_switcher_button);
|
||||
|
||||
private static final UrlPage sInstance = new UrlPage();
|
||||
private UrlPage() {}
|
||||
public static UrlPage getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UrlPage verifyActive() {
|
||||
UiLocatorHelper helper = mUtils.getLocatorHelper(PAGE_LOAD_TIMEOUT);
|
||||
helper.verifyOnScreen(LOCATOR_WEB_VIEW);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return mLocatorHelper.getOneText(LOCATOR_URL_BAR);
|
||||
}
|
||||
|
||||
public boolean isTextFoundAtCurrentScroll(String text) {
|
||||
IUi2Locator locator =
|
||||
Ui2Locators.withPath(LOCATOR_WEB_VIEW, Ui2Locators.withTextContaining(text));
|
||||
return mLocatorHelper.isOnScreen(locator);
|
||||
}
|
||||
|
||||
public TabSwitcherController openTabSwitcher() {
|
||||
mUtils.click(LOCATOR_TAB_SWITCHER);
|
||||
return TabSwitcherController.getInstance().verifyActive();
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
// Copyright 2020 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.controllers.webapk.first_run;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
|
||||
/**
|
||||
* Page Controller for the "light weight" version of the TOS dialog. Shown instead of the
|
||||
* normal TOS dialog when light weight first run experience is preferred, for example, when
|
||||
* a WebAPK is launched..
|
||||
*/
|
||||
public class LightWeightTOSController extends PageController {
|
||||
private static final IUi2Locator LOCATOR_TOS =
|
||||
Ui2Locators.withAnyResEntry(R.id.lightweight_fre_tos_and_privacy);
|
||||
private static final IUi2Locator LOCATOR_DUAL_CONTROL =
|
||||
Ui2Locators.withAnyResEntry(R.id.lightweight_fre_buttons);
|
||||
private static final IUi2Locator LOCATOR_ACCEPT_BUTTON =
|
||||
Ui2Locators.withAnyResEntry(R.id.button_primary);
|
||||
|
||||
private static final LightWeightTOSController sInstance = new LightWeightTOSController();
|
||||
private LightWeightTOSController() {}
|
||||
public static LightWeightTOSController getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LightWeightTOSController verifyActive() {
|
||||
mLocatorHelper.verifyOnScreen(LOCATOR_TOS);
|
||||
mLocatorHelper.verifyOnScreen(LOCATOR_DUAL_CONTROL);
|
||||
mLocatorHelper.verifyOnScreen(LOCATOR_ACCEPT_BUTTON);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void acceptAndContinue() {
|
||||
mUtils.click(LOCATOR_ACCEPT_BUTTON);
|
||||
}
|
||||
}
|
@ -9,70 +9,15 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import org.junit.rules.ExternalResource;
|
||||
|
||||
import org.chromium.base.Log;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.first_run.SyncConfirmationViewPageController;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.ntp.NewTabPageController;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.UiAutomatorUtils;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.UiLocationException;
|
||||
|
||||
/**
|
||||
* Test rule that provides access to a Chrome application.
|
||||
*/
|
||||
public class ChromeUiApplicationTestRule extends ExternalResource {
|
||||
public static final String PACKAGE_NAME_ARG = "org.chromium.chrome.test.pagecontroller.rules."
|
||||
+ "ChromeUiApplicationTestRule.PackageUnderTest";
|
||||
private static final String TAG = "ChromeUiAppTR";
|
||||
|
||||
private String mPackageName;
|
||||
|
||||
/**
|
||||
* Returns an instance of the page controller that corresponds to the current page.
|
||||
* @param controllers List of possible page controller instances to search among.
|
||||
* @return The detected page controller.
|
||||
* @throws UiLocationException If page can't be determined.
|
||||
*/
|
||||
public static PageController detectPageAmong(PageController... controllers) {
|
||||
for (PageController instance : controllers) {
|
||||
if (instance.isCurrentPageThis()) {
|
||||
Log.d(TAG, "Detected " + instance.getClass().getName());
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
throw new UiLocationException("Could not detect current Page.");
|
||||
}
|
||||
|
||||
/** Launch the chrome application */
|
||||
public void launchApplication() {
|
||||
UiAutomatorUtils utils = UiAutomatorUtils.getInstance();
|
||||
utils.launchApplication(mPackageName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to the New Tab Page after the application starts for the first time, or after
|
||||
* application data was cleared.
|
||||
* @return NewTabPageController
|
||||
*/
|
||||
public NewTabPageController navigateToNewTabPageOnFirstRun() {
|
||||
PageController controller = detectPageOnFirstRun();
|
||||
if (controller instanceof SyncConfirmationViewPageController) {
|
||||
((SyncConfirmationViewPageController) controller).clickNoThanks();
|
||||
controller = detectPageOnFirstRun();
|
||||
}
|
||||
if (controller instanceof NewTabPageController) {
|
||||
return (NewTabPageController) controller;
|
||||
} else {
|
||||
throw new UiLocationException("Could not navigate to new tab page from "
|
||||
+ controller.getClass().getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
/** Launch the application and navigate to the New Tab Page */
|
||||
public NewTabPageController launchIntoNewTabPageOnFirstRun() {
|
||||
launchApplication();
|
||||
return navigateToNewTabPageOnFirstRun();
|
||||
}
|
||||
|
||||
public String getApplicationPackage() {
|
||||
return mPackageName;
|
||||
}
|
||||
@ -87,16 +32,4 @@ public class ChromeUiApplicationTestRule extends ExternalResource {
|
||||
mPackageName = ApplicationProvider.getApplicationContext().getPackageName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect the page controller from among page controllers that could be displayed on first
|
||||
* launch or after application data was cleared.
|
||||
* Add potential page controllers that could show up before the New Tab Page here.
|
||||
* @return The detected page controller.
|
||||
* @throws UiLocationException If page can't be determined.
|
||||
*/
|
||||
private static PageController detectPageOnFirstRun() {
|
||||
return detectPageAmong(SyncConfirmationViewPageController.getInstance(),
|
||||
NewTabPageController.getInstance());
|
||||
}
|
||||
}
|
||||
|
@ -1,83 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.tests;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.RuleChain;
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.PageController;
|
||||
import org.chromium.chrome.test.pagecontroller.rules.ChromeUiApplicationTestRule;
|
||||
import org.chromium.chrome.test.pagecontroller.rules.ChromeUiAutomatorTestRule;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
|
||||
/**
|
||||
* An example test that demonstrates how to use Page Controllers.
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class ExampleTest {
|
||||
// ChromeUiAutomatorTestRule will capture a screen shot and UI Hierarchy info in the event
|
||||
// of a test failure to aid test debugging.
|
||||
public ChromeUiAutomatorTestRule mUiAutomatorRule = new ChromeUiAutomatorTestRule();
|
||||
|
||||
// ChromeUiApplicationTestRule provides a way to launch the Chrome Application under test
|
||||
// and access to the Page Controllers.
|
||||
public ChromeUiApplicationTestRule mChromeUiRule = new ChromeUiApplicationTestRule();
|
||||
|
||||
// The rule chain allows deterministic ordering of test rules so that the
|
||||
// UiAutomatorRule will print debugging information in case of errors
|
||||
// before the application is shut-down.
|
||||
@Rule
|
||||
public final TestRule mChain = RuleChain.outerRule(mChromeUiRule).around(mUiAutomatorRule);
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
// Do any common setup here.
|
||||
mChromeUiRule.launchApplication();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
// Do any common cleanup here.
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPageFound() {
|
||||
PageController controller = new PageController() {
|
||||
@Override
|
||||
public PageController verifyActive() {
|
||||
IUi2Locator packageLocator =
|
||||
Ui2Locators.withPackageName(mChromeUiRule.getApplicationPackage());
|
||||
mLocatorHelper.getOne(packageLocator);
|
||||
return this;
|
||||
}
|
||||
};
|
||||
Assert.assertTrue("Application should have loaded", controller.isCurrentPageThis());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPageNotFound() {
|
||||
PageController controller = new PageController() {
|
||||
@Override
|
||||
public PageController verifyActive() {
|
||||
IUi2Locator packageLocator = Ui2Locators.withPackageName("wrong.package.name");
|
||||
mLocatorHelper.getOne(packageLocator);
|
||||
return this;
|
||||
}
|
||||
};
|
||||
Assert.assertFalse(
|
||||
"Wrong package should not have been detected", controller.isCurrentPageThis());
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.tests;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.os.Build.VERSION_CODES;
|
||||
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.RuleChain;
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.chromium.base.test.util.DisableIf;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.ntp.ChromeMenu;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.ntp.NewTabPageController;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.urlpage.UrlPage;
|
||||
import org.chromium.chrome.test.pagecontroller.rules.ChromeUiApplicationTestRule;
|
||||
import org.chromium.chrome.test.pagecontroller.rules.ChromeUiAutomatorTestRule;
|
||||
|
||||
/**
|
||||
* Tests for the NewTabPageController.
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class NewTabPageControllerTest {
|
||||
public ChromeUiAutomatorTestRule mRule = new ChromeUiAutomatorTestRule();
|
||||
|
||||
public ChromeUiApplicationTestRule mChromeUiRule = new ChromeUiApplicationTestRule();
|
||||
|
||||
@Rule
|
||||
public final TestRule mChain = RuleChain.outerRule(mChromeUiRule).around(mRule);
|
||||
|
||||
private NewTabPageController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mController = mChromeUiRule.launchIntoNewTabPageOnFirstRun();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableIf.Build(sdk_is_greater_than = VERSION_CODES.O_MR1,
|
||||
message = "https://crbug.com/1130617 https://crbug.com/1141179")
|
||||
public void
|
||||
testIsCurrentPageThis() {
|
||||
Assert.assertTrue(mController.isCurrentPageThis());
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@Test
|
||||
@DisableIf.
|
||||
Build(sdk_is_greater_than = VERSION_CODES.O_MR1, message = "https://crbug.com/1130617")
|
||||
public void testScrollPage() {
|
||||
mController.scrollToTop();
|
||||
assertTrue(mController.hasScrolledToTop());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableIf.Build(sdk_is_greater_than = VERSION_CODES.O_MR1,
|
||||
message = "https://crbug.com/1130617 https://crbug.com/1141179")
|
||||
public void
|
||||
testOpenChromeMenu() {
|
||||
ChromeMenu menu = mController.openChromeMenu();
|
||||
Assert.assertTrue(menu.isCurrentPageThis());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableIf.Build(sdk_is_greater_than = VERSION_CODES.O_MR1,
|
||||
message = "https://crbug.com/1130617 https://crbug.com/1141179")
|
||||
public void
|
||||
testOmniboxSearch() {
|
||||
UrlPage urlPage = mController.omniboxSearch("www.google.com");
|
||||
Assert.assertTrue(urlPage.isCurrentPageThis());
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.tests;
|
||||
|
||||
import android.os.Build.VERSION_CODES;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.RuleChain;
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.chromium.base.test.util.Criteria;
|
||||
import org.chromium.base.test.util.CriteriaHelper;
|
||||
import org.chromium.base.test.util.DisableIf;
|
||||
import org.chromium.base.test.util.DisabledTest;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.ntp.NewTabPageController;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.tabswitcher.TabSwitcherController;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.tabswitcher.TabSwitcherMenuController;
|
||||
import org.chromium.chrome.test.pagecontroller.rules.ChromeUiApplicationTestRule;
|
||||
import org.chromium.chrome.test.pagecontroller.rules.ChromeUiAutomatorTestRule;
|
||||
|
||||
/**
|
||||
* Tests for the TabSwitcherController.
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class TabSwitcherControllerTest {
|
||||
public ChromeUiAutomatorTestRule mRule = new ChromeUiAutomatorTestRule();
|
||||
|
||||
public ChromeUiApplicationTestRule mChromeUiRule = new ChromeUiApplicationTestRule();
|
||||
|
||||
@Rule
|
||||
public final TestRule mChain = RuleChain.outerRule(mChromeUiRule).around(mRule);
|
||||
|
||||
private TabSwitcherController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mController = mChromeUiRule.launchIntoNewTabPageOnFirstRun().openTabSwitcher();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableIf.Build(sdk_is_greater_than = VERSION_CODES.O_MR1,
|
||||
message = "https://crbug.com/1130617 https://crbug.com/1141179")
|
||||
public void
|
||||
testOpenNewTab() {
|
||||
mController.clickNewTab();
|
||||
Assert.assertTrue(NewTabPageController.getInstance().isCurrentPageThis());
|
||||
}
|
||||
|
||||
private void waitForTabCount(final int count) {
|
||||
CriteriaHelper.pollInstrumentationThread(() -> {
|
||||
Criteria.checkThat(mController.getNumberOfOpenTabs(), Matchers.is(count));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableIf.Build(sdk_is_greater_than = VERSION_CODES.O_MR1,
|
||||
message = "https://crbug.com/1130617 https://crbug.com/1141179")
|
||||
public void
|
||||
testCloseAllTabs() {
|
||||
mController.clickNewTab().openTabSwitcher().clickNewTab().openTabSwitcher();
|
||||
mController.clickCloseAllTabs();
|
||||
waitForTabCount(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableIf.Build(sdk_is_greater_than = VERSION_CODES.O_MR1,
|
||||
message = "https://crbug.com/1130617 https://crbug.com/1141179")
|
||||
public void
|
||||
testNumberOfOpenTabs() {
|
||||
int startTabs = mController.getNumberOfOpenTabs();
|
||||
mController.clickNewTab().openTabSwitcher();
|
||||
waitForTabCount(startTabs + 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableIf.Build(sdk_is_greater_than = VERSION_CODES.O_MR1,
|
||||
message = "https://crbug.com/1130617 https://crbug.com/1141179")
|
||||
public void
|
||||
testClickTabSwitcher() {
|
||||
mController.clickTabSwitcher();
|
||||
Assert.assertTrue(NewTabPageController.getInstance().isCurrentPageThis());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisabledTest(message = "https://crbug.com/1140998")
|
||||
public void testOpenMenu() {
|
||||
mController.clickMenu();
|
||||
Assert.assertTrue(TabSwitcherMenuController.getInstance().isCurrentPageThis());
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.tests.codelab;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.RuleChain;
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.ntp.ChromeMenu;
|
||||
import org.chromium.chrome.test.pagecontroller.rules.ChromeUiApplicationTestRule;
|
||||
import org.chromium.chrome.test.pagecontroller.rules.ChromeUiAutomatorTestRule;
|
||||
|
||||
/**
|
||||
* Test for Page Controller Code Lab.
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class SettingsForCodelabTest {
|
||||
// ChromeUiAutomatorTestRule will capture a screen shot and UI Hierarchy info in the event
|
||||
// of a test failure to aid test debugging.
|
||||
public ChromeUiAutomatorTestRule mUiAutomatorRule = new ChromeUiAutomatorTestRule();
|
||||
|
||||
// ChromeUiApplicationTestRule provides a way to launch the Chrome Application under test
|
||||
// and access to the Page Controllers.
|
||||
public ChromeUiApplicationTestRule mChromeUiRule = new ChromeUiApplicationTestRule();
|
||||
|
||||
// The rule chain allows deterministic ordering of test rules so that the
|
||||
// UiAutomatorRule will print debugging information in case of errors
|
||||
// before the application is shut-down.
|
||||
@Rule
|
||||
public final TestRule mChain = RuleChain.outerRule(mChromeUiRule).around(mUiAutomatorRule);
|
||||
|
||||
private ChromeMenu mChromeMenu;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
// TODO: Obtain a ChromeMenu instance. Hint, start with
|
||||
// mChromeUiRule.launchIntoNewTabPageOnFirstRun().
|
||||
mChromeMenu = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenCodelabSettings() {
|
||||
// TODO: Uncomment and add a method to ChromeMenu that returns an
|
||||
// instance of SettingsControllerForCodelab to pass this test.
|
||||
|
||||
// mChromeMenu.openSettingsForCodelab();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitchSearchEngine() {
|
||||
// TODO: Uncomment and implement clickSearchEngine that verifies the
|
||||
// page has changed to the default search engine selection page.
|
||||
|
||||
// SearchEngineSelectionControllerForCodelab engineSelection =
|
||||
// mChromeMenu.openSettingsForCodelab().clickSearchEngine();
|
||||
// Assert.assertEquals(engineSelection.getEngineChoice(), "Google");
|
||||
|
||||
// TODO: Change the search engine to something else, then verify that
|
||||
// the change is reflected in the UI.
|
||||
}
|
||||
}
|
@ -1,199 +0,0 @@
|
||||
// Copyright 2020 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.chrome.test.pagecontroller.tests.webapk;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.RuleChain;
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.chromium.base.ApplicationStatus;
|
||||
import org.chromium.base.Log;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.chromium.base.test.util.CommandLineFlags;
|
||||
import org.chromium.base.test.util.CriteriaHelper;
|
||||
import org.chromium.chrome.browser.firstrun.FirstRunActivity;
|
||||
import org.chromium.chrome.browser.firstrun.FirstRunStatus;
|
||||
import org.chromium.chrome.browser.firstrun.FirstRunUtils;
|
||||
import org.chromium.chrome.browser.firstrun.LightweightFirstRunActivity;
|
||||
import org.chromium.chrome.browser.webapps.WebappActivity;
|
||||
import org.chromium.chrome.browser.webapps.WebappRegistry;
|
||||
import org.chromium.chrome.test.pagecontroller.controllers.webapk.first_run.LightWeightTOSController;
|
||||
import org.chromium.chrome.test.pagecontroller.rules.ChromeUiApplicationTestRule;
|
||||
import org.chromium.chrome.test.pagecontroller.rules.ChromeUiAutomatorTestRule;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.IUi2Locator;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.Ui2Locators;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.UiAutomatorUtils;
|
||||
import org.chromium.chrome.test.pagecontroller.utils.UiLocatorHelper;
|
||||
import org.chromium.components.webapk.lib.client.WebApkValidator;
|
||||
import org.chromium.content_public.browser.test.util.TestThreadUtils;
|
||||
|
||||
/**
|
||||
* Test the Maps Go First Run Experience. This test will be mostly focus on verifying the
|
||||
* lightweight first run is activated in different scenarios.
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class MapsGoFirstRunTest {
|
||||
private static final String TAG = "MapsGoFirstRunTest";
|
||||
private static final String FLAG_POLICY_TOS_DIALOG_BEHAVIOR_STANDARD =
|
||||
"policy={\"TosDialogBehavior\":1}";
|
||||
private static final String FLAG_POLICY_TOS_DIALOG_BEHAVIOR_SKIP =
|
||||
"policy={\"TosDialogBehavior\":2}";
|
||||
private static final String MAPS_GO_PACKAGE = "org.chromium.test.maps_go_webapk";
|
||||
|
||||
// Launching the PWA is currently taking 9-10 seconds on emulators. Increasing this
|
||||
// substantially to avoid flakes. See https://crbug.com/1142821.
|
||||
private static final long MAPS_GO_FRE_TIMEOUT_MS = 20000L;
|
||||
|
||||
public ChromeUiAutomatorTestRule mUiAutomatorRule = new ChromeUiAutomatorTestRule();
|
||||
public ChromeUiApplicationTestRule mChromeUiRule = new ChromeUiApplicationTestRule();
|
||||
|
||||
@Rule
|
||||
public final TestRule mChain = RuleChain.outerRule(mChromeUiRule).around(mUiAutomatorRule);
|
||||
|
||||
private Activity mLightweightFreActivity;
|
||||
private Activity mFirstRunActivity;
|
||||
private Activity mWebappActivity;
|
||||
private ApplicationStatus.ActivityStateListener mActivityStateListener;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
WebApkValidator.setDisableValidationForTesting(true);
|
||||
FirstRunUtils.setDisableDelayOnExitFreForTest(true);
|
||||
TestThreadUtils.runOnUiThreadBlocking(WebappRegistry::refreshSharedPrefsForTesting);
|
||||
|
||||
mActivityStateListener = (activity, newState) -> {
|
||||
if (activity instanceof LightweightFirstRunActivity) {
|
||||
if (mLightweightFreActivity == null) mLightweightFreActivity = activity;
|
||||
} else if (activity instanceof FirstRunActivity) {
|
||||
if (mFirstRunActivity == null) mFirstRunActivity = activity;
|
||||
} else if (activity instanceof WebappActivity) {
|
||||
if (mWebappActivity == null) mWebappActivity = activity;
|
||||
}
|
||||
};
|
||||
TestThreadUtils.runOnUiThreadBlocking(() -> {
|
||||
ApplicationStatus.registerStateListenerForAllActivities(mActivityStateListener);
|
||||
});
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
WebApkValidator.setDisableValidationForTesting(false);
|
||||
FirstRunUtils.setDisableDelayOnExitFreForTest(false);
|
||||
LightweightFirstRunActivity.setSupportSkippingTos(true);
|
||||
TestThreadUtils.runOnUiThreadBlocking(() -> {
|
||||
ApplicationStatus.unregisterActivityStateListener(mActivityStateListener);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirstRunIsShown() {
|
||||
LightweightFirstRunActivity.setSupportSkippingTos(false);
|
||||
FirstRunStatus.setLightweightFirstRunFlowComplete(false);
|
||||
launchWebapk();
|
||||
|
||||
LightWeightTOSController controller = LightWeightTOSController.getInstance();
|
||||
Assert.assertTrue("Light weight TOS page should be shown.", controller.isCurrentPageThis());
|
||||
|
||||
controller.acceptAndContinue();
|
||||
// Note for offline devices this PWA will not be healthy, see https://crbug.com/1142821 for
|
||||
// details. Just verify the right activity has started.
|
||||
verifyWebappActivityStarted();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirstRunFallbackForInvalidPwa() {
|
||||
// Verification will fail for this APK, so instead of using the LWFRE, the full FRE will be
|
||||
// shown instead.
|
||||
WebApkValidator.setDisableValidationForTesting(false);
|
||||
launchWebapk();
|
||||
|
||||
CriteriaHelper.pollInstrumentationThread(
|
||||
() -> mFirstRunActivity != null, "FirstRunActivity did not start");
|
||||
Assert.assertNull("Lightweight FRE should not have started.", mLightweightFreActivity);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirstRunIsNotShownAfterAck() {
|
||||
LightweightFirstRunActivity.setSupportSkippingTos(false);
|
||||
FirstRunStatus.setLightweightFirstRunFlowComplete(true);
|
||||
launchWebapk();
|
||||
|
||||
verifyWebappActivityStarted();
|
||||
Assert.assertNull("Lightweight FRE should not have started.", mLightweightFreActivity);
|
||||
}
|
||||
|
||||
@Test
|
||||
@CommandLineFlags.Add({"force-device-ownership", FLAG_POLICY_TOS_DIALOG_BEHAVIOR_SKIP})
|
||||
public void testTosSkipped() throws Exception {
|
||||
LightweightFirstRunActivity.setSupportSkippingTos(true);
|
||||
FirstRunStatus.setLightweightFirstRunFlowComplete(false);
|
||||
launchWebapk();
|
||||
|
||||
// Verify LWFRE activity is created before skipped to WebappActivity. See
|
||||
// https://crbug.com/1184149 for previous problems here.
|
||||
CriteriaHelper.pollInstrumentationThread(()
|
||||
-> mLightweightFreActivity != null,
|
||||
"Lightweight FRE should still launch before being skipped.");
|
||||
verifyWebappActivityStarted();
|
||||
}
|
||||
|
||||
@Test
|
||||
@CommandLineFlags.Add({FLAG_POLICY_TOS_DIALOG_BEHAVIOR_STANDARD})
|
||||
public void testTosNotSkippedByPolicy() {
|
||||
LightweightFirstRunActivity.setSupportSkippingTos(true);
|
||||
FirstRunStatus.setLightweightFirstRunFlowComplete(false);
|
||||
launchWebapk();
|
||||
|
||||
Assert.assertNotNull("Lightweight FRE should launch.", mLightweightFreActivity);
|
||||
LightWeightTOSController controller = LightWeightTOSController.getInstance();
|
||||
Assert.assertTrue("Light weight TOS page should be shown.", controller.isCurrentPageThis());
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch the Maps Go WebAPK.
|
||||
*
|
||||
* Maps Go WebAPK is a bound WebAPK to the apk under test so that there is
|
||||
* no browser choice on launch.
|
||||
*/
|
||||
private void launchWebapk() {
|
||||
String chromePackageName = ApplicationProvider.getApplicationContext().getPackageName();
|
||||
Log.d(TAG, "Launching %s in Chrome (%s)", MAPS_GO_PACKAGE, chromePackageName);
|
||||
|
||||
Context context = ApplicationProvider.getApplicationContext();
|
||||
final Intent intent =
|
||||
context.getPackageManager().getLaunchIntentForPackage(MAPS_GO_PACKAGE);
|
||||
if (intent == null) {
|
||||
throw new IllegalStateException("Could not get intent to launch " + MAPS_GO_PACKAGE
|
||||
+ ", please ensure that it is installed");
|
||||
}
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
|
||||
UiLocatorHelper helper =
|
||||
UiAutomatorUtils.getInstance().getLocatorHelper(MAPS_GO_FRE_TIMEOUT_MS);
|
||||
IUi2Locator packageLocator = Ui2Locators.withPackageName(chromePackageName);
|
||||
helper.verifyOnScreen(packageLocator);
|
||||
}
|
||||
|
||||
private void verifyWebappActivityStarted() {
|
||||
CriteriaHelper.pollInstrumentationThread(()
|
||||
-> mWebappActivity != null,
|
||||
"WebappActivity did not start.", MAPS_GO_FRE_TIMEOUT_MS,
|
||||
CriteriaHelper.DEFAULT_POLLING_INTERVAL);
|
||||
}
|
||||
}
|
@ -344,10 +344,6 @@
|
||||
"label": "//chrome/test/android:chrome_java_test_pagecontroller_junit_tests",
|
||||
"type": "generated_script",
|
||||
},
|
||||
"chrome_java_test_pagecontroller_tests": {
|
||||
"label": "//chrome/test/android:chrome_java_test_pagecontroller_tests",
|
||||
"type": "console_test_launcher",
|
||||
},
|
||||
"chrome_java_test_wpr_tests": {
|
||||
"label": "//chrome/test/android:chrome_java_test_wpr_tests",
|
||||
"type": "console_test_launcher",
|
||||
@ -416,10 +412,6 @@
|
||||
"label": "//chrome/test:chrome_sizes",
|
||||
"type": "generated_script",
|
||||
},
|
||||
"chrome_webapk_integration_tests": {
|
||||
"label": "//chrome/test/android:chrome_webapk_integration_tests",
|
||||
"type": "console_test_launcher",
|
||||
},
|
||||
"chromedriver": {
|
||||
"label": "//chrome/test/chromedriver:chromedriver_server",
|
||||
"type": "additional_compile_target",
|
||||
|
@ -435,11 +435,6 @@ targets.generated_script(
|
||||
label = "//chrome/test/android:chrome_java_test_pagecontroller_junit_tests",
|
||||
)
|
||||
|
||||
targets.console_test_launcher(
|
||||
name = "chrome_java_test_pagecontroller_tests",
|
||||
label = "//chrome/test/android:chrome_java_test_pagecontroller_tests",
|
||||
)
|
||||
|
||||
targets.console_test_launcher(
|
||||
name = "chrome_java_test_wpr_tests",
|
||||
label = "//chrome/test/android:chrome_java_test_wpr_tests",
|
||||
@ -525,11 +520,6 @@ targets.generated_script(
|
||||
label = "//chrome/test:chrome_sizes",
|
||||
)
|
||||
|
||||
targets.console_test_launcher(
|
||||
name = "chrome_webapk_integration_tests",
|
||||
label = "//chrome/test/android:chrome_webapk_integration_tests",
|
||||
)
|
||||
|
||||
targets.compile_target(
|
||||
name = "chromedriver",
|
||||
label = "//chrome/test/chromedriver:chromedriver_server",
|
||||
|
@ -20213,50 +20213,6 @@
|
||||
"test": "chrome_public_unit_test_apk",
|
||||
"test_id_prefix": "ninja://chrome/android:chrome_public_unit_test_apk/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--gs-results-bucket=chromium-result-details",
|
||||
"--recover-devices"
|
||||
],
|
||||
"merge": {
|
||||
"args": [
|
||||
"--bucket",
|
||||
"chromium-result-details",
|
||||
"--test-name",
|
||||
"chrome_webapk_integration_tests"
|
||||
],
|
||||
"script": "//build/android/pylib/results/presentation/test_results_presentation.py"
|
||||
},
|
||||
"resultdb": {
|
||||
"enable": true,
|
||||
"has_native_resultdb_integration": true
|
||||
},
|
||||
"swarming": {
|
||||
"can_use_on_swarming_builders": true,
|
||||
"dimension_sets": [
|
||||
{
|
||||
"device_os": "PQ3A.190801.002",
|
||||
"device_os_flavor": "google",
|
||||
"device_os_type": "userdebug",
|
||||
"device_type": "walleye",
|
||||
"os": "Android"
|
||||
}
|
||||
],
|
||||
"output_links": [
|
||||
{
|
||||
"link": [
|
||||
"https://luci-logdog.appspot.com/v/?s",
|
||||
"=android%2Fswarming%2Flogcats%2F",
|
||||
"${TASK_ID}%2F%2B%2Funified_logcats"
|
||||
],
|
||||
"name": "shard #${SHARD_INDEX} logcats"
|
||||
}
|
||||
],
|
||||
"service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
|
||||
},
|
||||
"test": "chrome_webapk_integration_tests",
|
||||
"test_id_prefix": "ninja://chrome/test/android:chrome_webapk_integration_tests/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--gs-results-bucket=chromium-result-details",
|
||||
@ -31889,50 +31845,6 @@
|
||||
},
|
||||
"android-pie-arm64-dbg": {
|
||||
"gtest_tests": [
|
||||
{
|
||||
"args": [
|
||||
"--gs-results-bucket=chromium-result-details",
|
||||
"--recover-devices"
|
||||
],
|
||||
"merge": {
|
||||
"args": [
|
||||
"--bucket",
|
||||
"chromium-result-details",
|
||||
"--test-name",
|
||||
"chrome_java_test_pagecontroller_tests"
|
||||
],
|
||||
"script": "//build/android/pylib/results/presentation/test_results_presentation.py"
|
||||
},
|
||||
"resultdb": {
|
||||
"enable": true,
|
||||
"has_native_resultdb_integration": true
|
||||
},
|
||||
"swarming": {
|
||||
"can_use_on_swarming_builders": true,
|
||||
"dimension_sets": [
|
||||
{
|
||||
"device_os": "PQ3A.190801.002",
|
||||
"device_os_flavor": "google",
|
||||
"device_os_type": "userdebug",
|
||||
"device_type": "walleye",
|
||||
"os": "Android"
|
||||
}
|
||||
],
|
||||
"output_links": [
|
||||
{
|
||||
"link": [
|
||||
"https://luci-logdog.appspot.com/v/?s",
|
||||
"=android%2Fswarming%2Flogcats%2F",
|
||||
"${TASK_ID}%2F%2B%2Funified_logcats"
|
||||
],
|
||||
"name": "shard #${SHARD_INDEX} logcats"
|
||||
}
|
||||
],
|
||||
"service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
|
||||
},
|
||||
"test": "chrome_java_test_pagecontroller_tests",
|
||||
"test_id_prefix": "ninja://chrome/test/android:chrome_java_test_pagecontroller_tests/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--gs-results-bucket=chromium-result-details",
|
||||
@ -32497,52 +32409,6 @@
|
||||
"test": "cc_unittests",
|
||||
"test_id_prefix": "ninja://cc:cc_unittests/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--use-persistent-shell",
|
||||
"--gs-results-bucket=chromium-result-details",
|
||||
"--recover-devices"
|
||||
],
|
||||
"isolate_profile_data": true,
|
||||
"merge": {
|
||||
"args": [
|
||||
"--bucket",
|
||||
"chromium-result-details",
|
||||
"--test-name",
|
||||
"chrome_java_test_pagecontroller_tests"
|
||||
],
|
||||
"script": "//build/android/pylib/results/presentation/test_results_presentation.py"
|
||||
},
|
||||
"resultdb": {
|
||||
"enable": true,
|
||||
"has_native_resultdb_integration": true
|
||||
},
|
||||
"swarming": {
|
||||
"can_use_on_swarming_builders": true,
|
||||
"dimension_sets": [
|
||||
{
|
||||
"device_os": "PQ3A.190801.002",
|
||||
"device_os_flavor": "google",
|
||||
"device_os_type": "userdebug",
|
||||
"device_type": "sailfish",
|
||||
"os": "Android"
|
||||
}
|
||||
],
|
||||
"output_links": [
|
||||
{
|
||||
"link": [
|
||||
"https://luci-logdog.appspot.com/v/?s",
|
||||
"=android%2Fswarming%2Flogcats%2F",
|
||||
"${TASK_ID}%2F%2B%2Funified_logcats"
|
||||
],
|
||||
"name": "shard #${SHARD_INDEX} logcats"
|
||||
}
|
||||
],
|
||||
"service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
|
||||
},
|
||||
"test": "chrome_java_test_pagecontroller_tests",
|
||||
"test_id_prefix": "ninja://chrome/test/android:chrome_java_test_pagecontroller_tests/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--use-persistent-shell",
|
||||
@ -32698,52 +32564,6 @@
|
||||
"test": "chrome_public_unit_test_apk",
|
||||
"test_id_prefix": "ninja://chrome/android:chrome_public_unit_test_apk/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--use-persistent-shell",
|
||||
"--gs-results-bucket=chromium-result-details",
|
||||
"--recover-devices"
|
||||
],
|
||||
"isolate_profile_data": true,
|
||||
"merge": {
|
||||
"args": [
|
||||
"--bucket",
|
||||
"chromium-result-details",
|
||||
"--test-name",
|
||||
"chrome_webapk_integration_tests"
|
||||
],
|
||||
"script": "//build/android/pylib/results/presentation/test_results_presentation.py"
|
||||
},
|
||||
"resultdb": {
|
||||
"enable": true,
|
||||
"has_native_resultdb_integration": true
|
||||
},
|
||||
"swarming": {
|
||||
"can_use_on_swarming_builders": true,
|
||||
"dimension_sets": [
|
||||
{
|
||||
"device_os": "PQ3A.190801.002",
|
||||
"device_os_flavor": "google",
|
||||
"device_os_type": "userdebug",
|
||||
"device_type": "walleye",
|
||||
"os": "Android"
|
||||
}
|
||||
],
|
||||
"output_links": [
|
||||
{
|
||||
"link": [
|
||||
"https://luci-logdog.appspot.com/v/?s",
|
||||
"=android%2Fswarming%2Flogcats%2F",
|
||||
"${TASK_ID}%2F%2B%2Funified_logcats"
|
||||
],
|
||||
"name": "shard #${SHARD_INDEX} logcats"
|
||||
}
|
||||
],
|
||||
"service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
|
||||
},
|
||||
"test": "chrome_webapk_integration_tests",
|
||||
"test_id_prefix": "ninja://chrome/test/android:chrome_webapk_integration_tests/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--use-persistent-shell",
|
||||
@ -34111,65 +33931,6 @@
|
||||
"test": "cc_unittests",
|
||||
"test_id_prefix": "ninja://cc:cc_unittests/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--gs-results-bucket=chromium-result-details",
|
||||
"--recover-devices",
|
||||
"--avd-config=../../tools/android/avd/proto/generic_android28.textpb"
|
||||
],
|
||||
"merge": {
|
||||
"args": [
|
||||
"--bucket",
|
||||
"chromium-result-details",
|
||||
"--test-name",
|
||||
"chrome_java_test_pagecontroller_tests"
|
||||
],
|
||||
"script": "//build/android/pylib/results/presentation/test_results_presentation.py"
|
||||
},
|
||||
"resultdb": {
|
||||
"enable": true,
|
||||
"has_native_resultdb_integration": true
|
||||
},
|
||||
"swarming": {
|
||||
"can_use_on_swarming_builders": true,
|
||||
"dimension_sets": [
|
||||
{
|
||||
"cores": "4",
|
||||
"cpu": "x86-64",
|
||||
"device_os": null,
|
||||
"device_type": null,
|
||||
"os": "Ubuntu-22.04",
|
||||
"pool": "chromium.tests.avd"
|
||||
}
|
||||
],
|
||||
"named_caches": [
|
||||
{
|
||||
"name": "generic_android28",
|
||||
"path": ".android_emulator/generic_android28"
|
||||
}
|
||||
],
|
||||
"optional_dimensions": {
|
||||
"60": [
|
||||
{
|
||||
"caches": "generic_android28"
|
||||
}
|
||||
]
|
||||
},
|
||||
"output_links": [
|
||||
{
|
||||
"link": [
|
||||
"https://luci-logdog.appspot.com/v/?s",
|
||||
"=android%2Fswarming%2Flogcats%2F",
|
||||
"${TASK_ID}%2F%2B%2Funified_logcats"
|
||||
],
|
||||
"name": "shard #${SHARD_INDEX} logcats"
|
||||
}
|
||||
],
|
||||
"service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
|
||||
},
|
||||
"test": "chrome_java_test_pagecontroller_tests",
|
||||
"test_id_prefix": "ninja://chrome/test/android:chrome_java_test_pagecontroller_tests/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--gs-results-bucket=chromium-result-details",
|
||||
|
@ -200,51 +200,6 @@
|
||||
"test": "chrome_public_unit_test_apk",
|
||||
"test_id_prefix": "ninja://chrome/android:chrome_public_unit_test_apk/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--gs-results-bucket=chromium-result-details",
|
||||
"--recover-devices"
|
||||
],
|
||||
"isolate_profile_data": true,
|
||||
"merge": {
|
||||
"args": [
|
||||
"--bucket",
|
||||
"chromium-result-details",
|
||||
"--test-name",
|
||||
"chrome_webapk_integration_tests"
|
||||
],
|
||||
"script": "//build/android/pylib/results/presentation/test_results_presentation.py"
|
||||
},
|
||||
"resultdb": {
|
||||
"enable": true,
|
||||
"has_native_resultdb_integration": true
|
||||
},
|
||||
"swarming": {
|
||||
"can_use_on_swarming_builders": true,
|
||||
"dimension_sets": [
|
||||
{
|
||||
"device_os": "PQ3A.190801.002",
|
||||
"device_os_flavor": "google",
|
||||
"device_os_type": "userdebug",
|
||||
"device_type": "walleye",
|
||||
"os": "Android"
|
||||
}
|
||||
],
|
||||
"output_links": [
|
||||
{
|
||||
"link": [
|
||||
"https://luci-logdog.appspot.com/v/?s",
|
||||
"=android%2Fswarming%2Flogcats%2F",
|
||||
"${TASK_ID}%2F%2B%2Funified_logcats"
|
||||
],
|
||||
"name": "shard #${SHARD_INDEX} logcats"
|
||||
}
|
||||
],
|
||||
"service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
|
||||
},
|
||||
"test": "chrome_webapk_integration_tests",
|
||||
"test_id_prefix": "ninja://chrome/test/android:chrome_webapk_integration_tests/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--gs-results-bucket=chromium-result-details",
|
||||
@ -1486,51 +1441,6 @@
|
||||
"test": "cc_unittests",
|
||||
"test_id_prefix": "ninja://cc:cc_unittests/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--gs-results-bucket=chromium-result-details",
|
||||
"--recover-devices"
|
||||
],
|
||||
"isolate_profile_data": true,
|
||||
"merge": {
|
||||
"args": [
|
||||
"--bucket",
|
||||
"chromium-result-details",
|
||||
"--test-name",
|
||||
"chrome_webapk_integration_tests"
|
||||
],
|
||||
"script": "//build/android/pylib/results/presentation/test_results_presentation.py"
|
||||
},
|
||||
"resultdb": {
|
||||
"enable": true,
|
||||
"has_native_resultdb_integration": true
|
||||
},
|
||||
"swarming": {
|
||||
"can_use_on_swarming_builders": true,
|
||||
"dimension_sets": [
|
||||
{
|
||||
"device_os": "PQ3A.190801.002",
|
||||
"device_os_flavor": "google",
|
||||
"device_os_type": "userdebug",
|
||||
"device_type": "walleye",
|
||||
"os": "Android"
|
||||
}
|
||||
],
|
||||
"output_links": [
|
||||
{
|
||||
"link": [
|
||||
"https://luci-logdog.appspot.com/v/?s",
|
||||
"=android%2Fswarming%2Flogcats%2F",
|
||||
"${TASK_ID}%2F%2B%2Funified_logcats"
|
||||
],
|
||||
"name": "shard #${SHARD_INDEX} logcats"
|
||||
}
|
||||
],
|
||||
"service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
|
||||
},
|
||||
"test": "chrome_webapk_integration_tests",
|
||||
"test_id_prefix": "ninja://chrome/test/android:chrome_webapk_integration_tests/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--gs-results-bucket=chromium-result-details",
|
||||
|
@ -13086,49 +13086,6 @@
|
||||
"test": "chrome_public_smoke_test",
|
||||
"test_id_prefix": "ninja://chrome/android:chrome_public_smoke_test/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--gs-results-bucket=chromium-result-details",
|
||||
"--recover-devices"
|
||||
],
|
||||
"merge": {
|
||||
"args": [
|
||||
"--bucket",
|
||||
"chromium-result-details",
|
||||
"--test-name",
|
||||
"chrome_webapk_integration_tests"
|
||||
],
|
||||
"script": "//build/android/pylib/results/presentation/test_results_presentation.py"
|
||||
},
|
||||
"resultdb": {
|
||||
"enable": true,
|
||||
"has_native_resultdb_integration": true
|
||||
},
|
||||
"swarming": {
|
||||
"can_use_on_swarming_builders": true,
|
||||
"dimension_sets": [
|
||||
{
|
||||
"device_os": "N2G48C",
|
||||
"device_os_type": "userdebug",
|
||||
"device_type": "bullhead",
|
||||
"os": "Android"
|
||||
}
|
||||
],
|
||||
"output_links": [
|
||||
{
|
||||
"link": [
|
||||
"https://luci-logdog.appspot.com/v/?s",
|
||||
"=android%2Fswarming%2Flogcats%2F",
|
||||
"${TASK_ID}%2F%2B%2Funified_logcats"
|
||||
],
|
||||
"name": "shard #${SHARD_INDEX} logcats"
|
||||
}
|
||||
],
|
||||
"service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
|
||||
},
|
||||
"test": "chrome_webapk_integration_tests",
|
||||
"test_id_prefix": "ninja://chrome/test/android:chrome_webapk_integration_tests/"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"--gs-results-bucket=chromium-result-details",
|
||||
|
@ -344,10 +344,6 @@
|
||||
"label": "//chrome/test/android:chrome_java_test_pagecontroller_junit_tests",
|
||||
"type": "generated_script",
|
||||
},
|
||||
"chrome_java_test_pagecontroller_tests": {
|
||||
"label": "//chrome/test/android:chrome_java_test_pagecontroller_tests",
|
||||
"type": "console_test_launcher",
|
||||
},
|
||||
"chrome_java_test_wpr_tests": {
|
||||
"label": "//chrome/test/android:chrome_java_test_wpr_tests",
|
||||
"type": "console_test_launcher",
|
||||
@ -416,10 +412,6 @@
|
||||
"label": "//chrome/test:chrome_sizes",
|
||||
"type": "generated_script",
|
||||
},
|
||||
"chrome_webapk_integration_tests": {
|
||||
"label": "//chrome/test/android:chrome_webapk_integration_tests",
|
||||
"type": "console_test_launcher",
|
||||
},
|
||||
"chromedriver": {
|
||||
"label": "//chrome/test/chromedriver:chromedriver_server",
|
||||
"type": "additional_compile_target",
|
||||
|
@ -1476,21 +1476,6 @@
|
||||
},
|
||||
},
|
||||
},
|
||||
'chrome_java_test_pagecontroller_tests': {
|
||||
'modifications': {
|
||||
'android-pie-arm64-rel': {
|
||||
# TODO(crbug.com/1111436): Move this back to walleye if/when additional
|
||||
# capacity has been deployed.
|
||||
'swarming': {
|
||||
'dimension_sets': [
|
||||
{
|
||||
'device_type': 'sailfish',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
'chrome_public_smoke_test': {
|
||||
'remove_from': [
|
||||
'android-code-coverage-native', # Does not generate profraw data.
|
||||
|
@ -184,10 +184,6 @@
|
||||
},
|
||||
},
|
||||
|
||||
'android_pagecontroller_self_tests': {
|
||||
'chrome_java_test_pagecontroller_tests': {},
|
||||
},
|
||||
|
||||
# TODO(crbug.com/1111436): Deprecate this group in favor of
|
||||
# android_pie_rel_gtests if/when android Pie capacity is fully restored.
|
||||
'android_pie_rel_reduced_capacity_gtests': {
|
||||
@ -513,7 +509,6 @@
|
||||
'skia_gold_test',
|
||||
],
|
||||
},
|
||||
'chrome_webapk_integration_tests': {},
|
||||
},
|
||||
|
||||
'chrome_public_wpt': {
|
||||
@ -5921,7 +5916,6 @@
|
||||
'android_ar_gtests',
|
||||
'android_ddready_vr_gtests',
|
||||
'android_monochrome_smoke_tests',
|
||||
'android_pagecontroller_self_tests',
|
||||
'android_smoke_tests',
|
||||
'chromium_tracing_gtests',
|
||||
# No standard tests due to capacity, no Vega tests since it's currently
|
||||
@ -5934,7 +5928,6 @@
|
||||
'android_pie_rel_emulator_gtests': [
|
||||
'android_emulator_specific_chrome_public_tests',
|
||||
'android_monochrome_smoke_tests',
|
||||
'android_pagecontroller_self_tests',
|
||||
'android_smoke_tests',
|
||||
'android_specific_chromium_gtests', # Already includes gl_gtests.
|
||||
'chromium_gtests',
|
||||
@ -5950,9 +5943,7 @@
|
||||
# TODO(crbug.com/1111436): Deprecate this when all the test suites below
|
||||
# it are re-enabled.
|
||||
'android_pie_rel_reduced_capacity_gtests',
|
||||
|
||||
'android_monochrome_smoke_tests',
|
||||
'android_pagecontroller_self_tests',
|
||||
'android_smoke_tests',
|
||||
# 'android_specific_chromium_gtests', # Already includes gl_gtests.
|
||||
# 'chromium_gtests',
|
||||
|
@ -1 +0,0 @@
|
||||
file://chrome/test/android/javatests/src/org/chromium/chrome/test/pagecontroller/OWNERS
|
@ -1,65 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2019 The Chromium Authors
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
"""Finds R.string.* ids in android_chrome_sstrings.grd file."""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import xml.etree.cElementTree as ElementTree
|
||||
|
||||
_SRC_DIR = os.path.abspath(os.path.join(
|
||||
os.path.dirname(__file__), '..', '..', '..'))
|
||||
|
||||
_DEFAULT_GRD = os.path.join(_SRC_DIR,
|
||||
'chrome/browser/ui/android/strings/android_chrome_strings.grd')
|
||||
_MATCH_MSG = u' R.string.{}:\n Text = "{}"\n Desc = "{}"'
|
||||
|
||||
class GrdSearch(object):
|
||||
""" Search strings.grd file. """
|
||||
def __init__(self, grd_path):
|
||||
grd_dom = ElementTree.parse(grd_path)
|
||||
messages = grd_dom.findall('.//message')
|
||||
self.message_lookup = {}
|
||||
for message in messages:
|
||||
self.message_lookup[message.get('name')] = {
|
||||
'text': message.itertext().next().strip(),
|
||||
'desc': message.get('desc')}
|
||||
|
||||
def find_term_in_grd(self, term, is_regex):
|
||||
""" Returns matches for term in the form (string id, text, desc) """
|
||||
results = []
|
||||
for name,value in self.message_lookup.iteritems():
|
||||
if ((not is_regex and value['text'] == term) or
|
||||
(is_regex and re.match(term, value['text']))):
|
||||
results.append((name[4:].lower(), value['text'], value['desc']))
|
||||
return results
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Find clank string resource ids'
|
||||
' based on string content.')
|
||||
parser.add_argument('-r', '--regex', action='store_true',
|
||||
help='perform regex search instead of literal')
|
||||
parser.add_argument('-g', '--grd-file',
|
||||
default=_DEFAULT_GRD,
|
||||
help='strings.grd file, default: {}'.format(_DEFAULT_GRD))
|
||||
parser.add_argument('terms', nargs='+',
|
||||
help='Search terms.')
|
||||
|
||||
args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
searcher = GrdSearch(args.grd_file)
|
||||
|
||||
for t in args.terms:
|
||||
print('{} search term: "{}", R.string.* matches:'.format(
|
||||
('Regex' if args.regex else 'Literal'), t))
|
||||
for name, text, desc, in searcher.find_term_in_grd(t.decode('utf-8'),
|
||||
args.regex):
|
||||
print(_MATCH_MSG.format(name, text, desc))
|
||||
print('')
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
Reference in New Issue
Block a user