Commit 2f264fc0 authored by nednguyen@google.com's avatar nednguyen@google.com

Get rid of PageSet.FromDict from unittests

BUG=239179

Review URL: https://codereview.chromium.org/252923002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266693 0039d316-1c4b-4281-b951-d872f2087c98
parent 6ebd60ce
...@@ -77,13 +77,9 @@ class TimelineBasedMetricsTests(unittest.TestCase): ...@@ -77,13 +77,9 @@ class TimelineBasedMetricsTests(unittest.TestCase):
metric = tbm_module._TimelineBasedMetrics( # pylint: disable=W0212 metric = tbm_module._TimelineBasedMetrics( # pylint: disable=W0212
self.model, self.renderer_thread, self.model, self.renderer_thread,
CreateMetricsForTimelineInteractionRecord) CreateMetricsForTimelineInteractionRecord)
ps = page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
"description": "hello", ps.AddPageWithDefaultRunNavigate('http://www.bar.com/')
"archive_path": "foo.wpr",
"pages": [
{"url": "http://www.bar.com/"}
]
}, os.path.dirname(__file__))
results.WillMeasurePage(ps.pages[0]) results.WillMeasurePage(ps.pages[0])
metric.AddResults(results) metric.AddResults(results)
results.DidMeasurePage() results.DidMeasurePage()
......
...@@ -12,14 +12,11 @@ BlockPageMeasurementResults = \ ...@@ -12,14 +12,11 @@ BlockPageMeasurementResults = \
block_page_measurement_results.BlockPageMeasurementResults block_page_measurement_results.BlockPageMeasurementResults
def _MakePageSet(): def _MakePageSet():
return page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
"description": "hello", ps.AddPageWithDefaultRunNavigate('http://www.foo.com/')
"archive_path": "foo.wpr", ps.AddPageWithDefaultRunNavigate('http://www.bar.com/')
"pages": [ return ps
{"url": "http://www.foo.com/"},
{"url": "http://www.bar.com/"}
]
}, os.path.dirname(__file__))
class NonPrintingBlockPageMeasurementResults(BlockPageMeasurementResults): class NonPrintingBlockPageMeasurementResults(BlockPageMeasurementResults):
def __init__(self, *args): def __init__(self, *args):
......
...@@ -11,15 +11,11 @@ from telemetry.value import list_of_scalar_values ...@@ -11,15 +11,11 @@ from telemetry.value import list_of_scalar_values
from telemetry.value import scalar from telemetry.value import scalar
def _MakePageSet(): def _MakePageSet():
return page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
"description": "hello", ps.AddPageWithDefaultRunNavigate('http://www.foo.com/')
"archive_path": "foo.wpr", ps.AddPageWithDefaultRunNavigate('http://www.bar.com/')
"pages": [ ps.AddPageWithDefaultRunNavigate('http://www.baz.com/')
{"url": "http://www.foo.com/"}, return ps
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"}
]
}, os.path.dirname(__file__))
class SummarySavingPageMeasurementResults( class SummarySavingPageMeasurementResults(
buildbot_page_measurement_results.BuildbotPageMeasurementResults): buildbot_page_measurement_results.BuildbotPageMeasurementResults):
......
...@@ -10,13 +10,10 @@ from telemetry.page import csv_page_measurement_results ...@@ -10,13 +10,10 @@ from telemetry.page import csv_page_measurement_results
from telemetry.page import page_set from telemetry.page import page_set
def _MakePageSet(): def _MakePageSet():
return page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
"description": "hello", ps.AddPageWithDefaultRunNavigate('http://www.foo.com/')
"pages": [ ps.AddPageWithDefaultRunNavigate('http://www.bar.com/')
{"url": "http://www.foo.com/"}, return ps
{"url": "http://www.bar.com/"}
]
}, os.path.dirname(__file__))
class NonPrintingCsvPageMeasurementResults( class NonPrintingCsvPageMeasurementResults(
csv_page_measurement_results.CsvPageMeasurementResults): csv_page_measurement_results.CsvPageMeasurementResults):
......
...@@ -10,15 +10,11 @@ from telemetry.page import page_set ...@@ -10,15 +10,11 @@ from telemetry.page import page_set
def _MakePageSet(): def _MakePageSet():
return page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
"description": "hello", ps.AddPageWithDefaultRunNavigate('http://www.foo.com/')
"archive_path": "foo.wpr", ps.AddPageWithDefaultRunNavigate('http://www.bar.com/')
"pages": [ ps.AddPageWithDefaultRunNavigate('http://www.baz.com/')
{"url": "http://www.foo.com/"}, return ps
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"}
]
}, os.path.dirname(__file__))
class DeterministicHtmlPageMeasurementResults( class DeterministicHtmlPageMeasurementResults(
......
...@@ -10,15 +10,11 @@ from telemetry.page import perf_tests_helper ...@@ -10,15 +10,11 @@ from telemetry.page import perf_tests_helper
from telemetry.value import scalar from telemetry.value import scalar
def _MakePageSet(): def _MakePageSet():
return page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
"description": "hello", ps.AddPageWithDefaultRunNavigate("http://www.bar.com/")
"archive_path": "foo.wpr", ps.AddPageWithDefaultRunNavigate("http://www.baz.com/")
"pages": [ ps.AddPageWithDefaultRunNavigate("http://www.foo.com/")
{"url": "http://www.bar.com/"}, return ps
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
class NonPrintingPageMeasurementResults( class NonPrintingPageMeasurementResults(
page_measurement_results.PageMeasurementResults): page_measurement_results.PageMeasurementResults):
......
...@@ -18,15 +18,10 @@ class NonPrintingPageTestResults( ...@@ -18,15 +18,10 @@ class NonPrintingPageTestResults(
class PageTestResultsTest(unittest.TestCase): class PageTestResultsTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.page_set = page_set.PageSet.FromDict({ self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
"description": "hello", self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
"archive_path": "foo.wpr", self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
"pages": [ self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
@property @property
def pages(self): def pages(self):
......
...@@ -42,113 +42,76 @@ class TestPage(unittest.TestCase): ...@@ -42,113 +42,76 @@ class TestPage(unittest.TestCase):
(os.altsep and apage.file_path_url.endswith(os.altsep))) (os.altsep and apage.file_path_url.endswith(os.altsep)))
def testSort(self): def testSort(self):
ps = page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
'description': 'hello', ps.AddPageWithDefaultRunNavigate('http://www.foo.com/')
'archive_path': 'foo.wpr', ps.AddPageWithDefaultRunNavigate('http://www.bar.com/')
'pages': [
{'url': 'http://www.foo.com/'},
{'url': 'http://www.bar.com/'}
]
}, os.path.dirname(__file__))
pages = [ps.pages[0], ps.pages[1]] pages = [ps.pages[0], ps.pages[1]]
pages.sort() pages.sort()
self.assertEquals([ps.pages[1], ps.pages[0]], self.assertEquals([ps.pages[1], ps.pages[0]],
pages) pages)
def testGetUrlBaseDirAndFileForUrlBaseDir(self): def testGetUrlBaseDirAndFileForUrlBaseDir(self):
ps = page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path='basedir/', serving_dirs=['../somedir/'])
'description': 'hello', ps.AddPageWithDefaultRunNavigate('file://../otherdir/file.html')
'archive_path': 'foo.wpr',
'serving_dirs': ['../somedir/'],
'pages': [
{'url': 'file://../otherdir/file.html'}
]}, 'basedir/')
self.assertPathEqual(ps[0].file_path, 'otherdir/file.html') self.assertPathEqual(ps[0].file_path, 'otherdir/file.html')
def testDisplayUrlForHttp(self): def testDisplayUrlForHttp(self):
ps = page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
'description': 'hello', ps.AddPageWithDefaultRunNavigate('http://www.foo.com/')
'archive_path': 'foo.wpr', ps.AddPageWithDefaultRunNavigate('http://www.bar.com/')
'pages': [
{'url': 'http://www.foo.com/'},
{'url': 'http://www.bar.com/'}
]
}, os.path.dirname(__file__))
self.assertEquals(ps[0].display_name, 'http://www.foo.com/') self.assertEquals(ps[0].display_name, 'http://www.foo.com/')
self.assertEquals(ps[1].display_name, 'http://www.bar.com/') self.assertEquals(ps[1].display_name, 'http://www.bar.com/')
def testDisplayUrlForHttps(self): def testDisplayUrlForHttps(self):
ps = page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
'description': 'hello', ps.AddPageWithDefaultRunNavigate('http://www.foo.com/')
'archive_path': 'foo.wpr', ps.AddPageWithDefaultRunNavigate('https://www.bar.com/')
'pages': [
{'url': 'http://www.foo.com/'},
{'url': 'https://www.bar.com/'}
]
}, os.path.dirname(__file__))
self.assertEquals(ps[0].display_name, 'http://www.foo.com/') self.assertEquals(ps[0].display_name, 'http://www.foo.com/')
self.assertEquals(ps[1].display_name, 'https://www.bar.com/') self.assertEquals(ps[1].display_name, 'https://www.bar.com/')
def testDisplayUrlForFile(self): def testDisplayUrlForFile(self):
ps = page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
'description': 'hello', ps.AddPageWithDefaultRunNavigate('file://../../otherdir/foo.html')
'archive_path': 'foo.wpr', ps.AddPageWithDefaultRunNavigate('file://../../otherdir/bar.html')
'pages': [
{'url': 'file://../../otherdir/foo.html'},
{'url': 'file://../../otherdir/bar.html'},
]
}, os.path.dirname(__file__))
self.assertEquals(ps[0].display_name, 'foo.html') self.assertEquals(ps[0].display_name, 'foo.html')
self.assertEquals(ps[1].display_name, 'bar.html') self.assertEquals(ps[1].display_name, 'bar.html')
def testDisplayUrlForFilesDifferingBySuffix(self): def testDisplayUrlForFilesDifferingBySuffix(self):
ps = page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
'description': 'hello', ps.AddPageWithDefaultRunNavigate('file://../../otherdir/foo.html')
'archive_path': 'foo.wpr', ps.AddPageWithDefaultRunNavigate('file://../../otherdir/foo1.html')
'pages': [
{'url': 'file://../../otherdir/foo.html'},
{'url': 'file://../../otherdir/foo1.html'},
]
}, os.path.dirname(__file__))
self.assertEquals(ps[0].display_name, 'foo.html') self.assertEquals(ps[0].display_name, 'foo.html')
self.assertEquals(ps[1].display_name, 'foo1.html') self.assertEquals(ps[1].display_name, 'foo1.html')
def testDisplayUrlForFileOfDifferentPaths(self): def testDisplayUrlForFileOfDifferentPaths(self):
ps = page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
'description': 'hello', ps.AddPageWithDefaultRunNavigate('file://../../somedir/foo.html')
'archive_path': 'foo.wpr', ps.AddPageWithDefaultRunNavigate('file://../../otherdir/bar.html')
'pages': [
{'url': 'file://../../somedir/foo.html'},
{'url': 'file://../../otherdir/bar.html'},
]
}, os.path.dirname(__file__))
self.assertEquals(ps[0].display_name, 'somedir/foo.html') self.assertEquals(ps[0].display_name, 'somedir/foo.html')
self.assertEquals(ps[1].display_name, 'otherdir/bar.html') self.assertEquals(ps[1].display_name, 'otherdir/bar.html')
def testDisplayUrlForFileDirectories(self): def testDisplayUrlForFileDirectories(self):
ps = page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
'description': 'hello', ps.AddPageWithDefaultRunNavigate('file://../../otherdir/foo')
'archive_path': 'foo.wpr', ps.AddPageWithDefaultRunNavigate('file://../../otherdir/bar')
'pages': [
{'url': 'file://../../otherdir/foo/'},
{'url': 'file://../../otherdir/bar/'},
]
}, os.path.dirname(__file__))
self.assertEquals(ps[0].display_name, 'foo') self.assertEquals(ps[0].display_name, 'foo')
self.assertEquals(ps[1].display_name, 'bar') self.assertEquals(ps[1].display_name, 'bar')
def testDisplayUrlForSingleFile(self): def testDisplayUrlForSingleFile(self):
ps = page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
'description': 'hello', ps.AddPageWithDefaultRunNavigate('file://../../otherdir/foo.html')
'archive_path': 'foo.wpr',
'pages': [{'url': 'file://../../otherdir/foo.html'}]
}, os.path.dirname(__file__))
self.assertEquals(ps[0].display_name, 'foo.html') self.assertEquals(ps[0].display_name, 'foo.html')
def testDisplayUrlForSingleDirectory(self): def testDisplayUrlForSingleDirectory(self):
ps = page_set.PageSet.FromDict({ ps = page_set.PageSet(file_path=os.path.dirname(__file__))
'description': 'hello', ps.AddPageWithDefaultRunNavigate('file://../../otherdir/foo')
'archive_path': 'foo.wpr',
'pages': [{'url': 'file://../../otherdir/foo/'}]
}, os.path.dirname(__file__))
self.assertEquals(ps[0].display_name, 'foo') self.assertEquals(ps[0].display_name, 'foo')
...@@ -10,15 +10,10 @@ from telemetry.value import histogram as histogram_module ...@@ -10,15 +10,10 @@ from telemetry.value import histogram as histogram_module
class TestBase(unittest.TestCase): class TestBase(unittest.TestCase):
def setUp(self): def setUp(self):
self.page_set = page_set.PageSet.FromDict({ self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
"description": "hello", self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
"archive_path": "foo.wpr", self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
"pages": [ self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
@property @property
def pages(self): def pages(self):
......
...@@ -10,15 +10,10 @@ from telemetry.value import list_of_scalar_values ...@@ -10,15 +10,10 @@ from telemetry.value import list_of_scalar_values
class TestBase(unittest.TestCase): class TestBase(unittest.TestCase):
def setUp(self): def setUp(self):
self.page_set = page_set.PageSet.FromDict({ self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
"description": "hello", self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
"archive_path": "foo.wpr", self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
"pages": [ self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
@property @property
def pages(self): def pages(self):
......
...@@ -10,15 +10,10 @@ from telemetry.value import list_of_string_values ...@@ -10,15 +10,10 @@ from telemetry.value import list_of_string_values
class TestBase(unittest.TestCase): class TestBase(unittest.TestCase):
def setUp(self): def setUp(self):
self.page_set = page_set.PageSet.FromDict({ self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
"description": "hello", self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
"archive_path": "foo.wpr", self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
"pages": [ self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
@property @property
def pages(self): def pages(self):
......
...@@ -11,15 +11,10 @@ from telemetry.value import scalar ...@@ -11,15 +11,10 @@ from telemetry.value import scalar
class TestBase(unittest.TestCase): class TestBase(unittest.TestCase):
def setUp(self): def setUp(self):
self.page_set = page_set.PageSet.FromDict({ self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
"description": "hello", self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
"archive_path": "foo.wpr", self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
"pages": [ self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
@property @property
def pages(self): def pages(self):
......
...@@ -10,15 +10,10 @@ from telemetry.value import scalar ...@@ -10,15 +10,10 @@ from telemetry.value import scalar
class TestBase(unittest.TestCase): class TestBase(unittest.TestCase):
def setUp(self): def setUp(self):
self.page_set = page_set.PageSet.FromDict({ self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
"description": "hello", self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
"archive_path": "foo.wpr", self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
"pages": [ self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
@property @property
def pages(self): def pages(self):
......
...@@ -10,15 +10,10 @@ from telemetry.value import string ...@@ -10,15 +10,10 @@ from telemetry.value import string
class TestBase(unittest.TestCase): class TestBase(unittest.TestCase):
def setUp(self): def setUp(self):
self.page_set = page_set.PageSet.FromDict({ self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
"description": "hello", self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
"archive_path": "foo.wpr", self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
"pages": [ self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
@property @property
def pages(self): def pages(self):
......
...@@ -9,15 +9,10 @@ from telemetry.page import page_set ...@@ -9,15 +9,10 @@ from telemetry.page import page_set
class TestBase(unittest.TestCase): class TestBase(unittest.TestCase):
def setUp(self): def setUp(self):
self.page_set = page_set.PageSet.FromDict({ self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
"description": "hello", self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
"archive_path": "foo.wpr", self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
"pages": [ self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
@property @property
def pages(self): def pages(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment