void UFunctionalTestingManager::AllTestsDone()
{
	if (GatheredFailedTestsReproString.IsEmpty() == false)
	{
		static const FText ReproStringLabel = LOCTEXT("ReproString", "Repro String:");
		AddLogItem(ReproStringLabel);
		AddLogItem(FText::FromString(GatheredFailedTestsReproString));
	}

	if (bLooped == true)
	{
		++CurrentIteration;

		// reset
		ensure(TestReproStrings.Num() == 0);
		SetReproString(StartingReproString);
		GatheredFailedTestsReproString = TEXT("");
		TestsLeft = AllTests;

		FFormatNamedArguments Arguments;
		Arguments.Add(TEXT("IterationIndex"), CurrentIteration);
		AddLogItem(FText::Format(LOCTEXT("StartingIteration", "----- Starting iteration {IterationIndex} -----"), Arguments));
		bIsRunning = RunFirstValidTest();
		if (bIsRunning == false)
		{
			static const FText FailedToStartAnotherIterationText = LOCTEXT("FailedToStartAnotherIteration", "Failed to start another iteration.");
			AddWarning(FailedToStartAnotherIterationText);
		}
	}
	else
	{
		AddLogItem(LOCTEXT("TestDone", "DONE."));
		RemoveFromRoot();
	}
}
Exemplo n.º 2
0
bool FLightingPromotionModifyProperties::RunTest(const FString& Parameters)
{
	//** SETUP **//
	UWorld* World = AutomationEditorCommonUtils::CreateNewMap();
	ULevel* CurrentLevel = World->GetCurrentLevel();
	// Test Summary
	AddLogItem(TEXT("The properties values for a point light are modified.\n- Intensity is set to 1000.\n- Color is set to R=0,G=0,B=255.\n- Attenuation Radius is set to 1024."));

	if (!LightingTestHelpers::DoesActorExistInTheLevel(CurrentLevel, TEXT("PointLight"), APointLight::StaticClass()))
	{
		//** TEST **//
		// Add a point light to the level.
		APointLight* PointLight = Cast<APointLight>(GEditor->AddActor(World->GetCurrentLevel(), APointLight::StaticClass(), FTransform()));
		// Modify the Lights Intensity, Light Color, and Attenuation Radius using it's properties.
		LightingTestHelpers::SetPropertyByName(PointLight->PointLightComponent, TEXT("Intensity"), TEXT("1000.f"));
		LightingTestHelpers::SetPropertyByName(PointLight->PointLightComponent, TEXT("LightColor"), TEXT("(R=0,G=0,B=255)"));
		LightingTestHelpers::SetPropertyByName(PointLight->PointLightComponent, TEXT("AttenuationRadius"), TEXT("1024.f"));

		//** VERIFY **//
		TestEqual<float>(TEXT("Light brightness property was not modified."), 1000.f, PointLight->PointLightComponent->Intensity);
		TestEqual<FColor>(TEXT("Light color property was not modified."), FColor(0,0,255), PointLight->PointLightComponent->LightColor);
		TestEqual<float>(TEXT("Light attenuation radius was not modified."), 1024.f, PointLight->PointLightComponent->AttenuationRadius);

		return true;
	}

	AddError(TEXT("A point light already exists in this level which will block the verification of a new point light."));
	return false;
}
Exemplo n.º 3
0
LRESULT CLogListView::OnAddLogItem(WPARAM wParam, LPARAM lParam)
{
    CListCtrl& listCtrl = GetListCtrl();
    int nListEntries = listCtrl.GetItemCount();
    LOG_ITEM * pItem = (PLOG_ITEM)lParam;

    AddLogItem(pItem, nListEntries, ++m_dwCurItem, listCtrl);

    return m_dwCurItem;
}
Exemplo n.º 4
0
bool FLightingPromotionDuplicationTest::RunTest(const FString& Parameters)
{
	//** SETUP **//
	UWorld* World = AutomationEditorCommonUtils::CreateNewMap();
	ULevel* CurrentLevel = World->GetCurrentLevel();
	// Test Summary
	AddLogItem(TEXT("Duplicate and Copy Paste\n- Duplicates a point light.\n- Copies and Pastes a point light."));

	if (!LightingTestHelpers::DoesActorExistInTheLevel(CurrentLevel, TEXT("PointLight"), APointLight::StaticClass()))
	{
		//** TEST **//
		// Add a point light to the level.
		APointLight* PointLight = Cast<APointLight>(GEditor->AddActor(World->GetCurrentLevel(), APointLight::StaticClass(), FTransform()));
		// Deselect all and then Select the light
		LightingTestHelpers::SelectActorInLevel(PointLight);
		// Copy and Paste.
		GEngine->Exec(World, TEXT("EDIT COPY"));
		GEngine->Exec(World, TEXT("EDIT PASTE"));
		// Deselect all and then select a light
		LightingTestHelpers::SelectActorInLevel(PointLight);
		// Duplicate the light
		GEngine->Exec(World, TEXT("DUPLICATE"));

		//** Verify **//
		int32 NumberOfPointLights = 0;
		// Count the number of point lights in the level.
		for (TObjectIterator<APointLight> It; It; ++It)
		{
			NumberOfPointLights++;
		}
		
		// We are expecting three point lights to be in the level now.
		TestEqual<int32>(TEXT("After duplicating a light the total number of them in the level is not correct."), 3, NumberOfPointLights);

		return true;
	}

	AddError(TEXT("A point light already exists in this level which would dirty the test results."));
	return false;
}
Exemplo n.º 5
0
bool FLightingPromotionPointLightPlaceRotScaleTest::RunTest(const FString& Parameters)
{
	//** SETUP **//
	// Create the world.
	UWorld* World = AutomationEditorCommonUtils::CreateNewMap();
	ULevel* CurrentLevel = World->GetCurrentLevel();
	// Test Summary
	AddLogItem(TEXT("Place, Scale, and Rotate.\n- A Point light is placed into the world.\n- The light is moved.\n- The light is rotated.\n- The light is scaled up."));

	if (!LightingTestHelpers::DoesActorExistInTheLevel(CurrentLevel, TEXT("PointLight"), APointLight::StaticClass()))
	{
		//** TEST **//
		// Add a point light to the level.
		APointLight* PointLight = Cast<APointLight>(GEditor->AddActor(World->GetCurrentLevel(), APointLight::StaticClass(), FTransform()));
		// Set the actors location, rotation, and scale3D.
		PointLight->SetActorLocation(POINT_LIGHT_UPDATED_LOCATION);
		PointLight->SetActorRotation(POINT_LIGHT_UPDATED_ROTATION);
		PointLight->SetActorScale3D(POINT_LIGHT_UPDATED_SCALE3D);

		//** VERIFY **//
		FVector CurrentLocation;
		LightingTestHelpers::GetActorCurrentLocation(CurrentLevel, PointLight->GetName(), CurrentLocation);
		FRotator CurrentRotation;
		LightingTestHelpers::GetActorCurrentRotation(CurrentLevel, PointLight->GetName(), CurrentRotation);
		FVector CurrentScale3D;
		LightingTestHelpers::GetActorCurrentScale3D(CurrentLevel, PointLight->GetName(), CurrentScale3D);
		bool RotationsAreEqual = CurrentRotation.Equals(POINT_LIGHT_UPDATED_ROTATION, 1);

		TestTrue(TEXT("The placed point light was not found."), LightingTestHelpers::DoesActorExistInTheLevel(CurrentLevel, PointLight->GetName(), PointLight->GetClass()));
		TestEqual<FVector>(TEXT("The point light is not in correct location"), POINT_LIGHT_UPDATED_LOCATION, CurrentLocation);
		TestTrue(TEXT("The point light is not rotated correctly."), RotationsAreEqual);
		TestEqual<FVector>(TEXT("The point light is not scaled correctly."), POINT_LIGHT_UPDATED_SCALE3D, CurrentScale3D);

		return true;
	}

	AddError(TEXT("A point light already exists in this level which will block the verification of a new point light."));
	return false;
}
Exemplo n.º 6
0
int CLogListView::RefreshLog(CAdapterInfo *pAdapterInfo)
{
    CListCtrl& listCtrl = GetListCtrl();

    // 1. 装载日志到系统内存空间
    if (! (m_bLogLoaded = ((CMainFrame *)AfxGetMainWnd())->LoadLogFile()))
    {
        return 0;
    }

    // 2. 计算总共有多少项日志以及一页可以显示的项数
    DWORD dwLogSize		= ((CMainFrame *)AfxGetMainWnd())->m_dwLogFileSize;
    DWORD dwLogCount	= dwLogSize / sizeof(LOG_ITEM);//38
    int   nCountPerPage = listCtrl.GetCountPerPage();
    int   nPageCount	= (dwLogSize + nCountPerPage) / nCountPerPage;

    // 3. 如果数据超过10页,则首先显示前5页数据,否则显示所有数据
    int nIndex   = 0;
    m_dwCurItem  = 0;
    m_dwLogCount = dwLogCount;
    LOG_ITEM * pItem = (PLOG_ITEM)(((CMainFrame *)AfxGetMainWnd())->m_lpMapAddr);

    // 4. 如果数据少于10页,则显示所有数据
    if (nPageCount < 10)
    {
        while (m_dwCurItem < dwLogCount)
        {
            AddLogItem(pItem++, nIndex++, ++m_dwCurItem, listCtrl);
        }

        return m_dwCurItem;
    }

    // 5. 如果数据超过10页,则首先显示前5页数据,
    while (m_dwCurItem < dwLogCount)
    {
        AddLogItem(pItem++, nIndex++, ++m_dwCurItem, listCtrl);

        if (m_dwCurItem == nCountPerPage * 5)
        {
            break;
        }
    }

    // 6. 如果执行到这里,需要创建一个线程继续添加后面的项
    m_pThreadParams = new ThreadParams;
    if (! m_pThreadParams)
    {
        AfxMessageBox("不能创建日志装载线程!");
        return m_dwCurItem;
    }

    HANDLE hWaitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
    if (hWaitEvent == NULL)
    {
        AfxMessageBox("不能创建日志装载线程!");
        delete m_pThreadParams;
        m_pThreadParams = NULL;
        return m_dwCurItem;
    }

    m_pThreadParams->m_hwndProgress = AfxGetMainWnd()->m_hWnd;
    m_pThreadParams->m_hwndView   = this->GetSafeHwnd();
    m_pThreadParams->m_lpLogBase  = ((CMainFrame *)AfxGetMainWnd())->m_lpMapAddr;
    m_pThreadParams->m_dwLogCount = m_dwLogCount;
    m_pThreadParams->m_dwCurItem  = m_dwCurItem;
    m_pThreadParams->m_hWaitEvent = hWaitEvent;
    m_pThreadParams->m_bPaused    = FALSE;
    m_pThreadParams->m_bInterrupt = FALSE;
    m_pThreadParams->m_bDone	  = FALSE;

    AfxBeginThread(LogThreadFunction, m_pThreadParams);

    m_bThreadStarted = TRUE;

    SetEvent(m_pThreadParams->m_hWaitEvent);

    ::SendMessage(m_pThreadParams->m_hwndProgress,
                  WM_USER_LOGTHREAD_STATUS, 0, (LPARAM)m_pThreadParams);

    ::SendMessage(m_pThreadParams->m_hwndProgress,
                  WM_USER_LOGTHREAD_STATUS, 1, (LPARAM)m_pThreadParams);

    ::SendMessage(m_pThreadParams->m_hwndProgress,
                  WM_USER_LOGTHREAD_STATUS, 2, (LPARAM)m_pThreadParams);

    ::SendMessage(m_pThreadParams->m_hwndProgress,
                  WM_USER_LOGTHREAD_STATUS, 3, (LPARAM)m_pThreadParams);

    return m_dwCurItem;
}
bool UFunctionalTestingManager::RunAllFunctionalTests(UObject* WorldContext, bool bNewLog, bool bRunLooped, bool bInWaitForNavigationBuildFinish, FString ReproString)
{
	UFunctionalTestingManager* Manager = GetManager(WorldContext);

	if (Manager->bIsRunning)
	{
		UE_LOG(LogFunctionalTest, Warning, TEXT("Functional tests are already running, aborting."));
		return true;
	}
	
	FMessageLog FunctionalTestingLog("FunctionalTestingLog");
	FunctionalTestingLog.Open();
	if (bNewLog)
	{
		FunctionalTestingLog.NewPage(LOCTEXT("NewLogLabel", "Functional Test"));
	}

	Manager->bLooped = bRunLooped;
	Manager->bWaitForNavigationBuildFinish = bInWaitForNavigationBuildFinish;
	Manager->CurrentIteration = 0;
	Manager->TestsLeft.Reset();
	Manager->SetReproString(ReproString);

	Manager->SetUpTests();

	if (Manager->TestReproStrings.Num() > 0)
	{
		static const FText RunningFromReproString = LOCTEXT("RunningFromReproString", "Running tests indicated by Repro String:");
		AddLogItem(RunningFromReproString);
		AddLogItem(FText::FromString(ReproString));
		Manager->TriggerFirstValidTest();
	}
	else
	{
		for (TActorIterator<AFunctionalTest> It(GWorld); It; ++It)
		{
			AFunctionalTest* Test = (*It);
			if (Test != NULL && Test->bIsEnabled == true)
			{
				Manager->AllTests.Add(Test);
			}
		}

		if (Manager->AllTests.Num() > 0)
		{
			Manager->TestsLeft = Manager->AllTests;
			Manager->TriggerFirstValidTest();
		}
	}

	if (Manager->bIsRunning == false)
	{
		AddLogItem(LOCTEXT("NoTestsDefined", "No tests defined on map or . DONE.")); 
		return false;
	}

#if WITH_EDITOR
	FEditorDelegates::EndPIE.AddUObject(Manager, &UFunctionalTestingManager::OnEndPIE);
#endif // WITH_EDITOR
	
	return true;
}