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

Side by Side Diff: functional/instant.py

Issue 6352003: Added one testcases to Instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/
Patch Set: '' Created 9 years, 10 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
« no previous file with comments | « no previous file | no next file » | 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 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 11
12 12
13 class InstantTest(pyauto.PyUITest): 13 class InstantTest(pyauto.PyUITest):
14 """TestCase for Omnibox Instant feature.""" 14 """TestCase for Omnibox Instant feature."""
15 15
16 def setUp(self): 16 def setUp(self):
17 pyauto.PyUITest.setUp(self) 17 pyauto.PyUITest.setUp(self)
18 self.SetPrefs(pyauto.kInstantEnabled, True) 18 self.SetPrefs(pyauto.kInstantEnabled, True)
19 19
20 def _DoneLoading(self): 20 def _DoneLoading(self):
21 info = self.GetInstantInfo() 21 info = self.GetInstantInfo()
22 return info.get('current') and not info.get('loading') 22 return info.get('current') and not info.get('loading')
23 23
24 def _CanDismissInstant(self):
25 test_dir = os.path.join(os.path.abspath(self.DataDir()), 'google')
26 file_path = os.path.join(test_dir, 'google.html')
27 file_url = self.GetFileURLForPath(file_path)
28 self.SetOmniboxText(file_url)
29 self.assertTrue(self.WaitUntil(self._DoneLoading))
30 location = self.GetInstantInfo()['location']
31 self.assertTrue('google.html' in location,
32 msg='No google.html in %s' % location)
33
24 def testInstantNavigation(self): 34 def testInstantNavigation(self):
25 """Test that instant navigates based on omnibox input.""" 35 """Test that instant navigates based on omnibox input."""
26 self.SetOmniboxText('google.com') 36 self.SetOmniboxText('google.com')
27 self.assertTrue(self.WaitUntil(self._DoneLoading)) 37 self.assertTrue(self.WaitUntil(self._DoneLoading))
28 location = self.GetInstantInfo()['location'] 38 location = self.GetInstantInfo()['location']
29 self.assertTrue('google.com' in location, 39 self.assertTrue('google.com' in location,
30 msg='No google.com in %s' % location) 40 msg='No google.com in %s' % location)
31 41
32 self.SetOmniboxText('google.es') 42 self.SetOmniboxText('google.es')
33 self.assertTrue(self.WaitUntil(self._DoneLoading)) 43 self.assertTrue(self.WaitUntil(self._DoneLoading))
(...skipping 22 matching lines...) Expand all
56 self.assertTrue(self.WaitUntil(self._DoneLoading)) 66 self.assertTrue(self.WaitUntil(self._DoneLoading))
57 history = self.GetHistoryInfo().History() 67 history = self.GetHistoryInfo().History()
58 self.assertEqual(0, len(history)) 68 self.assertEqual(0, len(history))
59 69
60 def testInstantDisabledForJavaScript(self): 70 def testInstantDisabledForJavaScript(self):
61 """Test that instant is disabled for javascript URLs.""" 71 """Test that instant is disabled for javascript URLs."""
62 self.SetOmniboxText('javascript:') 72 self.SetOmniboxText('javascript:')
63 self.assertFalse(self.GetInstantInfo()['active'], 73 self.assertFalse(self.GetInstantInfo()['active'],
64 'Instant enabled for javascript URL.') 74 'Instant enabled for javascript URL.')
65 75
66 76 def testInstantCanDismiss(self):
77 """Test that instant preview is dismissed by
78 find-in-page, new tab page, extenions page, new window."""
79 #Test with find-in-page
80 self._CanDismissInstant()
81 self.OpenFindInPage()
82 self.assertEqual(self.GetActiveTabTitle(), '')
83 #Test with new tab page.
84 self._CanDismissInstant()
85 self.AppendTab(pyauto.GURL('chrome://newtab'))
86 self.RunCommand(pyauto.IDC_CLOSE_TAB)
87 self.assertEqual(self.GetActiveTabTitle(), '')
88 #Test with extensions page
89 self._CanDismissInstant()
90 self.AppendTab(pyauto.GURL('chrome://extensions'))
91 self.RunCommand(pyauto.IDC_CLOSE_TAB)
92 self.assertEqual(self.GetActiveTabTitle(), '')
93 #Test with new window
94 self._CanDismissInstant()
95 self.RunCommand(pyauto.IDC_NEW_WINDOW)
96 self.CloseBrowserWindow(1)
97 self.assertEqual(self.GetActiveTabTitle(), '')
98 self._CanDismissInstant()
99
67 if __name__ == '__main__': 100 if __name__ == '__main__':
68 pyauto_functional.Main() 101 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698