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):
metric = tbm_module._TimelineBasedMetrics( # pylint: disable=W0212
self.model, self.renderer_thread,
CreateMetricsForTimelineInteractionRecord)
ps = page_set.PageSet.FromDict({
"description": "hello",
"archive_path": "foo.wpr",
"pages": [
{"url": "http://www.bar.com/"}
]
}, os.path.dirname(__file__))
ps = page_set.PageSet(file_path=os.path.dirname(__file__))
ps.AddPageWithDefaultRunNavigate('http://www.bar.com/')
results.WillMeasurePage(ps.pages[0])
metric.AddResults(results)
results.DidMeasurePage()
......
......@@ -12,14 +12,11 @@ BlockPageMeasurementResults = \
block_page_measurement_results.BlockPageMeasurementResults
def _MakePageSet():
return 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/')
return ps
class NonPrintingBlockPageMeasurementResults(BlockPageMeasurementResults):
def __init__(self, *args):
......
......@@ -11,15 +11,11 @@ from telemetry.value import list_of_scalar_values
from telemetry.value import scalar
def _MakePageSet():
return page_set.PageSet.FromDict({
"description": "hello",
"archive_path": "foo.wpr",
"pages": [
{"url": "http://www.foo.com/"},
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.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/')
ps.AddPageWithDefaultRunNavigate('http://www.baz.com/')
return ps
class SummarySavingPageMeasurementResults(
buildbot_page_measurement_results.BuildbotPageMeasurementResults):
......
......@@ -10,13 +10,10 @@ from telemetry.page import csv_page_measurement_results
from telemetry.page import page_set
def _MakePageSet():
return page_set.PageSet.FromDict({
"description": "hello",
"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/')
return ps
class NonPrintingCsvPageMeasurementResults(
csv_page_measurement_results.CsvPageMeasurementResults):
......
......@@ -10,15 +10,11 @@ from telemetry.page import page_set
def _MakePageSet():
return page_set.PageSet.FromDict({
"description": "hello",
"archive_path": "foo.wpr",
"pages": [
{"url": "http://www.foo.com/"},
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.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/')
ps.AddPageWithDefaultRunNavigate('http://www.baz.com/')
return ps
class DeterministicHtmlPageMeasurementResults(
......
......@@ -10,15 +10,11 @@ from telemetry.page import perf_tests_helper
from telemetry.value import scalar
def _MakePageSet():
return page_set.PageSet.FromDict({
"description": "hello",
"archive_path": "foo.wpr",
"pages": [
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
ps = page_set.PageSet(file_path=os.path.dirname(__file__))
ps.AddPageWithDefaultRunNavigate("http://www.bar.com/")
ps.AddPageWithDefaultRunNavigate("http://www.baz.com/")
ps.AddPageWithDefaultRunNavigate("http://www.foo.com/")
return ps
class NonPrintingPageMeasurementResults(
page_measurement_results.PageMeasurementResults):
......
......@@ -18,15 +18,10 @@ class NonPrintingPageTestResults(
class PageTestResultsTest(unittest.TestCase):
def setUp(self):
self.page_set = page_set.PageSet.FromDict({
"description": "hello",
"archive_path": "foo.wpr",
"pages": [
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
@property
def pages(self):
......
......@@ -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')
......@@ -10,15 +10,10 @@ from telemetry.value import histogram as histogram_module
class TestBase(unittest.TestCase):
def setUp(self):
self.page_set = page_set.PageSet.FromDict({
"description": "hello",
"archive_path": "foo.wpr",
"pages": [
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
@property
def pages(self):
......
......@@ -10,15 +10,10 @@ from telemetry.value import list_of_scalar_values
class TestBase(unittest.TestCase):
def setUp(self):
self.page_set = page_set.PageSet.FromDict({
"description": "hello",
"archive_path": "foo.wpr",
"pages": [
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
@property
def pages(self):
......
......@@ -10,15 +10,10 @@ from telemetry.value import list_of_string_values
class TestBase(unittest.TestCase):
def setUp(self):
self.page_set = page_set.PageSet.FromDict({
"description": "hello",
"archive_path": "foo.wpr",
"pages": [
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
@property
def pages(self):
......
......@@ -11,15 +11,10 @@ from telemetry.value import scalar
class TestBase(unittest.TestCase):
def setUp(self):
self.page_set = page_set.PageSet.FromDict({
"description": "hello",
"archive_path": "foo.wpr",
"pages": [
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
@property
def pages(self):
......
......@@ -10,15 +10,10 @@ from telemetry.value import scalar
class TestBase(unittest.TestCase):
def setUp(self):
self.page_set = page_set.PageSet.FromDict({
"description": "hello",
"archive_path": "foo.wpr",
"pages": [
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
@property
def pages(self):
......
......@@ -10,15 +10,10 @@ from telemetry.value import string
class TestBase(unittest.TestCase):
def setUp(self):
self.page_set = page_set.PageSet.FromDict({
"description": "hello",
"archive_path": "foo.wpr",
"pages": [
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
@property
def pages(self):
......
......@@ -9,15 +9,10 @@ from telemetry.page import page_set
class TestBase(unittest.TestCase):
def setUp(self):
self.page_set = page_set.PageSet.FromDict({
"description": "hello",
"archive_path": "foo.wpr",
"pages": [
{"url": "http://www.bar.com/"},
{"url": "http://www.baz.com/"},
{"url": "http://www.foo.com/"}
]
}, os.path.dirname(__file__))
self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__))
self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
@property
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