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