flowcrypt-android

Introduction: FlowCrypt Android App
More: Author   ReportBugs   OfficialWebsite   
Tags:
👋 Try our app
⬇ Download the FlowCrypt app on your device from the FlowCrypt Downloads page.

Build Status

🔍 Running tests

This guide follows Google's recommendations for testing apps on Android. Every scenario described in this section has been tested on Ubuntu. There are JUnit and Instrumentation tests. To be able to run tests locally, you should set up your environment.

✔️ Device setup instructions

Please follow these steps to setup your virtual or physical device:

  • Set up your test environment.
  • Some of the tests use MockWebServer. We run a local mock web server via FlowCryptMockWebServerRule. It uses TestConstants.MOCK_WEB_SERVER_PORT as a port. Unfortunately, the Android system doesn't allow us to use the HTTPS 433 port by default to run a web server on the localhost (127.0.0.1). That's why we have to run a mock web server on another port (for example, 1212) and route all traffic from 127.0.0.1:433 to 127.0.0.1:1212. For that purpose, you can use the script/ci-wait-for-emulator.sh script.
  • Additionally, the test environment should handle all requests to *.flowcrypt.test. All traffic to *.flowcrypt.test should be routed to localhost (127.0.0.1). You can use a DNS server to do this. For example, using these commands:
1. sudo apt install -y dnsmasq resolvconf
2. echo "#added by flowcrypt" | sudo tee -a /etc/dnsmasq.conf
3. echo "listen-address=127.0.0.1" | sudo tee -a /etc/dnsmasq.conf
4. echo "address=/flowcrypt.test/127.0.0.1" | sudo tee -a /etc/dnsmasq.conf
5. echo "address=/localhost/127.0.0.1" | sudo tee -a /etc/dnsmasq.conf
6. sudo systemctl restart dnsmasq

✔️ Test types

We have two types of tests:

  • Independent tests that don't require any additional dependencies.
  • Tests that depend on an email server. Such tests are marked with the @DependsOnMailServer annotation.

Additionally, we have separate tests for the consumer and enterprise versions. Enterprise tests are marked with the @EnterpriseTest annotation. These tests use the Gmail API and are independent of the mail server.

We run tests on Semaphore CI for every commit. To run tests that depend on an email server, we use a custom Docker image, which extends docker-mailserver. This image has predefined settings for local testing. It has accounts and messages which we need for testing. You can investigate the docker-mailserver folder to see more details. To be able to run tests that depend on an email server, please install docker-compose following the official instructions.

✔️ Run independent tests

⬇️ Please follow these steps to run the independent tests locally:

  1. Setup your device (virtual or physical) following the device setup instructions.
  2. Run ../script/ci-instrumentation-tests-without-mailserver.sh 1 0 (where 1 is a numShards and 0 is a shardIndex). You can find more details if you read the guide concerning AndroidX test libraries on sharding tests. It helps us run them in pieces on a few emulators at the same time to reduce runtime.

⬇️ Please follow these steps to run tests that depend on an email server locally:

  1. Setup your device (virtual or physical) following the device setup instructions.
  2. Run ./docker-mailserver/run_email_server.sh and wait while the email server is started.
  3. Run ../script/ci-instrumentation-tests-with-mailserver.sh.
  4. Run ./docker-mailserver/stop_email_server.sh to stop the email server.

⬇️ Please follow these steps to run all tests locally:

  1. Setup your device (virtual or physical) following the device setup instructions.
  2. Run ./docker-mailserver/run_email_server.sh and wait while the email server is started.
  3. Run ./script/run-all-tests.sh to execute all tests.
  4. Run ./docker-mailserver/stop_email_server.sh to stop the email server.

⬇️ Please follow these steps to run enterprise tests locally:

  1. Setup your device (virtual or physical) following the device setup instructions.
  2. Run ./script/ci-instrumentation-tests-enterprise.sh to execute enterprise tests.

⚙️ Running the app in the emulator for the first time

This section describes two main steps you need to accomplish to run the app in the emulaor:

✔️ Install and run the emulator

Please follow these steps to be able to install and run the emulator:

1. Run AVD Manager from ToolsAVD Manager or click on the highlighted icon: image

2. Click on Create Virtual Device: image

3. Select the hardware: Pixel 4 will be a good choice. After, click Next: image

4. Download one of the latest available system images: image

5. Click Finish: image

6. Select the downloaded image and click Next: image

7. Once you click Next, you'll see the final screen where you should click Finish: image

8. AVD Manager will show a new emulator. Click the green triangle to run the emulator: image

9. Once running, you'll see the home screen of the emulator: image

✔️ Build and run the app

Please follow these steps to be able to build and run the app:

1. First of all, you should select the correct version of the build variants. Please use consumerDebug: image

2. Make sure that your emulator is selected: image

3. Now, you can run the app via RunRun(Alt+Shift+F10) or click on the green Run button: image

4. You'll see the app on the emulator in a few minutes (it depends on the hardware performance characteristics): image

Apps
About Me
GitHub: Trinea
Facebook: Dev Tools