From 9e8ff243db03d8c9fd284e2a7cff718da0be7456 Mon Sep 17 00:00:00 2001 From: Kevin Grandon Date: Mon, 13 Oct 2014 21:21:48 -0700 Subject: [PATCH] Bug 1082329 - Remove unused tests in the tests/ directory r=etienne --- tests/browser_a_test_framework.js | 7 - tests/browser_all_apps.js | 21 -- tests/browser_clock_stopwatch.js | 36 --- tests/browser_clock_timer.js | 54 ---- tests/browser_desktop_notifications.js | 55 ---- tests/browser_dialer_call_from_contacts.js | 40 --- tests/browser_dialer_contact_intent.js | 31 --- tests/browser_dialer_contacts_edition.js | 122 --------- tests/browser_dialer_contacts_search.js | 57 ---- tests/browser_dialer_history.js | 75 ----- tests/browser_dialer_keypad_and_dial.js | 50 ---- .../browser_dialer_phone_number_sanitizing.js | 19 -- tests/browser_sms_conversation.js | 54 ---- tests/browser_sms_new.js | 42 --- tests/head.js | 258 ------------------ tests/perf/app_perf.py | 30 -- tests/perf/perf.ini | 11 - 17 files changed, 962 deletions(-) delete mode 100644 tests/browser_a_test_framework.js delete mode 100644 tests/browser_all_apps.js delete mode 100644 tests/browser_clock_stopwatch.js delete mode 100644 tests/browser_clock_timer.js delete mode 100644 tests/browser_desktop_notifications.js delete mode 100644 tests/browser_dialer_call_from_contacts.js delete mode 100644 tests/browser_dialer_contact_intent.js delete mode 100644 tests/browser_dialer_contacts_edition.js delete mode 100644 tests/browser_dialer_contacts_search.js delete mode 100644 tests/browser_dialer_history.js delete mode 100644 tests/browser_dialer_keypad_and_dial.js delete mode 100644 tests/browser_dialer_phone_number_sanitizing.js delete mode 100644 tests/browser_sms_conversation.js delete mode 100644 tests/browser_sms_new.js delete mode 100644 tests/head.js delete mode 100644 tests/perf/app_perf.py delete mode 100644 tests/perf/perf.ini diff --git a/tests/browser_a_test_framework.js b/tests/browser_a_test_framework.js deleted file mode 100644 index bf0d1843222d..000000000000 --- a/tests/browser_a_test_framework.js +++ /dev/null @@ -1,7 +0,0 @@ -function generatorTest() { - yield testApp('http://dialer.gaiamobile.org/', function(window, document, nextStep) { - ok(window.document === document, 'window and document are related'); - ok(document.readyState === 'complete', 'document fully loaded'); - ok(typeof nextStep === 'function', 'nextStep func is okay'); - }); -} diff --git a/tests/browser_all_apps.js b/tests/browser_all_apps.js deleted file mode 100644 index 28f6dd0d089e..000000000000 --- a/tests/browser_all_apps.js +++ /dev/null @@ -1,21 +0,0 @@ -function generatorTest() { - requestLongerTimeout(3); // We may need > 60s to open and close all apps - - // Wait until the content document is ready - yield until( - function() content.wrappedJSObject.document.readyState === 'complete', - nextStep); - - // Find all the icons on the homescreen - let contentWin = content.wrappedJSObject; - let contentDoc = contentWin.document; - let icons = contentDoc.querySelectorAll('#apps > .page > .icon'); - - // Loop through them all and launch and then kill each of the apps - for (let i = 0; i < icons.length; i++) { - let url = icons[i].dataset.url; - yield testApp(url, function(window, document, nextStep) { - ok(document, 'app launched from ' + url); - }); - } -} diff --git a/tests/browser_clock_stopwatch.js b/tests/browser_clock_stopwatch.js deleted file mode 100644 index e7e8c52ba02a..000000000000 --- a/tests/browser_clock_stopwatch.js +++ /dev/null @@ -1,36 +0,0 @@ -function generatorTest() { - waitForExplicitFinish(); - yield testApp('http://clock.gaiamobile.org/', testStopwatch); - finish(); -} - -function testStopwatch(window, document, nextStep) { - var stopWatch = window.StopWatch; - var actionButton = document.getElementById('stopwatch-action-button'); - var tickerView = document.getElementById('stopwatch-ticker-view'); - - // start the stopwatch - EventUtils.sendMouseEvent({type: 'click'}, actionButton); - yield setTimeout(nextStep, 100); - - ok(actionButton.dataset.action == 'stop', 'Stop button present'); - ok(tickerView.classList.contains('running'), 'Animation running'); - isnot(stopWatch._startTime, undefined, 'Start time set'); - isnot(stopWatch._ticker, undefined, 'Ticker running'); - - // stop the stopwatch - EventUtils.sendMouseEvent({type: 'click'}, actionButton); - yield setTimeout(nextStep, 100); - - ok(actionButton.dataset.action == 'start', 'Start button present'); - ok(!tickerView.classList.contains('running'), 'Animation stoped'); - isnot(stopWatch._elasped, 0, 'Elapsed time kept'); - is(stopWatch._ticker, undefined, 'Ticker cleared'); - is(stopWatch._startTime, undefined, 'Start time deleted'); - - // reset the stopwatch - EventUtils.sendMouseEvent({type: 'click'}, - document.getElementById('reset-button')); - yield setTimeout(nextStep, 100); - is(stopWatch._elapsed, 0, 'Elapsed time reset'); -} diff --git a/tests/browser_clock_timer.js b/tests/browser_clock_timer.js deleted file mode 100644 index cfe2692528b6..000000000000 --- a/tests/browser_clock_timer.js +++ /dev/null @@ -1,54 +0,0 @@ -function generatorTest() { - waitForExplicitFinish(); - yield testApp('http://clock.gaiamobile.org/', testTimer); - finish(); -} - -function testTimer(window, document, nextStep) { - var timer = window.Timer; - var actionButton = document.getElementById('timer-action-button'); - ok(actionButton !== null, 'action button defined'); - var durationField = document.getElementById('duration-field'); - ok(durationField !== null, 'duration field defined'); - var tickerView = document.getElementById('timer-ticker-view'); - var chronoView = document.getElementById('timer-chrono-view'); - - // start the timer - EventUtils.sendMouseEvent({type: 'click'}, actionButton); - yield setTimeout(nextStep, 100); - - ok(actionButton.dataset.action == 'cancel', 'Cancel button present'); - ok(tickerView.classList.contains('running'), 'Timer animation running'); - ok(chronoView.innerHTML != '00:00', 'End time set'); - isnot(timer._ticker, undefined, 'Ticker running'); - ok(durationField.disabled, 'Duration is not editable'); - - // cancel the timer - EventUtils.sendMouseEvent({type: 'click'}, actionButton); - yield setTimeout(nextStep, 100); - - ok(actionButton.dataset.action == 'start', 'Start button present'); - ok(!tickerView.classList.contains('running'), 'Timer animation stoped'); - is(timer._ticker, undefined, 'Ticker cleared'); - ok(chronoView.innerHTML == '00:00', 'End time not displayed'); - ok(!durationField.disabled, 'Duration is editable'); - - // timer duration parsing - ok(timer.duration('4') == 4000, 'Seconds are parsed correctly'); - ok(timer.duration('01:02') == 62000, 'Minutes are parsed correctly'); - ok(timer.duration('01:01:02') == 3662000, 'Hours are parsed correctly'); - - // timer duration validation - durationField.value = 'af02'; - ok(!durationField.validity.valid, 'Duration pattern invalid'); - durationField.value = '04:04'; - ok(durationField.validity.valid, 'Duration pattern valid'); - durationField.value = '01:04:04'; - ok(durationField.validity.valid, 'Duration pattern with hours valid'); - - // timer end - EventUtils.sendMouseEvent({type: 'click'}, actionButton); - timer.end(); - ok(chronoView.parentNode.classList.contains('ended'), - 'Ended style on chrono view'); -} diff --git a/tests/browser_desktop_notifications.js b/tests/browser_desktop_notifications.js deleted file mode 100644 index a81167e695e5..000000000000 --- a/tests/browser_desktop_notifications.js +++ /dev/null @@ -1,55 +0,0 @@ -function generatorTest() { - waitForExplicitFinish(); - yield testApp('http://dialer.gaiamobile.org', testDesktopNotifications); - finish(); -} - -function testDesktopNotifications(window, document, nextStep) { - let homescreenWin = content.wrappedJSObject; - - // Creating a desktop-notification - var notification = window.navigator.mozNotification.createNotification( - 'Missed call', 'From 424242' - ); - - var clickedCalled = false; - notification.onclick = function test_notificationClick() { - clickedCalled = true; - }; - - // Checking if the notifications was displayed - notification.show(); - var notificationsContainer = homescreenWin.NotificationScreen.container; - yield until(function () {return notificationsContainer.children.length > 0;}, nextStep); - ok(true, 'Notification was displayed'); - - var hasNotifications = homescreenWin.document.getElementById('state-notifications'); - ok(hasNotifications.dataset.visible == 'true', 'Indicator displayed'); - - // Testing the 'click' on a notification - var notificationElement = notificationsContainer.children[0]; - EventUtils.sendMouseEvent({type: 'click'}, notificationElement); - yield until(function() clickedCalled, nextStep); - ok(true, 'Clicked callback was called'); - ok(notificationsContainer.children.length == 0, 'Notification removed'); - ok(!hasNotifications.dataset.visible, 'Indicator removed'); - - // Testing the 'close' on a notification - var otherNotification = window.navigator.mozNotification.createNotification( - 'Missed call', 'From 12345' - ); - - var closedCalled = false; - otherNotification.onclose = function test_notificationClose() { - closedCalled = true; - }; - - otherNotification.show(); - yield until(function () {return notificationsContainer.children.length > 0;}, nextStep); - - var notificationClose = notificationsContainer.children[0].querySelector('.close'); - EventUtils.sendMouseEvent({type: 'click'}, notificationClose); - yield until(function() closedCalled, nextStep); - ok(true, 'Closed callback was called'); - ok(notificationsContainer.children.length == 0, 'Notification removed'); -} diff --git a/tests/browser_dialer_call_from_contacts.js b/tests/browser_dialer_call_from_contacts.js deleted file mode 100644 index 3b82344b2205..000000000000 --- a/tests/browser_dialer_call_from_contacts.js +++ /dev/null @@ -1,40 +0,0 @@ -function generatorTest() { - // Create a test contact - var testContact = new mozContact({ - givenName: ['Tom'], - familyName: ['Testing'], - name: ['Tom Testing'], - tel: [{value:'123-456-789'}] - }); - - yield navigator.mozContacts.save(testContact).onsuccess = nextStep; - yield testApp('http://dialer.gaiamobile.org/', testCallFromContacts); - yield navigator.mozContacts.remove(testContact).onsuccess = nextStep; -} - -function testCallFromContacts(window, document, nextStep) { - var keyboardTab = document.getElementById('keyboard-label'); - EventUtils.sendMouseEvent({type: 'click'}, keyboardTab); - - var contactTab = document.getElementById('contacts-label'); - EventUtils.sendMouseEvent({type: 'click'}, contactTab); - - ok(!document.getElementById('contacts-view').hidden, - 'Contact view displayed'); - - // Wait for at least one contact to be displayed - var contactsList = document.getElementById('contacts-container'); - yield until(function() contactsList.querySelector('.contact'), nextStep); - - var aContact = contactsList.querySelector('.contact'); - var overlay = window.ContactDetails.overlay; - EventUtils.sendMouseEvent({type: 'click'}, aContact); - yield until(function() overlay.classList.contains('displayed'), nextStep); - ok(overlay.classList.contains('displayed'), 'Overlay view displayed'); - - var number = window.ContactDetails.contactPhone; - var callScreen = window.CallHandler.callScreen; - EventUtils.sendMouseEvent({type: 'click'}, number); - yield until(function() callScreen.classList.contains('oncall'), nextStep); - ok(callScreen.classList.contains('oncall'), 'CallScreen displayed'); -} diff --git a/tests/browser_dialer_contact_intent.js b/tests/browser_dialer_contact_intent.js deleted file mode 100644 index 6d94bd9e0596..000000000000 --- a/tests/browser_dialer_contact_intent.js +++ /dev/null @@ -1,31 +0,0 @@ -function generatorTest() { - // creating a contact - var testContact = new mozContact({ - givenName: ['Andreas'], - familyName: ['Gal'], - name: ['Andreas Gal'] - }); - yield navigator.mozContacts.save(testContact).onsuccess = nextStep; - - yield testApp('http://dialer.gaiamobile.org/', testContactIntent); - - yield navigator.mozContacts.remove(testContact).onsuccess = nextStep; -} - -function testContactIntent(window, document, nextStep) { - var fakeEvt = { - data: { - hidden: false - } - }; - window.visibilityChanged('http://dialer.gaiamobile.org/index.html?choice=contact', fakeEvt); - - ok(!document.getElementById('contacts-view').hidden, - 'Contact view displayed'); - - yield until(function() window.Contacts && window.Contacts._loaded, nextStep); - - var containerId = 'contacts-container'; - var container = document.getElementById(containerId); - ok(container.children.length > 0, 'Contacts displayed'); -} diff --git a/tests/browser_dialer_contacts_edition.js b/tests/browser_dialer_contacts_edition.js deleted file mode 100644 index a66f61f64eec..000000000000 --- a/tests/browser_dialer_contacts_edition.js +++ /dev/null @@ -1,122 +0,0 @@ -function generatorTest() { - // Launch the dialer app - yield testApp('http://dialer.gaiamobile.org/', testContactsEdition); -} - -function testContactsEdition(window, document, nextStep) { - var contactTab = document.getElementById('contacts-label'); - EventUtils.sendMouseEvent({type: 'click'}, contactTab); - - // Waiting until the contacts are loaded - yield until(function() window.Contacts && window.Contacts._loaded, nextStep); - - var details = window.ContactDetails; - var contacts = window.Contacts; - var overlay = details.overlay; - - // -- Creating a contact - var addButton = document.getElementById('contact-add'); - overlay.addEventListener('transitionend', function trWait() { - overlay.removeEventListener('transitionend', trWait); - nextStep(); - }); - yield EventUtils.sendMouseEvent({type: 'click'}, addButton); - - var testNumber = '321-123-4242'; - - // Filling the form - details.contactGivenNameField.value = 'John'; - details.contactFamilyNameField.value = 'Appleseed'; - details.contactPhoneField.value = testNumber; - details.contactEmailField.value = 'john@appleseed.com'; - - // Saving the new contact - var submitButton = details.view.querySelector('input[type="submit"]'); - EventUtils.sendMouseEvent({type: 'click'}, submitButton); - - yield until(function() !details.view.classList.contains('editing'), nextStep); - - // Closing the modal view - overlay.addEventListener('transitionend', function trWait() { - overlay.removeEventListener('transitionend', trWait); - nextStep(); - }); - yield EventUtils.sendKey('ESCAPE', window); - - // Looking up the new contact in the mozContacts DB - var foundContact; - yield contacts.findByNumber(testNumber, function(contact) { - foundContact = contact; - nextStep(); - }); - - var contactId = foundContact.id; - var entry = document.getElementById(contactId); - ok(entry != null, 'Entry for the contact created'); - ok(foundContact.name == 'John Appleseed', 'The contact name was set'); - - - // Showing the contact details - overlay.addEventListener('transitionend', function trWait() { - overlay.removeEventListener('transitionend', trWait); - nextStep(); - }); - yield EventUtils.sendMouseEvent({type: 'click'}, entry); - - // -- Editing the new contact - var editSelector = 'button[data-action="edit"]'; - var editButton = details.view.querySelector(editSelector); - EventUtils.sendMouseEvent({type: 'click'}, editButton); - - ok(details.view.classList.contains('editing'), - 'In editing mode'); - - var newNumber = '0112345678'; - details.contactPhoneField.value = newNumber; - - // Saving the changes - EventUtils.sendMouseEvent({type: 'click'}, submitButton); - yield until(function() !details.view.classList.contains('editing'), nextStep); - - // Closing the modal view - overlay.addEventListener('transitionend', function trWait() { - overlay.removeEventListener('transitionend', trWait); - nextStep(); - }); - yield EventUtils.sendKey('ESCAPE', window); - - // Looking up the contact with the new number - yield contacts.findByNumber(newNumber, function(contact) { - foundContact = contact; - nextStep(); - }); - - ok(foundContact.id == contactId, 'Contact has been updated'); - - // -- Deleting the contact - entry = document.getElementById(contactId); - overlay.addEventListener('transitionend', function trWait() { - overlay.removeEventListener('transitionend', trWait); - nextStep(); - }); - yield EventUtils.sendMouseEvent({type: 'click'}, entry); - - // Entering edit mode - EventUtils.sendMouseEvent({type: 'click'}, editButton); - - var deleteSelector = 'button[data-action="destroy"]'; - var deleteButton = details.view.querySelector(deleteSelector); - - // Calling the delete action - overlay.addEventListener('transitionend', function trWait() { - overlay.removeEventListener('transitionend', trWait); - nextStep(); - }); - yield EventUtils.sendMouseEvent({type: 'click'}, deleteButton); - - ok(!details.view.classList.contains('editing'), - 'Out of editing mode'); - - entry = window.document.getElementById(contactId); - ok(entry == null, 'Entry for the contact removed'); -} diff --git a/tests/browser_dialer_contacts_search.js b/tests/browser_dialer_contacts_search.js deleted file mode 100644 index dbc9f4c1a1d3..000000000000 --- a/tests/browser_dialer_contacts_search.js +++ /dev/null @@ -1,57 +0,0 @@ -function generatorTest() { - // Add a new contact to the database - var testContact = new mozContact({ - givenName: ['Kennedy'], - familyName: ['Cooley'], - name: ['Kennedy Cooley'] - }); - - // Save the contact, and yield until the save is done - yield navigator.mozContacts.save(testContact).onsuccess = nextStep; - - // Launch the dialer app - yield testApp('http://dialer.gaiamobile.org/', testContactsSearch); - - // Remove the contact - navigator.mozContacts.remove(testContact); -} - -function testContactsSearch(window, document, nextStep) { - // Click on the contacts tab of the dialer - var contactTab = document.getElementById('contacts-label'); - EventUtils.sendMouseEvent({type: 'click'}, contactTab); - - // And wait until the app API is ready - yield until(function() window.Contacts && window.Contacts._loaded, nextStep); - - var contactsView = document.getElementById('contacts-view'); - var displayedContacts = contactsView.querySelectorAll('.contact'); - var contactElement = null; - for (var i = 0; i < displayedContacts.length; i++) { - if (displayedContacts[i].textContent == 'Kennedy Cooley') { - contactElement = displayedContacts[i]; - break; - } - } - ok(contactElement != null, 'Test contact displayed at first'); - - // focus the search field and wait until it actually has focus - var searchField = document.getElementById('contacts-search'); - searchField.focus(); - yield until(function() document.activeElement === searchField, nextStep); - - searchField.value = ''; - EventUtils.sendString('aaar'); - ok(contactElement.hidden, 'Test contact hidden when no match'); - - searchField.value = ''; - EventUtils.sendString('coo'); - ok(!contactElement.hidden, - 'Test contact displayed when matching on family name'); - - searchField.value = ''; - EventUtils.sendString('enn'); - ok(!contactElement.hidden, - 'Test contact displayed when matching on given name'); - -} diff --git a/tests/browser_dialer_history.js b/tests/browser_dialer_history.js deleted file mode 100644 index 3c1a4a273293..000000000000 --- a/tests/browser_dialer_history.js +++ /dev/null @@ -1,75 +0,0 @@ -function generatorTest() { - yield testApp('http://dialer.gaiamobile.org/', testDialerHistory); -} - -function testDialerHistory(window, document, nextStep) { - // simulating one outgoing call and one incoming call - - // Wait for the APIs we use in the test - yield until(function() window.Recents && window.CallHandler, nextStep); - - var initialHistory = null; - yield window.Recents.history(function(history) { - initialHistory = history; - nextStep(); - }); - - var initialCount = initialHistory.length; - var callScreen = window.CallHandler.callScreen; - - // Start a call and wait for the screen to settle down - window.CallHandler.call('42424242'); - yield callScreen.addEventListener('transitionend', function trWait() { - callScreen.removeEventListener('transitionend', trWait); - nextStep(); - }); - - // End the call and wait for the screen to settle down - window.CallHandler.end(); - window.CallHandler.disconnected(); - yield callScreen.addEventListener('transitionend', function trWait() { - callScreen.removeEventListener('transitionend', trWait); - nextStep(); - }); - - - var fakeCall = { - addEventListener: function() {}, - answer: function() {}, - hangUp: function() {}, - removeEventListener: function() {}, - state: 'dialing', - number: '123-4242-4242' - }; - - // Fake an incoming call, and wait for the transition - window.CallHandler.incoming(fakeCall); - yield callScreen.addEventListener('transitionend', function trWait() { - callScreen.removeEventListener('transitionend', trWait); - nextStep(); - }); - - window.CallHandler.answer(); - window.CallHandler.connected(); - window.CallHandler.end(); - window.CallHandler.disconnected(); - - // Get the history again and test that two calls have been added - yield window.Recents.history(function(history) { - ok(history.length == (initialCount + 2), - 'Calls added to recents history'); - nextStep(); - }); - - // Wait for those calls to be added to the document, too - var recentsView = document.getElementById('recents-view'); - yield until(function() { - return recentsView.querySelectorAll('.recent').length == initialCount + 2; - }, nextStep); - - var recents = recentsView.querySelectorAll('.recent'); - ok(recents[0].classList.contains('incoming-connected'), - 'Incoming call displayed'); - ok(recents[1].classList.contains('outgoing-refused'), - 'Outgoing call displayed'); -} diff --git a/tests/browser_dialer_keypad_and_dial.js b/tests/browser_dialer_keypad_and_dial.js deleted file mode 100644 index 3ecb21711024..000000000000 --- a/tests/browser_dialer_keypad_and_dial.js +++ /dev/null @@ -1,50 +0,0 @@ -function generatorTest() { - waitForExplicitFinish(); - yield testApp('http://dialer.gaiamobile.org/', testDialerKeypad); - finish(); -} - -function testDialerKeypad(window, document, nextStep) { - function pressKey(button) { - var selector = '.keyboard-key[data-value="' + button + '"]'; - var key = document.querySelector(selector); - EventUtils.sendMouseEvent({type: 'mousedown'}, key); - } - - //declare each of the keys - function dialNumeric(sequence) { - for (var i = 0; i < sequence.length; i++) { - pressKey(sequence[i]); - } - } - - var keyCall = document.querySelector('.keyboard-key[data-value="call"]'); - var keyEnd = document.getElementById('end-call'); - - // Having declared the keys, enter the number "15555215556" - dialNumeric('15555215556'); - - // Verify the phone number view contains the correct number - ok(document.getElementById('phone-number-view').textContent == '15555215556', - 'Phone number view updated'); - - - //dial the number - EventUtils.sendMouseEvent({type: 'click'}, keyCall); - - var callScreen = window.CallHandler.callScreen; - - // Wait until the call screen appears - yield until(function() callScreen.classList.contains('oncall'), nextStep); - ok(callScreen.classList.contains('oncall'), 'CallScreen displayed'); - - //hit 'end-call' button to end the call - EventUtils.sendMouseEvent({type: 'click'}, keyEnd); - - // simulating the end of the call - window.CallHandler.disconnected(); - - // Wait for the call screen to be hidden - yield until(function() !callScreen.classList.contains('oncall'), nextStep); - ok(!callScreen.classList.contains('oncall'), 'CallScreen hidden'); -} diff --git a/tests/browser_dialer_phone_number_sanitizing.js b/tests/browser_dialer_phone_number_sanitizing.js deleted file mode 100644 index bcb01632fa21..000000000000 --- a/tests/browser_dialer_phone_number_sanitizing.js +++ /dev/null @@ -1,19 +0,0 @@ -function generatorTest() { - waitForExplicitFinish(); - yield testApp('http://dialer.gaiamobile.org/', testDialerSanitizing); - finish(); -} - -function testDialerSanitizing(window, document, nextStep) { - - window.navigator.mozTelephony.dial = function fake_dial(number) { - ok(number == '5707534296', 'Phone number sanitized'); - var fakeCall = {number: '123', addEventListener: function() {}}; - return fakeCall; - }; - - // Wait for the call handler to be available - yield until(function() window.CallHandler, nextStep); - - window.CallHandler.call('570-753-4296'); -} diff --git a/tests/browser_sms_conversation.js b/tests/browser_sms_conversation.js deleted file mode 100644 index 83ed96e48ce5..000000000000 --- a/tests/browser_sms_conversation.js +++ /dev/null @@ -1,54 +0,0 @@ -function generatorTest() { - waitForExplicitFinish(); - yield testApp('http://sms.gaiamobile.org/', testSMSConversation); - finish(); -} - -function testSMSConversation(window, document, nextStep) { - let ConversationView = window.ConversationView; - let ConversationListView = window.ConversationListView; - - var message = { - 'hidden': false, - 'body': 'test', - 'name': 'test', - 'num': '888', - 'timestamp': Date.now(), - 'id': parseInt(21) - }; - - var view = ConversationListView.view; - view.innerHTML = ConversationListView.createNewConversation(message); - - var convSelector = "#msg-conversations-list > div[data-notempty='true']"; - var aConv = document.querySelector(convSelector); - -/* - * Commenting this part of the test out because the SMS database - * doesn't seem to be stable yet, and it is failing - * - // Send a click event on a conversation and wait for the pane to appear - EventUtils.sendMouseEvent({type: 'click'}, aConv); - yield until( - function() document.body.classList.contains('conversation'), - nextStep - ); - - ok(document.body.classList.contains('conversation'), - 'Conversation displayed'); - - var contactField = document.getElementById('view-num'); - ok(contactField.value.length != 0, 'To: field filled'); - - // Now send the back (escape) key and test that the - // conversation pane is hidden - EventUtils.sendKey('ESCAPE', window); - yield until( - function() !document.body.classList.contains('conversation'), - nextStep - ); - - ok(!document.body.classList.contains('conversation'), - 'Conversation hidden'); -*/ -} diff --git a/tests/browser_sms_new.js b/tests/browser_sms_new.js deleted file mode 100644 index 31e07e376dc1..000000000000 --- a/tests/browser_sms_new.js +++ /dev/null @@ -1,42 +0,0 @@ -function generatorTest() { - waitForExplicitFinish(); - yield testApp('http://sms.gaiamobile.org/', testSMSNew); - finish(); -} - -function testSMSNew(window, document, nextStep) { - let conversationView = document.getElementById('view'); - let contactField = document.getElementById('view-num'); - let textField = document.getElementById('view-msg-text'); - let sendButton = document.getElementById('view-msg-send'); - let newButton = document.getElementById('msg-new-message'); - - conversationView.addEventListener('transitionend', function trWait() { - conversationView.removeEventListener('transitionend', trWait); - nextStep(); - }); - yield EventUtils.sendMouseEvent({type: 'click'}, newButton); - - ok(document.body.classList.contains('conversation'), - 'Conversation displayed'); - ok(contactField.value.length == 0, 'To: field empty'); - - contactField.value = '123'; - textField.value = 'Hello world.'; - - // Click on the send button and wait until the message appears -/* - * commented out because of SMS database issues that are making it fail - * - EventUtils.sendMouseEvent({type: 'mousedown'}, sendButton); - yield until( - function() { - return document.querySelectorAll('#view-list > div').length > 0 - }, - nextStep); - - let messageCount = document.querySelectorAll('#view-list > div').length; - ok((messageCount == 1), 'Message added'); - */ -} - diff --git a/tests/head.js b/tests/head.js deleted file mode 100644 index 0b61f2d52cdb..000000000000 --- a/tests/head.js +++ /dev/null @@ -1,258 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -// Like console.log on top of dump() -function debug() { - let s = ''; - for (var i = 0; i < arguments.length; i++) - s += String(arguments[i]) + ' '; - dump('***DEBUG: ' + s + '\n'); -} - -// -// Swipe from (x0,y0) to (x1,y1) over element e, taking a total of interval ms -// and then call whendone(). EventUtils doesn't know how to send a mousemove -// event, so this function just sends a mouse down, waits, then sends a -// mouse up from the new point. -// -// TODO: use EventUtils.synthesizeMouse() to send mousemove events -// if we ever actually need them. -// -EventUtils.swipe = function swipe(e, x0, y0, x1, y1, interval, whendone) { - silentOK(e != null, 'trying to swipe on an inexistant element'); - var t = 0; // Start at time 0 - - // Begin with a mouse down event - EventUtils.sendMouseEvent({ - type: 'mousedown', - clientX: x0, - clientY: y0 - }, e); - - // Then, after interval ms, send the mouse up at a different spot - // and call the callback - setTimeout(function() { - EventUtils.sendMouseEvent({ - type: 'mouseup', - clientX: x1, - clientY: y1 - }, e); - if (whendone) whendone(); - }, interval); -}; - -// Poll every 50ms for the condition function to return a truthy value -// and then call the callback function when it does. -// This is designed to be used with yield, nextStep, and shortcut functions -// in an idiom like this: -// -// yield until(function() document.getElementById('foo'), nextStep); -// -// TODO: create a version of this function that waits for a given event -// on a given object instead of polling for a condition -// -// TODO: add an optional timeout argument -// -function until(condition, callback) { - var timer = setInterval(check, 50); - - function check() { - if (!condition()) - return; - clearInterval(timer); - callback(); - } -} - -// Like ok(), but don't print anything and don't count it if the test succeeds. -// Only generate output for tests that fail. -function silentOK(condition, message) { - if (!condition) - ok(condition, message); -} - -// -// testApp(): -// -// This function does the following: -// - unlocks the lock screen -// - launches the app specified by url -// - waits for the app to load -// - passes the app's window and document to testfunc() -// - brings up the app switcher and kills the app -// - locks the lockscreen again -// -// Write tests like this: -// -// function generatorTest() { -// yield testApp("http://dialer.gaiamobile.org/", dialerTest) -// } -// -// function dialerTest(window, document, nextStep) {...} -// -// Note that tests that use testApp() have to be generatorTest() tests. -// This won't work with plain test() tests. And the function you pass -// to testApp() can itself be a generator. The outer test generator yields -// while the inner app test generator runs. The third argument to the -// app test generator function will be the equivalent of nextStep() -// -// Note that this testing app depends on details of the the homescreen -// document structure and is therefore somewhat brittle. If the homescreen -// changes then this test framework may have to change to match. -// -// -function testApp(url, testfunc) { - var g = testAppGenerator(url, testfunc, testAppNextStep); - g.next(); - - function testAppNextStep() { - try { - g.next(); - } - catch (e if e instanceof StopIteration) { - nextStep(); // this is the real, mochikit nextStep function - } - } - - function testAppGenerator(url, testfunc, nextStep) { - // Wait until the content document is ready - // An about:blank page is loaded first, we keep waiting until - // the homescreen's readyState is complete - yield until( - function() ((content.wrappedJSObject.document.readyState === 'complete') && - (content.wrappedJSObject.document.body.children.length > 0)), - nextStep); - - let contentWin = content.wrappedJSObject; - let contentDoc = contentWin.document; - let lockscreen = contentDoc.getElementById('lockscreen'); - - // Make sure the LockScreen module is loaded before we go on - yield until(function() contentWin.LockScreen, nextStep); - - // Send the Home key to turn the screen on if it was off - EventUtils.sendKey('HOME', contentWin); - silentOK(navigator.mozPower.screenEnabled, 'screen not on'); - - // Unlock the screen - // FIXME: I used to do this by sending swipe events, but it broke - // for some reason, so now we just call a homescreen module to do it - yield contentWin.LockScreen.unlock(0, nextStep); - silentOK(!contentWin.LockScreen.locked, 'screen did not unlock'); - - // Find all the icons on the homescreen - yield until(function() contentDoc.querySelectorAll('#apps > .page > .icon').length > 0, nextStep); - var icons = contentDoc.querySelectorAll('#apps > .page > .icon'); - silentOK(icons.length > 0, 'no homescreen icons found'); - var icon = null; - - // Look through them for the one that launches the specified app - for (var i = 0; i < icons.length; i++) { - if (icons[i].dataset.url === url) { - icon = icons[i]; - break; - } - } - - silentOK(icon, 'no icon found for ' + url); - - // Before we launch the app, register an event handler that will notice - // when the app's window appears - var windowContainer = contentDoc.getElementById('windows'); - var appframe = null; - windowContainer.addEventListener('DOMNodeInserted', function handler(e) { - windowContainer.removeEventListener('DOMNodeInserted', handler); - appframe = e.target; - silentOK(appframe, 'got a newly launched window'); - nextStep(); - }); - - // Now, click on the icon. - // The homescreen IconGrid doesn't do anything with click events. It wants - // mousedown/mouseup. Since these events are dispatched synchronously - // we've got to to do them in a set timeout, or otherwise the nextStep() - // in the event handler above will fire before we can call yield - yield setTimeout(function() { - EventUtils.sendMouseEvent({type: 'mousedown'}, icon); - EventUtils.sendMouseEvent({type: 'mouseup'}, icon); - }, 0); - - // We've got a new iframe now, but we may need to wait until - // it has a src attribute set - yield until(function() appframe.src, nextStep); - - // Now wait until the frame's content document has a readyState of complete - let win = appframe.contentWindow.wrappedJSObject; - yield until(function() win.document.readyState === 'complete', nextStep); - - // Give the app one more chance to settle down. - // I'm not really sure why this line needs to be here, but it seems - // to prevent a very strange intermittent failure in one of the - // dialer tests. - yield setTimeout(nextStep, 0); - - // We now have a newly-launched app in an iframe, and it is time - // to call the test function for this app. This should work with - // regular functions and generator functions also. For generators, - // the third argument is the nextStep function to call - try { - if (testfunc) { - let generator = testfunc(win, win.document, - function() { - try { - generator.next(); - } - catch (e if e instanceof StopIteration) { - nextStep(); - } - }); - - // If the test function does, in fact, return a generator, then we - // need to yield until that nested generator throws StopIteration, at - // which point the code above will resume us. - if (generator && 'next' in generator) { - yield generator.next(); - } - } - } - catch (e) { - // Any exception from the test function gets reported as a failed test - ok(false, 'Exception in testApp() test function: ' + - e.toString() + ' ' + e.fileName + ':' + e.lineNumber + - '\n' + e.stack); - } - finally { - // At this point, testing is complete. Now we kill the app and re-lock - // the screen. And we do this even if there was a failure above. - - // Bring up the task switcher with a long press - EventUtils.synthesizeKey('VK_HOME', {type: 'keydown'}, contentWin); - yield setTimeout(function() { - EventUtils.synthesizeKey('VK_HOME', {type: 'keyup'}, contentWin); - nextStep(); - }, 1100); - - // Wait until the task switcher has some tasks in it - let closeselector = '#cardsView > ul > li > a'; - yield until( - function() contentDoc.querySelectorAll(closeselector).length > 0, - nextStep); - - // Find all the close buttons in the task switcher - // There should only be one task open, but click all buttons if more. - var closebtns = contentDoc.querySelectorAll('#cardsView > ul > li > a'); - silentOK(closebtns.length === 1, - closebtns.length + ' tasks running; expected 1.'); - for (var i = 0; i < closebtns.length; i++) { - var btn = closebtns[i]; - EventUtils.sendMouseEvent({type: 'click'}, btn); - } - - // Wait a bit for the app to close - yield until(function() appframe.parentNode == null, nextStep); - - // Lock the screen - yield contentWin.LockScreen.lock(false, nextStep); - } - } -} diff --git a/tests/perf/app_perf.py b/tests/perf/app_perf.py deleted file mode 100644 index 08529a340896..000000000000 --- a/tests/perf/app_perf.py +++ /dev/null @@ -1,30 +0,0 @@ -# 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/. - -import os -import time -from marionette_test import MarionetteTestCase - -class TestLaunch(MarionetteTestCase): - def test_launch(self): - apps = ['cuttherope','music','dialer','gallery','video','clock','browser','sms','camera', - 'calculator','cubevid','crystalskull','towerjelly','penguinpop','settings'] - - #kill all apps we're testing, then launch - for app in apps: - self.marionette.execute_script("window.wrappedJSObject.WindowManager.kill('http://%s.gaiamobile.org');" % app) - for app in apps: - self.marionette.set_script_timeout(10000) - t = self.marionette.execute_async_script("let marionetteAppStart = Date.now();" - + "window.addEventListener('mozChromeEvent', function(e) {" - + "if (e.detail.type === 'webapps-launch') {" - + " let marionetteAppLoad = Date.now() - marionetteAppStart;" - + " window.removeEventListener('mozChromeEvent', arguments.callee);" - + " marionetteScriptFinished(marionetteAppLoad);" - + "}" - + "});" - + "window.wrappedJSObject.WindowManager.launch('http://%s.gaiamobile.org');" % app) - self.marionette.add_perf_data("startup", app, t) - time.sleep(1) - self.marionette.execute_script("window.wrappedJSObject.WindowManager.kill('http://%s.gaiamobile.org');" % app) diff --git a/tests/perf/perf.ini b/tests/perf/perf.ini deleted file mode 100644 index ddbe9c45afaf..000000000000 --- a/tests/perf/perf.ini +++ /dev/null @@ -1,11 +0,0 @@ -[DEFAULT] -perfserv = http://10.8.73.32/b2g/api/load_test -platform = emulator -build_name = b2g -version = prerelease -branch = master - -b2g = true -skip = false - -[app_perf.py]