Index: build/android/emulator.py |
diff --git a/build/android/emulator.py b/build/android/emulator.py |
index 77c9a75daa11963c0de2502d33bc828363f5fef1..543a98e172e00b5081e262c65a88495a477a361b 100755 |
--- a/build/android/emulator.py |
+++ b/build/android/emulator.py |
@@ -21,6 +21,7 @@ import time |
from pylib import android_commands |
from pylib import cmd_helper |
+from pylib.utils import time_profile |
# adb_interface.py is under ../../third_party/android_testrunner/ |
sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..', |
@@ -99,6 +100,33 @@ def _GetAvailablePort(): |
return port |
+def LaunchEmulators(emulator_count, fast_and_loose=False): |
+ """Launch multiple emulators and wait for them to boot. |
+ |
+ Args: |
+ emulator_count: number of emulators to launch. |
+ |
+ Returns: |
+ List of emulators. |
+ """ |
+ emulators = [] |
+ for n in xrange(emulator_count): |
+ t = time_profile.TimeProfile('Emulator launch %d' % n) |
+ avd_name = None |
+ if n > 0: |
+ # Creates a temporary AVD for the extra emulators. |
+ avd_name = 'run_tests_avd_%d' % n |
+ logging.info('Emulator launch %d with avd_name=%s', n, avd_name) |
+ emulator = Emulator(avd_name, fast_and_loose) |
+ emulator.Launch(kill_all_emulators=n == 0) |
+ t.Stop() |
+ emulators.append(emulator) |
+ # Wait for all emulators to boot completed. |
+ for emulator in emulators: |
+ emulator.ConfirmLaunch(True) |
+ return emulators |
+ |
+ |
class Emulator(object): |
"""Provides the methods to lanuch/shutdown the emulator. |