summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-23 20:08:52 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-23 20:08:52 +0000
commitcb1b585553851c906543ccb3a8e7b5d4781cae74 (patch)
treeddabf9a481ad41eab43aba36b1722d78c4fa7f62 /chrome_frame
parent92c2d90545462a8952c193375009c3d8ef7b1f68 (diff)
downloadchromium_src-cb1b585553851c906543ccb3a8e7b5d4781cae74.zip
chromium_src-cb1b585553851c906543ccb3a8e7b5d4781cae74.tar.gz
chromium_src-cb1b585553851c906543ccb3a8e7b5d4781cae74.tar.bz2
Fix python scripts src/chrome_frame/tools/test/page_cycler/cf_cycler.py
Make sure that: - shebang is only present for executable files - __main__ is only present for executable files - file's executable bit is coherent Also fix EOF LF to be only one. * Doing it separately since the CQ cannot process it. TBR=robertshield@chromium.org BUG=105108 TEST= Review URL: http://codereview.chromium.org/8662025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111399 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rwxr-xr-x[-rw-r--r--]chrome_frame/tools/test/page_cycler/cf_cycler.py199
1 files changed, 100 insertions, 99 deletions
diff --git a/chrome_frame/tools/test/page_cycler/cf_cycler.py b/chrome_frame/tools/test/page_cycler/cf_cycler.py
index fd49ae8..9feba7c 100644..100755
--- a/chrome_frame/tools/test/page_cycler/cf_cycler.py
+++ b/chrome_frame/tools/test/page_cycler/cf_cycler.py
@@ -1,99 +1,100 @@
-# Copyright (c) 2009 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Automates IE to visit a list of web sites while running CF in full tab mode.
-
-The page cycler automates IE and navigates it to a series of URLs. It is
-designed to be run with Chrome Frame configured to load every URL inside
-CF full tab mode.
-
-TODO(robertshield): Make use of the python unittest module as per
-review comments.
-"""
-
-import optparse
-import sys
-import time
-import win32com.client
-import win32gui
-
-def LoadSiteList(path):
- """Loads a list of URLs from |path|.
-
- Expects the URLs to be separated by newlines, with no leading or trailing
- whitespace.
-
- Args:
- path: The path to a file containing a list of new-line separated URLs.
-
- Returns:
- A list of strings, each one a URL.
- """
- f = open(path)
- urls = f.readlines()
- f.close()
- return urls
-
-def LaunchIE():
- """Starts up IE, makes it visible and returns the automation object.
-
- Returns:
- The IE automation object.
- """
- ie = win32com.client.Dispatch("InternetExplorer.Application")
- ie.visible = 1
- win32gui.SetForegroundWindow(ie.HWND)
- return ie
-
-def RunTest(url, ie):
- """Loads |url| into the InternetExplorer.Application instance in |ie|.
-
- Waits for the Document object to be created and then waits for
- the document ready state to reach READYSTATE_COMPLETE.
- Args:
- url: A string containing the url to navigate to.
- ie: The IE automation object to navigate.
- """
-
- print "Navigating to " + url
- ie.Navigate(url)
- timer = 0
-
- READYSTATE_COMPLETE = 4
-
- last_ready_state = -1
- for retry in xrange(60):
- try:
- # TODO(robertshield): Become an event sink instead of polling for
- # changes to the ready state.
- last_ready_state = ie.Document.ReadyState
- if last_ready_state == READYSTATE_COMPLETE:
- break
- except:
- # TODO(robertshield): Find the precise exception related to ie.Document
- # being not accessible and handle it here.
- print "Unexpected error:", sys.exc_info()[0]
- raise
- time.sleep(1)
-
- if last_ready_state != READYSTATE_COMPLETE:
- print "Timeout waiting for " + url
-
-def main():
- parser = optparse.OptionParser()
- parser.add_option('-u', '--url_list', default='urllist',
- help='The path to the list of URLs')
- (opts, args) = parser.parse_args()
-
- urls = LoadSiteList(opts.url_list)
- ie = LaunchIE()
- for url in urls:
- RunTest(url, ie)
- time.sleep(1)
- ie.visible = 0
- ie.Quit()
-
-
-if __name__ == '__main__':
- main()
+#!/usr/bin/env python
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Automates IE to visit a list of web sites while running CF in full tab mode.
+
+The page cycler automates IE and navigates it to a series of URLs. It is
+designed to be run with Chrome Frame configured to load every URL inside
+CF full tab mode.
+
+TODO(robertshield): Make use of the python unittest module as per
+review comments.
+"""
+
+import optparse
+import sys
+import time
+import win32com.client
+import win32gui
+
+def LoadSiteList(path):
+ """Loads a list of URLs from |path|.
+
+ Expects the URLs to be separated by newlines, with no leading or trailing
+ whitespace.
+
+ Args:
+ path: The path to a file containing a list of new-line separated URLs.
+
+ Returns:
+ A list of strings, each one a URL.
+ """
+ f = open(path)
+ urls = f.readlines()
+ f.close()
+ return urls
+
+def LaunchIE():
+ """Starts up IE, makes it visible and returns the automation object.
+
+ Returns:
+ The IE automation object.
+ """
+ ie = win32com.client.Dispatch("InternetExplorer.Application")
+ ie.visible = 1
+ win32gui.SetForegroundWindow(ie.HWND)
+ return ie
+
+def RunTest(url, ie):
+ """Loads |url| into the InternetExplorer.Application instance in |ie|.
+
+ Waits for the Document object to be created and then waits for
+ the document ready state to reach READYSTATE_COMPLETE.
+ Args:
+ url: A string containing the url to navigate to.
+ ie: The IE automation object to navigate.
+ """
+
+ print "Navigating to " + url
+ ie.Navigate(url)
+ timer = 0
+
+ READYSTATE_COMPLETE = 4
+
+ last_ready_state = -1
+ for retry in xrange(60):
+ try:
+ # TODO(robertshield): Become an event sink instead of polling for
+ # changes to the ready state.
+ last_ready_state = ie.Document.ReadyState
+ if last_ready_state == READYSTATE_COMPLETE:
+ break
+ except:
+ # TODO(robertshield): Find the precise exception related to ie.Document
+ # being not accessible and handle it here.
+ print "Unexpected error:", sys.exc_info()[0]
+ raise
+ time.sleep(1)
+
+ if last_ready_state != READYSTATE_COMPLETE:
+ print "Timeout waiting for " + url
+
+def main():
+ parser = optparse.OptionParser()
+ parser.add_option('-u', '--url_list', default='urllist',
+ help='The path to the list of URLs')
+ (opts, args) = parser.parse_args()
+
+ urls = LoadSiteList(opts.url_list)
+ ie = LaunchIE()
+ for url in urls:
+ RunTest(url, ie)
+ time.sleep(1)
+ ie.visible = 0
+ ie.Quit()
+
+
+if __name__ == '__main__':
+ main()