OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 | 7 |
8 import pyauto_functional # must be imported before pyauto | 8 import pyauto_functional # must be imported before pyauto |
9 import pyauto | 9 import pyauto |
10 import test_utils | |
10 | 11 |
11 | 12 |
12 class CroshTest(pyauto.PyUITest): | 13 class CroshTest(pyauto.PyUITest): |
13 """Tests for crosh.""" | 14 """Tests for crosh.""" |
14 | 15 |
15 def setUp(self): | 16 def setUp(self): |
16 """Close all windows at startup.""" | 17 """Close all windows at startup.""" |
17 pyauto.PyUITest.setUp(self) | 18 pyauto.PyUITest.setUp(self) |
18 for _ in range(self.GetBrowserWindowCount()): | 19 for _ in range(self.GetBrowserWindowCount()): |
19 self.CloseBrowserWindow(0) | 20 self.CloseBrowserWindow(0) |
20 | 21 |
21 def testBasic(self): | 22 def testBasic(self): |
22 """Verify crosh basic flow.""" | 23 """Verify crosh basic flow.""" |
23 self.assertEqual(0, self.GetBrowserWindowCount()) | 24 test_utils.OpenCroshVerification(self) |
24 self.OpenCrosh() | |
25 self.assertEqual(1, self.GetBrowserWindowCount()) | |
26 self.assertEqual(1, self.GetTabCount(), | |
27 msg='Could not open crosh') | |
28 self.assertEqual('crosh', self.GetActiveTabTitle()) | |
29 | 25 |
30 # Verify crosh prompt. | 26 # Verify crosh prompt. |
31 self.WaitForHtermText(text='crosh> ', | 27 self.WaitForHtermText(text='crosh> ', |
32 msg='Could not find "crosh> " prompt') | 28 msg='Could not find "crosh> " prompt') |
33 self.assertTrue( | 29 self.assertTrue( |
34 self.GetHtermRowsText(start=0, end=2).endswith('crosh> '), | 30 self.GetHtermRowsText(start=0, end=2).endswith('crosh> '), |
35 msg='Could not find "crosh> " prompt') | 31 msg='Could not find "crosh> " prompt') |
36 | 32 |
37 # Run a crosh command. | 33 # Run a crosh command. |
38 self.SendKeysToHterm('help\\n') | 34 self.SendKeysToHterm('help\\n') |
39 self.WaitForHtermText(text='help_advanced', | 35 self.WaitForHtermText(text='help_advanced', |
40 msg='Could not find "help_advanced" in help output.') | 36 msg='Could not find "help_advanced" in help output.') |
41 | 37 |
42 # Exit crosh and close tab. | 38 # Exit crosh and close tab. |
43 self.SendKeysToHterm('exit\\n') | 39 self.SendKeysToHterm('exit\\n') |
44 self.WaitForHtermText(text='command crosh completed with exit code 0', | 40 self.WaitForHtermText(text='command crosh completed with exit code 0', |
45 msg='Could not exit crosh.') | 41 msg='Could not exit crosh.') |
46 | 42 |
43 def testAddBookmark(self): | |
44 """Test crosh URL can be bookmarked""" | |
45 test_utils.OpenCroshVerification(self) | |
46 | |
47 # Add bookmark. | |
48 bookmarks = self.GetBookmarkModel() | |
49 bar_id = bookmarks.BookmarkBar()['id'] | |
50 name = 'crosh' | |
51 url = self.GetActiveTabURL() | |
52 count = bookmarks.NodeCount() | |
53 self.AddBookmarkURL(bar_id, 0, name, url.spec()) | |
54 bookmarks = self.GetBookmarkModel() | |
55 node = bookmarks.BookmarkBar()['children'][0] | |
56 self.assertEqual(count + 1, bookmarks.NodeCount()) | |
57 self.assertEqual(node['type'], 'url') | |
58 self.assertEqual(node['name'], name) | |
59 self.assertTrue(url.spec() in node['url']) | |
Nirnimesh
2012/07/26 23:09:03
why use 'in'?
wouldn't assertTrue(url.spec(), nod
tturchetto
2012/07/26 23:37:47
Done.
| |
60 | |
47 | 61 |
48 if __name__ == '__main__': | 62 if __name__ == '__main__': |
49 pyauto_functional.Main() | 63 pyauto_functional.Main() |
OLD | NEW |