Esempio n. 1
0
class TestThunderOcdmWSAPI(unittest.TestCase):
    def setUp(self):
        self.__cpe_ip = sys.argv[1]
        self.__thunder_handler = ThunderWSAPI()
        self.__thunder_handler.open_ws_connection(self.__cpe_ip +
                                                  ":9998/jsonrpc")
        self.__thunder_handler.controller_activate_plugin("OCDM")

    def tearDown(self):
        self.__thunder_handler.controller_deactivate_plugin("OCDM")
        self.__thunder_handler.close_ws_connection()

    def test_D1_verify_ocdm_plugin(self):
        key_systems = None
        with self.subTest(msg="Fail while checking: OCDM plugin"):
            msg_prefix = "Method: ocdm_drms"
            result = self.__thunder_handler.ocdm_drms()
            self.assertFalse("error" in result, msg_prefix + " return error")
            self.assertEqual(
                len(result['result']), 2, "Expected 2 key_systems, reviced: " +
                str(len(result['result'])))
            key_systems = copy.deepcopy(result['result'])

        with self.subTest(msg="Fail while checking: OCDM plugin"):
            msg_prefix = "Method: ocdm_keysystems"
            for key_system in key_systems:
                result = self.__thunder_handler.ocdm_keysystems(
                    key_system['name'])
                self.assertFalse("error" in result,
                                 msg_prefix + " return error")
                self.assertNotEqual(
                    len(result['result']), 0,
                    "Expected non 0 keys, reviced: " +
                    str(len(result['result'])))
Esempio n. 2
0
class TestThunderWebKitBrowserWSAPI(unittest.TestCase):
    def setUp(self):
        self.__cpe_ip = sys.argv[1]
        self.__thunder_handler = ThunderWSAPI()
        self.__thunder_handler.open_ws_connection(self.__cpe_ip +
                                                  ":9998/jsonrpc")

    def tearDown(self):
        self.__thunder_handler.close_ws_connection()

    def verify_webkit_plugin(self, plugin):
        self.__thunder_handler.controller_activate_plugin(plugin)

        with self.subTest(msg="Fail while checking: " + plugin + " plugin"):
            msg_prefix = "Method: " + plugin + "_bridgeevent"
            result = self.__thunder_handler.webkitbrowser_bridgeevent(plugin)
            self.assertFalse("error" in result, msg_prefix + " return error")

        with self.subTest(msg="Fail while checking: " + plugin + " plugin"):
            msg_prefix = "Method: " + plugin + "_bridgereply"
            result = self.__thunder_handler.webkitbrowser_bridgereply(plugin)
            self.assertFalse("error" in result, msg_prefix + " return error")

        with self.subTest(msg="Fail while checking: " + plugin + " plugin"):
            msg_prefix = "Method: " + plugin + "_localstorageenabled"
            result = self.__thunder_handler.webkitbrowser_localstorageenabled(
                plugin)
            self.assertFalse("error" in result, msg_prefix + " return error")

        with self.subTest(msg="Fail while checking: " + plugin + " plugin"):
            msg_prefix = "Method: " + plugin + "_useragent"
            result = self.__thunder_handler.webkitbrowser_useragent(plugin)
            self.assertFalse("error" in result, msg_prefix + " return error")

        with self.subTest(msg="Fail while checking: " + plugin + " plugin"):
            msg_prefix = "Method: " + plugin + "_headers"
            result = self.__thunder_handler.webkitbrowser_headers(plugin)
            self.assertFalse("error" in result, msg_prefix + " return error")

        with self.subTest(msg="Fail while checking: " + plugin + " plugin"):
            msg_prefix = "Method: " + plugin + "_httpcookieacceptpolicy"
            result = self.__thunder_handler.webkitbrowser_httpcookieacceptpolicy(
                plugin)
            self.assertFalse("error" in result, msg_prefix + " return error")

        with self.subTest(msg="Fail while checking: " + plugin + " plugin"):
            msg_prefix = "Method: " + plugin + "_languages"
            result = self.__thunder_handler.webkitbrowser_languages(plugin)
            self.assertFalse("error" in result, msg_prefix + " return error")

        self.__thunder_handler.controller_deactivate_plugin(plugin)

    def test_L1_verify_webkitbrowser_plugins(self):
        for plugin in [
                "WebKitBrowser", "HtmlApp", "LightningApp", "ResidentApp",
                "SearchAndDiscoveryApp"
        ]:
            self.verify_webkit_plugin(plugin)
