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

Unified Diff: tools/telemetry/telemetry/page/page_unittest.py

Issue 252923002: Get rid of PageSet.FromDict from unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/page/page_unittest.py
diff --git a/tools/telemetry/telemetry/page/page_unittest.py b/tools/telemetry/telemetry/page/page_unittest.py
index 92be799971a927b7fc58e420471ff0a16e8441f7..61fabc07bd8ecec87a12d58ac500d385b49c5d56 100644
--- a/tools/telemetry/telemetry/page/page_unittest.py
+++ b/tools/telemetry/telemetry/page/page_unittest.py
@@ -42,113 +42,76 @@ class TestPage(unittest.TestCase):
(os.altsep and apage.file_path_url.endswith(os.altsep)))
def testSort(self):
- ps = page_set.PageSet.FromDict({
- 'description': 'hello',
- 'archive_path': 'foo.wpr',
- 'pages': [
- {'url': 'http://www.foo.com/'},
- {'url': 'http://www.bar.com/'}
- ]
- }, os.path.dirname(__file__))
+ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
+ ps.AddPageWithDefaultRunNavigate('http://www.foo.com/')
+ ps.AddPageWithDefaultRunNavigate('http://www.bar.com/')
+
pages = [ps.pages[0], ps.pages[1]]
pages.sort()
self.assertEquals([ps.pages[1], ps.pages[0]],
pages)
def testGetUrlBaseDirAndFileForUrlBaseDir(self):
- ps = page_set.PageSet.FromDict({
- 'description': 'hello',
- 'archive_path': 'foo.wpr',
- 'serving_dirs': ['../somedir/'],
- 'pages': [
- {'url': 'file://../otherdir/file.html'}
- ]}, 'basedir/')
+ ps = page_set.PageSet(file_path='basedir/', serving_dirs=['../somedir/'])
+ ps.AddPageWithDefaultRunNavigate('file://../otherdir/file.html')
self.assertPathEqual(ps[0].file_path, 'otherdir/file.html')
def testDisplayUrlForHttp(self):
- ps = page_set.PageSet.FromDict({
- 'description': 'hello',
- 'archive_path': 'foo.wpr',
- 'pages': [
- {'url': 'http://www.foo.com/'},
- {'url': 'http://www.bar.com/'}
- ]
- }, os.path.dirname(__file__))
+ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
+ ps.AddPageWithDefaultRunNavigate('http://www.foo.com/')
+ ps.AddPageWithDefaultRunNavigate('http://www.bar.com/')
+
self.assertEquals(ps[0].display_name, 'http://www.foo.com/')
self.assertEquals(ps[1].display_name, 'http://www.bar.com/')
def testDisplayUrlForHttps(self):
- ps = page_set.PageSet.FromDict({
- 'description': 'hello',
- 'archive_path': 'foo.wpr',
- 'pages': [
- {'url': 'http://www.foo.com/'},
- {'url': 'https://www.bar.com/'}
- ]
- }, os.path.dirname(__file__))
+ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
+ ps.AddPageWithDefaultRunNavigate('http://www.foo.com/')
+ ps.AddPageWithDefaultRunNavigate('https://www.bar.com/')
+
self.assertEquals(ps[0].display_name, 'http://www.foo.com/')
self.assertEquals(ps[1].display_name, 'https://www.bar.com/')
def testDisplayUrlForFile(self):
- ps = page_set.PageSet.FromDict({
- 'description': 'hello',
- 'archive_path': 'foo.wpr',
- 'pages': [
- {'url': 'file://../../otherdir/foo.html'},
- {'url': 'file://../../otherdir/bar.html'},
- ]
- }, os.path.dirname(__file__))
+ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
+ ps.AddPageWithDefaultRunNavigate('file://../../otherdir/foo.html')
+ ps.AddPageWithDefaultRunNavigate('file://../../otherdir/bar.html')
+
self.assertEquals(ps[0].display_name, 'foo.html')
self.assertEquals(ps[1].display_name, 'bar.html')
def testDisplayUrlForFilesDifferingBySuffix(self):
- ps = page_set.PageSet.FromDict({
- 'description': 'hello',
- 'archive_path': 'foo.wpr',
- 'pages': [
- {'url': 'file://../../otherdir/foo.html'},
- {'url': 'file://../../otherdir/foo1.html'},
- ]
- }, os.path.dirname(__file__))
+ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
+ ps.AddPageWithDefaultRunNavigate('file://../../otherdir/foo.html')
+ ps.AddPageWithDefaultRunNavigate('file://../../otherdir/foo1.html')
+
self.assertEquals(ps[0].display_name, 'foo.html')
self.assertEquals(ps[1].display_name, 'foo1.html')
def testDisplayUrlForFileOfDifferentPaths(self):
- ps = page_set.PageSet.FromDict({
- 'description': 'hello',
- 'archive_path': 'foo.wpr',
- 'pages': [
- {'url': 'file://../../somedir/foo.html'},
- {'url': 'file://../../otherdir/bar.html'},
- ]
- }, os.path.dirname(__file__))
+ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
+ ps.AddPageWithDefaultRunNavigate('file://../../somedir/foo.html')
+ ps.AddPageWithDefaultRunNavigate('file://../../otherdir/bar.html')
+
self.assertEquals(ps[0].display_name, 'somedir/foo.html')
self.assertEquals(ps[1].display_name, 'otherdir/bar.html')
def testDisplayUrlForFileDirectories(self):
- ps = page_set.PageSet.FromDict({
- 'description': 'hello',
- 'archive_path': 'foo.wpr',
- 'pages': [
- {'url': 'file://../../otherdir/foo/'},
- {'url': 'file://../../otherdir/bar/'},
- ]
- }, os.path.dirname(__file__))
+ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
+ ps.AddPageWithDefaultRunNavigate('file://../../otherdir/foo')
+ ps.AddPageWithDefaultRunNavigate('file://../../otherdir/bar')
+
self.assertEquals(ps[0].display_name, 'foo')
self.assertEquals(ps[1].display_name, 'bar')
def testDisplayUrlForSingleFile(self):
- ps = page_set.PageSet.FromDict({
- 'description': 'hello',
- 'archive_path': 'foo.wpr',
- 'pages': [{'url': 'file://../../otherdir/foo.html'}]
- }, os.path.dirname(__file__))
+ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
+ ps.AddPageWithDefaultRunNavigate('file://../../otherdir/foo.html')
+
self.assertEquals(ps[0].display_name, 'foo.html')
def testDisplayUrlForSingleDirectory(self):
- ps = page_set.PageSet.FromDict({
- 'description': 'hello',
- 'archive_path': 'foo.wpr',
- 'pages': [{'url': 'file://../../otherdir/foo/'}]
- }, os.path.dirname(__file__))
+ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
+ ps.AddPageWithDefaultRunNavigate('file://../../otherdir/foo')
+
self.assertEquals(ps[0].display_name, 'foo')
« no previous file with comments | « tools/telemetry/telemetry/page/page_test_results_unittest.py ('k') | tools/telemetry/telemetry/value/histogram_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698