summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/documentation/TESTS_REAL_DEVICES.md
blob: f10709fb21dc391952a5cf7031acaef80e422b42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Running Tests with real USB connected devices for the new about:debugging

This document explains how to test with real USB connected devices.

## Tests overview

The tests that use a real device are located in `devtools/client/aboutdebugging/test/browser/`and the name of tests starts with `browser_aboutdebugging_real`. These are normal mochitest, but we need to setup the environment before starting tests.

## Setup environment
### Real device side
1. Enable USB debugging on your device
2. Launch Firefox
3. Enable USB debugging on your Firefox
4. Connect to your PC via USB

You can refer to https://firefox-source-docs.mozilla.org/devtools-user/about_colon_debugging/index.html#connecting-to-a-remote-device

### PC side
Setup the real device information to evaluate the validity in tests.

1. Copy a sample file which is located at `devtools/client/aboutdebugging/test/browser/real/usb-runtimes-sample.json` and rename it for example to `devtools/client/aboutdebugging/test/browser/real/local-usb-runtimes.json`.
2. Edit the file.

   This is a JSON file like below, write your real device information in here. This example indicates that there should be one USB device and should be displayed `Pixel 2` as device name and `Firefox Nightly` as short name on the sidebar of about:debugging. Regarding the other information, please see `Detail of config file` section of this document.

```
[
  {
    "sidebarInfo": {
      "deviceName": "Pixel 2",
      "shortName": "Firefox Nightly"
    },
    ...
  },
  ...
]
```

## Test
Normally, although we do test `./mach mochitest <path>`, to load the real device information created, specify the path as `USB_RUNTIME` environment variable, then do test.
For example, if the name of the saved file is `devtools/client/aboutdebugging/test/browser/real/local-usb-runtimes.json`, run all real device test with a command like the one below:

```
USB_RUNTIMES=devtools/client/aboutdebugging/test/browser/real/local-usb-runtimes.json ./mach mochitest devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_real
```

If there is no `USB_RUNTIMES` environment variable, the tests will not run. This is also to avoid to run on try-server and so on.

## Detail of config file

```
[
  {
    "sidebarInfo": {
      "deviceName": "Pixel 2", // This should display as device name on the sidebar.
      "shortName": "Firefox Nightly" // This should display as short name on the sidebar.
    },
    "runtimeDetails": {
      "info": {
        "name": "Mozilla Nightly", // This should display on the runtime info of runtime page.
        "version": "64.0a1" // This should display on the runtime info of runtime page.
      }
    }
  }
  // Of course, you can append additional USB devices. Some tests can do with multiple devices.
]
```