2015-03-18 10:26:11 -04:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
# include "DirectoryWatcherPrivatePCH.h"
# include "DirectoryWatcherModule.h"
2015-03-18 11:53:56 -04:00
# include "ModuleManager.h"
2015-03-18 10:26:11 -04:00
DEFINE_LOG_CATEGORY_STATIC ( LogDirectoryWatcherTests , Log , All ) ;
struct FDirectoryWatcherTestPayload
{
FDelegateHandle WatcherDelegate ;
FString WorkingDir ;
TMap < FString , FFileChangeData : : EFileChangeAction > ReportedChanges ;
2015-06-25 20:17:42 -04:00
FDirectoryWatcherTestPayload ( const FString & InWorkingDir , uint32 Flags = 0 )
2015-03-18 10:26:11 -04:00
: WorkingDir ( InWorkingDir )
{
IFileManager : : Get ( ) . MakeDirectory ( * WorkingDir , true ) ;
FDirectoryWatcherModule & Module = FModuleManager : : LoadModuleChecked < FDirectoryWatcherModule > ( TEXT ( " DirectoryWatcher " ) ) ;
if ( IDirectoryWatcher * DirectoryWatcher = Module . Get ( ) )
{
auto Callback = IDirectoryWatcher : : FDirectoryChanged : : CreateRaw ( this , & FDirectoryWatcherTestPayload : : OnDirectoryChanged ) ;
2015-06-25 20:17:42 -04:00
DirectoryWatcher - > RegisterDirectoryChangedCallback_Handle ( WorkingDir , Callback , WatcherDelegate , Flags ) ;
2015-03-18 10:26:11 -04:00
}
}
~ FDirectoryWatcherTestPayload ( )
{
IFileManager : : Get ( ) . DeleteDirectory ( * WorkingDir , false , true ) ;
FDirectoryWatcherModule & Module = FModuleManager : : LoadModuleChecked < FDirectoryWatcherModule > ( TEXT ( " DirectoryWatcher " ) ) ;
if ( IDirectoryWatcher * DirectoryWatcher = Module . Get ( ) )
{
DirectoryWatcher - > UnregisterDirectoryChangedCallback_Handle ( WorkingDir , WatcherDelegate ) ;
}
}
void OnDirectoryChanged ( const TArray < FFileChangeData > & InFileChanges )
{
for ( const auto & Change : InFileChanges )
{
FString RelativeFilename = * FPaths : : ConvertRelativePathToFull ( Change . Filename ) + WorkingDir . Len ( ) ;
UE_LOG ( LogDirectoryWatcherTests , Log , TEXT ( " File '%s'. Code: %d. " ) , * Change . Filename , ( uint8 ) Change . Action ) ;
FFileChangeData : : EFileChangeAction * Existing = ReportedChanges . Find ( RelativeFilename ) ;
if ( Existing )
{
switch ( Change . Action )
{
case FFileChangeData : : FCA_Added :
* Existing = FFileChangeData : : FCA_Modified ;
break ;
case FFileChangeData : : FCA_Modified :
// We ignore these since added + modified == added, and removed + modified = removed.
break ;
case FFileChangeData : : FCA_Removed :
* Existing = FFileChangeData : : FCA_Removed ;
break ;
}
}
else
{
ReportedChanges . Add ( RelativeFilename , Change . Action ) ;
}
}
}
} ;
class FDelayedCallbackLatentCommand : public IAutomationLatentCommand
{
public :
FDelayedCallbackLatentCommand ( TFunction < void ( ) > InCallback , float InDelay = 0.1f )
: Callback ( InCallback ) , Delay ( InDelay )
{ }
virtual bool Update ( ) override
{
float NewTime = FPlatformTime : : Seconds ( ) ;
if ( NewTime - StartTime > = Delay )
{
Callback ( ) ;
return true ;
}
return false ;
}
private :
TFunction < void ( ) > Callback ;
float Delay ;
} ;
FString GetWorkingDir ( )
{
return FPaths : : ConvertRelativePathToFull ( FPaths : : AutomationTransientDir ( ) / TEXT ( " DirectoryWatcher " ) ) / TEXT ( " " ) ;
}
static const float TestTickDelay = 0.1f ;
2015-08-28 13:23:02 -04:00
IMPLEMENT_SIMPLE_AUTOMATION_TEST ( FDirectoryWatcherSimpleCreateTest , " System.Plugins.Directory Watcher.Simple Create " , EAutomationTestFlags : : EditorContext | EAutomationTestFlags : : EngineFilter )
2015-03-18 10:26:11 -04:00
bool FDirectoryWatcherSimpleCreateTest : : RunTest ( const FString & Parameters )
{
const FString WorkingDir = GetWorkingDir ( ) ;
static const TCHAR * Filename = TEXT ( " created.tmp " ) ;
// Start watching the directory
TSharedPtr < FDirectoryWatcherTestPayload > Test = MakeShareable ( new FDirectoryWatcherTestPayload ( WorkingDir ) ) ;
// Give the stream time to start up before doing the test
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
// Create a file and check that it got reported as created
FFileHelper : : SaveStringToFile ( TEXT ( " " ) , * ( WorkingDir / Filename ) ) ;
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
FFileChangeData : : EFileChangeAction * Action = Test - > ReportedChanges . Find ( Filename ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Added )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " New file '%s' was not correctly reported as being added. " ) , Filename ) ;
}
} ) ) ;
} ) ) ;
return true ;
}
2015-08-28 13:23:02 -04:00
IMPLEMENT_SIMPLE_AUTOMATION_TEST ( FDirectoryWatcherSimpleModifyTest , " System.Plugins.Directory Watcher.Simple Modify " , EAutomationTestFlags : : EditorContext | EAutomationTestFlags : : EngineFilter )
2015-03-18 10:26:11 -04:00
bool FDirectoryWatcherSimpleModifyTest : : RunTest ( const FString & Parameters )
{
const FString WorkingDir = GetWorkingDir ( ) ;
static const TCHAR * Filename = TEXT ( " modified.tmp " ) ;
// Create a file first
FFileHelper : : SaveStringToFile ( TEXT ( " " ) , * ( WorkingDir / Filename ) ) ;
2015-07-15 16:01:11 -04:00
# if _MSC_VER >= 1900
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
// Start watching the directory
TSharedPtr < FDirectoryWatcherTestPayload > Test = MakeShareable ( new FDirectoryWatcherTestPayload ( WorkingDir ) ) ;
void * Holder = & Test ;
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
// Manipulate the file
FFileHelper : : SaveStringToFile ( TEXT ( " Some content " ) , * ( WorkingDir / Filename ) ) ;
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
TSharedPtr < FDirectoryWatcherTestPayload > LocalTest = * ( const TSharedPtr < FDirectoryWatcherTestPayload > * ) Holder ;
FFileChangeData : : EFileChangeAction * Action = LocalTest - > ReportedChanges . Find ( Filename ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Modified )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " File '%s' was not correctly reported as being modified. " ) , Filename ) ;
}
} ) ) ;
} ) ) ;
} ) ) ;
# else
2015-03-18 10:26:11 -04:00
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
// Start watching the directory
TSharedPtr < FDirectoryWatcherTestPayload > Test = MakeShareable ( new FDirectoryWatcherTestPayload ( WorkingDir ) ) ;
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
// Manipulate the file
FFileHelper : : SaveStringToFile ( TEXT ( " Some content " ) , * ( WorkingDir / Filename ) ) ;
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
FFileChangeData : : EFileChangeAction * Action = Test - > ReportedChanges . Find ( Filename ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Modified )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " File '%s' was not correctly reported as being modified. " ) , Filename ) ;
}
} ) ) ;
} ) ) ;
} ) ) ;
2015-07-15 16:01:11 -04:00
# endif
2015-03-18 10:26:11 -04:00
return true ;
}
2015-08-28 13:23:02 -04:00
IMPLEMENT_SIMPLE_AUTOMATION_TEST ( FDirectoryWatcherSimpleDeleteTest , " System.Plugins.Directory Watcher.Simple Delete " , EAutomationTestFlags : : EditorContext | EAutomationTestFlags : : EngineFilter )
2015-03-18 10:26:11 -04:00
bool FDirectoryWatcherSimpleDeleteTest : : RunTest ( const FString & Parameters )
{
const FString WorkingDir = GetWorkingDir ( ) ;
static const TCHAR * Filename = TEXT ( " removed.tmp " ) ;
// Create a file first
FFileHelper : : SaveStringToFile ( TEXT ( " " ) , * ( WorkingDir / Filename ) ) ;
// Start watching the directory
TSharedPtr < FDirectoryWatcherTestPayload > Test = MakeShareable ( new FDirectoryWatcherTestPayload ( WorkingDir ) ) ;
// Give the stream time to start up before doing the test
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
// Delete the file
IFileManager : : Get ( ) . Delete ( * ( WorkingDir / Filename ) ) ;
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
FFileChangeData : : EFileChangeAction * Action = Test - > ReportedChanges . Find ( Filename ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Removed )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " File '%s' was not correctly reported as being deleted. " ) , Filename ) ;
}
} ) ) ;
} ) ) ;
return true ;
}
2015-08-28 13:23:02 -04:00
IMPLEMENT_SIMPLE_AUTOMATION_TEST ( FDirectoryWatcherSubFolderTest , " System.Plugins.Directory Watcher.Sub Folder " , EAutomationTestFlags : : EditorContext | EAutomationTestFlags : : EngineFilter )
2015-03-18 10:26:11 -04:00
bool FDirectoryWatcherSubFolderTest : : RunTest ( const FString & Parameters )
{
const FString WorkingDir = GetWorkingDir ( ) ;
static const TCHAR * CreatedFilename = TEXT ( " sub_folder/created.tmp " ) ;
static const TCHAR * ModifiedFilename = TEXT ( " sub_folder/modified.tmp " ) ;
static const TCHAR * RemovedFilename = TEXT ( " sub_folder/removed.tmp " ) ;
// Create the file we wish to modify/delete first
FFileHelper : : SaveStringToFile ( TEXT ( " " ) , * ( WorkingDir / ModifiedFilename ) ) ;
FFileHelper : : SaveStringToFile ( TEXT ( " " ) , * ( WorkingDir / RemovedFilename ) ) ;
2015-07-15 16:01:11 -04:00
# if _MSC_VER >= 1900
2015-03-18 10:26:11 -04:00
// Give the stream time to start up before doing the test
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
// Start watching the directory
TSharedPtr < FDirectoryWatcherTestPayload > Test = MakeShareable ( new FDirectoryWatcherTestPayload ( WorkingDir ) ) ;
2015-07-15 16:01:11 -04:00
void * Holder = & Test ;
2015-03-18 10:26:11 -04:00
// Give the stream time to start up before doing the test
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
// Create a new file
FFileHelper : : SaveStringToFile ( TEXT ( " " ) , * ( WorkingDir / CreatedFilename ) ) ;
// Modify another file
FFileHelper : : SaveStringToFile ( TEXT ( " Some content " ) , * ( WorkingDir / ModifiedFilename ) ) ;
// Delete a file
IFileManager : : Get ( ) . Delete ( * ( WorkingDir / RemovedFilename ) ) ;
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
2015-07-15 16:01:11 -04:00
TSharedPtr < FDirectoryWatcherTestPayload > LocalTest = * ( const TSharedPtr < FDirectoryWatcherTestPayload > * ) Holder ;
FFileChangeData : : EFileChangeAction * Action = LocalTest - > ReportedChanges . Find ( CreatedFilename ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Added )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " File '%s' was not correctly reported as being added. " ) , CreatedFilename ) ;
}
Action = LocalTest - > ReportedChanges . Find ( ModifiedFilename ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Modified )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " File '%s' was not correctly reported as being modified. " ) , ModifiedFilename ) ;
}
Action = LocalTest - > ReportedChanges . Find ( RemovedFilename ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Removed )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " File '%s' was not correctly reported as being deleted. " ) , RemovedFilename ) ;
}
} ) ) ;
} ) ) ;
} ) ) ;
# else
// Give the stream time to start up before doing the test
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
// Start watching the directory
TSharedPtr < FDirectoryWatcherTestPayload > Test = MakeShareable ( new FDirectoryWatcherTestPayload ( WorkingDir ) ) ;
// Give the stream time to start up before doing the test
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
// Create a new file
FFileHelper : : SaveStringToFile ( TEXT ( " " ) , * ( WorkingDir / CreatedFilename ) ) ;
// Modify another file
FFileHelper : : SaveStringToFile ( TEXT ( " Some content " ) , * ( WorkingDir / ModifiedFilename ) ) ;
// Delete a file
IFileManager : : Get ( ) . Delete ( * ( WorkingDir / RemovedFilename ) ) ;
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
2015-03-18 10:26:11 -04:00
FFileChangeData : : EFileChangeAction * Action = Test - > ReportedChanges . Find ( CreatedFilename ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Added )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " File '%s' was not correctly reported as being added. " ) , CreatedFilename ) ;
}
Action = Test - > ReportedChanges . Find ( ModifiedFilename ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Modified )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " File '%s' was not correctly reported as being modified. " ) , ModifiedFilename ) ;
}
Action = Test - > ReportedChanges . Find ( RemovedFilename ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Removed )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " File '%s' was not correctly reported as being deleted. " ) , RemovedFilename ) ;
}
} ) ) ;
} ) ) ;
} ) ) ;
2015-07-15 16:01:11 -04:00
# endif
2015-03-18 10:26:11 -04:00
return true ;
}
2015-08-28 13:23:02 -04:00
IMPLEMENT_SIMPLE_AUTOMATION_TEST ( FDirectoryWatcherNewFolderTest , " System.Plugins.Directory Watcher.New Folder " , EAutomationTestFlags : : EditorContext | EAutomationTestFlags : : EngineFilter )
2015-05-12 08:01:38 -04:00
bool FDirectoryWatcherNewFolderTest : : RunTest ( const FString & Parameters )
{
const FString WorkingDir = GetWorkingDir ( ) ;
static const TCHAR * CreatedDirectory = TEXT ( " created " ) ;
static const TCHAR * RemovedDirectory = TEXT ( " removed " ) ;
2015-07-15 16:01:11 -04:00
# if _MSC_VER >= 1900
// Give the stream time to start up before doing the test
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
IFileManager : : Get ( ) . MakeDirectory ( * ( WorkingDir / RemovedDirectory ) , true ) ;
// Start watching the directory
TSharedPtr < FDirectoryWatcherTestPayload > Test = MakeShareable ( new FDirectoryWatcherTestPayload ( WorkingDir , IDirectoryWatcher : : WatchOptions : : IncludeDirectoryChanges ) ) ;
void * Holder = & Test ;
// Give the stream time to start up before doing the test
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
IFileManager : : Get ( ) . MakeDirectory ( * ( WorkingDir / CreatedDirectory ) , true ) ;
IFileManager : : Get ( ) . DeleteDirectory ( * ( WorkingDir / RemovedDirectory ) , true ) ;
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
TSharedPtr < FDirectoryWatcherTestPayload > LocalTest = * ( const TSharedPtr < FDirectoryWatcherTestPayload > * ) Holder ;
FFileChangeData : : EFileChangeAction * Action = LocalTest - > ReportedChanges . Find ( CreatedDirectory ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Added )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " Folder '%s' was not correctly reported as being added. " ) , CreatedDirectory ) ;
}
Action = LocalTest - > ReportedChanges . Find ( RemovedDirectory ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Removed )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " Folder '%s' was not correctly reported as being removed. " ) , RemovedDirectory ) ;
}
} ) ) ;
} ) ) ;
} ) ) ;
# else
2015-05-12 08:01:38 -04:00
// Give the stream time to start up before doing the test
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
IFileManager : : Get ( ) . MakeDirectory ( * ( WorkingDir / RemovedDirectory ) , true ) ;
// Start watching the directory
2015-06-25 20:17:42 -04:00
TSharedPtr < FDirectoryWatcherTestPayload > Test = MakeShareable ( new FDirectoryWatcherTestPayload ( WorkingDir , IDirectoryWatcher : : WatchOptions : : IncludeDirectoryChanges ) ) ;
2015-05-12 08:01:38 -04:00
// Give the stream time to start up before doing the test
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
IFileManager : : Get ( ) . MakeDirectory ( * ( WorkingDir / CreatedDirectory ) , true ) ;
IFileManager : : Get ( ) . DeleteDirectory ( * ( WorkingDir / RemovedDirectory ) , true ) ;
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
FFileChangeData : : EFileChangeAction * Action = Test - > ReportedChanges . Find ( CreatedDirectory ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Added )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " Folder '%s' was not correctly reported as being added. " ) , CreatedDirectory ) ;
}
Action = Test - > ReportedChanges . Find ( RemovedDirectory ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Removed )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " Folder '%s' was not correctly reported as being removed. " ) , RemovedDirectory ) ;
}
} ) ) ;
} ) ) ;
} ) ) ;
2015-07-15 16:01:11 -04:00
# endif
2015-05-12 08:01:38 -04:00
return true ;
}
2015-03-18 10:26:11 -04:00
2015-08-28 13:23:02 -04:00
IMPLEMENT_SIMPLE_AUTOMATION_TEST ( FDirectoryWatcherIgnoreSubtreeTest , " System.Plugins.Directory Watcher.Ignore Subtree " , EAutomationTestFlags : : EditorContext | EAutomationTestFlags : : EngineFilter )
2015-06-25 20:17:42 -04:00
bool FDirectoryWatcherIgnoreSubtreeTest : : RunTest ( const FString & Parameters )
{
const FString WorkingDir = GetWorkingDir ( ) ;
2015-03-18 10:26:11 -04:00
2015-06-25 20:17:42 -04:00
static const TCHAR * ChildDirectory = TEXT ( " child " ) ;
static const TCHAR * GrandchildDirectory = TEXT ( " grandchild " ) ;
2015-03-18 10:26:11 -04:00
2015-07-15 16:01:11 -04:00
# if _MSC_VER >= 1900
2015-06-25 20:17:42 -04:00
// Give the stream time to start up before doing the test
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
2015-03-18 10:26:11 -04:00
2015-06-25 20:17:42 -04:00
// Start watching the directory
TSharedPtr < FDirectoryWatcherTestPayload > Test = MakeShareable ( new FDirectoryWatcherTestPayload ( WorkingDir , IDirectoryWatcher : : WatchOptions : : IgnoreChangesInSubtree | IDirectoryWatcher : : WatchOptions : : IncludeDirectoryChanges ) ) ;
2015-07-15 16:01:11 -04:00
void * Holder = & Test ;
2015-03-18 10:26:11 -04:00
2015-06-25 20:17:42 -04:00
// Give the stream time to start up before doing the test
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
2015-03-18 10:26:11 -04:00
2015-06-25 20:17:42 -04:00
IFileManager : : Get ( ) . MakeDirectory ( * ( WorkingDir / ChildDirectory ) , true ) ;
IFileManager : : Get ( ) . MakeDirectory ( * ( WorkingDir / ChildDirectory / GrandchildDirectory ) , true ) ;
2015-03-18 10:26:11 -04:00
2015-06-25 20:17:42 -04:00
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
2015-03-18 10:26:11 -04:00
2015-07-15 16:01:11 -04:00
TSharedPtr < FDirectoryWatcherTestPayload > LocalTest = * ( const TSharedPtr < FDirectoryWatcherTestPayload > * ) Holder ;
FFileChangeData : : EFileChangeAction * Action = LocalTest - > ReportedChanges . Find ( ChildDirectory ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Added )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " Folder '%s' was not correctly reported as being added. " ) , ChildDirectory ) ;
}
Action = LocalTest - > ReportedChanges . Find ( GrandchildDirectory ) ;
if ( Action )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " Changes to folder '%s' (creation of subfolder '%s') was reported in spite of us setting the mode 'ignore changes in subtree'. " ) ,
ChildDirectory , GrandchildDirectory ) ;
}
} ) ) ;
} ) ) ;
} ) ) ;
# else
// Give the stream time to start up before doing the test
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
// Start watching the directory
TSharedPtr < FDirectoryWatcherTestPayload > Test = MakeShareable ( new FDirectoryWatcherTestPayload ( WorkingDir , IDirectoryWatcher : : WatchOptions : : IgnoreChangesInSubtree | IDirectoryWatcher : : WatchOptions : : IncludeDirectoryChanges ) ) ;
// Give the stream time to start up before doing the test
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
IFileManager : : Get ( ) . MakeDirectory ( * ( WorkingDir / ChildDirectory ) , true ) ;
IFileManager : : Get ( ) . MakeDirectory ( * ( WorkingDir / ChildDirectory / GrandchildDirectory ) , true ) ;
ADD_LATENT_AUTOMATION_COMMAND ( FDelayedCallbackLatentCommand ( [ = ] {
2015-06-25 20:17:42 -04:00
FFileChangeData : : EFileChangeAction * Action = Test - > ReportedChanges . Find ( ChildDirectory ) ;
if ( ! Action | | * Action ! = FFileChangeData : : FCA_Added )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " Folder '%s' was not correctly reported as being added. " ) , ChildDirectory ) ;
}
2015-03-18 10:26:11 -04:00
2015-06-25 20:17:42 -04:00
Action = Test - > ReportedChanges . Find ( GrandchildDirectory ) ;
if ( Action )
{
UE_LOG ( LogDirectoryWatcherTests , Error , TEXT ( " Changes to folder '%s' (creation of subfolder '%s') was reported in spite of us setting the mode 'ignore changes in subtree'. " ) ,
ChildDirectory , GrandchildDirectory ) ;
}
} ) ) ;
} ) ) ;
} ) ) ;
2015-07-15 16:01:11 -04:00
# endif
2015-06-25 20:17:42 -04:00
return true ;
}
2015-03-18 10:26:11 -04:00