These are on-device integration tests for android_webview with rest of the chromium code (covering both Java and native code). A large percentage of Android applications use WebView, and could trigger WebView specific code paths in the codebase, therefore it is important to have solid integration tests.
The tests are located in the javatests directory. They are roughly organized by the Aw classes (some tests are organized by overall functionality instead). Put new tests into an existing test class or create a new one if a suitable one isn't available.
See the instrumentation test doc.
Tests are written as JUnit4 tests. AwActivityTestRule is used to create and obtain references to WebView objects such as AwContents(internally it launches the WebView instrumentation shell application to hold AwTestContainerViews which in turn contains AwContents). AwContents will allow the test to trigger code paths such as loading urls, going forwards/backwards, etc... . AwActivityTestRule has some helper methods to call the AwContents methods, for example to ensure that they are called on the UI thread. Some AW components, such as AwCookieManager, can be directly created in tests.
Tests can use the load* methods in AwActivityTestRule to inject snippets of content. This will however bypass the network layer. To have end-to-end testing, use EmbeddedTestServer, which will allow simple loading of files from the data directory. For loading data from arbitrary URIs and more advanced control, the TestWebServer can be used. Note that, when simulating input or user actions on web content, the content should include some visiible text because input is typically ignored until something meaningful is painted.
These are off-device tests using robolectric that only exercise android_webview Java code.
The tests are located in the junit directory.
See the JUnit doc.
These are on-device gtests that only exercise android_webview native code.
The tests are located alongside respective source code files under android_webview directory.
See the GTest doc.
Running tests is covered in WebView Test Instructions.