Files
UnrealEngineUWP/Engine/Source/Developer/AutomationController/Private/AutomationControllerManger.cpp
Marc Audy a66199e8a7 Copying //UE4/Dev-Framework to //UE4/Dev-Main (Source: //UE4/Dev-Framework @ 3628051)
#lockdown Nick.Penwarden
#rb none
#rnx

============================
  MAJOR FEATURES & CHANGES
============================

Change 3582363 by Marc.Audy

	Make ComponentToWorld fully private and remove deprecation informing of this
	#jira UE-46286

Change 3582885 by Ben.Zeigler

	#jira UE-47642 Add ToString for SoftObjectReference/SoftClassReference/PrimaryAssetId/PrimaryAssetType to use for debugging. The other direction is not provided because the type validation cannot be done at runtime

Change 3584468 by Ben.Zeigler

	#jira UE-48301 Avoid infinite recursion crash when cooking client/server only component blueprints

Change 3584596 by Marc.Audy

	(4.17) Ensure that old user defined structs have their members properly marked as blueprint visible
	#jira UE-48346

Change 3586057 by Ben.Zeigler

	#jira UE-48413 Fix issue where running a dedicated server with a fixed framerate could cause a time crash because the "last time" was out of sync. Clarified code to indicate which times are real and which are logical. This manifested as a crash in EngineTest but could happen in any game with a fixed framerate

Change 3588211 by Marc.Audy

	PR #3889: Added BLUEPRINTGRAPH_API module specifier to the input nodes. (Contributed by karanseqwb)
	#jira UE-48318

Change 3588826 by Marc.Audy

	Don't ensure when connecting the output pin of a create delegate node to a wildcard input
	#jira UE-48157

Change 3588827 by Marc.Audy

	Always throw error when unable to validate a link connection instead of allowing totally broken content to compile

Change 3588872 by Ben.Zeigler

	#jira UE-48457 Add Export To CSV to content browser/asset audit windows that are in the column view. This is useful for preparing memory/disk usage reports

Change 3589134 by Dan.Oconnor

	Mirror 3585244 from Release 4.17
	Run actor construction via UBlueprint::BroadcastCompiled after reinstancing, matching non-compilation manager behavior
	#jira UE-48189

Change 3589140 by Dan.Oconnor

	Mirror 3588406 from Release-4.17
	Set "WorldContext" metadata earlier in the compilation process, so that it can be used reliably in other blueprints. This fixes occasionally 'None' WorldContext references

	#jira UE-48464

Change 3589141 by Dan.Oconnor

	Mirror 3588681 from Release-4.17
	Set Default values and CallInEditor meta data for event nodes

	#jira UE-48386

Change 3590690 by Ben.Zeigler

	#jira UE-48509 Fix crash in incremental cook when a file in the incremental cook was deleted from p4

Change 3590909 by Ben.Zeigler

	#jira UE-48509 Fix crash in incremental cooker when DDC data is not built for a package that is skipped for rebuilding. The cached data would not be checked for completness, but would assert becuase it was not complete.
	WillNeverCacheCookedPlatformDataAgain no longer does anything other than assert, so remove it.

Change 3591386 by Marc.Audy

	Split pins are now correctly handled when expanding macros and functions.
	#jira UE-47747

Change 3591939 by Dan.Oconnor

	Mirror 3591923 from Release-4.17
	Split ReplaceInstancesOfClass_Inner into two passes, one for objects and one for actors because actor reconstruction needs all components to be of final class type (e.g. not REINST_ or HOT_RELOAD_)
	#jira UE-48250

Change 3593243 by Marc.Audy

	PR #3910: Add FQuat initialization from FString (Contributed by cneumann)
	#jira UE-48534

Change 3593407 by Marc.Audy

	Properly expose Lex::To/FromString for FName

Change 3593648 by Marc.Audy

	Refactor AActor::PostEditUndo to have a single implementation to avoid incosistent fixes

Change 3593917 by Marc.Audy

	Improved comment

Change 3594501 by Marc.Audy

	Fix biased shuffle algorithm
	#jira UE-48432

Change 3594699 by Ben.Zeigler

	#jira UE-48555 Fix crash where async loading flush update callback was happening in the async loading thread, it's supposed to be a game delegate
	Fix InstancedStaticMesh to not ensure when loaded via the async loading thread

Change 3595327 by Phillip.Kavan

	#jira UE-16485 - Add an option to host global Blueprint searches in a dockable tab that's not tied to any Blueprint editor context.

	Change summary:
	- Added a few additional Slate editor style descriptors specifically for the Find Results tab.
	- Added a private dependency on the 'WorkspaceMenuStructure' module to the 'Kismet' editor module.
	- Added a new Blueprint Editor settings option to the "Workflow" section to toggle the feature on/off (now set to 'on' by default).
	- Added a UBluepriintEditorSettings::PostEditChangeProperty() implementation to reset FiB state upon changing the experimental toggle switch.
	- Modified the FFindResultsSummoner ctor to use an alternate tooltip when the feature is turned on. In that case the "local" Find Results tab will always search only the local BP context.
	- Modified FBlueprintEditor::OnRequestClose() to additionally find and close the local Find Results tab if the feature is turned on and we're not in a full BP editor context. This ensures that the local Find Results tab context will be reset to hidden if the option is toggled while a defaults-only BP editor context is active.
	- Modified FBlueprintEditor::SummonSearchUI() to invoke the global Find Results tab if the feature is turned on and 'bSetFindWithinBlueprint' is true.
	- Simplified FBlueprintEditor::FindInBlueprint_Clicked() and FBlueprintEditor::FindInBlueprints_OnClicked() to call SummonSearchUI().
	- Moved the FFindInBlueprintsResult declaration into FindInBlueprintManager.h. Also relocated the ExpandAllChildren API out of this class and into the localized FindInBlueprintsHelpers util class.
	- Added new FFindInBlueprintSearchManager public APIs - GetGlobalFindResults() and CloseAllGlobalResults(). Also added a delegate for handling cleanup after a global Find Results tab is closed.
	- When the feature is turned on, global Find Results tabs will be named "Find in Blueprints" to correlate to the menu command that's bound to CTRL-SHIFT-F. An index will be appended to the tab name if more than one context is active.
	- Extended FFindInBlueprintSearchManager to support spawning and maintaining up to 4 global Find Results widget contexts. These are registered and spawned as "nomad" tabs, but they don't currently auto-insert into the menu. Instead, they are invoked internally by the GetGlobalFindResults() API as needed, in response to the BP editor's "Find in Blueprints" command.
	- Extended the SFindInBlueprints widget to support a "locked" state and allow users to toggle it via an SButton. This is visible only in the global Find Results context.
	- Extended the SFindInBlueprints widget to support an additional "Find in All Blueprints" button on the local Find Results context. Clicking the button will invoke an unlocked global Find Results tab and initiate a global search with the text taken from the local context. This is visible only in the local Find Results context.
	- Removed the "Find in Current Blueprint only" checkbox from the local Find Results context when the feature is enabled. Global searches are instead redirected to the global Find Results tab.

Change 3596499 by Marc.Audy

	Fix non-editor CIS error

Change 3596653 by Marc.Audy

	When a transaction is cancelled the previous redo buffer will now be restored instead of lost
	#jira UE-48513

Change 3598187 by Ben.Zeigler

	Add ability for automation command line to run as remote session with Automation StartRemoteSession (SessionGuid). In this mode it waits for external clients to be ready
	Fix functional tests to work in editor builds with -game by forcing an asset registry scan

Change 3598193 by Ben.Zeigler

	Add support for -TcpMessagingListen=IP:port and TcpMessagingConnect=IP:Port command line options to the TCP messaging layer, this is used by automation to connect a specific device to an editor coordinator.

Change 3600168 by Marc.Audy

	(4.17.2) Protect against crash when ParentClass has become null for unknown reasons
	#jira UE-47467

Change 3600457 by Ben.Zeigler

	Fix issue where nonblocking BSD sockets on some platforms may return EINPROGRESS on initial connect, which should not be treated as an error

Change 3600462 by Ben.Zeigler

	Remove platform whitelist from TcpMessaging plugin, this was effectively blocking it on all other platforms

Change 3600685 by Marc.Audy

	(4.17.2) ParentClass is known to be able to be null if a class has been deleted without redirector. Allow the class to be marked deprecated under this circumstance.
	#jira UE-47467

Change 3600859 by Marc.Audy

	(4.17.2) Prevent error pop ups about failing to save world due to save on compile of blueprints
	#jira UE-48672

Change 3600918 by Marc.Audy

	Transient child actor components should create transient child actors.
	#jira UE-48605

Change 3601012 by Ben.Zeigler

	Fix TCP Messaging system to work better on non desktop by sleeping for some real time during the thread tick.
	Add verbose logs and fix warning spam about thread stats being duplicated by renaming the thread per connection.

Change 3602595 by Marc.Audy

	(4.17.2) PR #3930: Fix compiler error for PS4 if a nativized blueprint invokes a method of its own through interface (Contributed by hillin)
	#jira UE-48684

Change 3602644 by Ben.Zeigler

	Add game game thread asserts to streamable manager to track down possible async loading thread issues

Change 3602745 by Ben.Zeigler

	Add Tolerance parameters to AssertEqual_Rotator and Transform, Vector and Float already had them

