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 feca7e00a058e09619a9694cdcc67ddf8d552972..b100b4e9143a41e818e2a4ac4a55036171efbafa 100644 |
--- a/tools/telemetry/telemetry/page/page_unittest.py |
+++ b/tools/telemetry/telemetry/page/page_unittest.py |
@@ -1,60 +1,50 @@ |
# Copyright (c) 2012 The Chromium Authors. All rights reserved. |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
+ |
import os |
import unittest |
from telemetry.page import page |
from telemetry.page import page_set |
+ |
class TestPage(unittest.TestCase): |
- def testUrlPathJoin(self): |
- # pylint: disable=W0212 |
- self.assertEqual('a/b', page._UrlPathJoin('a', 'b')) |
- self.assertEqual('a/b', page._UrlPathJoin('a/', 'b')) |
- self.assertEqual('a/b', page._UrlPathJoin('a', '/b')) |
- self.assertEqual('a/b', page._UrlPathJoin('a/', '/b')) |
- self.assertEqual('a/b/c', page._UrlPathJoin('a', 'b', 'c')) |
- self.assertEqual('a/b/c', page._UrlPathJoin('a', 'b/', 'c')) |
- self.assertEqual('a/b/c', page._UrlPathJoin('a', 'b', '/c')) |
- self.assertEqual('a/b/c', page._UrlPathJoin('a', 'b/', '/c')) |
- self.assertEqual('a/b', page._UrlPathJoin('a', 'b', '')) |
+ def testFilePathRelative(self): |
+ apage = page.Page('file://somedir/otherdir/file.html', |
+ None, base_dir='basedir') |
+ self.assertEqual(apage.file_path, |
+ os.path.normpath('basedir/somedir/otherdir/file.html')) |
- def testGetUrlBaseDirAndFileForAbsolutePath(self): |
+ def testFilePathAbsolute(self): |
apage = page.Page('file:///somedir/otherdir/file.html', |
- None, # In this test, we don't need a page set. |
- base_dir='basedir') |
- serving_dirs, filename = apage.serving_dirs_and_file |
- self.assertEqual(serving_dirs, 'basedir/somedir/otherdir') |
- self.assertEqual(filename, 'file.html') |
+ None, base_dir='basedir') |
+ self.assertEqual(apage.file_path, |
+ os.path.normpath('/somedir/otherdir/file.html')) |
- def testGetUrlBaseDirAndFileForRelativePath(self): |
- apage = page.Page('file:///../../otherdir/file.html', |
- None, # In this test, we don't need a page set. |
- base_dir='basedir') |
- serving_dirs, filename = apage.serving_dirs_and_file |
- self.assertEqual(serving_dirs, 'basedir/../../otherdir') |
- self.assertEqual(filename, 'file.html') |
+ def testFilePathQueryString(self): |
+ apage = page.Page('file:///somedir/otherdir/file.html?key=val', |
+ None, base_dir='basedir') |
+ self.assertEqual(apage.file_path, |
+ os.path.normpath('/somedir/otherdir/file.html')) |
def testGetUrlBaseDirAndFileForUrlBaseDir(self): |
ps = page_set.PageSet.FromDict({ |
'description': 'hello', |
'archive_path': 'foo.wpr', |
- 'serving_dirs': ['../../somedir/'], |
+ 'serving_dirs': ['../somedir/'], |
'pages': [ |
- {'url': 'file:///../../somedir/otherdir/file.html'} |
+ {'url': 'file://../otherdir/file.html'} |
]}, 'basedir/') |
- serving_dirs, filename = ps[0].serving_dirs_and_file |
- self.assertEqual(serving_dirs, ['basedir/../../somedir/']) |
- self.assertEqual(filename, 'otherdir/file.html') |
+ self.assertEqual(ps[0].file_path, os.path.normpath('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/"} |
+ 'description': 'hello', |
+ 'archive_path': 'foo.wpr', |
+ '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/') |
@@ -62,11 +52,11 @@ class TestPage(unittest.TestCase): |
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/"} |
+ 'description': 'hello', |
+ 'archive_path': 'foo.wpr', |
+ '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/') |
@@ -74,11 +64,11 @@ class TestPage(unittest.TestCase): |
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"}, |
+ 'description': 'hello', |
+ 'archive_path': 'foo.wpr', |
+ 'pages': [ |
+ {'url': 'file://../../otherdir/foo.html'}, |
+ {'url': 'file://../../otherdir/bar.html'}, |
] |
}, os.path.dirname(__file__)) |
self.assertEquals(ps[0].display_name, 'foo.html') |
@@ -86,11 +76,11 @@ class TestPage(unittest.TestCase): |
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"}, |
+ 'description': 'hello', |
+ 'archive_path': 'foo.wpr', |
+ 'pages': [ |
+ {'url': 'file://../../otherdir/foo.html'}, |
+ {'url': 'file://../../otherdir/foo1.html'}, |
] |
}, os.path.dirname(__file__)) |
self.assertEquals(ps[0].display_name, 'foo.html') |
@@ -98,11 +88,11 @@ class TestPage(unittest.TestCase): |
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"}, |
+ 'description': 'hello', |
+ 'archive_path': 'foo.wpr', |
+ 'pages': [ |
+ {'url': 'file://../../somedir/foo.html'}, |
+ {'url': 'file://../../otherdir/bar.html'}, |
] |
}, os.path.dirname(__file__)) |
self.assertEquals(ps[0].display_name, 'somedir/foo.html') |
@@ -110,11 +100,11 @@ class TestPage(unittest.TestCase): |
def testDisplayUrlForFileDirectories(self): |
ps = page_set.PageSet.FromDict({ |
- "description": "hello", |
- "archive_path": "foo.wpr", |
- "pages": [ |
- {"url": "file:///../../otherdir/foo/"}, |
- {"url": "file:///../../otherdir/bar/"}, |
+ 'description': 'hello', |
+ 'archive_path': 'foo.wpr', |
+ 'pages': [ |
+ {'url': 'file://../../otherdir/foo/'}, |
+ {'url': 'file://../../otherdir/bar/'}, |
] |
}, os.path.dirname(__file__)) |
self.assertEquals(ps[0].display_name, 'foo') |
@@ -122,20 +112,16 @@ class TestPage(unittest.TestCase): |
def testDisplayUrlForSingleFile(self): |
ps = page_set.PageSet.FromDict({ |
- "description": "hello", |
- "archive_path": "foo.wpr", |
- "pages": [ |
- {"url": "file:///../../otherdir/foo.html"}, |
- ] |
+ 'description': 'hello', |
+ 'archive_path': 'foo.wpr', |
+ 'pages': [{'url': 'file://../../otherdir/foo.html'}] |
}, os.path.dirname(__file__)) |
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/"}, |
- ] |
+ 'description': 'hello', |
+ 'archive_path': 'foo.wpr', |
+ 'pages': [{'url': 'file://../../otherdir/foo/'}] |
}, os.path.dirname(__file__)) |
self.assertEquals(ps[0].display_name, 'foo') |