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

Side by Side Diff: telemetry/telemetry/internal/browser/browser_unittest.py

Issue 2162963002: [polymer] Merge of master into polymer10-migration (Closed) Base URL: git@github.com:catapult-project/catapult.git@polymer10-migration
Patch Set: Merge polymer10-migration int polymer10-merge Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 # Copyright 2012 The Chromium Authors. All rights reserved. 1 # Copyright 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import os 6 import os
7 import shutil 7 import shutil
8 import tempfile 8 import tempfile
9 import unittest 9 import unittest
10 10
11 from telemetry.core import util 11 from telemetry.core import util
12 from telemetry.core import exceptions
12 from telemetry import decorators 13 from telemetry import decorators
13 from telemetry.internal.browser import browser as browser_module 14 from telemetry.internal.browser import browser as browser_module
14 from telemetry.internal.browser import browser_finder 15 from telemetry.internal.browser import browser_finder
15 from telemetry.internal.platform import gpu_device 16 from telemetry.internal.platform import gpu_device
16 from telemetry.internal.platform import gpu_info 17 from telemetry.internal.platform import gpu_info
17 from telemetry.internal.platform import system_info 18 from telemetry.internal.platform import system_info
18 from telemetry.internal.util import path 19 from telemetry.internal.util import path
19 from telemetry.testing import browser_test_case 20 from telemetry.testing import browser_test_case
20 from telemetry.testing import options_for_unittests 21 from telemetry.testing import options_for_unittests
21 from telemetry.timeline import tracing_config 22 from telemetry.timeline import tracing_config
(...skipping 29 matching lines...) Expand all
51 52
52 def testMultipleTabCalls(self): 53 def testMultipleTabCalls(self):
53 self._browser.tabs[0].Navigate(self.UrlOfUnittestFile('blank.html')) 54 self._browser.tabs[0].Navigate(self.UrlOfUnittestFile('blank.html'))
54 self._browser.tabs[0].WaitForDocumentReadyStateToBeInteractiveOrBetter() 55 self._browser.tabs[0].WaitForDocumentReadyStateToBeInteractiveOrBetter()
55 56
56 def testTabCallByReference(self): 57 def testTabCallByReference(self):
57 tab = self._browser.tabs[0] 58 tab = self._browser.tabs[0]
58 tab.Navigate(self.UrlOfUnittestFile('blank.html')) 59 tab.Navigate(self.UrlOfUnittestFile('blank.html'))
59 self._browser.tabs[0].WaitForDocumentReadyStateToBeInteractiveOrBetter() 60 self._browser.tabs[0].WaitForDocumentReadyStateToBeInteractiveOrBetter()
60 61
62 # Disable bug: https://github.com/catapult-project/catapult/issues/2455
61 @decorators.Enabled('has tabs') 63 @decorators.Enabled('has tabs')
62 @decorators.Disabled('win') # crbug.com/321527 64 @decorators.Disabled('linux', 'mac')
63 def testCloseReferencedTab(self): 65 def testCloseReferencedTab(self):
64 self._browser.tabs.New() 66 self._browser.tabs.New()
65 tab = self._browser.tabs[0] 67 tab = self._browser.tabs[0]
66 tab.Navigate(self.UrlOfUnittestFile('blank.html')) 68 tab.Navigate(self.UrlOfUnittestFile('blank.html'))
67 tab.Close() 69 tab.Close()
68 self.assertEquals(1, len(self._browser.tabs)) 70 self.assertEquals(1, len(self._browser.tabs))
69 71
70 @decorators.Enabled('has tabs') 72 @decorators.Enabled('has tabs')
71 def testForegroundTab(self): 73 def testForegroundTab(self):
72 # Should be only one tab at this stage, so that must be the foreground tab 74 # Should be only one tab at this stage, so that must be the foreground tab
73 original_tab = self._browser.tabs[0] 75 original_tab = self._browser.tabs[0]
74 self.assertEqual(self._browser.foreground_tab, original_tab) 76 self.assertEqual(self._browser.foreground_tab, original_tab)
75 new_tab = self._browser.tabs.New() 77 new_tab = self._browser.tabs.New()
76 # New tab shouls be foreground tab 78 # New tab shouls be foreground tab
77 self.assertEqual(self._browser.foreground_tab, new_tab) 79 self.assertEqual(self._browser.foreground_tab, new_tab)
78 # Make sure that activating the background tab makes it the foreground tab 80 # Make sure that activating the background tab makes it the foreground tab
79 original_tab.Activate() 81 original_tab.Activate()
80 self.assertEqual(self._browser.foreground_tab, original_tab) 82 self.assertEqual(self._browser.foreground_tab, original_tab)
81 # Closing the current foreground tab should switch the foreground tab to the 83 # Closing the current foreground tab should switch the foreground tab to the
82 # other tab 84 # other tab
83 original_tab.Close() 85 original_tab.Close()
84 self.assertEqual(self._browser.foreground_tab, new_tab) 86 self.assertEqual(self._browser.foreground_tab, new_tab)
85 87
88 # This test uses the reference browser and doesn't have access to
89 # helper binaries like crashpad_database_util.
90 @decorators.Enabled('linux')
91 def testGetMinidumpPathOnCrash(self):
92 tab = self._browser.tabs[0]
93 with self.assertRaises(exceptions.AppCrashException):
94 tab.Navigate('chrome://crash', timeout=5)
95 crash_minidump_path = self._browser.GetMostRecentMinidumpPath()
96 self.assertIsNotNone(crash_minidump_path)
97
86 def testGetSystemInfo(self): 98 def testGetSystemInfo(self):
87 if not self._browser.supports_system_info: 99 if not self._browser.supports_system_info:
88 logging.warning( 100 logging.warning(
89 'Browser does not support getting system info, skipping test.') 101 'Browser does not support getting system info, skipping test.')
90 return 102 return
91 103
92 info = self._browser.GetSystemInfo() 104 info = self._browser.GetSystemInfo()
93 105
94 self.assertTrue(isinstance(info, system_info.SystemInfo)) 106 self.assertTrue(isinstance(info, system_info.SystemInfo))
95 self.assertTrue(hasattr(info, 'model_name')) 107 self.assertTrue(hasattr(info, 'model_name'))
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 options.profile_type = 'small_profile' 159 options.profile_type = 'small_profile'
148 160
149 @decorators.Disabled('chromeos') # crbug.com/243912 161 @decorators.Disabled('chromeos') # crbug.com/243912
150 def testDirtyProfileCreation(self): 162 def testDirtyProfileCreation(self):
151 self.assertEquals(1, len(self._browser.tabs)) 163 self.assertEquals(1, len(self._browser.tabs))
152 164
153 165
154 class BrowserLoggingTest(browser_test_case.BrowserTestCase): 166 class BrowserLoggingTest(browser_test_case.BrowserTestCase):
155 @classmethod 167 @classmethod
156 def CustomizeBrowserOptions(cls, options): 168 def CustomizeBrowserOptions(cls, options):
157 options.enable_logging = True 169 options.logging_verbosity = options.VERBOSE_LOGGING
158 170
159 @decorators.Disabled('chromeos', 'android') 171 @decorators.Disabled('chromeos', 'android')
160 def testLogFileExist(self): 172 def testLogFileExist(self):
161 self.assertTrue( 173 self.assertTrue(
162 os.path.isfile(self._browser._browser_backend.log_file_path)) 174 os.path.isfile(self._browser._browser_backend.log_file_path))
163 175
164 176
165 def _GenerateBrowserProfile(number_of_tabs): 177 def _GenerateBrowserProfile(number_of_tabs):
166 """ Generate a browser profile which browser had |number_of_tabs| number of 178 """ Generate a browser profile which browser had |number_of_tabs| number of
167 tabs opened before it was closed. 179 tabs opened before it was closed.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 browser_to_create = browser_finder.FindBrowser(options) 264 browser_to_create = browser_finder.FindBrowser(options)
253 self.assertIsNotNone(browser_to_create) 265 self.assertIsNotNone(browser_to_create)
254 before_browser_run_temp_dir_content = os.listdir(tempfile.tempdir) 266 before_browser_run_temp_dir_content = os.listdir(tempfile.tempdir)
255 with browser_to_create.Create(options) as browser: 267 with browser_to_create.Create(options) as browser:
256 tab = browser.tabs.New() 268 tab = browser.tabs.New()
257 tab.Navigate('about:blank') 269 tab.Navigate('about:blank')
258 self.assertEquals(2, tab.EvaluateJavaScript('1 + 1')) 270 self.assertEquals(2, tab.EvaluateJavaScript('1 + 1'))
259 after_browser_run_temp_dir_content = os.listdir(tempfile.tempdir) 271 after_browser_run_temp_dir_content = os.listdir(tempfile.tempdir)
260 self.assertEqual(before_browser_run_temp_dir_content, 272 self.assertEqual(before_browser_run_temp_dir_content,
261 after_browser_run_temp_dir_content) 273 after_browser_run_temp_dir_content)
OLDNEW
« no previous file with comments | « telemetry/telemetry/internal/browser/browser_options.py ('k') | telemetry/telemetry/internal/browser/tab_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698