Update scripts to use DEPS-pinned depot_tools

Always use gn.py in depot_tools instead of just gn.
The https://cs.chromium.org/chromium/src/build/find_depot_tools.py
is looking up the DEPS-pinned copy in third_party/depot_tools
and adds it to the path when add_depot_tools_to_path() is called.

Similar use:
 

https: //cs.chromium.org/search/?q=%22find_depot_tools.add_depot_tools_to_path()%22&sq=package:chromium&type=cs
Bug: webrtc:8393
Change-Id: I3cfa3d96b4d0f60e8099e556876bc94340b1bbb5
Reviewed-on: https://webrtc-review.googlesource.com/12540
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@google.com>
Commit-Queue: Henrik Kjellander <kjellander@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20333}
diff --git a/examples/androidtests/gradle_project_test.py b/examples/androidtests/gradle_project_test.py
index cd8fcd8..3ef6e06 100644
--- a/examples/androidtests/gradle_project_test.py
+++ b/examples/androidtests/gradle_project_test.py
@@ -60,10 +60,15 @@
   project_dir = os.path.abspath(project_dir)
 
   try:
+    env = os.environ.copy()
+    env['PATH'] = os.pathsep.join([
+        os.path.join(SRC_DIR, 'third_party', 'depot_tools'), env.get('PATH', '')
+    ])
     _RunCommand([GENERATE_GRADLE_SCRIPT, '--output-directory', output_dir,
         '--target', '//examples:AppRTCMobile',
         '--project-dir', project_dir,
-        '--use-gradle-process-resources', '--split-projects', '--canary'])
+        '--use-gradle-process-resources', '--split-projects', '--canary'],
+        env=env)
     _RunCommand([GRADLEW_BIN, 'assembleDebug'], project_dir)
   finally:
     # Do not delete temporary directory if user specified it manually.
diff --git a/examples/androidtests/video_quality_loopback_test.py b/examples/androidtests/video_quality_loopback_test.py
index 0b55878..6991a0a 100755
--- a/examples/androidtests/video_quality_loopback_test.py
+++ b/examples/androidtests/video_quality_loopback_test.py
@@ -34,6 +34,8 @@
 BAD_DEVICES_JSON = os.path.join(SRC_DIR,
                                 os.environ.get('CHROMIUM_OUT_DIR', 'out'),
                                 'bad_devices.json')
+sys.path.append(os.path.join(SRC_DIR, 'build'))
+import find_depot_tools
 
 
 class Error(Exception):
@@ -95,8 +97,13 @@
 
   if not build_dir_x86:
     build_dir_x86 = os.path.join(temp_dir, 'LocalBuild')
-    _RunCommand(['gn', 'gen', build_dir_x86])
-    _RunCommand(['ninja', '-C', build_dir_x86, 'frame_analyzer'])
+
+    def DepotToolPath(*args):
+      return os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, *args)
+
+    _RunCommand([sys.executable, DepotToolPath('gn.py'), 'gen', build_dir_x86])
+    _RunCommand([DepotToolPath('ninja'), '-C', build_dir_x86,
+                 'frame_analyzer'])
 
   tools_dir = os.path.join(SRC_DIR, 'tools_webrtc')
   toolchain_dir = os.path.join(tools_dir, 'video_quality_toolchain')