Bug 790787 - Enable more unit tests on B2G. r=mdas

This commit is contained in:
Jonathan Griffin 2013-08-06 17:34:30 -07:00
parent 9493cd9b02
commit 0c4337a6c0
13 changed files with 260 additions and 218 deletions

View File

@ -27,29 +27,3 @@ class TestClick(MarionetteTestCase):
self.fail("Element id=username not found after 30 seconds")
self.assertEqual(self.marionette.title, "XHTML Test Page")
class TestClickChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
self.marionette.switch_to_window('foo')
self.assertNotEqual(self.win, self.marionette.current_window_handle)
def tearDown(self):
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.marionette.execute_script("window.close();")
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def test_click(self):
wins = self.marionette.window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)
box = self.marionette.find_element(By.ID, "testBox")
self.assertFalse(self.marionette.execute_script("return arguments[0].checked;", [box]))
box.click()
self.assertTrue(self.marionette.execute_script("return arguments[0].checked;", [box]))

View File

@ -0,0 +1,32 @@
# 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_test import MarionetteTestCase
from by import By
class TestClickChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
self.marionette.switch_to_window('foo')
self.assertNotEqual(self.win, self.marionette.current_window_handle)
def tearDown(self):
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.marionette.execute_script("window.close();")
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def test_click(self):
wins = self.marionette.window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)
box = self.marionette.find_element(By.ID, "testBox")
self.assertFalse(self.marionette.execute_script("return arguments[0].checked;", [box]))
box.click()
self.assertTrue(self.marionette.execute_script("return arguments[0].checked;", [box]))

View File

@ -2,9 +2,9 @@
# 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/.
import os
from marionette_test import MarionetteTestCase
class TestState(MarionetteTestCase):
def test_isEnabled(self):
test_html = self.marionette.absolute_url("test.html")
@ -21,34 +21,3 @@ class TestState(MarionetteTestCase):
self.assertTrue(l.is_displayed())
self.marionette.execute_script("arguments[0].hidden = true;", [l])
self.assertFalse(l.is_displayed())
class TestStateChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
self.marionette.switch_to_window('foo')
self.assertNotEqual(self.win, self.marionette.current_window_handle)
def tearDown(self):
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.marionette.execute_script("window.close();")
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def test_isEnabled(self):
l = self.marionette.find_element("id", "textInput")
self.assertTrue(l.is_enabled())
self.marionette.execute_script("arguments[0].disabled = true;", [l])
self.assertFalse(l.is_enabled())
self.marionette.execute_script("arguments[0].disabled = false;", [l])
''' Switched on in Bug 896043 to be turned on in Bug 896046
def test_isDisplayed(self):
l = self.marionette.find_element("id", "textInput")
self.assertTrue(l.is_displayed())
self.marionette.execute_script("arguments[0].hidden = true;", [l])
self.assertFalse(l.is_displayed())
self.marionette.execute_script("arguments[0].hidden = false;", [l])
'''

View File

@ -0,0 +1,37 @@
# 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_test import MarionetteTestCase
class TestStateChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
self.marionette.switch_to_window('foo')
self.assertNotEqual(self.win, self.marionette.current_window_handle)
def tearDown(self):
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.marionette.execute_script("window.close();")
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def test_isEnabled(self):
l = self.marionette.find_element("id", "textInput")
self.assertTrue(l.is_enabled())
self.marionette.execute_script("arguments[0].disabled = true;", [l])
self.assertFalse(l.is_enabled())
self.marionette.execute_script("arguments[0].disabled = false;", [l])
''' Switched on in Bug 896043 to be turned on in Bug 896046
def test_isDisplayed(self):
l = self.marionette.find_element("id", "textInput")
self.assertTrue(l.is_displayed())
self.marionette.execute_script("arguments[0].hidden = true;", [l])
self.assertFalse(l.is_displayed())
self.marionette.execute_script("arguments[0].hidden = false;", [l])
'''

View File

