How to use cast method in localstack

Best Python code snippet using localstack_python

chromecast.gyp

Source:chromecast.gyp Github

copy

Full Screen

1# Copyright 2014 The Chromium Authors. All rights reserved.2# Use of this source code is governed by a BSD-style license that can be3# found in the LICENSE file.4{5 'variables': {6 'android_support_v13_target%':7 '../third_party/android_tools/android_tools.gyp:android_support_v13_javalib',8 'cast_build_release': 'internal/build/cast_build_release',9 'cast_is_debug_build%': 0,10 # Refers to enum CastProductType in components/metrics/proto/cast_logs.proto11 'cast_product_type%': 0, # CAST_PRODUCT_TYPE_UNKNOWN12 'chromium_code': 1,13 'chromecast_branding%': 'Chromium',14 'disable_display%': 0,15 'enable_default_cast_graphics%': 1,16 'ozone_platform_cast%': 0,17 'use_chromecast_webui%': 0,18 },19 'includes': [20 'chromecast_tests.gypi',21 ],22 'target_defaults': {23 'include_dirs': [24 '..', # Root of Chromium checkout25 ],26 'conditions': [27 ['disable_display==1', {28 'defines': ['DISABLE_DISPLAY'],29 }],30 ],31 },32 'targets': [33 # Public API target for OEM partners to replace shlibs.34 {35 'target_name': 'cast_public_api',36 'type': '<(component)',37 'sources': [38 'public/cast_egl_platform.h',39 'public/cast_egl_platform_shlib.h',40 'public/cast_media_shlib.h',41 'public/cast_sys_info.h',42 'public/chromecast_export.h',43 'public/graphics_properties_shlib.h',44 'public/graphics_types.h',45 'public/media/decoder_config.h',46 'public/media/stream_id.h',47 'public/osd_plane.h',48 'public/osd_plane_shlib.h',49 'public/osd_surface.h',50 'public/video_plane.h',51 ],52 },53 {54 'target_name': 'cast_base',55 'type': '<(component)',56 'dependencies': [57 '../base/base.gyp:base',58 ],59 'sources': [60 'base/cast_paths.cc',61 'base/cast_paths.h',62 'base/chromecast_switches.cc',63 'base/chromecast_switches.h',64 'base/error_codes.cc',65 'base/error_codes.h',66 'base/metrics/cast_histograms.h',67 'base/metrics/cast_metrics_helper.cc',68 'base/metrics/cast_metrics_helper.h',69 'base/metrics/grouped_histogram.cc',70 'base/metrics/grouped_histogram.h',71 'base/path_utils.cc',72 'base/path_utils.h',73 'base/process_utils.cc',74 'base/process_utils.h',75 'base/serializers.cc',76 'base/serializers.h'77 ],78 }, # end of target 'cast_base'79 {80 'target_name': 'cast_crash',81 'type': '<(component)',82 'include_dirs': [83 # TODO(gfhuang): we should not need to include this directly, but84 # somehow depending on component.gyp:breakpad_component is not85 # working as expected.86 '../breakpad/src',87 ],88 'dependencies': [89 'cast_base',90 'cast_version_header',91 '../breakpad/breakpad.gyp:breakpad_client',92 ],93 'sources': [94 'crash/app_state_tracker.cc',95 'crash/app_state_tracker.h',96 'crash/cast_crash_keys.cc',97 'crash/cast_crash_keys.h',98 'crash/cast_crashdump_uploader.cc',99 'crash/cast_crashdump_uploader.h',100 'crash/linux/crash_util.cc',101 'crash/linux/crash_util.h',102 'crash/linux/dummy_minidump_generator.cc',103 'crash/linux/dummy_minidump_generator.h',104 'crash/linux/dump_info.cc',105 'crash/linux/dump_info.h',106 'crash/linux/minidump_generator.h',107 'crash/linux/synchronized_minidump_manager.cc',108 'crash/linux/synchronized_minidump_manager.h',109 'crash/linux/minidump_params.cc',110 'crash/linux/minidump_params.h',111 'crash/linux/minidump_writer.cc',112 'crash/linux/minidump_writer.h',113 ],114 }, # end of target 'cast_crash'115 {116 'target_name': 'cast_crash_client',117 'type': '<(component)',118 'dependencies': [119 'cast_crash',120 '../components/components.gyp:crash_component',121 '../content/content.gyp:content_common',122 ],123 'sources' : [124 # TODO(slan): Move android crash_client here as well.125 'app/linux/cast_crash_reporter_client.cc',126 'app/linux/cast_crash_reporter_client.h',127 ],128 }, # end of target 'cast_crash_client'129 {130 'target_name': 'cast_net',131 'type': '<(component)',132 'sources': [133 'net/connectivity_checker.cc',134 'net/connectivity_checker.h',135 'net/connectivity_checker_impl.cc',136 'net/connectivity_checker_impl.h',137 'net/fake_connectivity_checker.cc',138 'net/fake_connectivity_checker.h',139 'net/net_switches.cc',140 'net/net_switches.h',141 'net/net_util_cast.cc',142 'net/net_util_cast.h',143 ],144 'conditions': [145 ['OS!="android"', {146 'sources': [147 'net/network_change_notifier_factory_cast.cc',148 'net/network_change_notifier_factory_cast.h',149 ],150 }],151 ],152 },153 {154 'target_name': 'cast_shell_resources',155 'type': 'none',156 'variables': {157 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chromecast',158 },159 'actions': [160 {161 'action_name': 'cast_shell_resources',162 'variables': {163 'grit_grd_file': 'app/resources/shell_resources.grd',164 'grit_resource_ids': 'app/resources/resource_ids',165 },166 'includes': [ '../build/grit_action.gypi' ],167 },168 ],169 'includes': [ '../build/grit_target.gypi' ],170 },171 {172 'target_name': 'cast_shell_pak',173 'type': 'none',174 'dependencies': [175 'cast_shell_resources',176 '../content/app/resources/content_resources.gyp:content_resources',177 '../content/app/strings/content_strings.gyp:content_strings',178 '../net/net.gyp:net_resources',179 '../third_party/WebKit/public/blink_resources.gyp:blink_resources',180 '../ui/resources/ui_resources.gyp:ui_resources',181 '../ui/strings/ui_strings.gyp:ui_strings',182 ],183 'actions': [184 {185 'action_name': 'repack_cast_shell_pak',186 'variables': {187 'pak_inputs': [188 '<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_resources.pak',189 '<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_image_resources_100_percent.pak',190 '<(SHARED_INTERMEDIATE_DIR)/chromecast/shell_resources.pak',191 '<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak',192 '<(SHARED_INTERMEDIATE_DIR)/content/app/resources/content_resources_100_percent.pak',193 '<(SHARED_INTERMEDIATE_DIR)/content/app/strings/content_strings_en-US.pak',194 '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak',195 '<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_100_percent.pak',196 '<(SHARED_INTERMEDIATE_DIR)/ui/resources/webui_resources.pak',197 '<(SHARED_INTERMEDIATE_DIR)/ui/strings/app_locale_settings_en-US.pak',198 '<(SHARED_INTERMEDIATE_DIR)/ui/strings/ui_strings_en-US.pak',199 ],200 'conditions': [201 ['chromecast_branding=="Chrome" and use_chromecast_webui==1', {202 'pak_inputs': [203 '<(SHARED_INTERMEDIATE_DIR)/chromecast/app_resources.pak',204 '<(SHARED_INTERMEDIATE_DIR)/chromecast/cast_webui_resources.pak',205 ],206 }],207 ],208 'pak_output': '<(PRODUCT_DIR)/assets/cast_shell.pak',209 },210 'includes': [ '../build/repack_action.gypi' ],211 },212 ],213 'conditions': [214 ['chromecast_branding=="Chrome" and use_chromecast_webui==1', {215 'dependencies': [216 'internal/chromecast_resources.gyp:chromecast_app_resources',217 'internal/chromecast_resources.gyp:chromecast_webui_resources',218 ],219 }],220 ],221 }, # end of target 'cast_shell_pak'222 # This target contains all content-embedder implementation that is223 # non-platform-specific.224 {225 'target_name': 'cast_shell_common',226 'type': '<(component)',227 'dependencies': [228 'cast_base',229 'cast_crash_client',230 'cast_net',231 'cast_shell_pak',232 'cast_shell_resources',233 'cast_sys_info',234 'cast_version_header',235 'chromecast_locales.gyp:chromecast_locales_pak',236 'chromecast_locales.gyp:chromecast_settings',237 'media/media.gyp:media_base',238 'media/media.gyp:media_cdm',239 '../base/base.gyp:base',240 '../components/components.gyp:breakpad_host',241 '../components/components.gyp:cdm_renderer',242 '../components/components.gyp:component_metrics_proto',243 '../components/components.gyp:crash_component',244 '../components/components.gyp:devtools_discovery',245 '../components/components.gyp:devtools_http_handler',246 '../components/components.gyp:network_hints_browser',247 '../components/components.gyp:network_hints_renderer',248 '../components/components.gyp:metrics',249 '../components/components.gyp:metrics_gpu',250 '../components/components.gyp:metrics_net',251 '../components/components.gyp:metrics_profiler',252 '../content/content.gyp:content',253 '../content/content.gyp:content_app_both',254 '../skia/skia.gyp:skia',255 '../third_party/WebKit/public/blink.gyp:blink',256 '../third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_version_h',257 ],258 'sources': [259 'app/cast_main_delegate.cc',260 'app/cast_main_delegate.h',261 'browser/cast_browser_context.cc',262 'browser/cast_browser_context.h',263 'browser/cast_browser_main_parts.cc',264 'browser/cast_browser_main_parts.h',265 'browser/cast_browser_process.cc',266 'browser/cast_browser_process.h',267 'browser/cast_content_browser_client.cc',268 'browser/cast_content_browser_client.h',269 'browser/cast_content_window.cc',270 'browser/cast_content_window.h',271 'browser/cast_download_manager_delegate.cc',272 'browser/cast_download_manager_delegate.h',273 'browser/cast_http_user_agent_settings.cc',274 'browser/cast_http_user_agent_settings.h',275 'browser/cast_net_log.cc',276 'browser/cast_net_log.h',277 'browser/cast_network_delegate.cc',278 'browser/cast_network_delegate.h',279 'browser/cast_permission_manager.cc',280 'browser/cast_permission_manager.h',281 'browser/cast_quota_permission_context.cc',282 'browser/cast_quota_permission_context.h',283 'browser/cast_resource_dispatcher_host_delegate.cc',284 'browser/cast_resource_dispatcher_host_delegate.h',285 'browser/devtools/cast_dev_tools_delegate.cc',286 'browser/devtools/cast_dev_tools_delegate.h',287 'browser/devtools/remote_debugging_server.cc',288 'browser/devtools/remote_debugging_server.h',289 'browser/geolocation/cast_access_token_store.cc',290 'browser/geolocation/cast_access_token_store.h',291 'browser/media/cast_media_client_android.cc',292 'browser/media/cast_media_client_android.h',293 'browser/metrics/cast_metrics_prefs.cc',294 'browser/metrics/cast_metrics_prefs.h',295 'browser/metrics/cast_metrics_service_client.cc',296 'browser/metrics/cast_metrics_service_client.h',297 'browser/metrics/cast_stability_metrics_provider.cc',298 'browser/metrics/cast_stability_metrics_provider.h',299 'browser/metrics/platform_metrics_providers.h',300 'browser/pref_service_helper.cc',301 'browser/pref_service_helper.h',302 'browser/service/cast_service.cc',303 'browser/service/cast_service.h',304 'browser/url_request_context_factory.cc',305 'browser/url_request_context_factory.h',306 'common/cast_content_client.cc',307 'common/cast_content_client.h',308 'common/cast_resource_delegate.cc',309 'common/cast_resource_delegate.h',310 'common/media/cast_messages.h',311 'common/media/cast_message_generator.cc',312 'common/media/cast_message_generator.h',313 'common/platform_client_auth.h',314 'common/pref_names.cc',315 'common/pref_names.h',316 'renderer/cast_content_renderer_client.cc',317 'renderer/cast_content_renderer_client.h',318 'renderer/cast_media_load_deferrer.cc',319 'renderer/cast_media_load_deferrer.h',320 'renderer/cast_render_process_observer.cc',321 'renderer/cast_render_process_observer.h',322 'renderer/key_systems_cast.cc',323 'renderer/key_systems_cast.h',324 'renderer/media/capabilities_message_filter.cc',325 'renderer/media/capabilities_message_filter.h',326 ],327 'conditions': [328 ['chromecast_branding=="Chrome"', {329 'dependencies': [330 'internal/chromecast_internal.gyp:cast_shell_internal',331 ],332 }, {333 'sources': [334 'browser/cast_content_browser_client_simple.cc',335 'browser/cast_network_delegate_simple.cc',336 'browser/devtools/remote_debugging_server_simple.cc',337 'browser/metrics/platform_metrics_providers_simple.cc',338 'browser/pref_service_helper_simple.cc',339 'common/platform_client_auth_simple.cc',340 'renderer/cast_content_renderer_client_simple.cc',341 ],342 'conditions': [343 ['OS=="android"', {344 'sources': [345 'browser/service/cast_service_android.cc',346 'browser/service/cast_service_android.h',347 ],348 }, {349 'sources': [350 'browser/media/cast_browser_cdm_factory_simple.cc',351 'browser/service/cast_service_simple.cc',352 'browser/service/cast_service_simple.h',353 ],354 }],355 ],356 }],357 # ExternalMetrics not necessary on Android and (as of this writing) uses358 # non-portable filesystem operations. Also webcrypto is not used on359 # Android either.360 ['OS=="linux"', {361 'sources': [362 'browser/metrics/external_metrics.cc',363 'browser/metrics/external_metrics.h',364 'graphics/cast_screen.cc',365 'graphics/cast_screen.h',366 ],367 'dependencies': [368 '../components/components.gyp:metrics_serialization',369 '../ui/aura/aura.gyp:aura_test_support',370 ],371 }],372 ['OS=="android"', {373 'dependencies': [374 '../components/components.gyp:cdm_browser',375 ],376 }],377 ],378 },379 {380 'target_name': 'cast_sys_info',381 'type': '<(component)',382 'dependencies': [383 'cast_public_api',384 '../base/base.gyp:base',385 ],386 'sources': [387 'base/cast_sys_info_util.h',388 'base/cast_sys_info_dummy.cc',389 'base/cast_sys_info_dummy.h',390 ],391 'conditions': [392 ['chromecast_branding!="Chrome" and OS!="android"', {393 'sources': [394 'base/cast_sys_info_util_simple.cc',395 ],396 }],397 ],398 }, # end of target 'cast_sys_info'399 {400 'target_name': 'cast_version_header',401 'type': 'none',402 'direct_dependent_settings': {403 'include_dirs': [404 '<(SHARED_INTERMEDIATE_DIR)',405 ],406 },407 'actions': [408 {409 'action_name': 'version_header',410 'message': 'Generating version header file: <@(_outputs)',411 'inputs': [412 '<(version_path)',413 'base/version.h.in',414 ],415 'outputs': [416 '<(SHARED_INTERMEDIATE_DIR)/chromecast/base/version.h',417 ],418 'action': [419 'python',420 '<(version_py_path)',421 '-e', 'VERSION_FULL="<(version_full)"',422 # CAST_BUILD_INCREMENTAL is taken from buildbot if available;423 # otherwise, a dev string is used.424 '-e', 'CAST_BUILD_INCREMENTAL="<!(echo ${CAST_BUILD_INCREMENTAL:="<!(date +%Y%m%d.%H%M%S)"})"',425 # CAST_BUILD_RELEASE is taken from cast_build_release file if exist;426 # otherwise, a dev string is used.427 '-e', 'CAST_BUILD_RELEASE="<!(if test -f <(cast_build_release); then cat <(cast_build_release); else echo eng.${USER}; fi)"',428 '-e', 'CAST_IS_DEBUG_BUILD=1 if "<(CONFIGURATION_NAME)" == "Debug" or <(cast_is_debug_build) == 1 else 0',429 '-e', 'CAST_PRODUCT_TYPE=<(cast_product_type)',430 'base/version.h.in',431 '<@(_outputs)',432 ],433 'includes': [434 '../build/util/version.gypi',435 ],436 },437 ],438 },439 ], # end of targets440 # Targets for Android receiver.441 'conditions': [442 ['OS=="android"', {443 'targets': [444 {445 'target_name': 'cast_shell_icudata',446 'type': 'none',447 'dependencies': [448 '../third_party/icu/icu.gyp:icudata',449 '../v8/tools/gyp/v8.gyp:v8_external_snapshot',450 ],451 'copies': [{452 'destination': '<(PRODUCT_DIR)/assets',453 'files': [454 '<(PRODUCT_DIR)/icudtl.dat',455 '<(PRODUCT_DIR)/natives_blob.bin',456 '<(PRODUCT_DIR)/snapshot_blob.bin',457 ],458 }],459 },460 {461 'target_name': 'libcast_shell_android',462 'type': 'shared_library',463 'dependencies': [464 'cast_jni_headers',465 'cast_shell_common',466 'cast_shell_icudata',467 'cast_shell_pak',468 'cast_version_header',469 '../base/base.gyp:base',470 '../breakpad/breakpad.gyp:breakpad_client',471 '../components/components.gyp:breakpad_host',472 '../components/components.gyp:crash_component',473 '../components/components.gyp:external_video_surface',474 '../content/content.gyp:content',475 '../skia/skia.gyp:skia',476 '../ui/gfx/gfx.gyp:gfx',477 '../ui/gl/gl.gyp:gl',478 ],479 'include_dirs': [480 '../breakpad/src',481 ],482 'sources': [483 'android/cast_jni_registrar.cc',484 'android/cast_jni_registrar.h',485 'android/cast_metrics_helper_android.cc',486 'android/cast_metrics_helper_android.h',487 'android/platform_jni_loader.h',488 'app/android/cast_crash_reporter_client_android.cc',489 'app/android/cast_crash_reporter_client_android.h',490 'app/android/cast_jni_loader.cc',491 'app/android/crash_handler.cc',492 'app/android/crash_handler.h',493 'base/cast_sys_info_android.cc',494 'base/cast_sys_info_android.h',495 'base/chromecast_config_android.cc',496 'base/chromecast_config_android.h',497 'browser/android/cast_window_android.cc',498 'browser/android/cast_window_android.h',499 'browser/android/cast_window_manager.cc',500 'browser/android/cast_window_manager.h',501 ],502 'conditions': [503 ['chromecast_branding=="Chrome"', {504 'dependencies': [505 'internal/chromecast_internal.gyp:cast_shell_android_internal'506 ],507 }, {508 'sources': [509 'android/platform_jni_loader_stub.cc',510 ],511 }]512 ],513 }, # end of target 'libcast_shell_android'514 {515 'target_name': 'cast_base_java',516 'type': 'none',517 'dependencies': [518 '../base/base.gyp:base_java',519 ],520 'variables': {521 'android_manifest_path': 'android/AndroidManifest.xml',522 'java_in_dir': 'base/java',523 },524 'includes': ['../build/java.gypi'],525 }, # end of target 'cast_base_java'526 {527 'target_name': 'cast_shell_java',528 'type': 'none',529 'dependencies': [530 '<(android_support_v13_target)',531 'cast_base_java',532 'cast_shell_manifest',533 '../base/base.gyp:base_java',534 '../components/components.gyp:external_video_surface_java',535 '../content/content.gyp:content_java',536 '../media/media.gyp:media_java',537 '../net/net.gyp:net_java',538 '../ui/android/ui_android.gyp:ui_java',539 ],540 'variables': {541 'android_manifest_path': '<(SHARED_INTERMEDIATE_DIR)/cast_shell_manifest/AndroidManifest.xml',542 'has_java_resources': 1,543 'java_in_dir': 'browser/android/apk',544 'resource_dir': 'browser/android/apk/res',545 'R_package': 'org.chromium.chromecast.shell',546 },547 'includes': ['../build/java.gypi'],548 }, # end of target 'cast_shell_java'549 {550 'target_name': 'cast_shell_manifest',551 'type': 'none',552 'variables': {553 'jinja_inputs': ['browser/android/apk/AndroidManifest.xml.jinja2'],554 'jinja_output': '<(SHARED_INTERMEDIATE_DIR)/cast_shell_manifest/AndroidManifest.xml',555 },556 'includes': [ '../build/android/jinja_template.gypi' ],557 },558 {559 'target_name': 'cast_shell_apk',560 'type': 'none',561 'dependencies': [562 'cast_shell_java',563 'libcast_shell_android',564 ],565 'variables': {566 'apk_name': 'CastShell',567 'manifest_package_name': 'org.chromium.chromecast.shell',568 # Note(gunsch): there are no Java files in the android/ directory.569 # Unfortunately, the java_apk.gypi target rigidly insists on having570 # a java_in_dir directory, but complains about duplicate classes571 # from the common cast_shell_java target (shared with internal APK)572 # if the actual Java path is used.573 # This will hopefully be removable after the great GN migration.574 'java_in_dir': 'android',575 'android_manifest_path': '<(SHARED_INTERMEDIATE_DIR)/cast_shell_manifest/AndroidManifest.xml',576 'package_name': 'org.chromium.chromecast.shell',577 'native_lib_target': 'libcast_shell_android',578 'asset_location': '<(PRODUCT_DIR)/assets',579 'additional_input_paths': ['<(PRODUCT_DIR)/assets/cast_shell.pak'],580 },581 'includes': [ '../build/java_apk.gypi' ],582 },583 {584 'target_name': 'cast_jni_headers',585 'type': 'none',586 'sources': [587 'base/java/src/org/chromium/chromecast/base/ChromecastConfigAndroid.java',588 'browser/android/apk/src/org/chromium/chromecast/shell/CastCrashHandler.java',589 'browser/android/apk/src/org/chromium/chromecast/shell/CastMetricsHelper.java',590 'browser/android/apk/src/org/chromium/chromecast/shell/CastSysInfoAndroid.java',591 'browser/android/apk/src/org/chromium/chromecast/shell/CastWindowAndroid.java',592 'browser/android/apk/src/org/chromium/chromecast/shell/CastWindowManager.java',593 ],594 'direct_dependent_settings': {595 'include_dirs': [596 '<(SHARED_INTERMEDIATE_DIR)/chromecast',597 ],598 },599 'variables': {600 'jni_gen_package': 'chromecast',601 },602 'includes': [ '../build/jni_generator.gypi' ],603 },604 ], # end of targets605 }, { # OS != "android"606 'targets': [607 {608 'target_name': 'cast_shell_media',609 'type': '<(component)',610 'dependencies': [611 'media/media.gyp:cast_media',612 '../content/content.gyp:content',613 '../ipc/ipc.gyp:ipc',614 '../media/media.gyp:media',615 ],616 'sources': [617 'browser/media/cast_browser_cdm_factory.cc',618 'browser/media/cast_browser_cdm_factory.h',619 'browser/media/cma_message_filter_host.cc',620 'browser/media/cma_message_filter_host.h',621 'browser/media/media_pipeline_host.cc',622 'browser/media/media_pipeline_host.h',623 'common/media/cma_ipc_common.h',624 'common/media/cma_messages.h',625 'common/media/cma_message_generator.cc',626 'common/media/cma_message_generator.h',627 'common/media/cma_param_traits.cc',628 'common/media/cma_param_traits.h',629 'common/media/shared_memory_chunk.cc',630 'common/media/shared_memory_chunk.h',631 'renderer/media/audio_pipeline_proxy.cc',632 'renderer/media/audio_pipeline_proxy.h',633 'renderer/media/chromecast_media_renderer_factory.cc',634 'renderer/media/chromecast_media_renderer_factory.h',635 'renderer/media/cma_message_filter_proxy.cc',636 'renderer/media/cma_message_filter_proxy.h',637 'renderer/media/media_channel_proxy.cc',638 'renderer/media/media_channel_proxy.h',639 'renderer/media/media_pipeline_proxy.cc',640 'renderer/media/media_pipeline_proxy.h',641 'renderer/media/video_pipeline_proxy.cc',642 'renderer/media/video_pipeline_proxy.h',643 ],644 }, # end of target 'cast_shell_media'645 # This target contains all of the primary code of |cast_shell|, except646 # for |main|. This allows end-to-end tests using |cast_shell|.647 # This also includes all targets that cannot be built on Android.648 {649 'target_name': 'cast_shell_core',650 'type': '<(component)',651 'dependencies': [652 'cast_shell_media',653 'cast_shell_common',654 'media/media.gyp:cast_media',655 ],656 'conditions': [657 ['ozone_platform_egltest==1', {658 'dependencies': [659 '../ui/ozone/ozone.gyp:eglplatform_shim_x11',660 ],661 }],662 ],663 },664 {665 'target_name': 'cast_shell',666 'type': 'executable',667 'dependencies': [668 'cast_shell_core',669 ],670 'sources': [671 'app/cast_main.cc',672 ],673 'ldflags': [674 # Allow OEMs to override default libraries that are shipped with675 # cast receiver package by installed OEM-specific libraries in676 # /oem_cast_shlib.677 '-Wl,-rpath=/oem_cast_shlib',678 # TODO(dougsteed): remove when Chromecast moves to boringssl.679 # Allow the cast shell to find the NSS module in the same680 # directory.681 '-Wl,-rpath=\$$ORIGIN'682 ],683 },684 ], # end of targets685 }],686 ['enable_default_cast_graphics==1', {687 'targets': [688 {689 'target_name': 'libcast_graphics_1.0',690 'type': 'shared_library',691 'dependencies': [692 'cast_public_api'693 ],694 'sources': [695 'graphics/cast_egl_platform_default.cc',696 'graphics/graphics_properties_default.cc',697 'graphics/osd_plane_default.cc'698 ],699 }700 ]701 }],702 ], # end of conditions...

