Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: chrome/test/functional/ntp.py

Issue 3477001: Add pyauto hook for getting and manipulating the data underneath the NTP.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/history/top_sites_unittest.cc ('k') | chrome/test/pyautolib/ntp_model.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import os
7
8 import pyauto_functional # Must be imported before pyauto
9 import pyauto
10
11
12 class NTPTest(pyauto.PyUITest):
13 """Test of the NTP."""
14
15 def Debug(self):
16 """Test method for experimentation.
17
18 This method is not run automatically.
19 """
20 while True:
21 raw_input('Interact with the browser and hit <enter> to dump NTP info...')
22 print '*' * 20
23 import pprint
24 pp = pprint.PrettyPrinter(indent=2)
25 pp.pprint(self.GetNTPModel()._GetInfo())
26
27 def setUp(self):
28 pyauto.PyUITest.setUp(self)
29 self.ntp = self.GetNTPModel()
30 # These tests should not have to worry about whatever defaults there are
31 # in the Most Visited section. Close them.
32 for thumbnail in self.ntp.GetThumbnails():
33 self.ntp.RemoveThumbnail(thumbnail)
34
35 # Create some dummy file urls we can use in the tests.
36 filenames = ['title1.html', 'title2.html']
37 titles = [u'', u'Title Of Awesomeness']
38 urls = map(lambda name: self.GetFileURLForDataPath(name), filenames)
39 self.PAGES = map(lambda url, title: {'url': url, 'title': title},
40 urls, titles)
41
42 def testFreshProfile(self):
43 """Tests that there are no sites or closed tabs with a fresh profile"""
44 # These should be zero thumbnails since we deleted them in |setUp|.
45 self.assertEqual(0, len(self.ntp.GetThumbnails()))
46 self.assertEqual(0, len(self.ntp.GetRecentlyClosed()))
47
48 def testOneMostVisitedSite(self):
49 """Tests that a site is added to the most visited sites"""
50 self.NavigateToURL(self.PAGES[1]['url'])
51 self.assertEqual(self.PAGES[1]['url'], self.ntp.GetThumbnails()[0]['url'])
52 self.assertEqual(self.PAGES[1]['title'],
53 self.ntp.GetThumbnails()[0]['title'])
54
55 def testOneRecentlyClosedTab(self):
56 """Tests that closing a tab populates the recently closed tabs list"""
57 self.AppendTab(pyauto.GURL(self.PAGES[1]['url']))
58 self.GetBrowserWindow(0).GetTab(1).Close(True)
59 self.assertEqual(self.PAGES[1]['url'],
60 self.ntp.GetRecentlyClosed()[0]['url'])
61 #raw_input()
62 self.assertEqual(self.PAGES[1]['title'],
63 self.ntp.GetRecentlyClosed()[0]['title'])
64
65 def testMoveThumbnailBasic(self):
66 """Tests moving a thumbnail to a different index"""
67 self.NavigateToURL(self.PAGES[0]['url'])
68 self.NavigateToURL(self.PAGES[1]['url'])
69 thumbnails = self.ntp.GetThumbnails()
70 self.ntp.MoveThumbnail(thumbnails[0], 1)
71 self.assertTrue(self.ntp.IsPinned(thumbnails[0]))
72 self.assertFalse(self.ntp.IsPinned(thumbnails[1]))
73 self.assertEqual(self.PAGES[0]['url'], self.ntp.GetThumbnails()[1]['url'])
74 self.assertEqual(1, self.ntp.GetThumbnailIndex(thumbnails[0]))
75
76 def testPinningThumbnailBasic(self):
77 """Tests that we can pin/unpin a thumbnail"""
78 self.NavigateToURL(self.PAGES[0]['url'])
79 thumbnail1 = self.ntp.GetThumbnails()[0]
80 self.assertFalse(self.ntp.IsPinned(thumbnail1))
81 self.ntp.PinThumbnail(thumbnail1)
82 self.assertTrue(self.ntp.IsPinned(thumbnail1))
83 self.ntp.UnpinThumbnail(thumbnail1)
84 self.assertFalse(self.ntp.IsPinned(thumbnail1))
85
86
87 if __name__ == '__main__':
88 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/browser/history/top_sites_unittest.cc ('k') | chrome/test/pyautolib/ntp_model.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698