Skip to content

Commit

Permalink
Bug 1107336: Update Marionette unit tests to use Marionette Driver mo…
Browse files Browse the repository at this point in the history
…dules; r=jgriffin

--HG--
extra : rebase_source : 2606f27c08b9e21f204278d8b35aae5a8321a415
  • Loading branch information
David Burns committed Jan 23, 2015
1 parent 1351c0e commit 0aa761d
Show file tree
Hide file tree
Showing 35 changed files with 81 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from marionette import Actions
from errors import TimeoutException
from marionette_driver.marionette import Actions
from marionette_driver.errors import TimeoutException

def wait_for_condition_else_raise(marionette, wait_for_condition, expected, script):
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# 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 import HTMLElement
from marionette_test import MarionetteTestCase
from errors import NoSuchElementException
from expected import element_present
from wait import Wait

from marionette_driver.errors import NoSuchElementException
from marionette_driver.expected import element_present
from marionette_driver.marionette import HTMLElement
from marionette_driver.wait import Wait

class TestAnonymousContent(MarionetteTestCase):
def setUp(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#See the License for the specific language governing permissions and
#limitations under the License.

from application_cache import ApplicationCache
from marionette_driver.application_cache import ApplicationCache
from marionette_test import MarionetteTestCase


Expand All @@ -24,7 +24,7 @@ def testWeCanGetTheStatusOfTheAppCache(self):
self.marionette.navigate(test_url)
app_cache = self.marionette.application_cache

status = app_cache.status
status = app_cache.status
while status == ApplicationCache.DOWNLOADING:
status = app_cache.status

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_test import MarionetteTestCase
from errors import InvalidElementStateException
from marionette_driver.errors import InvalidElementStateException

class TestClear(MarionetteTestCase):
def testWriteableTextInputShouldClear(self):
Expand Down Expand Up @@ -56,7 +56,7 @@ def testContentEditableAreaShouldClear(self):
element = self.marionette.find_element("id","content-editable")
element.clear()
self.assertEqual("", element.text)

def testTextInputShouldNotClearWhenDisabled(self):
test_html = self.marionette.absolute_url("test_clearing.html")
self.marionette.navigate(test_html)
Expand Down
6 changes: 3 additions & 3 deletions testing/marionette/client/marionette/tests/unit/test_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# 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 by import By
from errors import NoSuchElementException, ElementNotVisibleException
from marionette_driver.by import By
from marionette_driver.errors import NoSuchElementException, ElementNotVisibleException
from marionette_test import MarionetteTestCase
from wait import Wait
from marionette_driver.wait import Wait


class TestClick(MarionetteTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_test import MarionetteTestCase
from by import By
from marionette_driver.by import By


class TestClickChrome(MarionetteTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# 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 by import By
from errors import MoveTargetOutOfBoundsException
from marionette_driver.by import By
from marionette_driver.errors import MoveTargetOutOfBoundsException
from marionette_test import MarionetteTestCase, skip


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from marionette_test import MarionetteTestCase
from datetime import datetime
from date_time_value import DateTimeValue
from marionette_driver.date_time_value import DateTimeValue

class TestDateTime(MarionetteTestCase):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

import sys

import errors
import marionette_test

from errors import ErrorCodes
from marionette_driver import errors
from marionette_driver.errors import ErrorCodes

def fake_cause():
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_test import MarionetteTestCase
from errors import JavascriptException, MarionetteException, ScriptTimeoutException
from marionette_driver.errors import ( JavascriptException,
MarionetteException,
ScriptTimeoutException )
import time


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_test import MarionetteTestCase, skip_if_b2g
from errors import JavascriptException, MarionetteException, ScriptTimeoutException
from marionette_driver.errors import (JavascriptException,
MarionetteException,
ScriptTimeoutException)

class TestExecuteIsolationContent(MarionetteTestCase):
def setUp(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import urllib

from by import By
from errors import JavascriptException, MarionetteException
from marionette_driver.by import By
from marionette_driver.errors import JavascriptException, MarionetteException
from marionette_test import MarionetteTestCase

def inline(doc):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

import urllib

import expected
from marionette_driver import expected
from marionette_driver.by import By

import marionette_test

from by import By

def inline(doc):
return "data:text/html;charset=utf-8,%s" % urllib.quote(doc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_test import MarionetteTestCase
from marionette import HTMLElement
from by import By
from errors import NoSuchElementException, InvalidSelectorException
from marionette_driver.marionette import HTMLElement
from marionette_driver.by import By
from marionette_driver.errors import NoSuchElementException, InvalidSelectorException


class TestElements(MarionetteTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_test import MarionetteTestCase
from marionette import HTMLElement
from by import By
from errors import NoSuchElementException
from marionette_driver.marionette import HTMLElement
from marionette_driver.by import By
from marionette_driver.errors import NoSuchElementException


class TestElementsChrome(MarionetteTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_test import MarionetteTestCase
from errors import NoSuchElementException
from marionette_driver.errors import NoSuchElementException

class TestImplicitWaits(MarionetteTestCase):
def testShouldImplicitlyWaitForASingleElement(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
from marionette_test import MarionetteTestCase
from errors import JavascriptException
from marionette_driver.errors import JavascriptException

class TestImportScript(MarionetteTestCase):
def setUp(self):
Expand All @@ -18,14 +18,14 @@ def clear_other_context(self):
def check_file_exists(self):
return self.marionette.execute_script("""
let FileUtils = SpecialPowers.Cu.import("resource://gre/modules/FileUtils.jsm", {}).FileUtils;
let importedScripts = FileUtils.getFile('TmpD', ['marionetteContentScripts']);
let importedScripts = FileUtils.getFile('TmpD', ['marionetteContentScripts']);
return importedScripts.exists();
""", special_powers=True)

def get_file_size(self):
return self.marionette.execute_script("""
let FileUtils = SpecialPowers.Cu.import("resource://gre/modules/FileUtils.jsm", {}).FileUtils;
let importedScripts = FileUtils.getFile('TmpD', ['marionetteContentScripts']);
let importedScripts = FileUtils.getFile('TmpD', ['marionetteContentScripts']);
return importedScripts.fileSize;
""", special_powers=True)

Expand Down Expand Up @@ -109,7 +109,7 @@ def test_importing_another_script_and_check_they_append(self):
self.marionette.import_script(firstjs)
self.marionette.import_script(secondjs)

self.assertEqual("i'm a test function!",
self.assertEqual("i'm a test function!",
self.marionette.execute_script("return testFunc();"))

self.assertEqual("i'm yet another test function!",
Expand All @@ -129,14 +129,14 @@ def clear_other_context(self):
def check_file_exists(self):
return self.marionette.execute_async_script("""
let FileUtils = Components.utils.import("resource://gre/modules/FileUtils.jsm", {}).FileUtils;
let importedScripts = FileUtils.getFile('TmpD', ['marionetteChromeScripts']);
let importedScripts = FileUtils.getFile('TmpD', ['marionetteChromeScripts']);
marionetteScriptFinished(importedScripts.exists());
""")

def get_file_size(self):
return self.marionette.execute_async_script("""
let FileUtils = Components.utils.import("resource://gre/modules/FileUtils.jsm", {}).FileUtils;
let importedScripts = FileUtils.getFile('TmpD', ['marionetteChromeScripts']);
let importedScripts = FileUtils.getFile('TmpD', ['marionetteChromeScripts']);
marionetteScriptFinished(importedScripts.fileSize);
""")

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# 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 errors import MarionetteException, TimeoutException
from marionette_test import MarionetteTestCase, skip_if_b2g, skip_if_e10s
from marionette_driver.errors import MarionetteException, TimeoutException

class TestNavigate(MarionetteTestCase):
def test_navigate(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import os
from errors import JavascriptException
from marionette_driver.errors import JavascriptException
from marionette_test import MarionetteTestCase

class TestLog(MarionetteTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 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 errors import MarionetteException
from marionette_driver.errors import MarionetteException
from marionette_test import MarionetteTestCase
from mozrunner.devices.emulator_screen import EmulatorScreen

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# 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 errors import MarionetteException
from marionette_driver.errors import MarionetteException
from marionette_test import MarionetteTestCase

class TestSetWindowSize(MarionetteTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_test import MarionetteTestCase
from errors import JavascriptException, MarionetteException, ScriptTimeoutException
from marionette_driver.errors import (JavascriptException,
MarionetteException,
ScriptTimeoutException)

class SimpletestSanityTest(MarionetteTestCase):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_test import MarionetteTestCase
from marionette import Actions
from errors import MarionetteException
from marionette_driver.marionette import Actions
from marionette_driver.errors import MarionetteException
#add this directory to the path
import os
import sys
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from marionette_test import MarionetteTestCase
from marionette import Actions
from errors import MarionetteException
from marionette_driver.marionette import Actions
from marionette_driver.errors import MarionetteException
#add this directory to the path
import os
import sys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_test import MarionetteTestCase
from errors import JavascriptException, MarionetteException
from marionette_driver.errors import JavascriptException, MarionetteException

class TestSpecialPowersContent(MarionetteTestCase):

Expand All @@ -15,7 +15,7 @@ def test_prefs(self):
SpecialPowers.setCharPref("%(pref)s", "%(value)s");
return SpecialPowers.getCharPref("%(pref)s")
""" % {'pref': self.testpref, 'value': self.testvalue}, special_powers=True);
self.assertEqual(result, self.testvalue)
self.assertEqual(result, self.testvalue)

def test_prefs_after_navigate(self):
test_html = self.marionette.absolute_url("test.html")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

import time

from by import By
from errors import NoSuchElementException
from marionette_driver.by import By
from marionette_driver.errors import NoSuchElementException
from marionette_driver.wait import Wait
from marionette_test import MarionetteTestCase
from wait import Wait


class TestSubmit(MarionetteTestCase):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_test import MarionetteTestCase
from errors import JavascriptException
from errors import NoSuchFrameException
from marionette_driver.errors import (JavascriptException,
NoSuchFrameException)


class TestSwitchFrame(MarionetteTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,3 @@ def test_stack_trace(self):
self.marionette.execute_async_script("foo();")
except JavascriptException as e:
self.assertIn("foo", e.msg)

def test_we_can_switch_to_a_browser_frame(self):
self.assertIn("test.xul", self.marionette.get_url(), "Initial navigation has failed")
browser = self.marionette.find_element(By.ID, 'aBrowser')
self.marionette.switch_to_frame(browser)
self.assertIn("test2.xul", self.marionette.get_url(), "Switching by element failed")
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_test import MarionetteTestCase
from keys import Keys
from marionette_driver.keys import Keys


class TestText(MarionetteTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

import os
from marionette_test import MarionetteTestCase
from marionette import HTMLElement
from errors import NoSuchElementException, JavascriptException, MarionetteException, ScriptTimeoutException
from marionette_driver.marionette import HTMLElement
from marionette_driver.errors import (NoSuchElementException,
JavascriptException,
MarionetteException,
ScriptTimeoutException)

class TestTimeouts(MarionetteTestCase):
def test_pagetimeout_notdefinetimeout_pass(self):
Expand Down
Loading

0 comments on commit 0aa761d

Please sign in to comment.