Bug 1372205 - Fix AutocompleteResults.visible_results() to only return visible items. r=mak

Instead of 'itemCount' the 'maxResults' property of the autocomplete popup
has to be used, because it doens't get increased similar to 'itemCount' but
stays the same all the time.

Further we cannot do an equal check in the puppeteer unit test but only do
a check for 0 < visible results <= maxResults, to ensure that items are
visible. Using the dot instead, should also give us more and more accurate
results across different locales.

MozReview-Commit-ID: KZEhq87kvx7

--HG--
extra : rebase_source : f429730d3f4a8da28b481b42c916145ae82e6bb5
This commit is contained in:
Henrik Skupin 2017-06-12 17:54:17 +02:00
Родитель b9302e66b5
Коммит 350d41d533
1 изменённых файлов: 5 добавлений и 8 удалений

Просмотреть файл

@ -153,16 +153,13 @@ class TestAutoCompleteResults(PuppeteerMixin, MarionetteTestCase):
super(TestAutoCompleteResults, self).tearDown()
def test_popup_elements(self):
# TODO: This test is not very robust because it relies on the history
# in the default profile.
self.assertFalse(self.autocomplete_results.is_open)
self.browser.navbar.locationbar.urlbar.send_keys('a')
results = self.autocomplete_results.results
self.browser.navbar.locationbar.urlbar.send_keys('.')
Wait(self.marionette).until(lambda _: self.autocomplete_results.is_complete)
visible_result_count = len(self.autocomplete_results.visible_results)
self.assertTrue(visible_result_count > 0)
self.assertEqual(visible_result_count,
int(results.get_property('itemCount')))
count_visible_results = len(self.autocomplete_results.visible_results)
self.assertTrue(count_visible_results > 0)
self.assertLessEqual(count_visible_results,
self.autocomplete_results.element.get_property('maxResults'))
def test_close(self):
self.browser.navbar.locationbar.urlbar.send_keys('a')