Esempio n. 3
0
class TestThunderControllerWSAPI(unittest.TestCase):
    def setUp(self):
        self.__cpe_ip = sys.argv[1]
        self.__plugins = json_file_reader(sys.argv[2])
        self.__thunder_handler = ThunderWSAPI()
        self.__thunder_handler.open_ws_connection(self.__cpe_ip +
                                                  ":9998/jsonrpc")

    def tearDown(self):
        self.__thunder_handler.close_ws_connection()

    def test_A1_verify_number_of_plugins(self):
        result = self.__thunder_handler.controller_get_status()
        self.assertEqual(
            len(result['result']), len(self.__plugins),
            "The number of plugins does not match pattern: " +
            str(len(result['result'])) + " != " + str(len(self.__plugins)))

    def test_A2_verify_plugins_status(self):
        plugins = copy.deepcopy(self.__plugins)
        result = self.__thunder_handler.controller_get_status()
        for plugin in result['result']:
            if plugin['callsign'] in plugins:
                with self.subTest(msg="Fail while checking: " +
                                  plugin['callsign']):
                    self.assertEqual(
                        plugin['classname'],
                        plugins[plugin['callsign']]['classname'],
                        "Controller returned unknown classname: " +
                        plugin['classname'])
                    self.assertEqual(
                        plugin['callsign'],
                        plugins[plugin['callsign']]['callsign'],
                        "Controller returned unknown callsign: " +
                        plugin['callsign'])
                    for key in plugins[plugin['callsign']]:
                        self.assertEqual(
                            plugin[key], plugins[plugin['callsign']][key],
                            "Key: " + key + " value: " + str(plugin[key]) +
                            " don't match pattern: " +
                            str(plugins[plugin['callsign']][key]))

                del plugins[plugin['callsign']]
        self.assertEqual(
            len(plugins), 0,
            "Controller did not return all expected plugins: " + str(plugins))

    def test_A3_verify_plugins_state_change(self):
        result = self.__thunder_handler.controller_get_status()
        del result['result'][0]
        self.__thunder_handler.controller_register_event(
            "all", "client.Controller.events")
        for plugin in result['result']:
            with self.subTest(msg="Fail while checking: " +
                              plugin['callsign']):
                if plugin['state'] == "activated":
                    msg_prefix = "Method: controller_deactivate " + plugin[
                        'callsign'] + " plugin"

                    def signalValidator(resp):
                        self.assertEqual(resp['params']['callsign'],
                                         plugin['callsign'])
                        self.assertEqual(resp['params']['data']['state'],
                                         "deactivated")
                        self.assertEqual(resp['params']['data']['reason'],
                                         "Requested")
                        return True

                    result = self.__thunder_handler.controller_deactivate_plugin(
                        plugin['callsign'], signalValidator)
                else:
                    msg_prefix = "Method: controller_activate " + plugin[
                        'callsign'] + " plugin"

                    def signalValidator(resp):
                        self.assertEqual(resp['params']['callsign'],
                                         plugin['callsign'])
                        self.assertEqual(resp['params']['data']['state'],
                                         "activated")
                        self.assertEqual(resp['params']['data']['reason'],
                                         "Requested")
                        return True

                    result = self.__thunder_handler.controller_activate_plugin(
                        plugin['callsign'], signalValidator)
                self.assertFalse("error" in result,
                                 msg_prefix + " return error " + str(result))

        self.__thunder_handler.controller_unregister_event(
            "all", "client.Controller.events")

    def test_Z1_set_plugins_init_state(self):
        plugins = copy.deepcopy(self.__plugins)
        del plugins['Controller']
        for plugin in plugins:
            if plugins[plugin]['state'] == "activated":
                self.__thunder_handler.controller_activate_plugin(
                    plugins[plugin]['callsign'])
            else:
                self.__thunder_handler.controller_deactivate_plugin(
                    plugins[plugin]['callsign'])
