Skip to content

Commit 69994f9

Browse files
committed
Add a selenium test for osm layer rotation.
This also tests the ctrl+mouse drag. It will need a base-line image.
1 parent f399845 commit 69994f9

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

testing/test-cases/selenium-tests/osmLayer/testDrawOsm.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ def test_osm_pan(self):
3232
self.waitForIdle()
3333
self.screenshotTest(testName)
3434

35+
def test_osm_rotate(self):
36+
testName = 'osmRotate'
37+
self.loadPage()
38+
self.drag('#map', (50, 100), (100, 200), True)
39+
self.waitForIdle()
40+
self.screenshotTest(testName)
41+
3542

3643
class FirefoxOSM(osmBase, FirefoxTest):
3744
testCase = osmBase.testCase + ('firefox',)

testing/test-runners/selenium_test.py.in

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ else:
2727

2828
from selenium import webdriver
2929
from selenium.webdriver.support.wait import WebDriverWait
30-
from selenium.webdriver.common.action_chains import ActionChains
30+
from selenium.webdriver.common.action_chains import ActionChains, Keys
3131
from PIL import Image, ImageStat, ImageChops
3232

3333
from midas_handler import MidasHandler
@@ -443,7 +443,7 @@ class BaseTest(TestCase):
443443
url = self.testBaseURL + url
444444
return self.driver.get(url)
445445

446-
def drag(self, element, delta, offset=(0, 0)):
446+
def drag(self, element, delta, offset=(0, 0), ctrlDown=False):
447447
'''
448448
Drag the element given (by a CSS selector) starting
449449
at ``offset`` relative to the center of the element by
@@ -454,6 +454,7 @@ class BaseTest(TestCase):
454454
:type delta: [x, y]
455455
:param offset: The offset from the element center to start the drag.
456456
:type offset: [x, y]
457+
:param ctrlDown: if True, hold down control key during the drag.
457458
458459
For example,
459460
@@ -464,11 +465,15 @@ class BaseTest(TestCase):
464465
'''
465466
el = self.getElement(element)
466467
action = ActionChains(self.driver)
468+
if ctrlDown:
469+
action.key_down(Keys.CONTROL)
467470

468471
action.move_to_element_with_offset(el, offset[0], offset[1])
469472
action.click_and_hold()
470473
action.move_by_offset(delta[0], delta[1])
471474
action.release()
475+
if ctrlDown:
476+
action.key_up(Keys.CONTROL)
472477
action.perform()
473478

474479
def hover(self, element, offset=(0, 0)):

0 commit comments

Comments
 (0)