[2.7] Enable GUI testing on Travis Linux builds via Xvfb (GH-7887)

(cherry picked from commit b12112b5ba608cdd7a0962a6b18cad4fe58b46e6)
diff --git a/.travis.yml b/.travis.yml
index 695b5a7..7e1c2ef 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -31,6 +31,10 @@
       # compiler here and the other to run the coverage build. Clang is preferred
       # in this instance for its better error messages.
       env: TESTING=cpython
+      addons:
+        apt:
+          packages:
+            - xvfb
     - os: linux
       language: python
       python: 2.7
@@ -91,7 +95,7 @@
   # Check that all symbols exported by libpython start with "Py" or "_Py"
   - make smelly
   # `-r -w` implicitly provided through `make buildbottest`.
-  - make buildbottest TESTOPTS="-j4 -uall,-cpu"
+  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then XVFB_RUN=xvfb-run; fi; $XVFB_RUN make buildbottest TESTOPTS="-j4 -uall,-cpu"
 
 notifications:
   email: false