@ -2,7 +2,6 @@
# 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/.
import os
from marionette_test import MarionetteTestCase
from marionette import HTMLElement
from by import By
@ -145,70 +144,3 @@ class TestElements(MarionetteTestCase):
fbody = self.marionette.find_element(By.TAG_NAME, 'body')
abody = self.marionette.get_active_element()
self.assertEqual(fbody, abody)
class TestElementsChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
self.marionette.switch_to_window('foo')
self.assertNotEqual(self.win, self.marionette.current_window_handle)
def tearDown(self):
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.marionette.execute_script("window.close();")
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def test_id(self):
el = self.marionette.execute_script("return window.document.getElementById('textInput');")
found_el = self.marionette.find_element(By.ID, "textInput")
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(el, found_el)
def test_child_element(self):
el = self.marionette.find_element(By.ID, "textInput")
parent = self.marionette.find_element(By.ID, "things")
found_el = parent.find_element(By.TAG_NAME, "textbox")
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(el, found_el)
def test_child_elements(self):
el = self.marionette.find_element(By.ID, "textInput3")
parent = self.marionette.find_element(By.ID, "things")
found_els = parent.find_elements(By.TAG_NAME, "textbox")
self.assertTrue(el.id in [found_el.id for found_el in found_els])
def test_tag_name(self):
el = self.marionette.execute_script("return window.document.getElementsByTagName('vbox')[0];")
found_el = self.marionette.find_element(By.TAG_NAME, "vbox")
self.assertEquals('vbox', found_el.tag_name)
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(el, found_el)
def test_class_name(self):
el = self.marionette.execute_script("return window.document.getElementsByClassName('asdf')[0];")
found_el = self.marionette.find_element(By.CLASS_NAME, "asdf")
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(el, found_el)
def test_xpath(self):
el = self.marionette.execute_script("return window.document.getElementById('testBox');")
found_el = self.marionette.find_element(By.XPATH, "id('testBox')")
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(el, found_el)
def test_not_found(self):
self.marionette.set_search_timeout(1000)
self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "I'm not on the page")
self.marionette.set_search_timeout(0)
self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "I'm not on the page")
def test_timeout(self):
self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "myid")
self.assertTrue(True, self.marionette.set_search_timeout(4000))
self.marionette.execute_script("window.setTimeout(function() {var b = window.document.createElement('button'); b.id = 'myid'; document.getElementById('things').appendChild(b);}, 1000)")
self.assertEqual(HTMLElement, type(self.marionette.find_element(By.ID, "myid")))
self.marionette.execute_script("window.document.getElementById('things').removeChild(window.document.getElementById('myid'));")

View File

@ -0,0 +1,75 @@
# 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_test import MarionetteTestCase
from marionette import HTMLElement
from by import By
from errors import NoSuchElementException
class TestElementsChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
self.marionette.switch_to_window('foo')
self.assertNotEqual(self.win, self.marionette.current_window_handle)
def tearDown(self):
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.marionette.execute_script("window.close();")
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def test_id(self):
el = self.marionette.execute_script("return window.document.getElementById('textInput');")
found_el = self.marionette.find_element(By.ID, "textInput")
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(el, found_el)
def test_child_element(self):
el = self.marionette.find_element(By.ID, "textInput")
parent = self.marionette.find_element(By.ID, "things")
found_el = parent.find_element(By.TAG_NAME, "textbox")
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(el, found_el)
def test_child_elements(self):
el = self.marionette.find_element(By.ID, "textInput3")
parent = self.marionette.find_element(By.ID, "things")
found_els = parent.find_elements(By.TAG_NAME, "textbox")
self.assertTrue(el.id in [found_el.id for found_el in found_els])
def test_tag_name(self):
el = self.marionette.execute_script("return window.document.getElementsByTagName('vbox')[0];")
found_el = self.marionette.find_element(By.TAG_NAME, "vbox")
self.assertEquals('vbox', found_el.tag_name)
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(el, found_el)
def test_class_name(self):
el = self.marionette.execute_script("return window.document.getElementsByClassName('asdf')[0];")
found_el = self.marionette.find_element(By.CLASS_NAME, "asdf")
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(el, found_el)
def test_xpath(self):
el = self.marionette.execute_script("return window.document.getElementById('testBox');")
found_el = self.marionette.find_element(By.XPATH, "id('testBox')")
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(el, found_el)
def test_not_found(self):
self.marionette.set_search_timeout(1000)
self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "I'm not on the page")
self.marionette.set_search_timeout(0)
self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "I'm not on the page")
def test_timeout(self):
self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "myid")
self.assertTrue(True, self.marionette.set_search_timeout(4000))
self.marionette.execute_script("window.setTimeout(function() {var b = window.document.createElement('button'); b.id = 'myid'; document.getElementById('things').appendChild(b);}, 1000)")
self.assertEqual(HTMLElement, type(self.marionette.find_element(By.ID, "myid")))
self.marionette.execute_script("window.document.getElementById('things').removeChild(window.document.getElementById('myid'));")

View File

@ -2,32 +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/.
import os
from marionette_test import MarionetteTestCase
class TestGetAttribute(MarionetteTestCase):
def test_getAttribute(self):
test_html = self.marionette.absolute_url("test.html")
self.marionette.navigate(test_html)
l = self.marionette.find_element("id", "mozLink")
self.assertEqual("mozLink", l.get_attribute("id"))
class TestGetAttributeChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
self.marionette.switch_to_window('foo')
self.assertNotEqual(self.win, self.marionette.current_window_handle)
def tearDown(self):
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.marionette.execute_script("window.close();")
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def test_getAttribute(self):
el = self.marionette.execute_script("return window.document.getElementById('textInput');")
self.assertEqual(el.get_attribute("id"), "textInput")

View File

