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 TestThunderSecurityAgentWSAPI(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 test_H1_verify_securityagent_plugin(self):
        # this method is avaliable only when "SECURITY_TESTING_MODE" is defined in the code
        '''
        msg_prefix="Method: securityagent_createtoken"
        url = "https://test.comcast.com"
        user = "******"
        hash = "1CLYex47SY"
        result = self.__thunder_handler.securityagent_createtoken(url, hash, user)
        self.assertFalse("error" in result, msg_prefix +" return error")
        self.assertTrue("token" in result['result'], msg_prefix +" didn't return key \"token\"")
        token = result['result']['token']
        '''
        msg_prefix = "Method: securityagent_validate"
        result = self.__thunder_handler.securityagent_validate(
            "some_random_token")
        self.assertFalse("error" in result, msg_prefix + " return error")
        self.assertTrue("valid" in result['result'],
                        msg_prefix + " didn't return key \"valid\"")
        self.assertFalse(
            result['result']['valid'],
            msg_prefix + " token valid = " + str(result['result']['valid']))
Esempio n. 3
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)
class TestThunderMonitorWSAPI(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 test_K1_verify_monitor_plugin(self):
        with self.subTest(msg="Fail while checking: Monitor plugin"):
            msg_prefix = "Method: monitor_status"
            result = self.__thunder_handler.monitor_status()
            self.assertFalse("error" in result, msg_prefix + " return error")
class TestThunderDeviceInfoWSAPI(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 test_B1_verify_device_info_plugin(self):
        with self.subTest(msg="Fail while checking: DeviceInfo plugin"):
            msg_prefix="Method: deviceinfo_systeminfo"
            result = self.__thunder_handler.deviceinfo_systeminfo()
            self.assertFalse("error" in result, msg_prefix +" return error")
            self.assertTrue("version" in result['result'], msg_prefix +" didn't return key \"version\"")
            self.assertTrue("uptime" in result['result'], msg_prefix +" didn't return key \"uptime\"")
            self.assertTrue("totalram" in result['result'], msg_prefix +" didn't return key \"totalram\"")
            self.assertTrue("freeram" in result['result'], msg_prefix +" didn't return key \"freeram\"")
            self.assertTrue("devicename" in result['result'], msg_prefix +" didn't return key \"devicename\"")
            self.assertTrue("cpuload" in result['result'], msg_prefix +" didn't return key \"cpuload\"")
            self.assertTrue("serialnumber" in result['result'], msg_prefix +" didn't return key \"serialnumber\"")
            self.assertTrue("time" in result['result'], msg_prefix +" didn't return key \"time\"")

        with self.subTest(msg="Fail while checking: DeviceInfo plugin"):
            msg_prefix="Method: deviceinfo_addresses"
            result = self.__thunder_handler.deviceinfo_addresses()
            self.assertFalse("error" in result, msg_prefix +" return error")
            self.assertEqual(len(result['result']), 3, "Expected 3 interfaces, reviced: " + str(len(result['result'])))
            for interface in result['result']:
                self.assertTrue("name" in interface, msg_prefix +" didn't return key \"name\"")
                self.assertTrue("mac" in interface, msg_prefix +" didn't return key \"mac\"")
                # "ip" is optional so we don't verify that key now

        with self.subTest(msg="Fail while checking: DeviceInfo plugin"):
            msg_prefix="Method: deviceinfo_socketinfo"
            result = self.__thunder_handler.deviceinfo_socketinfo()
            self.assertFalse("error" in result, msg_prefix +" return error")
            self.assertTrue("runs" in result['result'], msg_prefix +" didn't return key \"runs\"")
class TestThunderTraceControlWSAPI(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 test_I1_verify_tracecontrol_plugin(self):
        msg_prefix = "Method: tracecontrol_set"
        module = "Plugin_DeviceInfo"
        category = "Information"
        state = "enabled"
        result = self.__thunder_handler.tracecontrol_set(
            module, category, state)
        self.assertFalse("error" in result, msg_prefix + " return error")

        result = self.__thunder_handler.tracecontrol_status(module, category)
        self.assertFalse("error" in result, msg_prefix + " return error")
class TestThunderPlayerInfoWSAPI(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("PlayerInfo")

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

    def test_G1_verify_playerinfo_plugin(self):

        with self.subTest(msg="Fail while checking: PlayerInfo plugin"):
            codecs_list = [
                "VideoH263", "VideoH264", "VideoH265", "VideoMpeg", "VideoVp8",
                "VideoVp9"
            ]
            msg_prefix = "Method: playerinfo_videocodecs"
            result = self.__thunder_handler.playerinfo_videocodecs()
            self.assertFalse("error" in result, msg_prefix + " return error")
            self.assertEqual(
                len(result['result']), len(codecs_list),
                msg_prefix + " return unexpected number of video codecs")
            for codec in codecs_list:
                self.assertTrue(
                    codec in result['result'],
                    msg_prefix + " didn't return video codec: " + codec)

        with self.subTest(msg="Fail while checking: PlayerInfo plugin"):
            codecs_list = [
                "AudioAac", "AudioAc3", "AudioAc3Plus", "AudioDts",
                "AudioMpeg1", "AudioMpeg2", "AudioMpeg3", "AudioMpeg4",
                "AudioOpus", "AudioVorbisOgg"
            ]  # exclude "AudioUndefined",
            msg_prefix = "Method: playerinfo_audiocodecs"
            result = self.__thunder_handler.playerinfo_audiocodecs()
            self.assertFalse("error" in result, msg_prefix + " return error")
            self.assertEqual(
                len(result['result']), len(codecs_list),
                msg_prefix + " return unexpected number of audio codecs")
            for codec in codecs_list:
                self.assertTrue(
                    codec in result['result'],
                    msg_prefix + " didn't return audio codec: " + codec)

        with self.subTest(msg="Fail while checking: PlayerInfo plugin"):

            pfx = "FMP"
            pid = "MyPlayer"
            url = "http://wowzaec2demo.streamlock.net/vod/_definst_/ElephantsDream/smil:ElephantsDream.smil/manifest_mvtime.mpd"

            self.assertFalse("error" in result, pfx + " return error")
            self.__thunder_handler.controller_activate_plugin("OCDM")
            self.__thunder_handler.controller_activate_plugin(
                "org.rdk.FireboltMediaPlayer")

            result = self.__thunder_handler.fmp_create(pid)
            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")

            time.sleep(5)

            validate_list = [
                "Resolution480I", "Resolution480P", "Resolution576I",
                "Resolution576P", "Resolution720P", "Resolution1080I",
                "Resolution1080P", "Resolution2160P30", "Resolution2160P60"
            ]  # exclude "ResolutionUnknown"
            msg_prefix = "Method: playerinfo_resolution"
            result = self.__thunder_handler.playerinfo_resolution()
            self.assertFalse("error" in result, msg_prefix + " return error")
            self.assertTrue(
                result['result'] in validate_list, msg_prefix +
                " return unexpected value: " + str(result['result']))

            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")

        with self.subTest(msg="Fail while checking: PlayerInfo plugin"):
            msg_prefix = "Method: playerinfo_isaudioequivalenceenabled"
            result = self.__thunder_handler.playerinfo_isaudioequivalenceenabled(
            )
            self.assertFalse("error" in result, msg_prefix + " return error")
            self.assertTrue(
                type(result['result']) is bool,
                msg_prefix + " result is not boolen value")

        with self.subTest(msg="Fail while checking: PlayerInfo plugin"):
            msg_prefix = "Method: playerinfo_dolby_atmosmetadata"
            result = self.__thunder_handler.playerinfo_dolby_atmosmetadata()
            self.assertFalse("error" in result, msg_prefix + " return error")
            self.assertTrue(
                type(result['result']) is bool,
                msg_prefix + " result is not boolen value")

        with self.subTest(msg="Fail while checking: PlayerInfo plugin"):
            validate_list = ["Mono", "Stereo", "Surround",
                             "Passthru"]  # exclude "Unknown"
            msg_prefix = "Method: playerinfo_dolby_soundmode"
            result = self.__thunder_handler.playerinfo_dolby_soundmode()
            self.assertFalse("error" in result, msg_prefix + " return error")
            self.assertTrue(
                result['result'] in validate_list, msg_prefix +
                " return unexpected value: " + str(result['result']))

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

        with self.subTest(msg="Fail while checking: PlayerInfo plugin"):
            validate_list = [
                "DigitalPcm", "DigitalPlus", "DigitalAc3", "Auto", "Ms12"
            ]
            msg_prefix = "Method: playerinfo_dolby_get_mode"
            result = self.__thunder_handler.playerinfo_dolby_get_mode()
            self.assertFalse("error" in result, msg_prefix + " return error")
            self.assertTrue(
                result['result'] in validate_list, msg_prefix +
                " return unexpected value: " + str(result['result']))

            for dolby_mode in validate_list:
                result = self.__thunder_handler.playerinfo_dolby_set_mode(
                    dolby_mode)
                msg_prefix = "Method: playerinfo_dolby_set_mode"
                self.assertFalse("error" in result,
                                 msg_prefix + " return error")
                result = self.__thunder_handler.playerinfo_dolby_get_mode()
                msg_prefix = "Method: playerinfo_dolby_get_mode"
                self.assertEqual(
                    result['result'], dolby_mode, msg_prefix + " return " +
                    str(result['result']) + " instead of " + dolby_mode)
class TestThunderDisplayInfoWSAPI(unittest.TestCase):

    def setUp(self):
        self.__cpe_ip = sys.argv[1]
        self.__tv_set = True
        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_C1_verify_display_info_plugin(self):

        with self.subTest(msg="Fail while checking: DisplayInfo plugin"):
            msg_prefix="Methods:"
            result = self.__thunder_handler.displayinfo_connected()
            self.assertFalse("error" in result, msg_prefix +" displayinfo_connected return error")
            self.assertTrue(type(result['result']) is bool, msg_prefix + " displayinfo_connected result is not boolen value")
            hdmi_is_connected = result['result']
            if self.__tv_set == True:
                self.assertTrue(result['result'], msg_prefix + " displayinfo_connected: " + str(result['result']) +
                    ". Make sure that CPE is connected to the TV via HDMI cable and TV is turned on" )

            edid_result = self.__thunder_handler.displayinfo_edid(1000)
            self.assertFalse("error" in edid_result, msg_prefix +" displayinfo_edid return error")
            self.assertTrue("length" in edid_result['result'], msg_prefix + " displayinfo_edid didn't return key \"length\"")
            self.assertTrue("data" in edid_result['result'], msg_prefix + " displayinfo_edid didn't return key \"data\"")

            width_result = self.__thunder_handler.displayinfo_widthincentimeters()
            self.assertFalse("error" in width_result, msg_prefix +" displayinfo_widthincentimeters return error")
            height_result = self.__thunder_handler.displayinfo_heightincentimeters()
            self.assertFalse("error" in height_result, msg_prefix +" displayinfo_heightincentimeters return error")

            if hdmi_is_connected == True:
                self.assertTrue((edid_result['result']['length'] > 20), msg_prefix + " displayinfo_edid length ")
                self.assertIn("AP///////w", edid_result['result']['data'], msg_prefix + " displayinfo_edid don't return fixed edid header pattern")
                self.assertEqual(width_result['result'], 16, msg_prefix + " displayinfo_widthincentimeters return "+str(width_result['result'])+" instead of 16")
                self.assertEqual(height_result['result'], 9, msg_prefix + " displayinfo_heightincentimeters return "+str(height_result['result'])+" instead of 9")
            else:
                self.assertTrue((edid_result['result']['length'] == 9), msg_prefix + " didn't return key \"length\"")
                self.assertEqual(edid_result['result']['data'], "dW5rbm93bgAA" , msg_prefix + " didn't return key \"length\"")
                self.assertEqual(width_result['result'], 0 , msg_prefix + " displayinfo_widthincentimeters return key "+str(width_result['result'])+" instead of 0")
                self.assertEqual(height_result['result'], 0 , msg_prefix + " displayinfo_heightincentimeters return key "+str(height_result['result'])+" instead of 0")

        with self.subTest(msg="Fail while checking: DisplayInfo plugin"):
            msg_prefix="Method: displayinfo_totalgpuram"
            result = self.__thunder_handler.displayinfo_totalgpuram()
            self.assertFalse("error" in result, msg_prefix +" return error")
            self.assertTrue(result['result'] > 400000000, msg_prefix + " didn't return expected (402653184) totalgpuram value: " + str(result['result']))

        with self.subTest(msg="Fail while checking: DisplayInfo plugin"):
            msg_prefix="Method: displayinfo_freegpuram"
            result = self.__thunder_handler.displayinfo_freegpuram()
            self.assertFalse("error" in result, msg_prefix +" return error")
            self.assertTrue(result['result'] > 270000000, msg_prefix + " didn't return expected freegpuramvalue ")

        with self.subTest(msg="Fail while checking: DisplayInfo plugin"):
            msg_prefix="Method: displayinfo_isaudiopassthrough"
            result = self.__thunder_handler.displayinfo_isaudiopassthrough()
            self.assertFalse("error" in result, msg_prefix +" return error")
            self.assertTrue(type(result['result']) is bool, msg_prefix + " result is not boolen value")

        with self.subTest(msg="Fail while checking: DisplayInfo plugin"):
            msg_prefix="Method: displayinfo_width"
            result = self.__thunder_handler.displayinfo_width()
            self.assertFalse("error" in result, msg_prefix +" return error")
            self.assertEqual(result['result'], 1920, msg_prefix + " return "+str(result['result']) + " instead of 1920")

        with self.subTest(msg="Fail while checking: DisplayInfo plugin"):
            msg_prefix="Method: displayinfo_height"
            result = self.__thunder_handler.displayinfo_height()
            self.assertFalse("error" in result, msg_prefix +" return error")
            self.assertEqual(result['result'], 1080, msg_prefix + " return "+str(result['result']) + " instead of 1080")


        with self.subTest(msg="Fail while checking: DisplayInfo plugin"):
            msg_prefix="Method: displayinfo_verticalfreq"
            result = self.__thunder_handler.displayinfo_verticalfreq()
            self.assertFalse("error" in result, msg_prefix +" return error")
            self.assertTrue(result['result'] > 0 and result['result'] <= 120, msg_prefix +
                " displayinfo_verticalfreq return value out of range:" + str(result['result']))

        with self.subTest(msg="Fail while checking: DisplayInfo plugin"):
            validate_list = ["HdcpUnencrypted", "Hdcp1X", "Hdcp2X", "HdcpAuto"]
            msg_prefix="Method: displayinfo_get_hdcpprotection"
            initial_result = self.__thunder_handler.displayinfo_get_hdcpprotection()
            self.assertFalse("error" in initial_result, msg_prefix + " return error")
            self.assertTrue(initial_result['result'] in validate_list, msg_prefix + " return unexpected value: " + str(initial_result['result']))

            for hdcp_protocol in validate_list:
                result = self.__thunder_handler.displayinfo_set_hdcpprotection(hdcp_protocol)
                msg_prefix="Method: displayinfo_set_hdcpprotection"
                self.assertFalse("error" in result, msg_prefix +" return error")
                result = self.__thunder_handler.displayinfo_get_hdcpprotection()
                msg_prefix="Method: displayinfo_set_hdcpprotection"
                self.assertEqual(result['result'], hdcp_protocol, msg_prefix + " return " + str(result['result']) + " instead of " + hdcp_protocol)

            result = self.__thunder_handler.displayinfo_set_hdcpprotection(initial_result['result'])

        with self.subTest(msg="Fail while checking: DisplayInfo plugin"):
            msg_prefix="Method: displayinfo_portname"
            result = self.__thunder_handler.displayinfo_portname()
            self.assertFalse("error" in result, msg_prefix +" return error")
            self.assertEqual(result['result'], "HDMI0", msg_prefix + " return "+str(result['result']) + " instead of HDMI0")
Esempio n. 9
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'])
Esempio n. 10
0
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)"
        )