Full Screen

Full Screen

presentation_cast.js

Source:presentation_cast.js Github

copy

Full Screen

1// presentation_cast.js2// Implementation of the Presentation API [1] using the Google Cast SDK [2]3// mark a. foltz <mfoltz@google.com>4// [1] http://w3c.github.io/presentation-api/5// [2] https://developers.google.com/cast/docs/reference/chrome/6(function() {7 // Utility for logging messages to the developer console.8 window.log = {9 info: function(message) {console.info('[presentation_cast] ' + message);},10 warn: function(message) {console.warn('[presentation_cast] ' + message);},11 error: function(message) {console.error('[presentation_cast] ' + message);}12 };13 ////////////////////////////////////////////////////////////////////////////14 // Bookkeeping for the polyfill.15 // Whether the SDK is initialized.16 var castApiInitialized_ = false;17 // Cast Application Id for which the SDK was initialized18 var castApplicationId_ = undefined;19 // DIAL application name for which the SDK was initialized20 var dialApplicationName_ = undefined;21 // Map from presentationUrlL|id to the corresponding PresentationSession.22 var presentationSessions_ = {};23 // Map from Cast session id to the corresponding PresentationSession.24 var castSessions_ = {};25 // Keeps track of the PresentationSession that is currently being started or26 // joined, to link up with listeners in the Cast SDK.27 var pendingSession_ = null;28 var ORIGIN_RE_ = new RegExp('https?://[^/]+');29 var DIAL_URL_RE_ = new RegExp('https?://[^#]*#__dialAppName__=([^/]*)(/__dialPostData__=(.*))?$');30 var CAST_URL_RE_ = new RegExp('https?://[^#]*#__castAppId__=.*$');31 32 // Register DIAL applications that support WebSocket messaging here33 var DIAL_CAST_REGISTRY = {34 "Netflix" : { "cast" : "CA5E8412", "port" : 9080 }35 };36 37 // Register CAST applications that support CAST messaging here38 var CAST_NAMESPACE_REGISTRY = {39 "B46B8FE4" : 'urn:x-cast:org.w3.webscreens.presentationapi.shim',40 "5E735230" : 'urn:x-cast:org.w3.webscreens.presentationapi.shim',41 "CC9C7FD8" : 'urn:x-cast:org.w3.webscreens.presentationapi.shim'42 };43 // @return {string} A random 8 character identifier.44 var generateId_ = function() {45 return (Math.round(Math.random() * 3221225472) + 1073741824).toString(16);46 };47 ////////////////////////////////////////////////////////////////////////////48 // Implementation of Presentation API at49 // http://webscreens.github.io/presentation-api/50 // Namespace for the Presentation API51 var presentation = {52 // Event handler for AvailableChangeEvent.53 onavailablechange: null,54 // Is always null on the controlling page.55 session: null56 };57 // Constructor for AvailableChangeEvent.58 // @param {boolean} available True if a screen is available, false otherwise.59 var AvailableChangeEvent = function(available) {60 this.bubbles = false;61 this.cancelable = false;62 this.available = available;63 };64 // Constructor for StateChangeEvent.65 var StateChangeEvent = function(state) {66 this.bubbles = false;67 this.cancelable = false;68 this.state = state;69 };70 // Requests the initiation of a new presentation.71 // @param {string} presentationUrl The URL of the document to present.72 // @param {string=} presentationId An optional id to assign the presentation.73 // If not provided, a random one will be assigned.74 presentation.startSession = function(presentationUrl, presentationId) {75 var session = new PresentationSession(presentationUrl,76 presentationId || generateId_());77 return new Promise(function(resolve, reject) {78 if (!castApiInitialized_) {79 reject(Error('Cast SDK not initialized'));80 return;81 }82 var existingSession = presentationSessions_[session.key_];83 if (existingSession) {84 // User agent cannot have two sessions with identical URL+id.85 // TODO(mfoltz): Resolve to the existing session if the user selects86 // a screen running the same Cast session.87 reject(Error('Session already running for ' + session.key_));88 return;89 }90 presentationSessions_[session.key_] = session;91 // Request a new session from the Cast SDK.92 chrome.cast.requestSession(function(castSession) {93 log.info('Got cast session ' + castSession.sessionId +94 ' for presentation ' + session.key_);95 session.setCastSession_(castSession);96 castSessions_[castSession.sessionId] = session;97 resolve(session);98 // If it was a DIAL launch, after resolving the promise we'll asynchronously99 // post a message to the presentation session with the additionalData field100 // containing the <webSocketUrl> field.101 // CAST does not expose the additionalData from the DIAL REST API, so 102 // we reconstruct it here from the things that CAST does expose103 if (castSession.receiver.receiverType === "dial") {104 window.setTimeout(function() {105 106 // CAST does not pass back the Additional Data field, so for the107 // moment we need to fake out what it would contain108 var ipAddress = castSession.receiver.ipAddress;109 // Hardcoded port for now110 var port = DIAL_CAST_REGISTRY[ dialApplicationName_ ]['port'];111 // This ID is only required for Netflix MDX112 var id = encodeURIComponent(castSession.receiver.label);113 // Return the URL with all the info we need encoded114 var wsUrl = "ws://" + ipAddress + ":" + port + "?id=" + id,115 wsElement = "<webSocketUrl>" + wsUrl + "</webSocketUrl>",116 adElement = "<additionalData>" + wsElement + "</additionalData>";117 session.onmessage(adElement);118 }, 0);119 }120 }, function(castError) {121 reject(Error('Unable to create Cast session: ' + JSON.stringify(castError)));122 });123 });124 };125 // Requests the PresentationSession for an existing presentation.126 // @param {string} presentationUrl The URL of the document being presented.127 // @param {string} presentationId The id of the presentation..128 presentation.joinSession = function(presentationUrl, presentationId) {129 var session = new PresentationSession(presentationUrl,130 presentationId || generateId_());131 return new Promise(function(resolve, reject) {132 if (!castApiInitialized_) {133 reject(Error('Cast SDK not initialized'));134 return;135 }136 var existingSession = presentationSessions_[session.key_];137 if (existingSession) {138 resolve(existingSession);139 } else {140 // TODO(mfoltz): Keep promise pending in case the session is discovered later.141 reject(Error('No session available for ' + session.key_));142 }143 });144 };145 // Constructor for PresentationSession.146 // @param {string} presentationUrl The URL of the presentation.147 // @param {string} presentationId The id of the presentation.148 var PresentationSession = function(presentationUrl, presentationId) {149 this.url = presentationUrl;150 this.id = presentationId;151 this.state = 'disconnected';152 this.onmessage = null;153 this.onstatechange = null;154 // Private properties.155 this.key_ = this.url + '|' + this.id;156 this.origin_ = ORIGIN_RE_.exec(this.url)[0];157 this.castSessionId_ = null;158 this.castSession_ = null;159 };160 // Posts a message to the presentation.161 // @param {string} message The message to send.162 PresentationSession.prototype.postMessage = function(message) {163 if (this.castSession_ && this.state == 'connected' && this.castNamespace_ ) {164 log.info('postMessage to ' + this.key_ + ': ' + message);165 this.castSession_.sendMessage(this.castNamespace_,166 message,167 null,168 this.close.bind(this));169 } else {170 log.warn('postMessage failed for session ' + this.key_ +171 '; no Cast session or not connected or app does not support cast messaging');172 }173 };174 // Closes the presentation (by disconnecting from the underlying Cast175 // session).176 PresentationSession.prototype.close = function() {177 if (this.state == 'disconnected') {178 return;179 }180 if (this.castSession_) {181 this.castSession_.leave(182 function() {183 log.info('Cast session ' + this.castSessionId_ +184 ' left for presentation ' + this.key_);185 }.bind(this),186 function(error) {187 log.error('Cast session ' + this.castSessionId_ +188 ' for presentation ' + this.key_ + ' not left: ' +189 JSON.stringify(error));190 }.bind(this));191 }192 this.state = 'disconnected';193 this.fireStateChange_();194 };195 ////////////////////////////////////////////////////////////////////////////196 // Implementation specific functions. Not part of public API.197 PresentationSession.prototype.setCastSession_ = function(session) {198 if (this.castSession_) {199 console.info('PresentationSession ' + this.getKey_() +200 ' already associated with Cast session ' + session.id);201 return;202 }203 this.castSession_ = session;204 this.castSessionId = session.id;205 206 // See if this cast application is registered for CAST messaging207 if ( CAST_NAMESPACE_REGISTRY[ castApplicationId_ ] ) {208 209 this.castNamespace_ = CAST_NAMESPACE_REGISTRY[ castApplicationId_ ];210 211 this.castSession_.addMessageListener(this.castNamespace_,212 this.onPresentationMessage_.bind(this));213 }214 215 this.castSession_.addUpdateListener(this.onCastSessionUpdate_.bind(this));216 217 this.state = 'connected';218 this.fireStateChange_();219 };220 PresentationSession.prototype.onPresentationMessage_ =221 function(namespace, message) {222 if (namespace != this.castNamespace_ ||223 typeof(this.onmessage) != 'function') {224 return;225 }226 this.onmessage({data: message, origin: this.origin_, lastEventId: '',227 source: null, ports: null});228 };229 PresentationSession.prototype.onCastSessionUpdate_ = function(isAlive) {230 if (isAlive && this.state == 'disconnected') {231 this.state = 'connected';232 this.fireStateChange_();233 }234 if (!isAlive && this.state == 'connected') {235 this.state = 'disconnected';236 this.fireStateChange_();237 }238 };239 PresentationSession.prototype.fireStateChange_ = function() {240 if (typeof(this.onstatechange) == 'function') {241 this.onstatechange(new StateChangeEvent(this.state));242 }243 };244 PresentationSession.prototype.getKey_ = function() {245 return this.url + '|' + this.id;246 };247 PresentationSession.prototype.hasCastSession_ = function() {248 return typeof(this.castSession_) == 'object';249 };250 PresentationSession.prototype.maybePresentUrl_ = function() {251 // TODO(mfoltz): Check if the receiver is already displaying the URL.252 this.postMessage({cmd: 'open', url: this.url});253 };254 ////////////////////////////////////////////////////////////////////////////255 // Integration with Cast SDK.256 // Invoked when a Cast session is automatically connected. Currently we don't257 // support auto-join/auto-fling with this polyfill.258 var onCastSession_ = function(castSession) {259 log.info('onCastSession: connected to session ' + castSession.sessionId);260 };261 // Invoked when a Cast receiver is available or not.262 var onCastReceiverAvailable_ = function(availability) {263 if (typeof(navigator.presentation.onavailablechange) != 'function') {264 return;265 }266 log.info('onCastReceiverAvailable: available = ' + availability);267 if (availability == chrome.cast.ReceiverAvailability.AVAILABLE) {268 navigator.presentation.onavailablechange(new AvailableChangeEvent(true));269 } else {270 navigator.presentation.onavailablechange(new AvailableChangeEvent(false));271 }272 };273 // Initialization function for CAST detection274 var initializeCast_ = function( castAppId ) {275 return new Promise(function(resolve, reject) {276 var apiConfig = new chrome.cast.ApiConfig(277 new chrome.cast.SessionRequest(castAppId),278 onCastSession_,279 onCastReceiverAvailable_,280 chrome.cast.AutoJoinPolicy.PAGE_SCOPED);281 chrome.cast.initialize(282 apiConfig,283 function() {284 log.info('Cast Sender SDK initialized successfully for CAST App Id ' + castAppId );285 castApiInitialized_ = true;286 castApplicationId_ = castAppId;287 resolve();288 },289 function(error) {290 log.error('Unable to initialize Cast Sender SDK: ' + JSON.stringify(error));291 reject(Error(JSON.stringify(error)));292 });293 });294 };295 296 // Initialization function for DIAL detection297 var initializeDial_ = function(castAppId, dialAppName, dialLaunchPayload) {298 return new Promise(function(resolve, reject) {299 chrome.cast.timeout.requestSession = 30000;300 var sessionRequest = new chrome.cast.SessionRequest(castAppId);301 sessionRequest.dialRequest = new chrome.cast.DialRequest(dialAppName, dialLaunchPayload);302 var apiConfig = new chrome.cast.ApiConfig(303 sessionRequest,304 onCastSession_,305 onCastReceiverAvailable_,306 chrome.cast.AutoJoinPolicy.PAGE_SCOPED,307 chrome.cast.DefaultActionPolicy.CREATE_SESSION);308 chrome.cast.initialize(309 apiConfig,310 function() {311 log.info('Cast Sender SDK initialized successfully for DIAL application ' + dialAppName),312 castApiInitialized_ = true;313 castApplicationId_ = castAppId;314 dialApplicationName_ = dialAppName;315 resolve();316 },317 function(error) {318 log.error('Unable to initialize Cast Sender SDK: ' + JSON.stringify(error));319 reject(Error(JSON.stringify(error)));320 });321 });322 };323 // Load the Cast Sender SDK.324 window['__onGCastApiAvailable'] = function(loaded, error) {325 if (!loaded) {326 log.error('Cast Sender SDK not available: ' + JSON.stringify(error));327 return;328 }329 // Look for default URL330 var links = Array.prototype.slice.call( document.head.getElementsByTagName("link") )331 .filter( function( l ) { return l.rel == "default-presentation"; } );332 333 if ( links.length == 0 ) {334 log.error("No default presentation URL found");335 return;336 }337 338 var match = DIAL_URL_RE_.exec( links[ 0 ].href );339 if ( match && match[ 0 ] ) {340 341 // Initialize Cast detection for this application342 var dialAppName = match[1],343 castAppId = DIAL_CAST_REGISTRY[ dialAppName ]['cast'];344 345 if ( !castAppId ) {346 log.error("No CAST Application ID for DIAL Application " + dialAppName );347 return;348 }349 350 log.info("Initializing with DIAL Application Name: " + dialAppName351 + " and post data: " + match[3] );352 353 // Bind polyfill.354 navigator['presentation'] = presentation;355 356 // Initialize DIAL 357 initializeDial_( castAppId, dialAppName, match[3] ).then( function() {358 // Invoke a well-known callback so clients are notified when they can359 // call functions in the polyfill.360 if (typeof window['__onPresentationAvailable'] == 'function') {361 window['__onPresentationAvailable']();362 }363 } );364 } else {365 366 match = CAST_URL_RE_.exec( links[ 0 ].href );367 if ( !match || !match[0] ) {368 log.error("No CAST or DIAL application name in default presentation URL");369 return;370 }371 372 // Bind polyfill.373 navigator['presentation'] = presentation;374 375 // Initialize CAST 376 initializeCast_( match[0] ).then( function() {377 // Invoke a well-known callback so clients are notified when they can378 // call functions in the polyfill.379 if (typeof window['__onPresentationAvailable'] == 'function') {380 window['__onPresentationAvailable']();381 }382 } ); 383 }384 };385 386 // Pull in the CAST sender SDK387 var script = document.createElement('script');388 script.src = 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js';389 document.head.appendChild(script);390})();391// TODO: Fix this...

