summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-03 22:35:27 +0000
committernirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-03 22:35:27 +0000
commit98ec2c4c1cfb7146107b549522ef7c14b7719454 (patch)
tree3381d5a2746a46bbf10b7778c7dd8eb5e434f520
parent06821f42d58c7b7f88303fd09de1ec86dace6f8e (diff)
downloadchromium_src-98ec2c4c1cfb7146107b549522ef7c14b7719454.zip
chromium_src-98ec2c4c1cfb7146107b549522ef7c14b7719454.tar.gz
chromium_src-98ec2c4c1cfb7146107b549522ef7c14b7719454.tar.bz2
Add new bookmarks tests.
testURLTypes (from Srikanth): test for different URL types - http: https: ftp: javascript:, etc testDuplicateBookmarks (from Ismail): Verify bookmark duplicates testBookmarksPersistence (from Deepak): Verify that bookmarks and groups persist browser restart testSessionRestoreShowBookmarkBar (from Srikanth): Verify restore for bookmark bar visibility Review URL: http://codereview.chromium.org/1719002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46292 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/test/data/bookmarks/url_types15
-rw-r--r--chrome/test/functional/bookmarks.py90
-rw-r--r--chrome/test/functional/prefs.py9
3 files changed, 114 insertions, 0 deletions
diff --git a/chrome/test/data/bookmarks/url_types b/chrome/test/data/bookmarks/url_types
new file mode 100644
index 0000000..1a427b6
--- /dev/null
+++ b/chrome/test/data/bookmarks/url_types
@@ -0,0 +1,15 @@
+# Data file for different types of urls. http:// https:// ftp:// and so on
+# Used by: chrome/test/functional/bookmarks.py
+
+{
+ "http://muse.jhu.edu/journals/american_literature/" : u"Static URL",
+ "http://www.springerlink.com/link.asp?id=100408/" : u"Dynamic URL",
+ "http://www.bioone.org/bioone/?request=get-journals-list&issn=0002-8444**/" :u"Formula URL",
+ "http://www.google.cn/" : u"Redirection UTL",
+ "https://www.blogger.com/start/" : u"This is a https url",
+ "file:///Users/Shared/Library/Application%20Support/" : u"The file URL specifies a file stored",
+ "ftp://mirrors.xmission.com/debian-cd/" : u"FTP URL ",
+ """javascript:(t13nb=window.t13nb||function(l){var%20t=t13nb,d=document,o=d.body,c="createElement",a="appendChild",w="clientWidth",i=d[c]("span"),s=i.style,x=o[a](d[c]("script"));if(o){if(!t.l){t.l=x.id="t13ns";o[a](i).id="t13n";i.innerHTML="Loading%20transliteration";s.cssText="z-index:99;font-size:18px;background:#FFF1A8;top:0";s.position=d.all?"absolute":"fixed";s.left=((o[w]-i[w])/2)+"px";x.src="http://t13n.googlecode.com/svn/trunk/blet/rt13n.js?l="+l}}else%20setTimeout(t,500)})('hi')""" : u"title [Type in Hindi]",
+ "http://www.baidu.com/" : u"\u767e\u5ea6\u4e00\u4e0b\uff0c\u4f60\u5c31\u77e5\u9053",
+ "http://www.flickr.com/" : u" Redirection URL Welcome to Flickr - Photo Sharing",
+}
diff --git a/chrome/test/functional/bookmarks.py b/chrome/test/functional/bookmarks.py
index 10f2924..f4c5e2f 100644
--- a/chrome/test/functional/bookmarks.py
+++ b/chrome/test/functional/bookmarks.py
@@ -376,6 +376,96 @@ class BookmarksTest(pyauto.PyUITest):
nodes = bookmarks.FindByTitle('Group %d' % (num_folders - 1))
self.assertEqual([], nodes[0]['children'])
+ def testURLTypes(self):
+ """Test bookmarks with different types of URLS."""
+ bookmarks = self.GetBookmarkModel()
+ bar_id = bookmarks.BookmarkBar()['id']
+ orig_nodes_count = bookmarks.NodeCount()
+ url_data = self._GetTestURLs("url_types")
+ for index, (url, name) in enumerate(url_data.iteritems()):
+ self.AddBookmarkURL(bar_id, index, name, url)
+ # check that we added them correctly
+ bookmarks = self.GetBookmarkModel()
+ self.assertEqual(orig_nodes_count + len(url_data), bookmarks.NodeCount())
+ for node, (url, name) in zip(bookmarks.BookmarkBar()['children'],
+ url_data.iteritems()):
+ self.assertEqual(node['type'], 'url')
+ self.assertEqual(node['name'], name)
+ self.assertEqual(node['url'], url)
+
+ def _VerifyBookmarkURL(self, node, name, url):
+ """Verify that node is a bookmark URL of the given name and url."""
+ self.assertTrue(node)
+ self.assertEqual(node['type'], 'url')
+ self.assertEqual(node['name'], name)
+ self.assertEqual(node['url'], url)
+
+ def testDuplicateBookmarks(self):
+ """Verify bookmark duplicates."""
+ url_data = self._GetTestURLs("urls_and_titles")
+ list_of_urls = url_data.keys()
+ list_of_titles = url_data.values()
+ bookmarks = self.GetBookmarkModel()
+ nodes = bookmarks.NodeCount()
+ bar_id = bookmarks.BookmarkBar()['id']
+ # Create some duplicate bookmarks
+ self.AddBookmarkURL(bar_id, 0, list_of_titles[0], list_of_urls[0])
+ self.AddBookmarkURL(bar_id, 1, list_of_titles[0], list_of_urls[0])
+ self.AddBookmarkURL(bar_id, 2, list_of_titles[0], list_of_urls[1])
+ self.AddBookmarkURL(bar_id, 3, list_of_titles[1], list_of_urls[0])
+ # Create a folder with any existing bookmark title
+ self.AddBookmarkGroup(bar_id, 4, list_of_titles[0])
+ bookmarks = self.GetBookmarkModel()
+ self.assertEqual(nodes + 5, bookmarks.NodeCount())
+ # Verify 1st bookmark is created
+ bar_child = bookmarks.BookmarkBar()['children'][0]
+ self._VerifyBookmarkURL(bar_child, list_of_titles[0], list_of_urls[0])
+ # Verify this is a duplicate bookmark of 1st bookmark
+ bar_child = bookmarks.BookmarkBar()['children'][1]
+ self._VerifyBookmarkURL(bar_child, list_of_titles[0], list_of_urls[0])
+ # Verify the bookmark with same title and different URL of 1st bookmark
+ bar_child = bookmarks.BookmarkBar()['children'][2]
+ self._VerifyBookmarkURL(bar_child, list_of_titles[0], list_of_urls[1])
+ # Verify the bookmark with different title and same URL of 1st bookmark
+ bar_child = bookmarks.BookmarkBar()['children'][3]
+ self._VerifyBookmarkURL(bar_child, list_of_titles[1], list_of_urls[0])
+ # Verify Bookmark group got created with same title of 1st bookmark
+ bar_child = bookmarks.BookmarkBar()['children'][4]
+ self.assertEqual(bar_child['type'], 'folder')
+ self.assertEqual(bar_child['name'], list_of_titles[0])
+
+ def testBookmarksPersistence(self):
+ """Verify that bookmarks and groups persist browser restart."""
+ # Populate bookmarks and groups
+ bookmarks = self.GetBookmarkModel()
+ bar_id = bookmarks.BookmarkBar()['id']
+ other_id = bookmarks.Other()['id']
+ self.AddBookmarkURL(bar_id, 0, "Google", "http://www.news.google.com/")
+ self.AddBookmarkURL(other_id, 0, "Yahoo", "http://www.yahoo.com/")
+ self.AddBookmarkGroup(bar_id, 0, "MS")
+ bookmarks = self.GetBookmarkModel()
+ bar_folder_id = bookmarks.BookmarkBar()['children'][0]['id']
+ self.AddBookmarkURL(bar_folder_id, 0, "BING", "http://www.bing.com/")
+ self.AddBookmarkGroup(other_id, 0, "Oracle")
+ bookmarks = self.GetBookmarkModel()
+ other_folder_id = bookmarks.Other()['id']
+ self.AddBookmarkURL(other_folder_id, 0, "DB", "http://www.oracle.com/")
+
+ nodes_before = self.GetBookmarkModel().NodeCount()
+ self.RestartBrowser(clear_profile=False)
+ # Verify that all bookmarks persist
+ bookmarks = self.GetBookmarkModel()
+ node = bookmarks.FindByTitle('Google')
+ self.assertEqual(nodes_before, bookmarks.NodeCount())
+ self._VerifyBookmarkURL(node[0], 'Google', 'http://www.news.google.com/')
+ self._VerifyBookmarkURL(bookmarks.FindByTitle('Yahoo')[0],
+ 'Yahoo', 'http://www.yahoo.com/')
+ bmb_child = bookmarks.BookmarkBar()['children'][0]
+ self.assertEqual(bmb_child['type'], 'folder')
+ self.assertEqual(bmb_child['name'],'MS')
+ self._VerifyBookmarkURL(bmb_child['children'][0],
+ 'BING', 'http://www.bing.com/')
+
if __name__ == '__main__':
pyauto_functional.Main()
diff --git a/chrome/test/functional/prefs.py b/chrome/test/functional/prefs.py
index 31f8937..32eb332 100644
--- a/chrome/test/functional/prefs.py
+++ b/chrome/test/functional/prefs.py
@@ -59,6 +59,15 @@ class PrefsTest(pyauto.PyUITest):
self.ActivateTab(1)
self.assertEqual(url2, self.GetActiveTabURL().spec())
+ def testSessionRestoreShowBookmarkBar(self):
+ """Verify restore for bookmark bar visibility."""
+ assert not self.GetPrefsInfo().Prefs(pyauto.kShowBookmarkBar)
+ self.SetPrefs(pyauto.kShowBookmarkBar, True)
+ self.assertEqual(True, self.GetPrefsInfo().Prefs(pyauto.kShowBookmarkBar))
+ self.RestartBrowser(clear_profile=False)
+ self.assertEqual(True, self.GetPrefsInfo().Prefs(pyauto.kShowBookmarkBar))
+ self.assertTrue(self.GetBookmarkBarVisibility())
+
if __name__ == '__main__':
pyauto_functional.Main()