OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import os | 7 import os |
8 | 8 |
9 import pyauto_functional # Must be imported before pyauto | 9 import pyauto_functional # Must be imported before pyauto |
10 import pyauto | 10 import pyauto |
11 import time | |
11 | 12 |
12 | 13 |
13 class InstantTest(pyauto.PyUITest): | 14 class InstantTest(pyauto.PyUITest): |
14 """TestCase for Omnibox Instant feature.""" | 15 """TestCase for Omnibox Instant feature.""" |
15 | 16 |
16 def setUp(self): | 17 def setUp(self): |
17 pyauto.PyUITest.setUp(self) | 18 pyauto.PyUITest.setUp(self) |
18 self.SetPrefs(pyauto.kInstantEnabled, True) | 19 self.SetPrefs(pyauto.kInstantEnabled, True) |
19 | 20 |
20 def _DoneLoading(self): | 21 def _DoneLoading(self): |
21 info = self.GetInstantInfo() | 22 info = self.GetInstantInfo() |
22 return info.get('current') and not info.get('loading') | 23 return info.get('current') and not info.get('loading') |
23 | 24 |
25 def _NotLoading(self): | |
dyu1
2011/01/19 23:14:45
Is this needed? If instant is not active you can h
| |
26 """Sometime instant will decide not to prefetch a query.""" | |
Nirnimesh
2011/01/19 02:04:36
this docstring is not clear
| |
27 info = self.GetInstantInfo() | |
28 return not info.get('current') and not info.get('loading') | |
29 | |
24 def testInstantNavigation(self): | 30 def testInstantNavigation(self): |
25 """Test that instant navigates based on omnibox input.""" | 31 """Test that instant navigates based on omnibox input.""" |
26 self.SetOmniboxText('google.com') | 32 self.SetOmniboxText('google.com') |
27 self.assertTrue(self.WaitUntil(self._DoneLoading)) | 33 self.assertTrue(self.WaitUntil(self._DoneLoading)) |
28 location = self.GetInstantInfo()['location'] | 34 location = self.GetInstantInfo()['location'] |
29 self.assertTrue('google.com' in location, | 35 self.assertTrue('google.com' in location, |
30 msg='No google.com in %s' % location) | 36 msg='No google.com in %s' % location) |
31 | 37 |
32 self.SetOmniboxText('google.es') | 38 self.SetOmniboxText('google.es') |
33 self.assertTrue(self.WaitUntil(self._DoneLoading)) | 39 self.assertTrue(self.WaitUntil(self._DoneLoading)) |
(...skipping 22 matching lines...) Expand all Loading... | |
56 self.assertTrue(self.WaitUntil(self._DoneLoading)) | 62 self.assertTrue(self.WaitUntil(self._DoneLoading)) |
57 history = self.GetHistoryInfo().History() | 63 history = self.GetHistoryInfo().History() |
58 self.assertEqual(0, len(history)) | 64 self.assertEqual(0, len(history)) |
59 | 65 |
60 def testInstantDisabledForJavaScript(self): | 66 def testInstantDisabledForJavaScript(self): |
61 """Test that instant is disabled for javascript URLs.""" | 67 """Test that instant is disabled for javascript URLs.""" |
62 self.SetOmniboxText('javascript:') | 68 self.SetOmniboxText('javascript:') |
63 self.assertFalse(self.GetInstantInfo()['active'], | 69 self.assertFalse(self.GetInstantInfo()['active'], |
64 'Instant enabled for javascript URL.') | 70 'Instant enabled for javascript URL.') |
65 | 71 |
72 def testInstantDisablesPopupsOnPrefetch(self): | |
73 """Test that instant disables popups when prefetching.""" | |
74 popups_site = ('http://www.javascript-coder.com/files/' | |
Allen
2011/01/19 00:31:32
does instant work with file:// urls? if so, shoul
Nirnimesh
2011/01/19 02:04:36
Use one of the files used in popups.py
dyu1
2011/01/19 23:14:45
Can use something like popup_url = self.GetFileURL
Huyen
2011/01/19 23:27:07
Looks like it does. I've changed the test to use a
| |
75 'window-popup/javascript-popup-example3.html') | |
76 self.SetOmniboxText(popups_site) | |
77 self.assertTrue(self.WaitUntil(self._DoneLoading)) | |
78 location = self.GetInstantInfo()['location'] | |
79 self.assertTrue(popups_site in location, | |
80 msg='Prefetched page is not %s' % popups_site) | |
81 blocked_popups = self.GetBlockedPopupsInfo() | |
82 self.assertEqual(0, len(blocked_popups), msg='Popup not disabled.') | |
Nirnimesh
2011/01/19 02:04:36
correct the msg string to apply better here. somet
Huyen
2011/01/19 23:27:07
Done.
| |
83 | |
84 def testInstantSearchQueryLimit_100Chars(self): | |
Nirnimesh
2011/01/19 02:04:36
no _ in fn name please
Huyen
2011/01/19 23:27:07
Done.
| |
85 """Test that instant loads for search querty of 100 characters.""" | |
Allen
2011/01/19 00:31:32
this test case has no failure condition
Allen
2011/01/19 22:49:18
Just to be clear, this test is basically fine, it'
Huyen
2011/01/19 23:27:07
Fixed by waiting until the query string shows up i
| |
86 ahundred = ('##################################################' | |
Nirnimesh
2011/01/19 02:04:36
a_hundred = '#' * 100
Huyen
2011/01/19 23:27:07
Done.
| |
87 '##################################################') | |
88 self.SetOmniboxText(ahundred) | |
89 self.assertTrue(self.WaitUntil(self._DoneLoading)) | |
90 | |
91 def testInstantSearchQueryLimit_101Chars(self): | |
Nirnimesh
2011/01/19 02:04:36
can be merged with the previous test.
and renamed
Huyen
2011/01/19 23:27:07
Done.
| |
92 """Test that instant does not load for search querty of 101 characters.""" | |
Nirnimesh
2011/01/19 02:04:36
s/querty/query/
Huyen
2011/01/19 23:27:07
Done.
| |
93 ahundredone = ('##################################################' | |
Allen
2011/01/19 00:31:32
probably not the best variable name. maybe someth
Huyen
2011/01/19 23:27:07
Done.
| |
94 '###################################################') | |
95 self.SetOmniboxText(ahundredone) | |
96 # Sleep to verify instant does not load results | |
97 time.sleep(2) | |
Allen
2011/01/19 00:31:32
need an alternative to sleep. not reliable/effici
Nirnimesh
2011/01/19 02:04:36
+1 do not use sleep(). You're asking for trouble.
dyu1
2011/01/19 23:14:45
You can use WaitUntil and check for a specific DOM
Allen
2011/01/19 23:19:59
in this case seeing a dom is not expected, but huy
Huyen
2011/01/19 23:27:07
I'm taking this test case out of this CL for now.
| |
98 self.assertTrue(self._NotLoading()) | |
66 | 99 |
Nirnimesh
2011/01/19 02:04:36
leave 2 blank lines at global scope
Huyen
2011/01/19 23:27:07
Done.
| |
67 if __name__ == '__main__': | 100 if __name__ == '__main__': |
68 pyauto_functional.Main() | 101 pyauto_functional.Main() |
OLD | NEW |