OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 def testTabsOpenClose(self): | 43 def testTabsOpenClose(self): |
44 """Verify tabs open/close.""" | 44 """Verify tabs open/close.""" |
45 urls = self._ObtainURLList() | 45 urls = self._ObtainURLList() |
46 def _OpenCloseTabsInWindow(windex): | 46 def _OpenCloseTabsInWindow(windex): |
47 """Open/close tabs in window at given index.""" | 47 """Open/close tabs in window at given index.""" |
48 self.AppendTab(pyauto.GURL(urls[0]), windex) | 48 self.AppendTab(pyauto.GURL(urls[0]), windex) |
49 self.assertEqual(2, self.GetTabCount(windex)) | 49 self.assertEqual(2, self.GetTabCount(windex)) |
50 self.AppendTab(pyauto.GURL(urls[1]), windex) | 50 self.AppendTab(pyauto.GURL(urls[1]), windex) |
51 self.assertEqual(3, self.GetTabCount(windex)) | 51 self.assertEqual(3, self.GetTabCount(windex)) |
52 self.GetBrowserWindow(windex).GetTab(2).Close(True) | 52 self.CloseTab(tab_index=2, windex=windex) |
53 self.assertEqual(2, self.GetTabCount(windex)) | 53 self.assertEqual(2, self.GetTabCount(windex)) |
54 self.GetBrowserWindow(windex).GetTab(1).Close(True) | 54 self.CloseTab(tab_index=1, windex=windex) |
55 self.assertEqual(1, self.GetTabCount(windex)) | 55 self.assertEqual(1, self.GetTabCount(windex)) |
56 _OpenCloseTabsInWindow(0) | 56 _OpenCloseTabsInWindow(0) |
57 self.OpenNewBrowserWindow(True) | 57 self.OpenNewBrowserWindow(True) |
58 _OpenCloseTabsInWindow(1) | 58 _OpenCloseTabsInWindow(1) |
59 | 59 |
60 def testForwardBackward(self): | 60 def testForwardBackward(self): |
61 """Verify forward/backward actions.""" | 61 """Verify forward/backward actions.""" |
62 urls = self._ObtainURLList() | 62 urls = self._ObtainURLList() |
63 assert len(urls) >= 3, 'Need at least 3 urls.' | 63 assert len(urls) >= 3, 'Need at least 3 urls.' |
64 for url in urls: | 64 for url in urls: |
65 self.NavigateToURL(url) | 65 self.NavigateToURL(url) |
66 tab = self.GetBrowserWindow(0).GetTab(0) | |
67 self.assertEqual(self.GetActiveTabURL().spec(), urls[-1]) | 66 self.assertEqual(self.GetActiveTabURL().spec(), urls[-1]) |
68 for i in [-2, -3]: | 67 for i in [-2, -3]: |
69 tab.GoBack() | 68 self.TabGoBack() |
70 self.assertEqual(self.GetActiveTabURL().spec(), urls[i]) | 69 self.assertEqual(self.GetActiveTabURL().spec(), urls[i]) |
71 for i in [-2, -1]: | 70 for i in [-2, -1]: |
72 tab.GoForward() | 71 self.TabGoForward() |
73 self.assertEqual(self.GetActiveTabURL().spec(), urls[i]) | 72 self.assertEqual(self.GetActiveTabURL().spec(), urls[i]) |
74 | 73 |
75 def testCanDuplicateTab(self): | 74 def testCanDuplicateTab(self): |
76 """Open a page, duplicate it and make sure the new tab was duplicated""" | 75 """Open a page, duplicate it and make sure the new tab was duplicated""" |
77 urls = self._ObtainURLList() | 76 urls = self._ObtainURLList() |
78 assert len(urls) >= 3, 'Need at least 3 urls.' | 77 assert len(urls) >= 3, 'Need at least 3 urls.' |
79 self.NavigateToURL(urls[0]) | 78 self.NavigateToURL(urls[0]) |
80 self.ApplyAccelerator(pyauto.IDC_DUPLICATE_TAB) | 79 self.ApplyAccelerator(pyauto.IDC_DUPLICATE_TAB) |
81 self.assertEqual(self.GetTabCount(), 2) | 80 self.assertEqual(self.GetTabCount(), 2) |
82 self.assertEqual(urls[0], self.GetActiveTabURL().spec()) | 81 self.assertEqual(urls[0], self.GetActiveTabURL().spec()) |
83 | 82 |
84 def testBrutalTabsAndWindows(self): | 83 def testBrutalTabsAndWindows(self): |
85 """Open "many" windows and tabs.""" | 84 """Open "many" windows and tabs.""" |
86 urls = self._ObtainURLList() | 85 urls = self._ObtainURLList() |
87 num_windows = 10 | 86 num_windows = 10 |
88 orig_num_windows = self.GetBrowserWindowCount() | 87 orig_num_windows = self.GetBrowserWindowCount() |
89 for windex in range(1, num_windows): | 88 for windex in range(1, num_windows): |
90 self.OpenNewBrowserWindow(True) | 89 self.OpenNewBrowserWindow(True) |
91 self.assertEqual(orig_num_windows + windex, self.GetBrowserWindowCount()) | 90 self.assertEqual(orig_num_windows + windex, self.GetBrowserWindowCount()) |
92 # Open many tabs in 1st window | 91 # Open many tabs in 1st window |
93 num_tabs = 20 | 92 num_tabs = 20 |
94 orig_num_tabs = self.GetTabCount(windex) | 93 orig_num_tabs = self.GetTabCount(windex) |
95 for tindex in range(1, num_tabs): | 94 for tindex in range(1, num_tabs): |
96 self.AppendTab(pyauto.GURL(urls[0])) | 95 self.AppendTab(pyauto.GURL(urls[0])) |
97 self.assertEqual(orig_num_tabs + tindex, self.GetTabCount()) | 96 self.assertEqual(orig_num_tabs + tindex, self.GetTabCount()) |
98 | 97 |
99 | 98 |
100 if __name__ == '__main__': | 99 if __name__ == '__main__': |
101 pyauto_functional.Main() | 100 pyauto_functional.Main() |
OLD | NEW |