The dPWA integration tests use a special framework. Each test is defined by a series of “testing actions”, and test cases are read from a csv file.
Every test will log a message that will give:
In addition to this, every testing action will be printed to console before it is executed, giving insight into where test failures are occurring.
Test files live in //chrome/browser/test/data/web_apps/:
To disable a failing / crashing test, add an entry to the TestExpectations file mentioned above. The format is as follows:
crbug.com/id [ Platform ] [ Expectation ] list,of,actions,in,test
The list of supported platforms and expectations is maintained in the TestExpectations file. This test suite requires adding an entry per-platform that the test should be disabled on. Please create a bug for each test case added to this file.
This testing framework uses a script to generate a minimal set of test cases that produce the maximum amount of code coverage, and reading in that script output in these test implementations.
This suite of tests has two main parts:
The python script takes (among other things) as input:
These lists will be checked in via csv files with the above-linked CL, but the source of truth lives in this spreadsheet. See “Test Input Files” section for location of test case files.
The testing actions represent actions that users can take that trigger dPWA code, such as navigating to an installable site, or installing a PWA. Testing actions can also represent things such as setting up an enterprise policy to install an app. The script will generate a coverage graph, prune the graph to only include actions currently supported by the framework, and it will generate a test case definition csv file with the goal of minimizing the number of test cases to get maximum coverage.
The high level flow of execution is as follows:
std::vector<std::vector<std::string>>testing::ValuesIn(), which will run a test for each line in the input fileExecuteAction(action_string)ExecuteAction() will switch on the string, and call the appropriate action implementation methodA helper class containing most of the test implementation, meant to be used as a private member on the test-driving classes. Contains most of the test implementation:
An abstract class that’s an application of the delegate interface pattern. WebAppIntegrationBrowserTestBase stores an instance of this class as a private member, delegate_, allowing the base class to call into protected members of InProcessBrowserTest or SyncTest, such as InProcessBrowserTest::browser() or SyncTest::GetAllProfiles(). This also has pure virtual methods for sync functionality that needs to be implemented in TwoClientWebAppsSyncTest, but called from the base class.
Subclass of both InProcessBrowserTest and WebAppIntegrationBrowserTestBase::TestDelegate. Drives the test by calling IN_PROC_BROWSER_TEST_P and instantiating the parameterized test as described above. Responsible for telling the base class where the test input files live, handling test setup, and implementing TestDelegate methods to expose protected members of InProcessBrowserTest to the base class. This class owns the base class, and stores it as a private member, helper_, passing it an instance of itself (as the TestDelegate) on construction.
Similar to WebAppIntegrationBrowserTest, but inheriting from SyncTest instead of from InProcessBrowserTest. In addition, some testing actions related to profile sync are implemented in this class, and are exposed via TestDelegate pure virtual method overrides.