Change 3602807 by Phillip.Kavan

	#jira UE-48426
	- Fix runtime crash in a nativized child Blueprint that includes a parent function call node in a replicated function implementation.

	Change summary:
	- Modified FBlueprintCompilerCppBackend::EmitCallStatmentInner() to append the "_Implementation" postfix to parent RPC calls in a child class RPC implementation.

Change 3602856 by Ben.Zeigler

	Fix fixed frame rate to be more stable by computing delta time as doubles, to avoid rounding issues

Change 3602903 by Marc.Audy

	Allow Scale to be set on an AnimNotify as well as the spawn emitter gameplay statics
	#jira UE-39362

Change 3602963 by Marc.Audy

	PR #3762: DisableHaptics disables haptics properly (Contributed by projectgheist)
	#jira UE-46960

Change 3603249 by Marc.Audy

	Prevent compilation of a blueprint containing a child actor component to mark the blueprint the child actor's class dirty
	#jira UE-43328

Change 3603311 by Ben.Zeigler

	Add -nocodesign option to disable code signing during staging

Change 3603504 by Ben.Zeigler

	#jira UE-27124 Fix crash during PIE by ensuring the world package PIE flag is always set, even if it's loaded via redirector

Change 3604790 by Marc.Audy

	Fix inability to undo Add Pin via context menu to make container nodes.
	#jira UE-48751

Change 3605079 by mason.seay

	Renamed component from Cube to Cylinder, because it's actually a Cylinder

Change 3605113 by Mieszko.Zielinski

	PR #3927: Fixed issue of behavior if setting InfiniteLoopTimeoutTime variable (Contributed by yhase7)


Change 3605276 by mason.seay

	Fixed comment error in level bp

Change 3605706 by Zak.Middleton

	#ue4 - Fix redundant GetDefault<>.

	#jira none

Change 3605850 by Zak.Middleton

	#ue4 -  Fix client assert when trying to send RPCs while connection is pending closure due to queued bunches. ChIndex is -1 during this time, though the channel is not actually closed. Added ensure when calling SendBunch() under this condition to catch future cases like this.

	(Mirror CL 3602849 in Fortnite)

	#jira FORT-51215, UT-6139

Change 3607677 by Dan.Oconnor

	Mirror 3597636 from Release-4.17
	Don't clear UClass CDO until after we've duplicated the class, in case class duplication wants to read from the CDO (e.g. when duplicating a class that has ChildActorComponents)
	#jira UE-48524

Change 3607704 by Dan.Oconnor

	Back out changelist 3607677 - want to obliterate integration record

Change 3607727 by Dan.Oconnor

	Mirror 3597636 from Release-4.17 - now with integrations converted to edits
	Don't clear UClass CDO until after we've duplicated the class, in case class duplication wants to read from the CDO (e.g. when duplicating a class that has ChildActorComponents)
	#jira UE-48524

Change 3607735 by Dan.Oconnor

	Mirror 3606248 from Release-4.17
	When copying data from old archetypes to new archetypes we want to use delta's from the old instances, but only when reliable (e.g. not CDO)

	#jira UE-48697, UE-48465

Change 3607919 by Ben.Zeigler

	#jira UE- 48815
	Fix issue where StreamableHandle CompletedDelegate wasn't being reset after being called. If this had a payload pointing to the handle the handle would then be kept alive forever due to the reference counting, causing bad memory leaks
	Copy of CL #3607743

Change 3608447 by mason.seay

	Fixing deprecated node

Change 3608779 by Ben.Zeigler

	#jira UE-48762 Do not rename a PIE world in place if it was loaded by redirector, this corrupts the redirector and later crashes if used again

Change 3609860 by Marc.Audy

	Allow uint8:1 properties to be used as expose on spawn

	#jira FORT-52043

Change 3609877 by Marc.Audy

	Reduce size of UProperty and UWidgetBlueprintGeneratedClass by 8 bytes
	Reduce size UBlueprintGeneratedClass by 32 bytes

	#jira FORT-52043

Change 3609944 by Marc.Audy

	Remove unused per instance physics create/destroyed delegates from UActorComponent (reduce size by 224 bytes)

Change 3610009 by mason.seay

	Moving assets to another folder for organization

Change 3610840 by Ben.Zeigler

	#jira UE-47351 Fix multiple launch ons inside the editor to correctly detect changed source files by refreshing the asset registry each time.
	Packages are now always saved to disk before launch on so we just need to load the data off disk and then refresh the registry generators.

Change 3610961 by Ben.Zeigler

	Fix it so when a test times out it writes out the full report with a proper error
	Fix typo with ErrorCount

Change 3611183 by Marc.Audy

	(4.17.2) Don't crash clicking the variable of a deleted component
	#jira UE-47678

Change 3611262 by Ben.Zeigler

	#jira UE-41412 Fix Delegate ImportText to check the outer chain for owning object before searching all packages, this fixes several issues with copy-pasting actors that have bound delegates

Change 3611667 by Phillip.Kavan

	#jira UE-48450
	- Fix UHT C++ codegen compile error (regression) after choosing to package with Blueprint nativization enabled if the project includes a converted User-Defined Structure asset.

Change 3612641 by Marc.Audy

	Private StaticMesh, remove deprecation warning

Change 3612990 by Marc.Audy

	Reduce memory footprint of UClass

Change 3613137 by Ben.Zeigler

	#jira UE-44570 Fix issue with GUID struct customization where it would generate a post edit after modifying only the first element in the GUID, which caused the property handle to get invalidated

Change 3613161 by Ben.Zeigler

	#jira UE-48372 Add InRange (Int) for Blueprints, and cleanup KismetMathLibrary.h comments
	PR #3899

Change 3613192 by Ben.Zeigler

	#jira UE-48366 PR #3895 Fix missing small icons within the blueprint Merge and diff tools

Change 3613320 by Mason.Seay

	Submitting deleted redirectors

Change 3613321 by Marc.Audy

	Shrink AActor 32 bytes

Change 3613326 by Marc.Audy

	Move Serialize to be editoronly

Change 3613358 by Phillip.Kavan

	#jira UE-48525 - Fix non-native script interface property value initialization for nativized Blueprint class default objects.

	Change summary:
	- Modified FEmitDefaultValueHelper::HandleSpecialTypes() to special-case interface property values when emitting initialization code for converted class subobjects.

Change 3613827 by Marc.Audy

	Combine material parameter caches of UMeshComponent in to a single sorted map instead of 3 independent maps (saves ~224 bytes)

Change 3613841 by Ben.Zeigler

	#jira UE-48800 Fix crash with undoing blueprint changes while blueprint differ is open, it now listens for blueprint changes

Change 3614031 by Marc.Audy

	Fix initialization order

Change 3614033 by Marc.Audy

	Use Reset instead of Empty in get functions

Change 3615211 by Ben.Zeigler

	Fix CIS warning

Change 3615386 by Ben.Zeigler

	#jira UE-48976 Fix crash compiling user struct when out of date nodes point to it

Change 3615571 by Ben.Zeigler

	#jira UE-48974 Fix crash trying to reconnect blueprint pins with null connections

Change 3615844 by Marc.Audy

	(4.17.2) Reexpose WeightedBlendables/Post Process Materials to blueprints
	#jira UE-48977

Change 3615887 by Marc.Audy

	(4.17.2) Don't crash getting context menu actions if the variable get doesn't have a value pin
	#jira UE-48970

Change 3615965 by Dan.Oconnor

	Make sure that depedent blueprints are bytecode recompiled (e.g. child blueprints that are also dependent must also be bytecode recompiled), also no longer call RefreshNodes on dependent blueprints of interfaces, as this is no longer needed and can result in incoherent skeleton class hierarchies

	#jira UE-48429, UE-48433, UE-48437, UE-48445, UE-48692

Change 3616149 by mason.seay

	Updated BP for more thorough Find in BP testing

Change 3616261 by Dan.Oconnor

	Mirror 3594264 and 3594798 from Release-4.17
	Fix crash after compiling a blueprint that has an invalid ParentClass
	#jira UE-48430, UE-48903

Change 3616816 by Zak.Middleton

	#ue4 - Add GetTargetRotation() to SpringArmComponent, which returns the rotation target based on the combination of various rotation setting flags (bUsePawnControlRotation, bInheritPitch, bInheritYaw, bInheritRoll, absolute rotation flags).

	#jira UE-48351

Change 3616934 by Phillip.Kavan

	#jira UE-48877 - Close a disabled new-style global find tab if docked after restoring a previously-saved Blueprint editor layout.

	Change summary:
	- Modified FBlueprintEditor::PostLayoutBlueprintEditorInitialization() to close any active global tabs after restoring from a saved layout if the option is disabled.

Change 3616946 by Phillip.Kavan

	#jira UE-48595 - Global FiB Results are now accessible through the main Window menu.

Change 3618007 by Marc.Audy

	(4.17.2) Ensure that RootComponent is correct after undo/redo
	#jira UE-48995

Change 3618014 by Phillip.Kavan

	#jira UE-49025 - Fix global FiB menu item names.

Change 3618206 by Dan.Oconnor

	Make sure instances in the same package as a UBlueprintGeneratedClass are properly created after the CDO

	#jira UE-47991, UE-47726

