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

Side by Side Diff: chrome/test/functional/find_in_page.py

Issue 4166006: moved commonly used private functions to it's own utility file. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « no previous file | chrome/test/functional/test_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import os 6 import os
7 import unittest 7 import unittest
8 8
9 import pyauto_functional 9 import pyauto_functional
10 import pyauto 10 import pyauto
11 import test_utils
11 12
12 13
13 class FindMatchTests(pyauto.PyUITest): 14 class FindMatchTests(pyauto.PyUITest):
14 15
15 def testCanFindMatchCount(self): 16 def testCanFindMatchCount(self):
16 """Verify Find match count for valid search""" 17 """Verify Find match count for valid search"""
17 url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title1.html')) 18 url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title1.html'))
18 self.NavigateToURL(url) 19 self.NavigateToURL(url)
19 self.assertEqual(1, self.FindInPage('title')['match_count']) 20 self.assertEqual(1, self.FindInPage('title')['match_count'])
20 21
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 self.DataDir(), 'find_in_page', 'populatedform.html'))) 68 self.DataDir(), 'find_in_page', 'populatedform.html')))
68 for url in urls: 69 for url in urls:
69 self.NavigateToURL(url) 70 self.NavigateToURL(url)
70 self.assertEqual(1, self.FindInPage('cat')['match_count']) 71 self.assertEqual(1, self.FindInPage('cat')['match_count'])
71 self.assertEqual(0, self.FindInPage('bat')['match_count']) 72 self.assertEqual(0, self.FindInPage('bat')['match_count'])
72 73
73 def testSearchWithinSpecialURL(self): 74 def testSearchWithinSpecialURL(self):
74 """Verify search for text within special URLs such as chrome:history. 75 """Verify search for text within special URLs such as chrome:history.
75 chrome://history, chrome://downloads, pyAuto Data directory 76 chrome://history, chrome://downloads, pyAuto Data directory
76 """ 77 """
78 zip_file = 'a_zip_file.zip'
77 self.NavigateToURL(self.GetFileURLForPath(self.DataDir())) 79 self.NavigateToURL(self.GetFileURLForPath(self.DataDir()))
78 # search in Data directory 80 # search in Data directory
79 self.assertEqual(1, 81 self.assertEqual(1,
80 self.FindInPage('downloads', tab_index=0)['match_count']) 82 self.FindInPage('downloads', tab_index=0)['match_count'])
81 # search in History page 83 # search in History page
82 self.AppendTab(pyauto.GURL('chrome://history')) 84 self.AppendTab(pyauto.GURL('chrome://history'))
85 # the contents in the history page load asynchronously after tab loads
86 self.WaitUntil(
87 lambda: self.FindInPage('data', tab_index=1)['match_count'],
88 expect_retval=1)
83 self.assertEqual(1, self.FindInPage('data', tab_index=1)['match_count']) 89 self.assertEqual(1, self.FindInPage('data', tab_index=1)['match_count'])
84 # search in Downloads page 90 # search in Downloads page
85 self._DownloadZipFile() 91 test_utils.DownloadTestFile(self, zip_file)
86 self.AppendTab(pyauto.GURL('chrome://downloads')) 92 self.AppendTab(pyauto.GURL('chrome://downloads'))
93 # the contents in the downloads page load asynchronously after tab loads
94 self.WaitUntil(
95 lambda: self.FindInPage(zip_file, tab_index=2)['match_count'],
96 expect_retval=2)
87 self.assertEqual(2, 97 self.assertEqual(2,
88 self.FindInPage('a_zip_file.zip', tab_index=2)['match_count']) 98 self.FindInPage(zip_file, tab_index=2)['match_count'])
89 self._RemoveZipFile() 99 test_utils.RemoveTestFile(self, zip_file)
90
91 def _DownloadZipFile(self):
92 """Download a zip file."""
93 zip_file = 'a_zip_file.zip'
94 download_dir = os.path.join(os.path.abspath(self.DataDir()), 'downloads')
95 file_path = os.path.join(download_dir, zip_file)
96 file_url = self.GetFileURLForPath(file_path)
97 downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), zip_file)
98 # Check if zip file already exists. If so then delete it.
99 if os.path.exists(downloaded_pkg):
100 self._RemoveZipFile()
101 self.DownloadAndWaitForStart(file_url)
102 # Wait for the download to finish
103 self.WaitForAllDownloadsToComplete()
104
105 def _RemoveZipFile(self):
106 """Delete a_zip_file.zip from the download directory."""
107 downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(),
108 'a_zip_file.zip')
109 os.remove(downloaded_pkg)
110 100
111 101
112 if __name__ == '__main__': 102 if __name__ == '__main__':
113 pyauto_functional.Main() 103 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | chrome/test/functional/test_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698