OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/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 import time | 7 import time |
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 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 def testFtpHistory(self): | 212 def testFtpHistory(self): |
213 """Verify a site using ftp protocol shows up within history.""" | 213 """Verify a site using ftp protocol shows up within history.""" |
214 ftp_url = 'ftp://ftp.kernel.org/' | 214 ftp_url = 'ftp://ftp.kernel.org/' |
215 ftp_title = 'Index of /' | 215 ftp_title = 'Index of /' |
216 self.NavigateToURL(ftp_url) | 216 self.NavigateToURL(ftp_url) |
217 history = self.GetHistoryInfo().History() | 217 history = self.GetHistoryInfo().History() |
218 self.assertEqual(len(history), 1) | 218 self.assertEqual(len(history), 1) |
219 self.assertEqual(ftp_title, history[0]['title']) | 219 self.assertEqual(ftp_title, history[0]['title']) |
220 self.assertEqual(ftp_url, history[0]['url']) | 220 self.assertEqual(ftp_url, history[0]['url']) |
221 | 221 |
222 def _CheckHistory(self, title, url, length, index=0): | |
223 """Verify that the current history matches expectations. | |
224 | |
225 Verify that history item has the given title and url | |
226 and that length of history list is as expected. | |
227 | |
228 Args: | |
229 title: Expected title of given web page. | |
230 url: Expected address of given web page. | |
231 length: Expected length of history list. | |
232 index: Position of item we want to check in history list. | |
233 """ | |
234 history = self.GetHistoryInfo().History() | |
235 self.assertEqual( | |
236 length, len(history), | |
237 msg='History length: expected = %d, actual = %d.' | |
238 % (length, len(history))) | |
239 self.assertEqual( | |
240 title, history[index]['title'], | |
241 msg='Title: expected = %s, actual = %s.' | |
242 % (title, history[index]['title'])) | |
243 self.assertEqual( | |
244 url, history[index]['url'], msg='URL: expected = %s, actual = %s.' | |
245 % (url, history[index]['url'])) | |
246 | |
247 def _NavigateAndCheckHistory(self, title, page, length): | |
248 """Navigate to a page, then verify the history. | |
249 | |
250 Args: | |
251 title: Title of given web page. | |
252 page: Filename of given web page. | |
253 length: Length of history list. | |
254 index: Position of item we want to check in history list. | |
dennis_jeffrey
2011/08/05 00:29:18
Remove this line.
| |
255 """ | |
256 url = self.GetFileURLForDataPath(page) | |
257 self.NavigateToURL(url) | |
258 self._CheckHistory(title, url, length) | |
259 | |
260 def testNavigateBringPageToTop(self): | |
261 """Verify that navigation brings current page to top of history list.""" | |
262 self._NavigateAndCheckHistory('Title Of Awesomeness', 'title2.html', 1) | |
263 self._NavigateAndCheckHistory('Title Of More Awesomeness', 'title3.html', | |
264 2) | |
265 | |
266 def testReloadBringPageToTop(self): | |
267 """Verify that reloading a page brings it to top of history list.""" | |
268 url1 = self.GetFileURLForDataPath('title2.html') | |
269 title1 = 'Title Of Awesomeness' | |
270 self._NavigateAndCheckHistory(title1, 'title2.html', 1) | |
271 | |
272 url2 = self.GetFileURLForDataPath('title3.html') | |
273 title2 = 'Title Of More Awesomeness' | |
274 self.AppendTab(pyauto.GURL(url2)) | |
275 self._CheckHistory(title2, url2, 2) | |
276 | |
277 self.ActivateTab(0) | |
278 self.ReloadActiveTab() | |
279 self._CheckHistory(title1, url1, 2) | |
280 | |
281 def testBackForwardBringPageToTop(self): | |
282 """Verify that back/forward brings current page to top of history list.""" | |
283 url1 = self.GetFileURLForDataPath('title2.html') | |
284 title1 = 'Title Of Awesomeness' | |
285 self._NavigateAndCheckHistory(title1, 'title2.html', 1) | |
286 | |
287 url2 = self.GetFileURLForDataPath('title3.html') | |
288 title2 = 'Title Of More Awesomeness' | |
289 self._NavigateAndCheckHistory(title2, 'title3.html', 2) | |
290 | |
291 tab = self.GetBrowserWindow(0).GetTab(0) | |
292 tab.GoBack() | |
293 self._CheckHistory(title1, url1, 2) | |
294 tab.GoForward() | |
295 self._CheckHistory(title2, url2, 2) | |
296 | |
297 def testAppendTabAddPage(self): | |
298 """Verify that opening a new tab adds that page to history.""" | |
299 self._NavigateAndCheckHistory('Title Of Awesomeness', 'title2.html', 1) | |
300 | |
301 url2 = self.GetFileURLForDataPath('title3.html') | |
302 title2 = 'Title Of More Awesomeness' | |
303 self.AppendTab(pyauto.GURL(url2)) | |
304 self._CheckHistory(title2, url2, 2) | |
305 | |
306 def testOpenWindowAddPage(self): | |
307 """Verify that opening new window to a page adds the page to history.""" | |
308 self._NavigateAndCheckHistory('Title Of Awesomeness', 'title2.html', 1) | |
309 | |
310 url2 = self.GetFileURLForDataPath('title3.html') | |
311 title2 = 'Title Of More Awesomeness' | |
312 self.OpenNewBrowserWindow(True) | |
313 self.NavigateToURL(url2, 1) | |
314 self._CheckHistory(title2, url2, 2) | |
315 | |
222 | 316 |
223 if __name__ == '__main__': | 317 if __name__ == '__main__': |
224 pyauto_functional.Main() | 318 pyauto_functional.Main() |
OLD | NEW |