testing/marionette/harness/marionette_harness/tests/unit/test_window_position.py
author Andreas Tolfsen <ato@mozilla.com>
Thu, 02 Feb 2017 14:46:58 +0000
changeset 481996 637edd708738129a7639c5fccdaab943e48fb92c
parent 479649 4f4dcc23d36b2c9598349c0a05583efb9fefd0c3
child 481997 a032a9cef3a45f5a4799035631590263c914b0e0
permissions -rw-r--r--
Bug 1319237 - Donate window position test to Mozilla; r=automatedtester The window positioning test has been sufficiently rewritten that it can no longer be considered a derived work from Selenium. MozReview-Commit-ID: 9FtGEPeMXQs

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_driver.errors import InvalidArgumentException

from marionette_harness import MarionetteTestCase


class TestWindowPosition(MarionetteTestCase):
    def test_get_types(self):
        position = self.marionette.get_window_position()
        self.assertTrue(isinstance(position["x"], int))
        self.assertTrue(isinstance(position["y"], int))

    def test_set_types(self):
        for x, y in (["a", "b"], [1.2, 3.4], [True, False], [[], []], [{}, {}]):
            with self.assertRaises(InvalidArgumentException):
                self.marionette.set_window_position(x, y)

    def test_out_of_bounds_arguments(self):
        with self.assertRaises(InvalidArgumentException):
            self.marionette.set_window_position(-1, 0)
        with self.assertRaises(InvalidArgumentException):
            self.marionette.set_window_position(0, -1)

    def test_move(self):
        old_position = self.marionette.get_window_position()
        new_position = {"x": old_position["x"] + 10, "y": old_position["y"] + 10}
        self.marionette.set_window_position(new_position["x"], new_position["y"])
        self.assertNotEqual(old_position['x'], new_position["x"])
        self.assertNotEqual(old_position['y'], new_position["y"])