testing/marionette/harness/marionette/tests/unit/test_log.py
author Andreas Tolfsen <ato@mozilla.com>
Sat, 06 Feb 2016 17:34:10 +0000
changeset 285593 29caf02c0eb04ae7703b6dc18a6949ab74fae102
parent 231821 testing/marionette/client/marionette/tests/unit/test_log.py@8add60e27b0a9210a092058a1afe20f36cf21f43
child 296474 08754cfc737c8fa87532132c7530b59591c33399
permissions -rw-r--r--
Bug 1246407 - Rename parent directories for Marionette client and test harness; r=automatedtester This change moves testing/marionette/client to testing/marionette/harness, and testing/marionette/driver to testing/marionette/client. This parent directory name change reflects the true purpose of these Python packages. MozReview-Commit-ID: B0KrGzDTLlQ

# 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 import MarionetteTestCase


class TestLog(MarionetteTestCase):
    def test_log_basic(self):
        # clear any previous data
        self.marionette.get_logs()

        self.marionette.log("I am info")
        self.assertTrue("I am info" in self.marionette.get_logs()[0])
        self.marionette.log("I AM ERROR", "ERROR")
        self.assertTrue("I AM ERROR" in self.marionette.get_logs()[0])

    def test_that_we_can_clear_the_logs(self):
        # clear any previous data
        self.marionette.get_logs()

        self.marionette.log("I am info")
        self.assertTrue("I am info" in self.marionette.get_logs()[0])
        self.marionette.log("I AM ERROR", "ERROR")
        self.assertTrue("I AM ERROR" in self.marionette.get_logs()[0])

        # Check that is empty if we call it again
        self.assertEqual(0, len(self.marionette.get_logs()))

    def test_log_script(self):
        # clear any previous data
        self.marionette.get_logs()

        self.marionette.execute_script("log('some log');")
        self.assertTrue("some log" in self.marionette.get_logs()[0])
        self.marionette.execute_script("log('some error', 'ERROR');")
        self.assertTrue("some error" in self.marionette.get_logs()[0])
        self.marionette.set_script_timeout(2000)
        self.marionette.execute_async_script("log('some more logs'); finish();")
        self.assertTrue("some more logs" in self.marionette.get_logs()[0])
        self.marionette.execute_async_script("log('some more errors', 'ERROR'); finish();")
        self.assertTrue("some more errors" in self.marionette.get_logs()[0])

class TestLogChrome(TestLog):
    def setUp(self):
        MarionetteTestCase.setUp(self)
        self.marionette.set_context("chrome")