summaryrefslogtreecommitdiffstats
path: root/testing/chromoting/browser_tests_launcher.py
diff options
context:
space:
mode:
authorkelvinp <kelvinp@chromium.org>2015-01-16 18:13:52 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-17 02:15:03 +0000
commit90518a3cb18b513b95a091cffffd1591b6a3ca76 (patch)
tree912c62c92b06c2bc8d6cc062ec179313a1a54046 /testing/chromoting/browser_tests_launcher.py
parent25f305d269d3ab52cd74ad93d5a32dfb96923a0c (diff)
downloadchromium_src-90518a3cb18b513b95a091cffffd1591b6a3ca76.zip
chromium_src-90518a3cb18b513b95a091cffffd1591b6a3ca76.tar.gz
chromium_src-90518a3cb18b513b95a091cffffd1591b6a3ca76.tar.bz2
Clean the user profile directory after each test run
Currently browser_tests_launcher.py doesn't remove the chrome user profile directory after each test run. As a result, each browser test is inheriting the profile and thus the local state of the test before it. If the previous test signed in successfully, the Authorize() method of the current test will fail as the user is already signed-in. This CL 1. Modifies browser_tests_launcher.py to clean the Chrome user profile directory after each test run. 2. Modifies HTMLElementExists to dump the DOM if the element is not found. BUG=449706 Review URL: https://codereview.chromium.org/853313002 Cr-Commit-Position: refs/heads/master@{#312010}
Diffstat (limited to 'testing/chromoting/browser_tests_launcher.py')
-rw-r--r--testing/chromoting/browser_tests_launcher.py47
1 files changed, 28 insertions, 19 deletions
diff --git a/testing/chromoting/browser_tests_launcher.py b/testing/chromoting/browser_tests_launcher.py
index dab4c97..0cb903b 100644
--- a/testing/chromoting/browser_tests_launcher.py
+++ b/testing/chromoting/browser_tests_launcher.py
@@ -80,21 +80,14 @@ def TestCleanUp(user_profile_dir):
shutil.rmtree(user_profile_dir)
-def InitialiseTestMachineForLinux(cfg_file, me2me_manifest_file,
- it2me_manifest_file, user_profile_dir):
+def InitialiseTestMachineForLinux(cfg_file):
"""Sets up a Linux machine for connect-to-host browser-tests.
- Copy over me2me host-config and manifest files to expected locations.
+ Copy over me2me host-config to expected locations.
By default, the Linux me2me host expects the host-config file to be under
$HOME/.config/chrome-remote-desktop
Its name is expected to have a hash that is specific to a machine.
- When a user launches the remoting web-app, the native-message host process is
- started. For this to work, the manifest file for me2me host and it2me host is
- expected to be in a specific folder under the user-profile dir.
-
- This function performs both the above tasks.
-
TODO(anandc):
Once we have Linux machines in the swarming lab already installed with the
me2me host, this function should also perform the step of starting the host.
@@ -103,9 +96,6 @@ def InitialiseTestMachineForLinux(cfg_file, me2me_manifest_file,
Args:
cfg_file: location of test account's host-config file.
- me2me_manifest_file: location of me2me host manifest file.
- it2me_manifest_file: location of it2me host manifest file.
- user_profile_dir: user-profile-dir to be used by the connect-to-host tests.
"""
# First get home directory on current machine.
@@ -123,8 +113,27 @@ def InitialiseTestMachineForLinux(cfg_file, me2me_manifest_file,
config_file_src,
os.path.join(default_config_file_location, default_config_file_name))
- # Next, create a user-profile dir, and place the me2me manifest.json file in
- # the expected location for native-messating-host to work properly.
+ # Finally, start chromoting host.
+ RunCommandInSubProcess(CHROMOTING_HOST_PATH + ' --start')
+
+
+def SetupUserProfileDir(me2me_manifest_file, it2me_manifest_file,
+ user_profile_dir):
+ """Sets up the Google Chrome user profile directory
+
+ Delete the previous user profile directory if exists and create a new one.
+ This invalidates any state changes by the previous test so each test can start
+ with the same environment.
+
+ When a user launches the remoting web-app, the native messaging host process
+ is started. For this to work, this function places the me2me and it2me native
+ messaging host manifest files in a specific folder under the user-profile dir.
+
+ Args:
+ me2me_manifest_file: location of me2me native messaging host manifest file.
+ it2me_manifest_file: location of it2me native messaging host manifest file.
+ user_profile_dir: Chrome user-profile-directory.
+ """
native_messaging_folder = os.path.join(user_profile_dir, NATIVE_MESSAGING_DIR)
if os.path.exists(user_profile_dir):
@@ -138,9 +147,6 @@ def InitialiseTestMachineForLinux(cfg_file, me2me_manifest_file,
os.path.join(native_messaging_folder, os.path.basename(manifest_file)))
shutil.copyfile(manifest_file_src, manifest_file_dest)
- # Finally, start chromoting host.
- RunCommandInSubProcess(CHROMOTING_HOST_PATH + ' --start')
-
def main():
parser = argparse.ArgumentParser()
@@ -160,11 +166,14 @@ def main():
args = parser.parse_args()
- InitialiseTestMachineForLinux(args.cfg_file, args.me2me_manifest_file,
- args.it2me_manifest_file, args.user_profile_dir)
+ InitialiseTestMachineForLinux(args.cfg_file)
with open(args.commands_file) as f:
for line in f:
+ # Reset the user profile directory to start each test with a clean slate.
+ SetupUserProfileDir(args.me2me_manifest_file, args.it2me_manifest_file,
+ args.user_profile_dir)
+
# Replace the PROD_DIR value in the command-line with
# the passed in value.
line = line.replace(PROD_DIR_ID, args.prod_dir)