Change 3618211 by Dan.Oconnor

	Fix 'bad' USE_DEFERRED_DEPENDENCY_CHECK_VERIFICATION_TEST - this is only broken until we get the fix from core that restores CLASS_Intrinsic

Change 3618299 by Zak.Middleton

	#ue4 - Fix comment in GetComponents (UActorComponent version)

	#jira none

Change 3618409 by Marc.Audy

	Make linker placeholder properly support map and set properties
	#jira UE-48925

Change 3618436 by Marc.Audy

	Fix shadow variable

Change 3618682 by Ben.Zeigler

	Fix issue where pressing escape or losing focus while using a SpinBox would leave the UI in a state where the SpinBox could never be used again, caused by CL #3173966. Also fix the initial value to be correct the first time it is dragged

Change 3618783 by Ben.Zeigler

	Fix several issues with the Component Transform details UI
	#jira UE-48959 Fix it so the world/relative transform type bools are correctly propagated to inherited components when modified via editor customizations
	#jira UE-48963 Refactor Transform customization to handle paste and reset to default as atomic operations, allowing them to work properly on blueprint component instances
	#jira UE-48960 Correctly notify blueprint system when component transforms are changed
	#jira UE-4311 Preserve exact rotation typed into component rotation field in most cases
	Fix the "Reset to Defaults" icon to be correct in transform details

Change 3618904 by Ben.Zeigler

	#jira UE-489999 Fix blueprint breakpoint crash when breakpoint data is out of date with UI

Change 3618984 by Zak.Middleton

	#ue4 - Reduce memory churn/allocations when duplicating for PIE.

	#jira none

Change 3619895 by Marc.Audy

	Very minor cleanup

Change 3620129 by Marc.Audy

	PR #3958: Exposing GetOwningPlayerController and GetOwningPawn as public in AHUD. (Contributed by ill)
	#jira UE-49083

Change 3620350 by Lukasz.Furman

	restored intended behavior of path following's acceptance radius: additive with goal and agent radii (included when FAIMoveRequest flags allow it)
	copy of CL# 3618825, 3618828
	#ue4

Change 3620628 by Zak.Middleton

	#ue4 - Moved hardcoded limits on FCollisionShape extents to a static value and refactored external code to reference that instead.

	Fixed Capsules where axis length (half-height - radius) < 1 were clamped to a new capsule with axis length of 1. Changed the clamp threshold to 1e-4 and changed FPhysXShapeAdaptor to use a Sphere instead when Radius >= HalfHeight.

	This would cause sweeps using the capsule params to use a capsule of a different size, up to 1 UU different along the axis.

	#jira UE-49035

Change 3620700 by Lukasz.Furman

	moved blackboard decortator's version of requesting abort to parent class, so all decorators can use it with external events
	#ue4

Change 3620716 by mason.seay

	Test map for flow control save issue

Change 3620723 by mason.seay

	Minor improvement

Change 3620792 by Ben.Zeigler

	Clang doesn't like template specializations in classes, switch to an overload instead to fix CIS

Change 3621084 by Marc.Audy

	Fix NegateInt/Float in StandardMacros
	#jira UE-36242
	#jira UE-36470

Change 3621152 by Marc.Audy

	Fix backwards compatibility on FEdGraphPinType for particularly old blueprints.
	#jira UE-49111

Change 3621246 by mason.seay

	Test BP for UE-48800

Change 3621257 by Michael.Noland

	Animation: Corrected a comment on the LegIK node

Change 3621480 by Zak.Middleton

	#ue4 - Added FTransform::TransformRotation(FQuat) and FTransform::InverseTransformRotation(FQuat). Added matching Blueprint library functions taking FRotator.

	#jira UE-39088
	#github PR 2985 (modified)

Change 3621685 by Phillip.Kavan

	#jira UE-49024 - Add/remove global FiB menu items from the Main Menu when the global FiB option is enabled/disabled.

	Change summary:
	- Added FFindInBlueprintSearchManager::EnableGlobalFindResults(). Now using this API to enable/disable both the Main menu items as well as the global FiB workflow change within the BP editor context.
	- Renamed FFindInBlueprintSearchManager::CloseAllGlobalResults() to CloseOrphanedGlobalFindResultsTabs(). This is now being called to clean up any orphaned global FiB tabs when opening the BP editor context.

Change 3622629 by Marc.Audy

	Reduce memory footprint of UMG/Slate classes: UWidget, UBorder, UImage, UUserWidget, SWidget, SButton, SOverlay, SBoxPanel, SInlineEditableTextBlock, FSlateFontInfo, EVisibility, FSlateBrush, FCheckBoxStyle, FButtonStyle, FComboBoxStyle

Change 3622779 by Zak.Middleton

	#ue4 - Rename USceneComponent::bWorldToComponentUpdated to bComponentToWorldUpdated (since the transform is called ComponentToWorld).

	#jira none

Change 3623020 by Marc.Audy

	Fix initialization order

Change 3623021 by Marc.Audy

	Reorganize USceneComponent to improve cache coherency

Change 3623261 by Ben.Zeigler

	#jira UE-48555: Fix for corruption of shared pointers by the async loading thread. It is unsafe to copy delegates by value on the async loading threads because they may have shared pointers on them that are being used by the main thread. Instead of copying by value, we now allocate once on the game thread and copy by TUniquePtr.

Change 3623294 by Marc.Audy

	Realign UActorComponent to avoid members crossing cache lines

Change 3623383 by Marc.Audy

	Compress UParticleSystemComponent and fix up cases of members crossing cache lines

Change 3623492 by Marc.Audy

	(4.17.2) Fix pin values on function nodes not correctly carrying the value between reloads/refreshes
	#jira UE-49189
	#jira UE-49196

Change 3623573 by Ben.Zeigler

	#jira UE-49223 Fix crash when undoing changes to actors that have been recompiled. We need to skip most of PostEditUndo when the class is out of date and this got broken in a recent refactor

Change 3623642 by Dan.Oconnor

	Make sure we don't attempt to defer exports that rely on CDOs that have been regenerated

	#jira UE-49211

Change 3623719 by Marc.Audy

	PR #3387: Added new Swap method (blueprint KismetArrayLibrary). (Contributed by RChehowski)
	#jira UE-42970

Change 3624191 by Marc.Audy

	Cache GetWorld()

Change 3624232 by Marc.Audy

	Remove accidentally checked in change

Change 3624688 by Marc.Audy

	PR #3491: Client play force feedback can now ignore time dilation. (Contributed by miracle7)
	Force feedback component can also ignore time dilation
	#jira UE-44155

Change 3624880 by Marc.Audy

	PR #3970: SpawnObject not checking for a nullptr causing an editor crash

Change 3625740 by Mason.Seay

	Check in the correct file this time...

Change 3625806 by Ben.Zeigler

	#jira UE-48555 Code review fix for async loading thread fixes, disable an assert when cancel is called in non-EDL, and add comment + assert if Cancel is re-enabled for EDL in the future

Change 3626128 by Marc.Audy

	Fix dragging off component tree in to graph showing an error message
	#jira UE-49114

Change 3626655 by Ben.Zeigler

	#jira OR-43846 Fix asset import objects to correctly load off disk again. They aren't marked as SubObjects so the special case code to add the NeedsLoad flag wasn't getting hit. Change it so in the editor it marks all unloaded subobjects as needs load, need to talk to Core about rather this fix should be editor specific or not

Change 3626740 by Marc.Audy

	Fix compile errors when nativizing when a property references a sub object of a dervied type with modified default properties
	#jira UE-49276

Change 3626831 by Marc.Audy

	Remove BOM

Change 3627162 by Phillip.Kavan

	#jira UE-49239 - Fix an invalid cast emitted to nativized codegen for converted AnimBP types.

	- Regression introduced in CL# 3613358.

Change 3628051 by Marc.Audy

	Fix spelling of redundant
	#jira UE-49343

Change 3596437 by Marc.Audy

	Don't copy metadata unnecessarily

Change 3613302 by Marc.Audy

	Reduce size of UStaticMeshComponent by 224 bytes (cumulative, 56 bytes exclusive)
	Reduce size of UPrimitiveComponent by 176 bytes (cumulative, 64 bytes exclusive).
	Reduce size of USceneComponent by 112 bytes.
	Reduce size of FLightingChannels from 3 bytes to 1.
	Reduce size of FBodyInstance by 16 bytes.

Change 3620363 by Lukasz.Furman

	split UBTTask_MoveTo.bStopOnOverlap flag to separate goal & agent parts to match actual parameters of AI move request, added simple versioning for behavior tree nodes
	copy of CL# 3620248
	#ue4

Change 3622569 by Marc.Audy

	Remove unnecessarily deprecated visibility member and use redirect instead

Change 3624879 by Marc.Audy

	Add a deprecated version of ClientPlayForceFeedback for backwards compatibility.
	Adjust existing game calls to ClientPlayrForceFeedback to use new API

[CL 3628687 by Marc Audy in Main branch]
2017-09-06 14:17:59 -04:00