Full Screen

Full Screen

cast_testing.gypi

Source:cast_testing.gypi Github

copy

Full Screen

1# Copyright 2014 The Chromium Authors. All rights reserved.2# Use of this source code is governed by a BSD-style license that can be3# found in the LICENSE file.4{5 'targets': [6 {7 # GN version: //media/cast:test_support8 'target_name': 'cast_test_utility',9 'type': 'static_library',10 'include_dirs': [11 '<(DEPTH)/',12 ],13 'dependencies': [14 'cast_net',15 'cast_receiver',16 '<(DEPTH)/testing/gtest.gyp:gtest',17 '<(DEPTH)/third_party/ffmpeg/ffmpeg.gyp:ffmpeg',18 '<(DEPTH)/third_party/libyuv/libyuv.gyp:libyuv',19 '<(DEPTH)/third_party/mt19937ar/mt19937ar.gyp:mt19937ar',20 '<(DEPTH)/ui/gfx/gfx.gyp:gfx_geometry',21 ],22 'sources': [23 'test/fake_media_source.cc',24 'test/fake_media_source.h',25 'test/fake_single_thread_task_runner.cc',26 'test/fake_single_thread_task_runner.h',27 'test/loopback_transport.cc',28 'test/loopback_transport.h',29 'test/skewed_single_thread_task_runner.cc',30 'test/skewed_single_thread_task_runner.h',31 'test/skewed_tick_clock.cc',32 'test/skewed_tick_clock.h',33 'test/utility/audio_utility.cc',34 'test/utility/audio_utility.h',35 'test/utility/barcode.cc',36 'test/utility/barcode.h',37 'test/utility/default_config.cc',38 'test/utility/default_config.h',39 'test/utility/in_process_receiver.cc',40 'test/utility/in_process_receiver.h',41 'test/utility/input_builder.cc',42 'test/utility/input_builder.h',43 'test/utility/net_utility.cc',44 'test/utility/net_utility.h',45 'test/utility/standalone_cast_environment.cc',46 'test/utility/standalone_cast_environment.h',47 'test/utility/udp_proxy.cc',48 'test/utility/udp_proxy.h',49 'test/utility/video_utility.cc',50 'test/utility/video_utility.h',51 ], # source52 },53 {54 # GN version: //media/cast:cast_unittests55 'target_name': 'cast_unittests',56 'type': '<(gtest_target_type)',57 'include_dirs': [58 '<(DEPTH)/',59 ],60 'dependencies': [61 'cast_base',62 'cast_net',63 'cast_receiver',64 'cast_sender',65 'cast_test_utility',66 # Not a true dependency. This is here to make sure the CQ can verify67 # the tools compile correctly.68 'cast_tools',69 '<(DEPTH)/base/base.gyp:test_support_base',70 '<(DEPTH)/net/net.gyp:net',71 '<(DEPTH)/testing/gmock.gyp:gmock',72 '<(DEPTH)/testing/gtest.gyp:gtest',73 ],74 'sources': [75 '<(DEPTH)/media/base/run_all_unittests.cc',76 'logging/encoding_event_subscriber_unittest.cc',77 'logging/logging_impl_unittest.cc',78 'logging/logging_raw_unittest.cc',79 'logging/receiver_time_offset_estimator_impl_unittest.cc',80 'logging/serialize_deserialize_test.cc',81 'logging/simple_event_subscriber_unittest.cc',82 'logging/stats_event_subscriber_unittest.cc',83 'net/cast_transport_sender_impl_unittest.cc',84 'net/frame_id_wrap_helper_test.cc',85 'net/mock_cast_transport_sender.cc',86 'net/mock_cast_transport_sender.h',87 'net/pacing/mock_paced_packet_sender.cc',88 'net/pacing/mock_paced_packet_sender.h',89 'net/pacing/paced_sender_unittest.cc',90 'net/rtcp/receiver_rtcp_event_subscriber_unittest.cc',91 'net/rtcp/rtcp_builder_unittest.cc',92 'net/rtcp/rtcp_unittest.cc',93 'net/rtcp/rtcp_utility_unittest.cc',94# TODO(miu): The following two are test utility modules. Rename/move the files.95 'net/rtcp/test_rtcp_packet_builder.cc',96 'net/rtcp/test_rtcp_packet_builder.h',97 'net/rtp/cast_message_builder_unittest.cc',98 'net/rtp/frame_buffer_unittest.cc',99 'net/rtp/framer_unittest.cc',100 'net/rtp/mock_rtp_payload_feedback.cc',101 'net/rtp/mock_rtp_payload_feedback.h',102 'net/rtp/packet_storage_unittest.cc',103 'net/rtp/receiver_stats_unittest.cc',104 'net/rtp/rtp_header_parser.cc',105 'net/rtp/rtp_header_parser.h',106 'net/rtp/rtp_packet_builder.cc',107 'net/rtp/rtp_packetizer_unittest.cc',108 'net/rtp/rtp_parser_unittest.cc',109 'net/rtp/rtp_receiver_defines.h',110 'net/udp_transport_unittest.cc',111 'receiver/audio_decoder_unittest.cc',112 'receiver/frame_receiver_unittest.cc',113 'receiver/video_decoder_unittest.cc',114 'sender/audio_encoder_unittest.cc',115 'sender/audio_sender_unittest.cc',116 'sender/congestion_control_unittest.cc',117 'sender/fake_video_encode_accelerator_factory.cc',118 'sender/fake_video_encode_accelerator_factory.h',119 'sender/video_encoder_unittest.cc',120 'sender/video_sender_unittest.cc',121 'test/end2end_unittest.cc',122 'test/fake_receiver_time_offset_estimator.cc',123 'test/fake_receiver_time_offset_estimator.h',124 'test/fake_single_thread_task_runner.cc',125 'test/fake_single_thread_task_runner.h',126 'test/utility/audio_utility_unittest.cc',127 'test/utility/barcode_unittest.cc',128 ], # source129 },130 {131 'target_name': 'cast_benchmarks',132 'type': '<(gtest_target_type)',133 'include_dirs': [134 '<(DEPTH)/',135 ],136 'dependencies': [137 'cast_base',138 'cast_net',139 'cast_receiver',140 'cast_sender',141 'cast_test_utility',142 '<(DEPTH)/base/base.gyp:test_support_base',143 '<(DEPTH)/net/net.gyp:net',144 '<(DEPTH)/testing/gtest.gyp:gtest',145 ],146 'sources': [147 'test/cast_benchmarks.cc',148 'test/fake_single_thread_task_runner.cc',149 'test/fake_single_thread_task_runner.h',150 'test/utility/test_util.cc',151 'test/utility/test_util.h',152 ], # source153 'conditions': [154 ['os_posix==1 and OS!="mac" and OS!="ios" and use_allocator!="none"',155 {156 'dependencies': [157 '<(DEPTH)/base/allocator/allocator.gyp:allocator',158 ],159 }160 ],161 ],162 },163 {164 # This is a target for the collection of cast development tools.165 # They are built on bots but not shipped.166 'target_name': 'cast_tools',167 'type': 'none',168 'dependencies': [169 'cast_receiver_app',170 'cast_sender_app',171 'cast_simulator',172 'udp_proxy',173 ],174 },175 {176 'target_name': 'cast_receiver_app',177 'type': 'executable',178 'include_dirs': [179 '<(DEPTH)/',180 ],181 'dependencies': [182 'cast_base',183 'cast_net',184 'cast_receiver',185 'cast_test_utility',186 '<(DEPTH)/ui/gfx/gfx.gyp:gfx_geometry',187 '<(DEPTH)/net/net.gyp:net_test_support',188 '<(DEPTH)/media/media.gyp:media',189 '<(DEPTH)/testing/gtest.gyp:gtest',190 '<(DEPTH)/third_party/libyuv/libyuv.gyp:libyuv',191 ],192 'sources': [193 '<(DEPTH)/media/cast/test/receiver.cc',194 ],195 'conditions': [196 ['OS == "linux" and use_x11==1', {197 'dependencies': [198 '<(DEPTH)/build/linux/system.gyp:x11',199 '<(DEPTH)/build/linux/system.gyp:xext',200 ],201 'sources': [202 '<(DEPTH)/media/cast/test/linux_output_window.cc',203 '<(DEPTH)/media/cast/test/linux_output_window.h',204 ],205 }],206 ],207 },208 {209 'target_name': 'cast_sender_app',210 'type': 'executable',211 'include_dirs': [212 '<(DEPTH)/',213 ],214 'dependencies': [215 'cast_base',216 'cast_net',217 'cast_sender',218 'cast_test_utility',219 '<(DEPTH)/net/net.gyp:net_test_support',220 '<(DEPTH)/media/media.gyp:media',221 '<(DEPTH)/testing/gtest.gyp:gtest',222 '<(DEPTH)/third_party/ffmpeg/ffmpeg.gyp:ffmpeg',223 '<(DEPTH)/third_party/opus/opus.gyp:opus',224 '<(DEPTH)/ui/gfx/gfx.gyp:gfx_geometry',225 ],226 'sources': [227 '<(DEPTH)/media/cast/test/sender.cc',228 ],229 },230 {231 'target_name': 'cast_simulator',232 'type': 'executable',233 'include_dirs': [234 '<(DEPTH)/',235 ],236 'dependencies': [237 'cast_base',238 'cast_net',239 'cast_network_model_proto',240 'cast_sender',241 'cast_test_utility',242 '<(DEPTH)/net/net.gyp:net_test_support',243 '<(DEPTH)/media/media.gyp:media',244 '<(DEPTH)/testing/gtest.gyp:gtest',245 '<(DEPTH)/third_party/ffmpeg/ffmpeg.gyp:ffmpeg',246 '<(DEPTH)/third_party/opus/opus.gyp:opus',247 '<(DEPTH)/ui/gfx/gfx.gyp:gfx_geometry',248 ],249 'sources': [250 '<(DEPTH)/media/cast/test/simulator.cc',251 ],252 },253 {254 # GN version: //media/cast/test/proto255 'target_name': 'cast_network_model_proto',256 'type': 'static_library',257 'include_dirs': [258 '<(DEPTH)/',259 ],260 'sources': [261 'test/proto/network_simulation_model.proto',262 ],263 'variables': {264 'proto_in_dir': 'test/proto',265 'proto_out_dir': 'media/cast/test/proto',266 },267 'includes': ['../../build/protoc.gypi'],268 },269 {270 # GN version: //media/cast:generate_barcode_video271 'target_name': 'generate_barcode_video',272 'type': 'executable',273 'include_dirs': [274 '<(DEPTH)/',275 ],276 'dependencies': [277 'cast_test_utility',278 '<(DEPTH)/base/base.gyp:base',279 '<(DEPTH)/media/media.gyp:media',280 ],281 'sources': [282 'test/utility/generate_barcode_video.cc',283 ],284 },285 {286 # GN version: //media/cast:generate_timecode_audio287 'target_name': 'generate_timecode_audio',288 'type': 'executable',289 'include_dirs': [290 '<(DEPTH)/',291 ],292 'dependencies': [293 'cast_base',294 'cast_net',295 'cast_test_utility',296 '<(DEPTH)/base/base.gyp:base',297 '<(DEPTH)/media/media.gyp:media',298 ],299 'sources': [300 'test/utility/generate_timecode_audio.cc',301 ],302 },303 {304 # GN version: //media/cast:udp_proxy305 'target_name': 'udp_proxy',306 'type': 'executable',307 'include_dirs': [308 '<(DEPTH)/',309 ],310 'dependencies': [311 'cast_test_utility',312 '<(DEPTH)/base/base.gyp:base',313 '<(DEPTH)/media/media.gyp:media',314 ],315 'sources': [316 'test/utility/udp_proxy_main.cc',317 ],318 },319 ], # targets320 'conditions': [321 ['OS=="linux"',322 { 'targets': [323 {324 'target_name': 'tap_proxy',325 'type': 'executable',326 'include_dirs': [327 '<(DEPTH)/',328 ],329 'dependencies': [330 'cast_test_utility',331 '<(DEPTH)/base/base.gyp:base',332 '<(DEPTH)/media/media.gyp:media',333 ],334 'sources': [335 'test/utility/tap_proxy.cc',336 ],337 }338 ]339 }340 ],341 ['OS=="ios" or OS=="mac"', {342 'targets': [343 {344 # GN version: //media/cast:cast_h264_vt_encoder_unittests345 'target_name': 'cast_h264_vt_encoder_unittests',346 'type': '<(gtest_target_type)',347 'include_dirs': [348 '<(DEPTH)/',349 ],350 'dependencies': [351 'cast_base',352 'cast_sender',353 'cast_test_utility',354 '<(DEPTH)/base/base.gyp:test_support_base',355 '<(DEPTH)/testing/gmock.gyp:gmock',356 '<(DEPTH)/testing/gtest.gyp:gtest',357 '<(DEPTH)/third_party/ffmpeg/ffmpeg.gyp:ffmpeg',358 ],359 'sources': [360 'sender/h264_vt_encoder_unittest.cc',361 ],362 }], # targets363 }], # OS=="ios" or OS=="mac"364 ['test_isolation_mode != "noop"', {365 'targets': [366 {367 'target_name': 'cast_unittests_run',368 'type': 'none',369 'dependencies': [370 'cast_unittests',371 ],372 'includes': [373 '../../build/isolate.gypi',374 ],375 'sources': [376 'cast_unittests.isolate',377 ],378 },379 ],380 }],381 ], # conditions...

