Skip to content

Commit

Permalink
Merge pull request #1349 from zacc/change_do_not_track_prefs
Browse files Browse the repository at this point in the history
Change do not track tests and page object region
  • Loading branch information
Zac committed Sep 11, 2013
2 parents cfabda2 + 19b98d2 commit 78542b8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 30 deletions.
24 changes: 12 additions & 12 deletions gaiatest/apps/settings/regions/do_not_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@

class DoNotTrack(Base):

_do_not_track_label_locator = (By.CSS_SELECTOR, '#doNotTrack label')
_do_not_track_checkbox_locator = (By.CSS_SELECTOR, '#doNotTrack input')
_allow_tracking_checkbox_locator = (By.XPATH, '//li[p[@data-l10n-id="allowTracking"]]/label')
_do_not_track_checkbox_locator = (By.XPATH, '//li[p[@data-l10n-id="doNotHavePrefOnTracking"]]/label')

@property
def is_do_not_track_enabled(self):
return self.marionette.find_element(*self._do_not_track_checkbox_locator).get_attribute('checked')
def tap_allow_tracking(self):
el = self.marionette.find_element(*self._allow_tracking_checkbox_locator)
checked = el.get_attribute('checked')
el.tap()
self.wait_for_condition(lambda m: el.get_attribute('checked') is not checked)

def enable_do_not_track(self):
self.marionette.find_element(*self._do_not_track_label_locator).tap()
self.wait_for_condition(lambda m: self.is_do_not_track_enabled)

def disable_do_not_track(self):
self.marionette.find_element(*self._do_not_track_label_locator).tap()
self.wait_for_condition(lambda m: not self.is_do_not_track_enabled)
def tap_do_not_track(self):
el = self.marionette.find_element(*self._do_not_track_checkbox_locator)
checked = el.get_attribute('checked')
el.tap()
self.wait_for_condition(lambda m: el.get_attribute('checked') is not checked)
3 changes: 3 additions & 0 deletions gaiatest/gaia_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ def cleanUp(self):
self.data_layer.set_setting("time.timezone", "America/Los_Angeles")
self.data_layer.set_setting("time.timezone.user-selected", "America/Los_Angeles")

# Set do not track pref back to the default
self.data_layer.set_setting('privacy.donottrackheader.value', '-1')

# restore settings from testvars
[self.data_layer.set_setting(name, value) for name, value in self.testvars.get('settings', {}).items()]

Expand Down
22 changes: 4 additions & 18 deletions gaiatest/tests/settings/test_settings_do_not_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,14 @@ def test_enable_do_not_track_via_settings_app(self):
settings.launch()
do_not_track_settings = settings.open_do_not_track_settings()

# turned off by default
self.wait_for_condition(
lambda m: not do_not_track_settings.is_do_not_track_enabled
)

# turn on
do_not_track_settings.enable_do_not_track()
do_not_track_settings.tap_allow_tracking()

# should be on
self.assertTrue(self.data_layer.get_setting('privacy.donottrackheader.enabled'),
'Do Not Track was not enabled via Settings app')
self.assertEqual(self.data_layer.get_setting('privacy.donottrackheader.value'), '1')

# turn back off
do_not_track_settings.disable_do_not_track()
do_not_track_settings.tap_do_not_track()

# should be off
self.assertFalse(self.data_layer.get_setting('privacy.donottrackheader.enabled'),
'Do Not Track was not disabled via Settings app')

def tearDown(self):

# make sure Do Not Track is off at the end of the test
self.data_layer.set_setting('privacy.donottrackheader.enabled', False)

GaiaTestCase.tearDown(self)
self.assertEqual(self.data_layer.get_setting('privacy.donottrackheader.value'), '-1')

0 comments on commit 78542b8

Please sign in to comment.