@ -0,0 +1,26 @@
# 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_test import MarionetteTestCase
class TestGetAttributeChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
self.marionette.switch_to_window('foo')
self.assertNotEqual(self.win, self.marionette.current_window_handle)
def tearDown(self):
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.marionette.execute_script("window.close();")
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def test_getAttribute(self):
el = self.marionette.execute_script("return window.document.getElementById('textInput');")
self.assertEqual(el.get_attribute("id"), "textInput")

View File

@ -2,9 +2,9 @@
# 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/.
import os
from marionette_test import MarionetteTestCase
class TestSelected(MarionetteTestCase):
def test_selected(self):
test_html = self.marionette.absolute_url("test.html")
@ -13,25 +13,3 @@ class TestSelected(MarionetteTestCase):
self.assertFalse(box.is_selected())
box.click()
self.assertTrue(box.is_selected())
class TestSelectedChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', '_blank', 'chrome,centerscreen');")
def tearDown(self):
self.marionette.execute_script("window.close();")
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def test_selected(self):
wins = self.marionette.window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)
box = self.marionette.find_element("id", "testBox")
self.assertFalse(box.is_selected())
self.assertFalse(self.marionette.execute_script("arguments[0].checked = true;", [box]))
self.assertTrue(box.is_selected())

View File

@ -0,0 +1,28 @@
# 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_test import MarionetteTestCase
class TestSelectedChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', '_blank', 'chrome,centerscreen');")
def tearDown(self):
self.marionette.execute_script("window.close();")
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def test_selected(self):
wins = self.marionette.window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)
box = self.marionette.find_element("id", "testBox")
self.assertFalse(box.is_selected())
self.assertFalse(self.marionette.execute_script("arguments[0].checked = true;", [box]))
self.assertTrue(box.is_selected())

View File

@ -2,9 +2,9 @@
# 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/.
import os
from marionette_test import MarionetteTestCase
class TestText(MarionetteTestCase):
def test_getText(self):
test_html = self.marionette.absolute_url("test.html")
@ -27,48 +27,3 @@ class TestText(MarionetteTestCase):
self.assertEqual("asdf", self.marionette.execute_script("return arguments[0].value;", [l]))
l.send_keys("o")
self.assertEqual("asdfo", self.marionette.execute_script("return arguments[0].value;", [l]))
''' Disabled in bug 896043 and when working on Chrome code re-enable for bug 896046
class TestTextChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
self.marionette.switch_to_window('foo')
self.assertNotEqual(self.win, self.marionette.current_window_handle)
def tearDown(self):
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.marionette.execute_script("window.close();")
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def test_getText(self):
wins = self.marionette.window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)
box = self.marionette.find_element("id", "textInput")
self.assertEqual("test", box.text)
def test_clearText(self):
wins = self.marionette.window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)
box = self.marionette.find_element("id", "textInput")
self.assertEqual("test", box.text)
box.clear()
self.assertEqual("", box.text)
def test_sendKeys(self):
wins = self.marionette.window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)
box = self.marionette.find_element("id", "textInput")
self.assertEqual("test", box.text)
box.send_keys("at")
self.assertEqual("attest", box.text)
'''

View File

@ -0,0 +1,51 @@
# 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_test import MarionetteTestCase
''' Disabled in bug 896043 and when working on Chrome code re-enable for bug 896046
class TestTextChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
self.marionette.switch_to_window('foo')
self.assertNotEqual(self.win, self.marionette.current_window_handle)
def tearDown(self):
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.marionette.execute_script("window.close();")
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def test_getText(self):
wins = self.marionette.window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)
box = self.marionette.find_element("id", "textInput")
self.assertEqual("test", box.text)
def test_clearText(self):
wins = self.marionette.window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)
box = self.marionette.find_element("id", "textInput")
self.assertEqual("test", box.text)
box.clear()
self.assertEqual("", box.text)
def test_sendKeys(self):
wins = self.marionette.window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)
box = self.marionette.find_element("id", "textInput")
self.assertEqual("test", box.text)
box.send_keys("at")
self.assertEqual("attest", box.text)
'''

View File

@ -16,15 +16,20 @@ skip = false
[test_import_script_content.py.py]
b2g = false
[test_click.py]
[test_click_chrome.py]
b2g = false
[test_selected.py]
[test_selected_chrome.py]
b2g = false
[test_getattr.py]
[test_getattr_chrome.py]
b2g = false
[test_elementState.py]
[test_elementState_chrome.py]
b2g = false
[test_text.py]
b2g = false
[test_text_chrome.py]
disabled = "Bug 896046"
[test_log.py]
[test_emulator.py]
@ -35,13 +40,13 @@ qemu = true
[test_execute_script.py]
[test_simpletest_fail.js]
[test_findelement.py]
[test_findelement_chrome.py]
b2g = false
[test_navigation.py]
b2g = false
[test_timeouts.py]
b2g = false
[test_element_touch.py]
b2g = true