| Index: chrome/test/functional/ntp.py
|
| ===================================================================
|
| --- chrome/test/functional/ntp.py (revision 0)
|
| +++ chrome/test/functional/ntp.py (revision 0)
|
| @@ -0,0 +1,88 @@
|
| +#!/usr/bin/python
|
| +# 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'])
|
| + #raw_input()
|
| + 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()
|
|
|
| Property changes on: chrome\test\functional\ntp.py
|
| ___________________________________________________________________
|
| Added: svn:eol-style
|
| + LF
|
|
|
|
|