1205 lines
40 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "CoreMinimal.h"
#include "HAL/FileManager.h"
#include "Misc/CommandLine.h"
#include "Misc/Paths.h"
#include "Misc/ConfigCacheIni.h"
#include "Misc/AutomationTest.h"
#include "Misc/App.h"
#include "IAutomationReport.h"
#include "AutomationWorkerMessages.h"
#include "IMessageContext.h"
#include "MessageEndpoint.h"
#include "MessageEndpointBuilder.h"
#include "Modules/ModuleManager.h"
#include "AssetEditorMessages.h"
#include "ImageComparer.h"
#include "AutomationControllerManager.h"
#include "Interfaces/IScreenShotToolsModule.h"
#include "Serialization/JsonSerializer.h"
#include "JsonObjectConverter.h"
#include "Misc/EngineVersion.h"
#include "Misc/FileHelper.h"
#include "PlatformHttp.h"
#if WITH_EDITOR
#include "Logging/MessageLog.h"
#endif
DEFINE_LOG_CATEGORY_STATIC(AutomationControllerLog, Log, All)
FAutomationControllerManager::FAutomationControllerManager()
{
CheckpointFile = nullptr;
if ( !FParse::Value(FCommandLine::Get(), TEXT("ReportOutputPath="), ReportOutputPath, false) )
{
if ( FParse::Value(FCommandLine::Get(), TEXT("DeveloperReportOutputPath="), ReportOutputPath, false) )
{
ReportOutputPath = ReportOutputPath / TEXT("dev") / FString(FPlatformProcess::UserName()).ToLower();
}
}
if ( FParse::Value(FCommandLine::Get(), TEXT("DeveloperReportUrl="), DeveloperReportUrl, false) )
{
DeveloperReportUrl = DeveloperReportUrl / TEXT("dev") / FString(FPlatformProcess::UserName()).ToLower() / TEXT("index.html");
}
}
void FAutomationControllerManager::RequestAvailableWorkers(const FGuid& SessionId)
{
//invalidate previous tests
++ExecutionCount;
DeviceClusterManager.Reset();
ControllerResetDelegate.Broadcast();
// Don't allow reports to be exported
bTestResultsAvailable = false;
//store off active session ID to reject messages that come in from different sessions
ActiveSessionId = SessionId;
//EAutomationTestFlags::FilterMask
//TODO AUTOMATION - include change list, game, etc, or remove when launcher is integrated
int32 ChangelistNumber = 10000;
FString ProcessName = TEXT("instance_name");
MessageEndpoint->Publish(new FAutomationWorkerFindWorkers(ChangelistNumber, FApp::GetProjectName(), ProcessName, SessionId), EMessageScope::Network);
// Reset the check test timers
LastTimeUpdateTicked = FPlatformTime::Seconds();
CheckTestTimer = 0.f;
IScreenShotToolsModule& ScreenShotModule = FModuleManager::LoadModuleChecked<IScreenShotToolsModule>("ScreenShotComparisonTools");
ScreenshotManager = ScreenShotModule.GetScreenShotManager();
}
void FAutomationControllerManager::RequestTests()
{
//invalidate incoming results
ExecutionCount++;
//reset the number of responses we have received
RefreshTestResponses = 0;
ReportManager.Empty();
for ( int32 ClusterIndex = 0; ClusterIndex < DeviceClusterManager.GetNumClusters(); ++ClusterIndex )
{
int32 DevicesInCluster = DeviceClusterManager.GetNumDevicesInCluster(ClusterIndex);
if ( DevicesInCluster > 0 )
{
FMessageAddress MessageAddress = DeviceClusterManager.GetDeviceMessageAddress(ClusterIndex, 0);
//issue tests on appropriate platforms
MessageEndpoint->Send(new FAutomationWorkerRequestTests(bDeveloperDirectoryIncluded, RequestedTestFlags), MessageAddress);
}
}
}
void FAutomationControllerManager::RunTests(const bool bInIsLocalSession)
{
ExecutionCount++;
CurrentTestPass = 0;
ReportManager.SetCurrentTestPass(CurrentTestPass);
ClusterDistributionMask = 0;
bTestResultsAvailable = false;
TestRunningArray.Empty();
bIsLocalSession = bInIsLocalSession;
// Reset the check test timers
LastTimeUpdateTicked = FPlatformTime::Seconds();
CheckTestTimer = 0.f;
#if WITH_EDITOR
FMessageLog AutomationTestingLog("AutomationTestingLog");
FString NewPageName = FString::Printf(TEXT("-----Test Run %d----"), ExecutionCount);
FText NewPageNameText = FText::FromString(*NewPageName);
AutomationTestingLog.Open();
AutomationTestingLog.NewPage(NewPageNameText);
AutomationTestingLog.Info(NewPageNameText);
#endif
//reset all tests
ReportManager.ResetForExecution(NumTestPasses);
for ( int32 ClusterIndex = 0; ClusterIndex < DeviceClusterManager.GetNumClusters(); ++ClusterIndex )
{
//enable each device cluster
ClusterDistributionMask |= ( 1 << ClusterIndex );
//for each device in this cluster
for ( int32 DeviceIndex = 0; DeviceIndex < DeviceClusterManager.GetNumDevicesInCluster(ClusterIndex); ++DeviceIndex )
{
//mark the device as idle
DeviceClusterManager.SetTest(ClusterIndex, DeviceIndex, NULL);
// Send command to reset tests (delete local files, etc)
FMessageAddress MessageAddress = DeviceClusterManager.GetDeviceMessageAddress(ClusterIndex, DeviceIndex);
MessageEndpoint->Send(new FAutomationWorkerResetTests(), MessageAddress);
}
}
// Inform the UI we are running tests
if ( ClusterDistributionMask != 0 )
{
SetControllerStatus(EAutomationControllerModuleState::Running);
}
}
void FAutomationControllerManager::StopTests()
{
bTestResultsAvailable = false;
ClusterDistributionMask = 0;
ReportManager.StopRunningTests();
// Inform the UI we have stopped running tests
if ( DeviceClusterManager.HasActiveDevice() )
{
SetControllerStatus(EAutomationControllerModuleState::Ready);
}
else
{
SetControllerStatus(EAutomationControllerModuleState::Disabled);
}
TestRunningArray.Empty();
}
void FAutomationControllerManager::Init()
{
extern void EmptyLinkFunctionForStaticInitializationAutomationExecCmd();
EmptyLinkFunctionForStaticInitializationAutomationExecCmd();
AutomationTestState = EAutomationControllerModuleState::Disabled;
bTestResultsAvailable = false;
bSendAnalytics = FParse::Param(FCommandLine::Get(), TEXT("SendAutomationAnalytics"));
}
void FAutomationControllerManager::RequestLoadAsset(const FString& InAssetName)
{
MessageEndpoint->Publish(new FAssetEditorRequestOpenAsset(InAssetName), EMessageScope::Process);
}
void FAutomationControllerManager::Tick()
{
ProcessAvailableTasks();
ProcessComparisonQueue();
}
void FAutomationControllerManager::ProcessComparisonQueue()
{
TSharedPtr<FComparisonEntry> Entry;
if ( ComparisonQueue.Peek(Entry) )
{
if ( Entry->PendingComparison.IsReady() )
{
const bool Dequeued = ComparisonQueue.Dequeue(Entry);
check(Dequeued);
FImageComparisonResult Result = Entry->PendingComparison.Get();
// Send the message back to the automation worker letting it know the results of the comparison test.
{
FAutomationWorkerImageComparisonResults* Message = new FAutomationWorkerImageComparisonResults(
Result.IsNew(), Result.AreSimilar(), Result.MaxLocalDifference, Result.GlobalDifference, Result.ErrorMessage.ToString());
MessageEndpoint->Send(Message, Entry->Sender);
}
// Find the game session instance info
int32 ClusterIndex;
int32 DeviceIndex;
verify(DeviceClusterManager.FindDevice(Entry->Sender, ClusterIndex, DeviceIndex));
// Get the current test.
TSharedPtr<IAutomationReport> Report = DeviceClusterManager.GetTest(ClusterIndex, DeviceIndex);
if (Report.IsValid())
{
// Record the artifacts for the test.
FString ApprovedFolder = ScreenshotManager->GetLocalApprovedFolder();
FString UnapprovedFolder = ScreenshotManager->GetLocalUnapprovedFolder();
FString ComparisonFolder = ScreenshotManager->GetLocalComparisonFolder();
TMap<FString, FString> LocalFiles;
LocalFiles.Add(TEXT("approved"), ApprovedFolder / Result.ApprovedFile);
LocalFiles.Add(TEXT("unapproved"), UnapprovedFolder / Result.IncomingFile);
LocalFiles.Add(TEXT("difference"), ComparisonFolder / Result.ComparisonFile);
Report->AddArtifact(ClusterIndex, CurrentTestPass, FAutomationArtifact(Entry->Name, EAutomationArtifactType::Comparison, LocalFiles));
}
else
{
UE_LOG(AutomationControllerLog, Error, TEXT("Cannot generate screenshot report for screenshot %s as report is missing"), *Result.IncomingFile);
}
}
}
}
void FAutomationControllerManager::ProcessAvailableTasks()
{
// Distribute tasks
if ( ClusterDistributionMask != 0 )
{
// For each device cluster
for ( int32 ClusterIndex = 0; ClusterIndex < DeviceClusterManager.GetNumClusters(); ++ClusterIndex )
{
bool bAllTestsComplete = true;
// If any of the devices were valid
if ( ( ClusterDistributionMask & ( 1 << ClusterIndex ) ) && DeviceClusterManager.GetNumDevicesInCluster(ClusterIndex) > 0 )
{
ExecuteNextTask(ClusterIndex, bAllTestsComplete);
}
//if we're all done running our tests
if ( bAllTestsComplete )
{
//we don't need to test this cluster anymore
ClusterDistributionMask &= ~( 1 << ClusterIndex );
if ( ClusterDistributionMask == 0 )
{
ProcessResults();
//Notify the graphical layout we are done processing results.
TestsCompleteDelegate.Broadcast();
}
}
}
}
if ( bIsLocalSession == false )
{
// Update the test status for timeouts if this is not a local session
UpdateTests();
}
}
void FAutomationControllerManager::ReportTestResults()
{
GLog->Logf(TEXT("Test Pass Results:"));
for ( int32 i = 0; i < OurPassResults.Tests.Num(); i++ )
{
GLog->Logf(TEXT("%s: %s"), *OurPassResults.Tests[i].TestDisplayName, ToString(OurPassResults.Tests[i].State));
}
}
void FAutomationControllerManager::CollectTestResults(TSharedPtr<IAutomationReport> Report, const FAutomationTestResults& Results)
{
// TODO This is slow, change to a map.
for ( int32 i = 0; i < OurPassResults.Tests.Num(); i++ )
{
FAutomatedTestResult& ReportResult = OurPassResults.Tests[i];
if ( ReportResult.FullTestPath == Report->GetFullTestPath() )
{
ReportResult.SetEvents(Results.GetEvents(), Results.GetWarningTotal(), Results.GetErrorTotal());
ReportResult.State = Results.State;
ReportResult.Artifacts = Results.Artifacts;
switch ( Results.State )
{
case EAutomationState::Success:
if ( Results.GetWarningTotal() > 0 )
{
OurPassResults.SucceededWithWarnings++;
}
else
{
OurPassResults.Succeeded++;
}
break;
case EAutomationState::Fail:
OurPassResults.Failed++;
break;
default:
OurPassResults.NotRun++;
break;
}
OurPassResults.TotalDuration += Results.Duration;
return;
}
}
}
bool FAutomationControllerManager::GenerateJsonTestPassSummary(const FAutomatedTestPassResults& SerializedPassResults, FDateTime Timestamp)
{
FString Json;
if ( FJsonObjectConverter::UStructToJsonObjectString(SerializedPassResults, Json) )
{
FString ReportFileName = FString::Printf(TEXT("%s/index.json"), *ReportOutputPath);
if ( FFileHelper::SaveStringToFile(Json, *ReportFileName, FFileHelper::EEncodingOptions::ForceUTF8) )
{
return true;
}
}
UE_LOG(AutomationControllerLog, Warning, TEXT("Test Report Json is invalid - report not generated."));
return false;
}
bool FAutomationControllerManager::GenerateHtmlTestPassSummary(const FAutomatedTestPassResults& SerializedPassResults, FDateTime Timestamp)
{
FString ReportTemplate;
const bool bLoadedResult = FFileHelper::LoadFileToString(ReportTemplate, *( FPaths::EngineContentDir() / TEXT("Automation/Report-Template.html") ));
if ( bLoadedResult )
{
FString ReportFileName = FString::Printf(TEXT("%s/index.html"), *ReportOutputPath);
if ( FFileHelper::SaveStringToFile(ReportTemplate, *ReportFileName, FFileHelper::EEncodingOptions::ForceUTF8) )
{
return true;
}
}
UE_LOG(AutomationControllerLog, Warning, TEXT("Test Report Html is invalid - report not generated."));
return false;
}
FString FAutomationControllerManager::SlugString(const FString& DisplayString) const
{
FString GeneratedName = DisplayString;
// Convert the display label, which may consist of just about any possible character, into a
// suitable name for a UObject (remove whitespace, certain symbols, etc.)
{
for ( int32 BadCharacterIndex = 0; BadCharacterIndex < ARRAY_COUNT(INVALID_OBJECTNAME_CHARACTERS) - 1; ++BadCharacterIndex )
{
const TCHAR TestChar[2] = { INVALID_OBJECTNAME_CHARACTERS[BadCharacterIndex], 0 };
const int32 NumReplacedChars = GeneratedName.ReplaceInline(TestChar, TEXT(""));
}
}
return GeneratedName;
}
FString FAutomationControllerManager::CopyArtifact(const FString& DestFolder, const FString& SourceFile) const
{
FString ArtifactFile = FString(TEXT("artifacts")) / FGuid::NewGuid().ToString(EGuidFormats::Digits) + FPaths::GetExtension(SourceFile, true);
FString ArtifactDestination = DestFolder / ArtifactFile;
IFileManager::Get().Copy(*ArtifactDestination, *SourceFile, true, true);
return ArtifactFile;
}
FString FAutomationControllerManager::GetReportOutputPath() const
{
return ReportOutputPath;
}
void FAutomationControllerManager::ExecuteNextTask( int32 ClusterIndex, OUT bool& bAllTestsCompleted )
{
bool bTestThatRequiresMultiplePraticipantsHadEnoughParticipants = false;
TArray< IAutomationReportPtr > TestsRunThisPass;
// For each device in this cluster
int32 NumDevicesInCluster = DeviceClusterManager.GetNumDevicesInCluster( ClusterIndex );
for ( int32 DeviceIndex = 0; DeviceIndex < NumDevicesInCluster; ++DeviceIndex )
{
// If this device is idle
if ( !DeviceClusterManager.GetTest(ClusterIndex, DeviceIndex).IsValid() && DeviceClusterManager.DeviceEnabled(ClusterIndex, DeviceIndex) )
{
// Get the next test that should be worked on
TSharedPtr< IAutomationReport > NextTest = ReportManager.GetNextReportToExecute(bAllTestsCompleted, ClusterIndex, CurrentTestPass, NumDevicesInCluster);
if ( NextTest.IsValid() )
{
// Get the status of the test
EAutomationState TestState = NextTest->GetState(ClusterIndex, CurrentTestPass);
if ( TestState == EAutomationState::NotRun )
{
// Reserve this device for the test
DeviceClusterManager.SetTest(ClusterIndex, DeviceIndex, NextTest);
TestsRunThisPass.Add(NextTest);
// Register this as a test we'll need to report on.
FAutomatedTestResult tempresult;
tempresult.Test = NextTest;
tempresult.TestDisplayName = NextTest->GetDisplayName();
tempresult.FullTestPath = NextTest->GetFullTestPath();
OurPassResults.Tests.Add(tempresult);
// If we now have enough devices reserved for the test, run it!
TArray<FMessageAddress> DeviceAddresses = DeviceClusterManager.GetDevicesReservedForTest(ClusterIndex, NextTest);
if ( DeviceAddresses.Num() == NextTest->GetNumParticipantsRequired() )
{
// Send it to each device
for ( int32 AddressIndex = 0; AddressIndex < DeviceAddresses.Num(); ++AddressIndex )
{
FAutomationTestResults TestResults;
GLog->Logf(ELogVerbosity::Display, TEXT("Running Automation: '%s' (Class Name: '%s')"), *TestsRunThisPass[AddressIndex]->GetFullTestPath(), *TestsRunThisPass[AddressIndex]->GetCommand());
TestResults.State = EAutomationState::InProcess;
if (CheckpointFile)
{
WriteLineToCheckpointFile(NextTest->GetFullTestPath());
}
TestResults.GameInstance = DeviceClusterManager.GetClusterDeviceName(ClusterIndex, DeviceIndex);
NextTest->SetResults(ClusterIndex, CurrentTestPass, TestResults);
NextTest->ResetNetworkCommandResponses();
// Mark the device as busy
FMessageAddress DeviceAddress = DeviceAddresses[AddressIndex];
// Send the test to the device for execution!
MessageEndpoint->Send(new FAutomationWorkerRunTests(ExecutionCount, AddressIndex, NextTest->GetCommand(), NextTest->GetDisplayName(), bSendAnalytics), DeviceAddress);
// Add a test so we can check later if the device is still active
TestRunningArray.Add(FTestRunningInfo(DeviceAddress));
}
}
}
}
}
else
{
// At least one device is still working
bAllTestsCompleted = false;
}
}
// Ensure any tests we have attempted to run on this pass had enough participants to successfully run.
for ( int32 TestIndex = 0; TestIndex < TestsRunThisPass.Num(); TestIndex++ )
{
IAutomationReportPtr CurrentTest = TestsRunThisPass[TestIndex];
if ( CurrentTest->GetNumDevicesRunningTest() != CurrentTest->GetNumParticipantsRequired() )
{
if ( GetNumDevicesInCluster(ClusterIndex) < CurrentTest->GetNumParticipantsRequired() )
{
FAutomationTestResults TestResults;
TestResults.State = EAutomationState::NotEnoughParticipants;
TestResults.GameInstance = DeviceClusterManager.GetClusterDeviceName(ClusterIndex, 0);
TestResults.AddEvent(FAutomationEvent(EAutomationEventType::Warning, FString::Printf(TEXT("Needed %d devices to participate, Only had %d available."), CurrentTest->GetNumParticipantsRequired(), DeviceClusterManager.GetNumDevicesInCluster(ClusterIndex))));
CurrentTest->SetResults(ClusterIndex, CurrentTestPass, TestResults);
DeviceClusterManager.ResetAllDevicesRunningTest(ClusterIndex, CurrentTest);
}
}
}
//Check to see if we finished a pass
if ( bAllTestsCompleted && CurrentTestPass < NumTestPasses - 1 )
{
CurrentTestPass++;
ReportManager.SetCurrentTestPass(CurrentTestPass);
bAllTestsCompleted = false;
}
}
void FAutomationControllerManager::Startup()
{
MessageEndpoint = FMessageEndpoint::Builder("FAutomationControllerModule")
.Handling<FAutomationWorkerFindWorkersResponse>(this, &FAutomationControllerManager::HandleFindWorkersResponseMessage)
.Handling<FAutomationWorkerPong>(this, &FAutomationControllerManager::HandlePongMessage)
.Handling<FAutomationWorkerRequestNextNetworkCommand>(this, &FAutomationControllerManager::HandleRequestNextNetworkCommandMessage)
.Handling<FAutomationWorkerRequestTestsReplyComplete>(this, &FAutomationControllerManager::HandleRequestTestsReplyCompleteMessage)
.Handling<FAutomationWorkerRunTestsReply>(this, &FAutomationControllerManager::HandleRunTestsReplyMessage)
.Handling<FAutomationWorkerScreenImage>(this, &FAutomationControllerManager::HandleReceivedScreenShot)
.Handling<FAutomationWorkerTestDataRequest>(this, &FAutomationControllerManager::HandleTestDataRequest)
.Handling<FAutomationWorkerWorkerOffline>(this, &FAutomationControllerManager::HandleWorkerOfflineMessage);
if ( MessageEndpoint.IsValid() )
{
MessageEndpoint->Subscribe<FAutomationWorkerWorkerOffline>();
}
ClusterDistributionMask = 0;
ExecutionCount = 0;
bDeveloperDirectoryIncluded = false;
RequestedTestFlags = EAutomationTestFlags::SmokeFilter | EAutomationTestFlags::EngineFilter | EAutomationTestFlags::ProductFilter | EAutomationTestFlags::PerfFilter;
NumTestPasses = 1;
//Default to machine name
DeviceGroupFlags = 0;
ToggleDeviceGroupFlag(EAutomationDeviceGroupTypes::MachineName);
}
void FAutomationControllerManager::Shutdown()
{
MessageEndpoint.Reset();
ShutdownDelegate.Broadcast();
RemoveCallbacks();
}
void FAutomationControllerManager::RemoveCallbacks()
{
ShutdownDelegate.Clear();
TestsAvailableDelegate.Clear();
TestsRefreshedDelegate.Clear();
TestsCompleteDelegate.Clear();
}
void FAutomationControllerManager::SetTestNames(const FMessageAddress& AutomationWorkerAddress, TArray<FAutomationTestInfo>& TestInfo)
{
int32 DeviceClusterIndex = INDEX_NONE;
int32 DeviceIndex = INDEX_NONE;
// Find the device that requested these tests
if ( DeviceClusterManager.FindDevice(AutomationWorkerAddress, DeviceClusterIndex, DeviceIndex) )
{
// Sort tests by display name
struct FCompareAutomationTestInfo
{
FORCEINLINE bool operator()(const FAutomationTestInfo& A, const FAutomationTestInfo& B) const
{
return A.GetDisplayName() < B.GetDisplayName();
}
};
TestInfo.Sort(FCompareAutomationTestInfo());
// Add each test to the collection
for ( int32 TestIndex = 0; TestIndex < TestInfo.Num(); ++TestIndex )
{
// Ensure our test exists. If not, add it
ReportManager.EnsureReportExists(TestInfo[TestIndex], DeviceClusterIndex, NumTestPasses);
}
}
else
{
//todo automation - make sure to report error if the device was not discovered correctly
}
// Note the response
RefreshTestResponses++;
// If we have received all the responses we expect to
if ( RefreshTestResponses == DeviceClusterManager.GetNumClusters() )
{
TestsRefreshedDelegate.Broadcast();
}
}
void FAutomationControllerManager::ProcessResults()
{
bHasErrors = false;
bHasWarning = false;
bHasLogs = false;
TArray< TSharedPtr< IAutomationReport > >& TestReports = GetReports();
if ( TestReports.Num() )
{
bTestResultsAvailable = true;
for ( int32 Index = 0; Index < TestReports.Num(); Index++ )
{
CheckChildResult(TestReports[Index]);
}
}
if ( !ReportOutputPath.IsEmpty() )
{
FDateTime Timestamp = FDateTime::Now();
UE_LOG(AutomationControllerLog, Display, TEXT("Generating Automation Report @ %s."), *ReportOutputPath);
if ( IFileManager::Get().DirectoryExists(*ReportOutputPath) )
{
UE_LOG(AutomationControllerLog, Display, TEXT("Existing report directory found, deleting %s."), *ReportOutputPath);
// Clear the old report folder. Why move it first? Because RemoveDirectory
// is actually an async call that is not immediately carried out by the Windows OS; Moving a directory on the other hand, is sync.
// So we move, to a temporary location, then delete it.
FString TempDirectory = FPaths::GetPath(ReportOutputPath) + TEXT("\\") + FGuid::NewGuid().ToString(EGuidFormats::DigitsWithHyphens);
IFileManager::Get().Move(*TempDirectory, *ReportOutputPath);
IFileManager::Get().DeleteDirectory(*TempDirectory, false, true);
}
FScreenshotExportResults ExportResults = ScreenshotManager->ExportComparisonResultsAsync(ReportOutputPath).Get();
FAutomatedTestPassResults SerializedPassResults = OurPassResults;
SerializedPassResults.ComparisonExported = ExportResults.Success;
SerializedPassResults.ComparisonExportDirectory = ExportResults.ExportPath;
{
SerializedPassResults.Tests.StableSort([] (const FAutomatedTestResult& A, const FAutomatedTestResult& B) {
if ( A.GetErrorTotal() > 0 )
{
if ( B.GetErrorTotal() > 0 )
return ( A.FullTestPath < B.FullTestPath );
else
return true;
}
else if ( B.GetErrorTotal() > 0 )
{
return false;
}
if ( A.GetWarningTotal() > 0 )
{
if ( B.GetWarningTotal() > 0 )
return ( A.FullTestPath < B.FullTestPath );
else
return true;
}
else if ( B.GetWarningTotal() > 0 )
{
return false;
}
return A.FullTestPath < B.FullTestPath;
});
for ( FAutomatedTestResult& Test : SerializedPassResults.Tests )
{
for ( FAutomationArtifact& Artifact : Test.Artifacts )
{
for ( const auto& Entry : Artifact.LocalFiles )
{
Artifact.Files.Add(Entry.Key, CopyArtifact(ReportOutputPath, Entry.Value));
}
}
}
}
UE_LOG(AutomationControllerLog, Display, TEXT("Writing reports... %s."), *ReportOutputPath);
// Generate Json
GenerateJsonTestPassSummary(SerializedPassResults, Timestamp);
// Generate Html
GenerateHtmlTestPassSummary(SerializedPassResults, Timestamp);
if ( !DeveloperReportUrl.IsEmpty() )
{
UE_LOG(AutomationControllerLog, Display, TEXT("Launching Report URL %s."), *DeveloperReportUrl);
FPlatformProcess::LaunchURL(*DeveloperReportUrl, nullptr, nullptr);
}
UE_LOG(AutomationControllerLog, Display, TEXT("Done writing reports... %s."), *ReportOutputPath);
}
// Then clean our array for the next pass.
OurPassResults.ClearAllEntries();
CleanUpCheckpointFile();
SetControllerStatus(EAutomationControllerModuleState::Ready);
}
void FAutomationControllerManager::CheckChildResult(TSharedPtr<IAutomationReport> InReport)
{
TArray<TSharedPtr<IAutomationReport> >& ChildReports = InReport->GetChildReports();
if ( ChildReports.Num() > 0 )
{
for ( int32 Index = 0; Index < ChildReports.Num(); Index++ )
{
CheckChildResult(ChildReports[Index]);
}
}
else if ( ( bHasErrors && bHasWarning && bHasLogs ) == false && InReport->IsEnabled() )
{
for ( int32 ClusterIndex = 0; ClusterIndex < GetNumDeviceClusters(); ++ClusterIndex )
{
FAutomationTestResults TestResults = InReport->GetResults(ClusterIndex, CurrentTestPass);
if ( TestResults.GetErrorTotal() > 0 )
{
bHasErrors = true;
}
if ( TestResults.GetWarningTotal() )
{
bHasWarning = true;
}
if ( TestResults.GetLogTotal() )
{
bHasLogs = true;
}
}
}
}
void FAutomationControllerManager::SetControllerStatus(EAutomationControllerModuleState::Type InAutomationTestState)
{
if ( InAutomationTestState != AutomationTestState )
{
// Inform the UI if the test state has changed
AutomationTestState = InAutomationTestState;
TestsAvailableDelegate.Broadcast(AutomationTestState);
}
}
void FAutomationControllerManager::RemoveTestRunning(const FMessageAddress& TestAddressToRemove)
{
for ( int32 Index = 0; Index < TestRunningArray.Num(); Index++ )
{
if ( TestRunningArray[Index].OwnerMessageAddress == TestAddressToRemove )
{
TestRunningArray.RemoveAt(Index);
break;
}
}
}
void FAutomationControllerManager::AddPingResult(const FMessageAddress& ResponderAddress)
{
for ( int32 Index = 0; Index < TestRunningArray.Num(); Index++ )
{
if ( TestRunningArray[Index].OwnerMessageAddress == ResponderAddress )
{
TestRunningArray[Index].LastPingTime = 0;
break;
}
}
}
void FAutomationControllerManager::UpdateTests()
{
static const float CheckTestInterval = 1.0f;
static const float GameInstanceLostTimer = 200.0f;
CheckTestTimer += FPlatformTime::Seconds() - LastTimeUpdateTicked;
LastTimeUpdateTicked = FPlatformTime::Seconds();
if ( CheckTestTimer > CheckTestInterval )
{
for ( int32 Index = 0; Index < TestRunningArray.Num(); Index++ )
{
TestRunningArray[Index].LastPingTime += CheckTestTimer;
if ( TestRunningArray[Index].LastPingTime > GameInstanceLostTimer )
{
// Find the game session instance info
int32 ClusterIndex;
int32 DeviceIndex;
verify(DeviceClusterManager.FindDevice(TestRunningArray[Index].OwnerMessageAddress, ClusterIndex, DeviceIndex));
//verify this device thought it was busy
TSharedPtr <IAutomationReport> Report = DeviceClusterManager.GetTest(ClusterIndex, DeviceIndex);
check(Report.IsValid());
// A dummy array used to report the result
TArray<FString> EmptyStringArray;
TArray<FString> ErrorStringArray;
ErrorStringArray.Add(FString(TEXT("Failed")));
bHasErrors = true;
GLog->Logf(ELogVerbosity::Display, TEXT("Timeout hit. Nooooooo."));
FAutomationTestResults TestResults;
TestResults.State = EAutomationState::Fail;
TestResults.GameInstance = DeviceClusterManager.GetClusterDeviceName(ClusterIndex, DeviceIndex);
TestResults.AddEvent(FAutomationEvent(EAutomationEventType::Error, FString::Printf(TEXT("Timeout waiting for device %s"), *TestResults.GameInstance)));
// Set the results
Report->SetResults(ClusterIndex, CurrentTestPass, TestResults);
bTestResultsAvailable = true;
const FAutomationTestResults& FinalResults = Report->GetResults(ClusterIndex, CurrentTestPass);
// Gather all of the data relevant to this test for our json reporting.
CollectTestResults(Report, FinalResults);
// Disable the device in the cluster so it is not used again
DeviceClusterManager.DisableDevice(ClusterIndex, DeviceIndex);
// Remove the running test
TestRunningArray.RemoveAt(Index--);
// If there are no more devices, set the module state to disabled
if ( DeviceClusterManager.HasActiveDevice() == false )
{
// Process results first to write out the report
ProcessResults();
GLog->Logf(ELogVerbosity::Display, TEXT("Module disabled"));
SetControllerStatus(EAutomationControllerModuleState::Disabled);
ClusterDistributionMask = 0;
}
else
{
GLog->Logf(ELogVerbosity::Display, TEXT("Module not disabled. Keep looking."));
// Remove the cluster from the mask if there are no active devices left
if ( DeviceClusterManager.GetNumActiveDevicesInCluster(ClusterIndex) == 0 )
{
ClusterDistributionMask &= ~( 1 << ClusterIndex );
}
if ( TestRunningArray.Num() == 0 )
{
SetControllerStatus(EAutomationControllerModuleState::Ready);
}
}
}
else
{
MessageEndpoint->Send(new FAutomationWorkerPing(), TestRunningArray[Index].OwnerMessageAddress);
}
}
CheckTestTimer = 0.f;
}
}
const bool FAutomationControllerManager::ExportReport(uint32 FileExportTypeMask)
{
return ReportManager.ExportReport(FileExportTypeMask, GetNumDeviceClusters());
}
bool FAutomationControllerManager::IsTestRunnable(IAutomationReportPtr InReport) const
{
bool bIsRunnable = false;
for ( int32 ClusterIndex = 0; ClusterIndex < GetNumDeviceClusters(); ++ClusterIndex )
{
if ( InReport->IsSupported(ClusterIndex) )
{
if ( GetNumDevicesInCluster(ClusterIndex) >= InReport->GetNumParticipantsRequired() )
{
bIsRunnable = true;
break;
}
}
}
return bIsRunnable;
}
/* FAutomationControllerModule callbacks
*****************************************************************************/
void FAutomationControllerManager::HandleFindWorkersResponseMessage(const FAutomationWorkerFindWorkersResponse& Message, const TSharedRef<IMessageContext, ESPMode::ThreadSafe>& Context)
{
if ( Message.SessionId == ActiveSessionId )
{
DeviceClusterManager.AddDeviceFromMessage(Context->GetSender(), Message, DeviceGroupFlags);
}
RequestTests();
SetControllerStatus(EAutomationControllerModuleState::Ready);
}
void FAutomationControllerManager::HandlePongMessage( const FAutomationWorkerPong& Message, const TSharedRef<IMessageContext, ESPMode::ThreadSafe>& Context )
{
AddPingResult(Context->GetSender());
}
void FAutomationControllerManager::HandleReceivedScreenShot(const FAutomationWorkerScreenImage& Message, const TSharedRef<IMessageContext, ESPMode::ThreadSafe>& Context)
{
FString ScreenshotIncomingFolder = FPaths::ProjectSavedDir() / TEXT("Automation/Incoming/");
bool bTree = true;
FString FileName = ScreenshotIncomingFolder / Message.ScreenShotName;
IFileManager::Get().MakeDirectory(*FPaths::GetPath(FileName), bTree);
FFileHelper::SaveArrayToFile(Message.ScreenImage, *FileName);
// TODO Automation There is identical code in, Engine\Source\Runtime\AutomationWorker\Private\AutomationWorkerModule.cpp,
// need to move this code into common area.
FString Json;
if ( FJsonObjectConverter::UStructToJsonObjectString(Message.Metadata, Json) )
{
FString MetadataPath = FPaths::ChangeExtension(FileName, TEXT("json"));
FFileHelper::SaveStringToFile(Json, *MetadataPath, FFileHelper::EEncodingOptions::ForceUTF8WithoutBOM);
}
TSharedRef<FComparisonEntry> Comparison = MakeShareable(new FComparisonEntry());
Comparison->Sender = Context->GetSender();
Comparison->Name = Message.Metadata.Name;
Comparison->PendingComparison = ScreenshotManager->CompareScreensotAsync(Message.ScreenShotName);
ComparisonQueue.Enqueue(Comparison);
}
void FAutomationControllerManager::HandleTestDataRequest(const FAutomationWorkerTestDataRequest& Message, const TSharedRef<IMessageContext, ESPMode::ThreadSafe>& Context)
{
const FString TestDataRoot = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir() / TEXT("Test"));
const FString DataFile = Message.DataType / Message.DataPlatform / Message.DataTestName / Message.DataName + TEXT(".json");
const FString DataFullPath = TestDataRoot / DataFile;
// Generate the folder for the data if it doesn't exist.
const bool bTree = true;
IFileManager::Get().MakeDirectory(*FPaths::GetPath(DataFile), bTree);
bool bIsNew = true;
FString ResponseJsonData = Message.JsonData;
if ( FPaths::FileExists(DataFullPath) )
{
if ( FFileHelper::LoadFileToString(ResponseJsonData, *DataFullPath) )
{
bIsNew = false;
}
else
{
// TODO Error
}
}
if ( bIsNew )
{
FString IncomingTestData = FPaths::ProjectSavedDir() / TEXT("Automation/IncomingData/") / DataFile;
if ( FFileHelper::SaveStringToFile(Message.JsonData, *IncomingTestData) )
{
//TODO Anything extra to do here?
}
else
{
//TODO What do we do if this fails?
}
}
FAutomationWorkerTestDataResponse* ResponseMessage = new FAutomationWorkerTestDataResponse();
ResponseMessage->bIsNew = bIsNew;
ResponseMessage->JsonData = ResponseJsonData;
MessageEndpoint->Send(ResponseMessage, Context->GetSender());
}
void FAutomationControllerManager::HandlePerformanceDataRequest(const FAutomationWorkerPerformanceDataRequest& Message, const TSharedRef<IMessageContext, ESPMode::ThreadSafe>& Context)
{
//TODO Read/Performance data.
FAutomationWorkerPerformanceDataResponse* ResponseMessage = new FAutomationWorkerPerformanceDataResponse();
ResponseMessage->bSuccess = true;
ResponseMessage->ErrorMessage = TEXT("");
MessageEndpoint->Send(ResponseMessage, Context->GetSender());
}
void FAutomationControllerManager::HandleRequestNextNetworkCommandMessage(const FAutomationWorkerRequestNextNetworkCommand& Message, const TSharedRef<IMessageContext, ESPMode::ThreadSafe>& Context)
{
// Harvest iteration of running the tests this result came from (stops stale results from being committed to subsequent runs)
if ( Message.ExecutionCount == ExecutionCount )
{
// Find the device id for the address
int32 ClusterIndex;
int32 DeviceIndex;
verify(DeviceClusterManager.FindDevice(Context->GetSender(), ClusterIndex, DeviceIndex));
// Verify this device thought it was busy
TSharedPtr<IAutomationReport> Report = DeviceClusterManager.GetTest(ClusterIndex, DeviceIndex);
check(Report.IsValid());
// Increment network command responses
bool bAllResponsesReceived = Report->IncrementNetworkCommandResponses();
// Test if we've accumulated all responses AND this was the result for the round of test running AND we're still running tests
if ( bAllResponsesReceived && ( ClusterDistributionMask & ( 1 << ClusterIndex ) ) )
{
// Reset the counter
Report->ResetNetworkCommandResponses();
// For every device in this networked test
TArray<FMessageAddress> DeviceAddresses = DeviceClusterManager.GetDevicesReservedForTest(ClusterIndex, Report);
check(DeviceAddresses.Num() == Report->GetNumParticipantsRequired());
// Send it to each device
for ( int32 AddressIndex = 0; AddressIndex < DeviceAddresses.Num(); ++AddressIndex )
{
//send "next command message" to worker
MessageEndpoint->Send(new FAutomationWorkerNextNetworkCommandReply(), DeviceAddresses[AddressIndex]);
}
}
}
}
void FAutomationControllerManager::HandleRequestTestsReplyCompleteMessage(const FAutomationWorkerRequestTestsReplyComplete& Message, const TSharedRef<IMessageContext, ESPMode::ThreadSafe>& Context)
{
TArray<FAutomationTestInfo> TestInfo;
TestInfo.Reset(Message.Tests.Num());
for (const FAutomationWorkerSingleTestReply& SingleTestReply : Message.Tests)
{
FAutomationTestInfo NewTest = SingleTestReply.GetTestInfo();
TestInfo.Add(NewTest);
}
SetTestNames(Context->GetSender(), TestInfo);
}
void FAutomationControllerManager::HandleRunTestsReplyMessage(const FAutomationWorkerRunTestsReply& Message, const TSharedRef<IMessageContext, ESPMode::ThreadSafe>& Context)
{
// If we should commit these results
if ( Message.ExecutionCount == ExecutionCount )
{
FAutomationTestResults TestResults;
TestResults.State = Message.Success ? EAutomationState::Success : EAutomationState::Fail;
TestResults.Duration = Message.Duration;
// Mark device as back on the market
int32 ClusterIndex;
int32 DeviceIndex;
verify(DeviceClusterManager.FindDevice(Context->GetSender(), ClusterIndex, DeviceIndex));
TestResults.GameInstance = DeviceClusterManager.GetClusterDeviceName(ClusterIndex, DeviceIndex);
TestResults.SetEvents(Message.Events, Message.WarningTotal, Message.ErrorTotal);
// Verify this device thought it was busy
TSharedPtr<IAutomationReport> Report = DeviceClusterManager.GetTest(ClusterIndex, DeviceIndex);
check(Report.IsValid());
Report->SetResults(ClusterIndex, CurrentTestPass, TestResults);
const FAutomationTestResults& FinalResults = Report->GetResults(ClusterIndex, CurrentTestPass);
// Gather all of the data relevant to this test for our json reporting.
CollectTestResults(Report, FinalResults);
#if WITH_EDITOR
FMessageLog AutomationTestingLog("AutomationTestingLog");
AutomationTestingLog.Open();
#endif
for ( const FAutomationEvent& Event : TestResults.GetEvents() )
{
switch ( Event.Type )
{
case EAutomationEventType::Info:
GLog->Logf(ELogVerbosity::Log, TEXT("%s"), *Event.ToString());
#if WITH_EDITOR
AutomationTestingLog.Info(FText::FromString(Event.ToString()));
#endif
break;
case EAutomationEventType::Warning:
GLog->Logf(ELogVerbosity::Warning, TEXT("%s"), *Event.ToString());
#if WITH_EDITOR
AutomationTestingLog.Warning(FText::FromString(Event.ToString()));
#endif
break;
case EAutomationEventType::Error:
GLog->Logf(ELogVerbosity::Error, TEXT("%s"), *Event.ToString());
#if WITH_EDITOR
AutomationTestingLog.Error(FText::FromString(Event.ToString()));
#endif
break;
}
}
if ( TestResults.State == EAutomationState::Success )
{
FString SuccessString = FString::Printf(TEXT("...Automation Test Succeeded (%s)"), *Report->GetDisplayName());
GLog->Logf(ELogVerbosity::Log, TEXT("%s"), *SuccessString);
#if WITH_EDITOR
AutomationTestingLog.Info(FText::FromString(*SuccessString));
#endif
}
else
{
FString FailureString = FString::Printf(TEXT("...Automation Test Failed (%s)"), *Report->GetDisplayName());
GLog->Logf(ELogVerbosity::Log, TEXT("%s"), *FailureString);
#if WITH_EDITOR
AutomationTestingLog.Error(FText::FromString(*FailureString));
#endif
//FAutomationTestFramework::Get().Lo
}
// const bool TestSucceeded = (TestResults.State == EAutomationState::Success);
//FAutomationTestFramework::Get().LogEndTestMessage(Report->GetDisplayName(), TestSucceeded);
// Device is now good to go
DeviceClusterManager.SetTest(ClusterIndex, DeviceIndex, NULL);
}
// Remove the running test
RemoveTestRunning(Context->GetSender());
}
void FAutomationControllerManager::HandleWorkerOfflineMessage( const FAutomationWorkerWorkerOffline& Message, const TSharedRef<IMessageContext, ESPMode::ThreadSafe>& Context )
{
FMessageAddress DeviceMessageAddress = Context->GetSender();
DeviceClusterManager.Remove(DeviceMessageAddress);
}
bool FAutomationControllerManager::IsDeviceGroupFlagSet( EAutomationDeviceGroupTypes::Type InDeviceGroup ) const
{
const uint32 FlagMask = 1 << InDeviceGroup;
return (DeviceGroupFlags & FlagMask) > 0;
}
void FAutomationControllerManager::ToggleDeviceGroupFlag( EAutomationDeviceGroupTypes::Type InDeviceGroup )
{
const uint32 FlagMask = 1 << InDeviceGroup;
DeviceGroupFlags = DeviceGroupFlags ^ FlagMask;
}
void FAutomationControllerManager::UpdateDeviceGroups( )
{
DeviceClusterManager.ReGroupDevices( DeviceGroupFlags );
// Update the reports in case the number of clusters changed
int32 NumOfClusters = DeviceClusterManager.GetNumClusters();
ReportManager.ClustersUpdated(NumOfClusters);
}
TArray<FString> FAutomationControllerManager::GetCheckpointFileContents()
{
TestsRun.Empty();
FString CheckpointFileName = FString::Printf(TEXT("%sautomationcheckpoint.log"), *FPaths::AutomationDir());
if (IFileManager::Get().FileExists(*CheckpointFileName))
{
FString FileData;
FFileHelper::LoadFileToString(FileData, *CheckpointFileName);
FileData.ParseIntoArrayLines(TestsRun);
for (int i = 0; i < TestsRun.Num(); i++)
{
GLog->Log(TEXT("AutomationCheckpoint"), ELogVerbosity::Log, *TestsRun[i]);
}
}
return TestsRun;
}
FArchive* FAutomationControllerManager::GetCheckpointFileForWrite()
{
if (!CheckpointFile)
{
FString CheckpointFileName = FString::Printf(TEXT("%sautomationcheckpoint.log"), *FPaths::AutomationDir());
CheckpointFile = IFileManager::Get().CreateFileWriter(*CheckpointFileName, 8);
}
return CheckpointFile;
}
void FAutomationControllerManager::CleanUpCheckpointFile()
{
if (CheckpointFile)
{
CheckpointFile->Close();
CheckpointFile = nullptr;
}
FString CheckpointFileName = FString::Printf(TEXT("%sautomationcheckpoint.log"), *FPaths::AutomationDir());
if (IFileManager::Get().FileExists(*CheckpointFileName))
{
IFileManager::Get().Delete(*CheckpointFileName);
}
}
void FAutomationControllerManager::WriteLoadedCheckpointDataToFile()
{
GetCheckpointFileForWrite();
if (CheckpointFile)
{
for (int i = 0; i < TestsRun.Num(); i++)
{
FString LineToWrite = FString::Printf(TEXT("%s\r\n"), *TestsRun[i]);
CheckpointFile->Serialize(TCHAR_TO_ANSI(*LineToWrite), LineToWrite.Len());
CheckpointFile->Flush();
}
}
}
void FAutomationControllerManager::WriteLineToCheckpointFile(FString StringToWrite)
{
GetCheckpointFileForWrite();
if (CheckpointFile)
{
FString LineToWrite = FString::Printf(TEXT("%s\r\n"), *StringToWrite);
CheckpointFile->Serialize(TCHAR_TO_ANSI(*LineToWrite), LineToWrite.Len());
CheckpointFile->Flush();
}
}
void FAutomationControllerManager::ResetAutomationTestTimeout(const TCHAR* Reason)
{
GLog->Logf(ELogVerbosity::Display, TEXT("Resetting automation test timeout: %s"), Reason);
LastTimeUpdateTicked = FPlatformTime::Seconds();
}