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

Unified Diff: tools/telemetry/telemetry/core/backends/chrome/android_browser_finder_unittest.py

Issue 694233002: Add test for SelectDefaultBrowser and refactor implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comment. Shorter test code. Created 6 years, 1 month 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/core/backends/chrome/android_browser_finder_unittest.py
diff --git a/tools/telemetry/telemetry/core/backends/chrome/android_browser_finder_unittest.py b/tools/telemetry/telemetry/core/backends/chrome/android_browser_finder_unittest.py
index 926ad1f5a6628f6135fd4253706e52af8d18939c..f180e3183d20d6b8e01221bd3776cfa882cc7cf5 100644
--- a/tools/telemetry/telemetry/core/backends/chrome/android_browser_finder_unittest.py
+++ b/tools/telemetry/telemetry/core/backends/chrome/android_browser_finder_unittest.py
@@ -87,3 +87,32 @@ class AndroidBrowserFinderTest(unittest.TestCase):
browsers = android_browser_finder.FindAllAvailableBrowsers(finder_options)
self.assertEquals(1, len(browsers))
+
+
+class FakePossibleBrowser(object):
+ def __init__(self, last_modification_time):
+ self._last_modification_time = last_modification_time
+
+ def last_modification_time(self):
+ return self._last_modification_time
+
+
+class SelectDefaultBrowserTest(unittest.TestCase):
nednguyen 2014/11/03 16:04:54 +1 for test.
slamm 2014/11/03 16:25:55 This worked nicely. I wrote the test and had it pa
+ def testEmptyListGivesNone(self):
+ self.assertIsNone(android_browser_finder.SelectDefaultBrowser([]))
+
+ def testSinglePossibleReturnsSame(self):
+ possible_browsers = [FakePossibleBrowser(last_modification_time=1)]
+ self.assertIs(
+ possible_browsers[0],
+ android_browser_finder.SelectDefaultBrowser(possible_browsers))
+
+ def testListGivesNewest(self):
+ possible_browsers = [
+ FakePossibleBrowser(last_modification_time=2),
+ FakePossibleBrowser(last_modification_time=3), # newest
+ FakePossibleBrowser(last_modification_time=1),
+ ]
+ self.assertIs(
+ possible_browsers[1],
+ android_browser_finder.SelectDefaultBrowser(possible_browsers))

Powered by Google App Engine
This is Rietveld 408576698