Skip to content

Commit

Permalink
Increase coverage of telemetry's user_agent_unittest
Browse files Browse the repository at this point in the history
Added a mobile and desktop testing in case the browser being tested has a
user agent that defaults to the tablet user agent.

BUG=421229

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

Cr-Commit-Position: refs/heads/master@{#300349}
  • Loading branch information
Tyriar authored and Commit bot committed Oct 20, 2014
1 parent 7dc97b1 commit 63f233b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Craig Schlenter <craig.schlenter@gmail.com>
Daegyu Lee <na7jun8gi@gmail.com>
Dai Chunyang <chunyang.dai@intel.com>
Daniel Bomar <dbdaniel42@gmail.com>
Daniel Imms <daniimms@amazon.com>
Daniel Johnson <danielj41@gmail.com>
Daniel Nishi <dhnishi@gmail.com>
Daniel Shaulov <dshaulov@ptc.com>
Expand Down
20 changes: 19 additions & 1 deletion tools/telemetry/telemetry/core/user_agent_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,29 @@
from telemetry.unittest import tab_test_case


class UserAgentTest(tab_test_case.TabTestCase):
class MobileUserAgentTest(tab_test_case.TabTestCase):
@classmethod
def CustomizeBrowserOptions(cls, options):
options.browser_user_agent_type = 'mobile'

def testUserAgent(self):
ua = self._tab.EvaluateJavaScript('window.navigator.userAgent')
self.assertEquals(ua, user_agent.UA_TYPE_MAPPING['mobile'])

class TabletUserAgentTest(tab_test_case.TabTestCase):
@classmethod
def CustomizeBrowserOptions(cls, options):
options.browser_user_agent_type = 'tablet'

def testUserAgent(self):
ua = self._tab.EvaluateJavaScript('window.navigator.userAgent')
self.assertEquals(ua, user_agent.UA_TYPE_MAPPING['tablet'])

class DesktopUserAgentTest(tab_test_case.TabTestCase):
@classmethod
def CustomizeBrowserOptions(cls, options):
options.browser_user_agent_type = 'desktop'

def testUserAgent(self):
ua = self._tab.EvaluateJavaScript('window.navigator.userAgent')
self.assertEquals(ua, user_agent.UA_TYPE_MAPPING['desktop'])

0 comments on commit 63f233b

Please sign in to comment.