Full Screen

Full Screen

test_magic_shield_keeper.py

Source:test_magic_shield_keeper.py Github

copy

Full Screen

1#!/usr/bin/env python3.82import unittest3from typing import Dict, Any4from unittest import TestCase5from unittest.mock import Mock6from tibia_terminator.keeper.magic_shield_keeper import MagicShieldKeeper7from tibia_terminator.reader.color_spec import (AmuletName, RingName)8from tibia_terminator.common.char_status import CharStatus9from tibia_terminator.reader.equipment_reader import MagicShieldStatus10START_TIME = 10011TOTAL_HP = 100012TOTAL_MANA = 100013SPEED = 10014MAGIC_SHIELD = 100015MAGIC_SHIELD_TRESHOLD = 90016EQUIPMENT_STATUS = {17 'emergency_action_amulet': AmuletName.UNKNOWN,18 'equipped_amulet': AmuletName.EMPTY,19 'emergency_action_ring': RingName.UNKNOWN,20 'equipped_ring': RingName.EMPTY,21 'magic_shield_status': MagicShieldStatus.OFF_COOLDOWN22}23class CharStatusStub(CharStatus):24 def __init__(self,25 hp: int = TOTAL_HP,26 speed: int = SPEED,27 mana: int = TOTAL_MANA,28 magic_shield_level: int = MAGIC_SHIELD,29 equipment_status: Dict[str, Any] = EQUIPMENT_STATUS):30 super().__init__(hp, speed, mana, magic_shield_level, equipment_status)31class TestMagicShieldKeeper(TestCase):32 def setUp(self):33 self.char_status = CharStatus(TOTAL_MANA, TOTAL_HP, 1000, MAGIC_SHIELD,34 EQUIPMENT_STATUS)35 self.mock_client = Mock()36 self.mock_cast_magic_shield = self.mock_client.cast_magic_shield37 self.mock_cancel_magic_shield = self.mock_client.cancel_magic_shield38 self.target = MagicShieldKeeper(self.mock_client, TOTAL_HP,39 MAGIC_SHIELD_TRESHOLD, self.time_fn)40 self.time = START_TIME41 def time_fn(self):42 return self.time43 def make_equipment_status(self, **kwargs) -> Dict[str, Any]:44 result = EQUIPMENT_STATUS.copy()45 for key, value in kwargs.items():46 result[key] = value47 return result48 def make_char_status(self, *args, **kwargs):49 return CharStatusStub(*args, **kwargs)50 def test_should_cast_magic_shield(self):51 # given52 char_status = self.make_char_status(53 mana=(TOTAL_HP * 1.5) + 1,54 magic_shield_level=MAGIC_SHIELD_TRESHOLD,55 equipment_status=self.make_equipment_status(56 magic_shield_status=MagicShieldStatus.OFF_COOLDOWN))57 cases = [58 char_status,59 char_status.copy(mana=(TOTAL_HP * 1.5) + 2),60 char_status.copy(magic_shield_level=MAGIC_SHIELD_TRESHOLD - 1)61 ]62 # when - then63 for _char_status in cases:64 self.check_should_cast_magic_shield(_char_status)65 def check_should_cast_magic_shield(self, char_status: CharStatus):66 # given67 self.mock_cast_magic_shield.reset_mock()68 # when69 self.target.handle_status_change(char_status)70 # then71 self.mock_cast_magic_shield.assert_called_once()72 def test_should_not_cast_magic_shield(self):73 # given74 char_status = self.make_char_status(75 mana=(TOTAL_HP * 1.5) + 1,76 magic_shield_level=MAGIC_SHIELD_TRESHOLD,77 equipment_status=self.make_equipment_status(78 magic_shield_status=MagicShieldStatus.OFF_COOLDOWN))79 cases = [80 char_status.copy(magic_shield_level=MAGIC_SHIELD_TRESHOLD + 1),81 char_status.copy(mana=TOTAL_HP * 1.5),82 char_status.copy(equipment_status=self.make_equipment_status(83 magic_shield_status=MagicShieldStatus.ON_COOLDOWN))84 ]85 # when - then86 for _char_status in cases:87 self.check_should_not_cast_magic_shield(_char_status)88 def check_should_not_cast_magic_shield(self, char_status: CharStatus):89 # given90 # when91 self.target.handle_status_change(char_status)92 # then93 self.mock_cast_magic_shield.assert_not_called()94 def test_should_cast_cancel_magic_shield(self):95 # given96 cast_mana = (TOTAL_HP * 1.5) + 197 cast_char_status = self.make_char_status(98 mana=cast_mana,99 magic_shield_level=cast_mana / 2,100 equipment_status=self.make_equipment_status(101 magic_shield_status=MagicShieldStatus.OFF_COOLDOWN))102 cancel_mana = (TOTAL_HP * 1.25)103 cases = [104 cast_char_status.copy(mana=cancel_mana),105 cast_char_status.copy(mana=cancel_mana - 1),106 cast_char_status.copy(mana=cancel_mana,107 magic_shield_level=(cancel_mana / 2) + 1)108 ]109 for cancel_char_status in cases:110 self.mock_cancel_magic_shield.reset_mock()111 self.target.handle_status_change(cast_char_status)112 # when113 self.target.handle_status_change(cancel_char_status)114 # then115 self.mock_cancel_magic_shield.assert_called_once()116 def test_should_not_cast_cancel_magic_shield(self):117 # given118 cast_mana = (TOTAL_HP * 1.5) + 1119 cast_char_status = self.make_char_status(120 mana=cast_mana,121 magic_shield_level=cast_mana / 2,122 equipment_status=self.make_equipment_status(123 magic_shield_status=MagicShieldStatus.OFF_COOLDOWN))124 cancel_mana = (TOTAL_HP * 1.25)125 cases = [126 cast_char_status.copy(mana=cancel_mana + 1),127 cast_char_status.copy(mana=cancel_mana + 2),128 cast_char_status.copy(mana=cancel_mana,129 magic_shield_level=(cancel_mana / 2)),130 cast_char_status.copy(mana=cancel_mana,131 magic_shield_level=(cancel_mana / 2) - 1),132 cast_char_status.copy(mana=cancel_mana,133 magic_shield_level=(cancel_mana / 2) - 2)134 ]135 for not_cast_cancel_char_status in cases:136 self.mock_cancel_magic_shield.reset_mock()137 self.target.handle_status_change(cast_char_status)138 # when139 self.target.handle_status_change(not_cast_cancel_char_status)140 # then141 self.mock_cancel_magic_shield.assert_not_called()142 def test_should_recast_magic_shield(self):143 # given144 cast_mana = (TOTAL_HP * 1.5) + 1145 cast_char_status = self.make_char_status(146 mana=cast_mana,147 magic_shield_level=cast_mana / 2,148 equipment_status=self.make_equipment_status(149 magic_shield_status=MagicShieldStatus.OFF_COOLDOWN))150 recast_char_status = cast_char_status.copy(151 equipment_status=self.make_equipment_status(152 magic_shield_status=MagicShieldStatus.OFF_COOLDOWN))153 self.target.handle_status_change(cast_char_status)154 # when155 self.target.handle_status_change(recast_char_status)156 # then157 self.assertEqual(self.mock_cast_magic_shield.call_count, 2)158 def test_should_not_recast_magic_shield(self):159 # given160 cast_mana = (TOTAL_HP * 1.5) + 1161 cast_char_status = self.make_char_status(162 mana=cast_mana,163 magic_shield_level=cast_mana / 2,164 equipment_status=self.make_equipment_status(165 magic_shield_status=MagicShieldStatus.OFF_COOLDOWN))166 cases = [167 cast_char_status.copy(equipment_status=self.make_equipment_status(168 magic_shield_status=MagicShieldStatus.ON_COOLDOWN)),169 cast_char_status.copy(equipment_status=self.make_equipment_status(170 magic_shield_status=MagicShieldStatus.RECENTLY_CAST))171 ]172 for not_recast_char_status in cases:173 self.mock_cast_magic_shield.reset_mock()174 self.target.handle_status_change(cast_char_status)175 # when176 self.target.handle_status_change(not_recast_char_status)177 # then178 self.assertEqual(self.mock_cast_magic_shield.call_count, 1)179 def test_should_refresh_magic_shield(self):180 # given181 cast_mana = (TOTAL_HP * 1.5) + 1182 refresh_char_status = self.make_char_status(183 mana=cast_mana,184 magic_shield_level=MAGIC_SHIELD_TRESHOLD + 1,185 equipment_status=self.make_equipment_status(186 magic_shield_status=MagicShieldStatus.OFF_COOLDOWN))187 # when-then188 for time in [179, 180, 181, 170, 171]:189 self.check_refresh_magic_shield(refresh_char_status,190 time,191 call_count=1)192 def test_should_not_refresh_magic_shield(self):193 # given194 cast_mana = (TOTAL_HP * 1.5) + 1195 refresh_char_status = self.make_char_status(196 mana=cast_mana,197 magic_shield_level=MAGIC_SHIELD_TRESHOLD + 1,198 equipment_status=self.make_equipment_status(199 magic_shield_status=MagicShieldStatus.OFF_COOLDOWN))200 # when-then201 for time in [169, 168, 0, 1]:202 self.check_refresh_magic_shield(refresh_char_status,203 time,204 call_count=0)205 def check_refresh_magic_shield(self, refresh_char_status: CharStatus,206 time: int, call_count: int):207 # given208 cast_mana = (TOTAL_HP * 1.5) + 1209 cast_char_status = self.make_char_status(210 mana=cast_mana,211 magic_shield_level=cast_mana / 2,212 equipment_status=self.make_equipment_status(213 magic_shield_status=MagicShieldStatus.OFF_COOLDOWN))214 casted_char_status = cast_char_status.copy(215 equipment_status=self.make_equipment_status(216 magic_shield_status=MagicShieldStatus.ON_COOLDOWN))217 self.mock_cast_magic_shield.reset_mock()218 self.target.handle_status_change(cast_char_status)219 self.target.handle_status_change(casted_char_status)220 # when221 self.time += time222 self.target.handle_status_change(refresh_char_status)223 # then224 self.assertEqual(self.mock_cast_magic_shield.call_count,225 call_count + 1)226if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful