Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1079)

Side by Side Diff: client/site_tests/login_ChromeProfileSanitary/login_ChromeProfileSanitary.py

Issue 5740004: Move site_chrome_test, site_logging, site_log_reader, site_crash_test into cros dir. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging, os, stat, time, utils 5 import logging, os, stat, time, utils
6 from autotest_lib.client.common_lib import error 6 from autotest_lib.client.common_lib import error
7 from autotest_lib.client.cros import constants as chromeos_constants 7 from autotest_lib.client.cros import constants as chromeos_constants
8 from autotest_lib.client.cros import login, httpd, ui, ui_test 8 from autotest_lib.client.cros import cros_ui_test, login, httpd, ui
9 9
10 def respond_with_cookies(handler, url_args): 10 def respond_with_cookies(handler, url_args):
11 """Responds with a Set-Cookie header to any GET request, and redirects 11 """Responds with a Set-Cookie header to any GET request, and redirects
12 to a chosen URL. 12 to a chosen URL.
13 """ 13 """
14 handler.send_response(303) 14 handler.send_response(303)
15 handler.send_header('Set-Cookie', 'name=value') 15 handler.send_header('Set-Cookie', 'name=value')
16 handler.send_header('Location', url_args['continue'][0]) 16 handler.send_header('Location', url_args['continue'][0])
17 handler.end_headers() 17 handler.end_headers()
18 handler.wfile.write('Got form data:\n') 18 handler.wfile.write('Got form data:\n')
19 handler.wfile.write('%s:\n' % url_args) 19 handler.wfile.write('%s:\n' % url_args)
20 20
21 21
22 class login_ChromeProfileSanitary(ui_test.UITest): 22 class login_ChromeProfileSanitary(cros_ui_test.UITest):
23 version = 1 23 version = 1
24 24
25 def __wait_for_login_profile(self, timeout=10): 25 def __wait_for_login_profile(self, timeout=10):
26 start_time = time.time() 26 start_time = time.time()
27 while time.time() - start_time < timeout: 27 while time.time() - start_time < timeout:
28 if os.path.exists(chromeos_constants.LOGIN_PROFILE + '/Cookies'): 28 if os.path.exists(chromeos_constants.LOGIN_PROFILE + '/Cookies'):
29 break; 29 break;
30 time.sleep(1) 30 time.sleep(1)
31 else: 31 else:
32 raise error.TestError('Login Profile took too long to populate') 32 raise error.TestError('Login Profile took too long to populate')
33 33
34 34
35 def initialize(self, creds='$default'): 35 def initialize(self, creds='$default'):
36 spec = 'http://localhost:8000' 36 spec = 'http://localhost:8000'
37 path = '/set_cookie' 37 path = '/set_cookie'
38 self._wait_path = '/test_over' 38 self._wait_path = '/test_over'
39 self._test_url = spec + path + '?continue=' + spec + self._wait_path 39 self._test_url = spec + path + '?continue=' + spec + self._wait_path
40 self._testServer = httpd.HTTPListener(8000, docroot=self.srcdir) 40 self._testServer = httpd.HTTPListener(8000, docroot=self.srcdir)
41 self._testServer.add_url_handler('/set_cookie', respond_with_cookies) 41 self._testServer.add_url_handler('/set_cookie', respond_with_cookies)
42 self._testServer.run() 42 self._testServer.run()
43 43
44 ui_test.UITest.initialize(self, creds) 44 cros_ui_test.UITest.initialize(self, creds)
45 45
46 46
47 def cleanup(self): 47 def cleanup(self):
48 self._testServer.stop() 48 self._testServer.stop()
49 ui_test.UITest.cleanup(self) 49 cros_ui_test.UITest.cleanup(self)
50 50
51 51
52 def run_once(self, timeout = 10): 52 def run_once(self, timeout = 10):
53 # Get Default/Cookies mtime. 53 # Get Default/Cookies mtime.
54 cookies_info = os.stat(chromeos_constants.LOGIN_PROFILE + '/Cookies') 54 cookies_info = os.stat(chromeos_constants.LOGIN_PROFILE + '/Cookies')
55 cookies_mtime = cookies_info[stat.ST_MTIME] 55 cookies_mtime = cookies_info[stat.ST_MTIME]
56 56
57 # Wait for chrome to show, then "crash" it. 57 # Wait for chrome to show, then "crash" it.
58 login.wait_for_initial_chrome_window() 58 login.wait_for_initial_chrome_window()
59 login.nuke_process_by_name(chromeos_constants.BROWSER, 59 login.nuke_process_by_name(chromeos_constants.BROWSER,
(...skipping 16 matching lines...) Expand all
76 # Ensure chrome writes state to disk. 76 # Ensure chrome writes state to disk.
77 self.login() # will logout automatically 77 self.login() # will logout automatically
78 78
79 # Check mtime of Default/Cookies. If changed, KABLOOEY. 79 # Check mtime of Default/Cookies. If changed, KABLOOEY.
80 self.__wait_for_login_profile() 80 self.__wait_for_login_profile()
81 cookies_info = os.stat(chromeos_constants.LOGIN_PROFILE + '/Cookies') 81 cookies_info = os.stat(chromeos_constants.LOGIN_PROFILE + '/Cookies')
82 # TODO: Note that this currently (20100329) fails and will continue to 82 # TODO: Note that this currently (20100329) fails and will continue to
83 # do so until http://crosbug.com/1967 is fixed. 83 # do so until http://crosbug.com/1967 is fixed.
84 if cookies_mtime != cookies_info[stat.ST_MTIME]: 84 if cookies_mtime != cookies_info[stat.ST_MTIME]:
85 raise error.TestFail('Cookies in Default profile changed!') 85 raise error.TestFail('Cookies in Default profile changed!')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698