class TestThunderFmpWSAPI(unittest.TestCase):
    def setUp(self):
        self.pid = "MyPlayer"
        self.handler = FmpEventHandler(self.pid)
        self.__cpe_ip = sys.argv[1]
        self.__thunder_handler = ThunderWSAPI()
        self.__thunder_handler.open_ws_connection(
            self.__cpe_ip + ":9998/jsonrpc", self.handler)
        self.__thunder_handler.controller_activate_plugin("OCDM")
        self.__thunder_handler.controller_activate_plugin(
            "org.rdk.FireboltMediaPlayer")

    def tearDown(self):
        self.__thunder_handler.controller_deactivate_plugin(
            "org.rdk.FireboltMediaPlayer")
        self.__thunder_handler.controller_deactivate_plugin("OCDM")
        self.__thunder_handler.close_ws_connection()

    def checkState(self, expected):
        with self.subTest(msg="Check state"):
            state = self.handler.get('state')
            self.assertEqual(state, expected, "Wrong state")

    def checkSpeed(self, expected):
        with self.subTest(msg="Check speed"):
            speed = self.handler.get('speed')
            self.assertEqual(speed, expected, "Wrong speed")

    def checkPositionGt(self, expectedSec):
        with self.subTest(msg="Check position"):
            pos = self.handler.get('positionMiliseconds')
            self.assertGreater(pos, expectedSec * 1000, "Wrong position")

    def checkPositionLs(self, expectedSec):
        with self.subTest(msg="Check position"):
            pos = self.handler.get('positionMiliseconds')
            self.assertLess(pos, expectedSec * 1000, "Wrong position")

    def checkPlayback(self, url):
        pfx = "FMP"
        pid = self.pid
        pos1 = 20
        pos2 = 10

        result = self.__thunder_handler.fmp_create(pid)
        self.assertFalse("error" in result, pfx + " return error")

        with self.subTest(msg="Register event handler"):
            result = self.__thunder_handler.fmp_register_event(
                "playbackStarted", "org.rdk.FirebolMediaPlayer.1")
            self.assertFalse("error" in result, pfx + " return error")
            result = self.__thunder_handler.fmp_register_event(
                "playbackStateChanged", "org.rdk.FirebolMediaPlayer.1")
            self.assertFalse("error" in result, pfx + " return error")
            result = self.__thunder_handler.fmp_register_event(
                "playbackProgressUpdate", "org.rdk.FirebolMediaPlayer.1")
            self.assertFalse("error" in result, pfx + " return error")
            result = self.__thunder_handler.fmp_register_event(
                "bufferingChanged", "org.rdk.FirebolMediaPlayer.1")
            self.assertFalse("error" in result, pfx + " return error")
            result = self.__thunder_handler.fmp_register_event(
                "playbackSpeedChanged", "org.rdk.FirebolMediaPlayer.1")
            self.assertFalse("error" in result, pfx + " return error")
            result = self.__thunder_handler.fmp_register_event(
                "playbackFailed", "org.rdk.FirebolMediaPlayer.1")
            self.assertFalse("error" in result, pfx + " return error")

        print("Load '" + url + "'")
        result = self.__thunder_handler.fmp_load(pid, url, False)
        self.assertFalse("error" in result, pfx + " return error")

        result = self.__thunder_handler.fmp_play(pid)
        self.assertFalse("error" in result, pfx + " return error")

        with self.subTest(msg="Seek forward"):
            print("Wait before seek..")
            time.sleep(3)
            result = self.__thunder_handler.fmp_seek(pid, pos1)
            self.assertFalse("error" in result, pfx + " return error at seek")
            print("Wait after seek..")
            time.sleep(5)
            self.checkState(8)
            self.checkSpeed(1)
            self.checkPositionGt(pos1)

        with self.subTest(msg="Pause then play"):
            result = self.__thunder_handler.fmp_pause(pid)
            self.assertFalse("error" in result, pfx + " return error at pause")
            print("Wait before resume..")
            time.sleep(3)
            self.checkState(6)
            self.checkSpeed(0)
            result = self.__thunder_handler.fmp_play(pid)
            self.assertFalse("error" in result, pfx + " return error at play")

        with self.subTest(msg="Seek backward"):
            print("Wait before seek..")
            time.sleep(3)
            result = self.__thunder_handler.fmp_seek(pid, pos2)
            self.assertFalse("error" in result, pfx + " return error at seek")
            print("Wait after seek..")
            time.sleep(5)
            self.checkPositionLs(pos1)
            self.checkPositionGt(pos2)

        with self.subTest(msg="Stop"):
            print("Wait before stop..")
            time.sleep(3)
            result = self.__thunder_handler.fmp_stop(pid)
            self.assertFalse("error" in result, pfx + " return error at stop")

        result = self.__thunder_handler.fmp_release(pid)
        self.assertFalse("error" in result, pfx + " return error at release")

    def test_J1_verify_fmp_hls_playback(self):
        self.checkPlayback(
            "http://demo.unified-streaming.com/video/tears-of-steel/tears-of-steel.ism/.m3u8"
        )

    def test_J2_verify_fmp_dash_playback(self):
        self.checkPlayback(
            "http://amssamples.streaming.mediaservices.windows.net/bf657309-71d9-4436-b94b-8ac0d2ca222b/SintelTrailer.ism/manifest(format=mpd-time-csf)"
        )