Chromium Code Reviews| Index: chrome/test/functional/ntp.py |
| diff --git a/chrome/test/functional/ntp.py b/chrome/test/functional/ntp.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..42406380fe834ea843bc0ec1498374cb596c03a6 |
| --- /dev/null |
| +++ b/chrome/test/functional/ntp.py |
| @@ -0,0 +1,87 @@ |
| +#!/usr/bin/python |
|
Nirnimesh
2010/11/16 22:25:05
Please add this test in PYAUTO_TESTS
kkania
2010/11/17 01:11:34
Done.
|
| +# Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import os |
| + |
| +import pyauto_functional # Must be imported before pyauto |
| +import pyauto |
| + |
| + |
| +class NTPTest(pyauto.PyUITest): |
| + """Test of the NTP.""" |
| + |
| + def Debug(self): |
| + """Test method for experimentation. |
| + |
| + This method is not run automatically. |
| + """ |
| + while True: |
| + raw_input('Interact with the browser and hit <enter> to dump NTP info...') |
| + print '*' * 20 |
| + import pprint |
| + pp = pprint.PrettyPrinter(indent=2) |
| + pp.pprint(self.GetNTPModel()._GetInfo()) |
| + |
| + def setUp(self): |
| + pyauto.PyUITest.setUp(self) |
| + self.ntp = self.GetNTPModel() |
| + # These tests should not have to worry about whatever defaults there are |
| + # in the Most Visited section. Close them. |
| + for thumbnail in self.ntp.GetThumbnails(): |
| + self.ntp.RemoveThumbnail(thumbnail) |
| + |
| + # Create some dummy file urls we can use in the tests. |
| + filenames = ['title1.html', 'title2.html'] |
| + titles = [u'', u'Title Of Awesomeness'] |
| + urls = map(lambda name: self.GetFileURLForDataPath(name), filenames) |
| + self.PAGES = map(lambda url, title: {'url': url, 'title': title}, |
| + urls, titles) |
| + |
| + def testFreshProfile(self): |
| + """Tests that there are no sites or closed tabs with a fresh profile""" |
| + # These should be zero thumbnails since we deleted them in |setUp|. |
| + self.assertEqual(0, len(self.ntp.GetThumbnails())) |
| + self.assertEqual(0, len(self.ntp.GetRecentlyClosed())) |
| + |
| + def testOneMostVisitedSite(self): |
| + """Tests that a site is added to the most visited sites""" |
| + self.NavigateToURL(self.PAGES[1]['url']) |
| + self.assertEqual(self.PAGES[1]['url'], self.ntp.GetThumbnails()[0]['url']) |
| + self.assertEqual(self.PAGES[1]['title'], |
| + self.ntp.GetThumbnails()[0]['title']) |
| + |
| + def testOneRecentlyClosedTab(self): |
| + """Tests that closing a tab populates the recently closed tabs list""" |
| + self.AppendTab(pyauto.GURL(self.PAGES[1]['url'])) |
| + self.GetBrowserWindow(0).GetTab(1).Close(True) |
| + self.assertEqual(self.PAGES[1]['url'], |
| + self.ntp.GetRecentlyClosed()[0]['url']) |
| + self.assertEqual(self.PAGES[1]['title'], |
| + self.ntp.GetRecentlyClosed()[0]['title']) |
| + |
| + def testMoveThumbnailBasic(self): |
| + """Tests moving a thumbnail to a different index""" |
| + self.NavigateToURL(self.PAGES[0]['url']) |
| + self.NavigateToURL(self.PAGES[1]['url']) |
| + thumbnails = self.ntp.GetThumbnails() |
| + self.ntp.MoveThumbnail(thumbnails[0], 1) |
| + self.assertTrue(self.ntp.IsPinned(thumbnails[0])) |
| + self.assertFalse(self.ntp.IsPinned(thumbnails[1])) |
| + self.assertEqual(self.PAGES[0]['url'], self.ntp.GetThumbnails()[1]['url']) |
| + self.assertEqual(1, self.ntp.GetThumbnailIndex(thumbnails[0])) |
| + |
| + def testPinningThumbnailBasic(self): |
| + """Tests that we can pin/unpin a thumbnail""" |
| + self.NavigateToURL(self.PAGES[0]['url']) |
| + thumbnail1 = self.ntp.GetThumbnails()[0] |
| + self.assertFalse(self.ntp.IsPinned(thumbnail1)) |
| + self.ntp.PinThumbnail(thumbnail1) |
| + self.assertTrue(self.ntp.IsPinned(thumbnail1)) |
| + self.ntp.UnpinThumbnail(thumbnail1) |
| + self.assertFalse(self.ntp.IsPinned(thumbnail1)) |
| + |
| + |
| +if __name__ == '__main__': |
| + pyauto_functional.Main() |