Merge branch 'upstream/development' into GitIssue3155_MultiplayerComponentsUsingNetInputRequirePlayerInputComponent
This commit is contained in:
@@ -5,6 +5,7 @@ __pycache__
|
||||
AssetProcessorTemp/**
|
||||
[Bb]uild/**
|
||||
[Oo]ut/**
|
||||
CMakeUserPresets.json
|
||||
[Cc]ache/
|
||||
/install/
|
||||
Editor/EditorEventLog.xml
|
||||
@@ -25,3 +26,4 @@ TestResults/**
|
||||
*.swatches
|
||||
/imgui.ini
|
||||
/scripts/project_manager/logs/
|
||||
/AutomatedTesting/Gem/PythonTests/scripting/TestResults
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
ly_install_directory(DIRECTORIES .)
|
||||
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"Amazon": {
|
||||
"AssetProcessor": {
|
||||
"Settings": {
|
||||
"RC cgf": {
|
||||
"ignore": true
|
||||
},
|
||||
"RC fbx": {
|
||||
"ignore": true
|
||||
},
|
||||
"ScanFolder AtomTestData": {
|
||||
"watch": "@ENGINEROOT@/Gems/Atom/TestData",
|
||||
"recursive": 1,
|
||||
"order": 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,12 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
TARGETS Editor
|
||||
VARIANTS Tools)
|
||||
|
||||
# The Material Editor needs the Lyshine "Tools" gem variant for the custom LyShine pass
|
||||
ly_enable_gems(
|
||||
PROJECT_NAME AutomatedTesting GEMS LyShine
|
||||
TARGETS MaterialEditor
|
||||
VARIANTS Tools)
|
||||
|
||||
# The pipeline tools use "Builders" gem variants:
|
||||
ly_enable_gems(
|
||||
PROJECT_NAME AutomatedTesting GEM_FILE enabled_gems.cmake
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
################################################################################
|
||||
|
||||
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
# Only enable AWS automated tests on Windows
|
||||
if(NOT "${PAL_PLATFORM_NAME}" STREQUAL "Windows")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Enable after installing NodeJS and CDK on jenkins Windows AMI.
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::AWSTests
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# AWS Gem Automation Tests
|
||||
|
||||
## Prerequisites
|
||||
1. Build the O3DE Editor and AutomatedTesting.GameLauncher in Profile.
|
||||
2. AWS CLI is installed and configured following [Configuration and Credential File Settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html).
|
||||
3. [AWS Cloud Development Kit (CDK)](https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html#getting_started_install) is installed.
|
||||
|
||||
## Deploy CDK Applications
|
||||
1. Go to the AWS IAM console and create an IAM role called o3de-automation-tests which adds your own account as as a trusted entity and uses the "AdministratorAccess" permissions policy.
|
||||
2. Copy {engine_root}\scripts\build\Platform\Windows\deploy_cdk_applications.cmd to your engine root folder.
|
||||
3. Open a Command Prompt window at the engine root and set the following environment variables:
|
||||
Set O3DE_AWS_PROJECT_NAME=AWSAUTO
|
||||
Set O3DE_AWS_DEPLOY_REGION=us-east-1
|
||||
Set ASSUME_ROLE_ARN="arn:aws:iam::{your_aws_account_id}:role/o3de-automation-tests"
|
||||
Set COMMIT_ID=HEAD
|
||||
4. Deploy the CDK applications for AWS gems by running deploy_cdk_applications.cmd in the same Command Prompt window.
|
||||
5. Edit AWS\common\constants.py to replace the assume role ARN with your own:
|
||||
arn:aws:iam::{your_aws_account_id}:role/o3de-automation-tests
|
||||
|
||||
## Run Automation Tests
|
||||
### CLI
|
||||
Open a Command Prompt window at the engine root and run the following CLI command:
|
||||
python\python.cmd -m pytest {path_to_the_test_file} --build-directory {directory_to_the_profile_build}
|
||||
|
||||
### Pycharm
|
||||
You can also run any specific automation test directly from Pycharm by providing the "--build-directory" argument in the Run Configuration.
|
||||
+61
-45
@@ -9,18 +9,18 @@ import logging
|
||||
import os
|
||||
import pytest
|
||||
import typing
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
import ly_test_tools.log.log_monitor
|
||||
|
||||
from AWS.common import constants
|
||||
from .aws_metrics_custom_thread import AWSMetricsThread
|
||||
|
||||
# fixture imports
|
||||
from assetpipeline.ap_fixtures.asset_processor_fixture import asset_processor
|
||||
from .aws_metrics_utils import aws_metrics_utils
|
||||
from .aws_metrics_custom_thread import AWSMetricsThread
|
||||
|
||||
AWS_METRICS_FEATURE_NAME = 'AWSMetrics'
|
||||
GAME_LOG_NAME = 'Game.log'
|
||||
CONTEXT_VARIABLE = ['-c', 'batch_processing=true']
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -36,7 +36,7 @@ def setup(launcher: pytest.fixture,
|
||||
asset_processor.start()
|
||||
asset_processor.wait_for_idle()
|
||||
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), GAME_LOG_NAME)
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), constants.GAME_LOG_NAME)
|
||||
|
||||
# Initialize the log monitor.
|
||||
log_monitor = ly_test_tools.log.log_monitor.LogMonitor(launcher=launcher, log_file_path=file_to_monitor)
|
||||
@@ -73,23 +73,26 @@ def monitor_metrics_submission(log_monitor: pytest.fixture) -> None:
|
||||
f'unexpected_lines values: {unexpected_lines}')
|
||||
|
||||
|
||||
def query_metrics_from_s3(aws_metrics_utils: pytest.fixture, stack_name: str) -> None:
|
||||
def query_metrics_from_s3(aws_metrics_utils: pytest.fixture, resource_mappings: pytest.fixture, stack_name: str) -> None:
|
||||
"""
|
||||
Verify that the metrics events are delivered to the S3 bucket and can be queried.
|
||||
aws_metrics_utils: aws_metrics_utils fixture.
|
||||
stack_name: name of the CloudFormation stack.
|
||||
:param aws_metrics_utils: aws_metrics_utils fixture.
|
||||
:param resource_mappings: resource_mappings fixture.
|
||||
:param stack_name: name of the CloudFormation stack.
|
||||
"""
|
||||
analytics_bucket_name = aws_metrics_utils.get_analytics_bucket_name(stack_name)
|
||||
aws_metrics_utils.verify_s3_delivery(analytics_bucket_name)
|
||||
aws_metrics_utils.verify_s3_delivery(
|
||||
resource_mappings.get_resource_name_id('AWSMetrics.AnalyticsBucketName')
|
||||
)
|
||||
logger.info('Metrics are sent to S3.')
|
||||
|
||||
aws_metrics_utils.run_glue_crawler(f'{stack_name}-EventsCrawler')
|
||||
aws_metrics_utils.run_glue_crawler(
|
||||
resource_mappings.get_resource_name_id('AWSMetrics.EventsCrawlerName'))
|
||||
|
||||
# Remove the events_json table if exists so that the sample query can create a table with the same name.
|
||||
aws_metrics_utils.delete_table(f'{stack_name}-eventsdatabase', 'events_json')
|
||||
aws_metrics_utils.run_named_queries(f'{stack_name}-AthenaWorkGroup')
|
||||
logger.info('Query metrics from S3 successfully.')
|
||||
|
||||
# Empty the S3 bucket. S3 buckets can only be deleted successfully when it doesn't contain any object.
|
||||
aws_metrics_utils.empty_batch_analytics_bucket(analytics_bucket_name)
|
||||
|
||||
|
||||
def verify_operational_metrics(aws_metrics_utils: pytest.fixture, stack_name: str, start_time: datetime) -> None:
|
||||
"""
|
||||
@@ -102,7 +105,7 @@ def verify_operational_metrics(aws_metrics_utils: pytest.fixture, stack_name: st
|
||||
'AWS/Lambda',
|
||||
'Invocations',
|
||||
[{'Name': 'FunctionName',
|
||||
'Value': f'{stack_name}-AnalyticsProcessingLambdaName'}],
|
||||
'Value': f'{stack_name}-AnalyticsProcessingLambda'}],
|
||||
start_time)
|
||||
logger.info('AnalyticsProcessingLambda metrics are sent to CloudWatch.')
|
||||
|
||||
@@ -115,50 +118,59 @@ def verify_operational_metrics(aws_metrics_utils: pytest.fixture, stack_name: st
|
||||
logger.info('EventsProcessingLambda metrics are sent to CloudWatch.')
|
||||
|
||||
|
||||
def start_kinesis_analytics_application(aws_metrics_utils: pytest.fixture, stack_name: str) -> None:
|
||||
def update_kinesis_analytics_application_status(aws_metrics_utils: pytest.fixture,
|
||||
resource_mappings: pytest.fixture, start_application: bool) -> None:
|
||||
"""
|
||||
Start the Kinesis analytics application for real-time analytics.
|
||||
aws_metrics_utils: aws_metrics_utils fixture.
|
||||
stack_name: name of the CloudFormation stack.
|
||||
Update the Kinesis analytics application to start or stop it.
|
||||
:param aws_metrics_utils: aws_metrics_utils fixture.
|
||||
:param resource_mappings: resource_mappings fixture.
|
||||
:param start_application: whether to start or stop the application.
|
||||
"""
|
||||
analytics_application_name = f'{stack_name}-AnalyticsApplication'
|
||||
aws_metrics_utils.start_kinesis_data_analytics_application(analytics_application_name)
|
||||
if start_application:
|
||||
aws_metrics_utils.start_kinesis_data_analytics_application(
|
||||
resource_mappings.get_resource_name_id('AWSMetrics.AnalyticsApplicationName'))
|
||||
else:
|
||||
aws_metrics_utils.stop_kinesis_data_analytics_application(
|
||||
resource_mappings.get_resource_name_id('AWSMetrics.AnalyticsApplicationName'))
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.usefixtures('automatic_process_killer')
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['AWS/Metrics'])
|
||||
@pytest.mark.parametrize('feature_name', [AWS_METRICS_FEATURE_NAME])
|
||||
@pytest.mark.usefixtures('resource_mappings')
|
||||
@pytest.mark.parametrize('resource_mappings_filename', ['default_aws_resource_mappings.json'])
|
||||
@pytest.mark.usefixtures('aws_credentials')
|
||||
@pytest.mark.usefixtures('resource_mappings')
|
||||
@pytest.mark.parametrize('assume_role_arn', [constants.ASSUME_ROLE_ARN])
|
||||
@pytest.mark.parametrize('feature_name', [AWS_METRICS_FEATURE_NAME])
|
||||
@pytest.mark.parametrize('level', ['AWS/Metrics'])
|
||||
@pytest.mark.parametrize('profile_name', ['AWSAutomationTest'])
|
||||
@pytest.mark.parametrize('region_name', ['us-west-2'])
|
||||
@pytest.mark.parametrize('assume_role_arn', ['arn:aws:iam::645075835648:role/o3de-automation-tests'])
|
||||
@pytest.mark.usefixtures('cdk')
|
||||
@pytest.mark.parametrize('session_name', ['o3de-Automation-session'])
|
||||
@pytest.mark.parametrize('deployment_params', [CONTEXT_VARIABLE])
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('region_name', [constants.AWS_REGION])
|
||||
@pytest.mark.parametrize('resource_mappings_filename', [constants.AWS_RESOURCE_MAPPING_FILE_NAME])
|
||||
@pytest.mark.parametrize('session_name', [constants.SESSION_NAME])
|
||||
@pytest.mark.parametrize('stacks', [[f'{constants.AWS_PROJECT_NAME}-{AWS_METRICS_FEATURE_NAME}-{constants.AWS_REGION}']])
|
||||
class TestAWSMetricsWindows(object):
|
||||
"""
|
||||
Test class to verify the real-time and batch analytics for metrics.
|
||||
"""
|
||||
|
||||
@pytest.mark.parametrize('destroy_stacks_on_teardown', [False])
|
||||
def test_realtime_and_batch_analytics(self,
|
||||
level: str,
|
||||
launcher: pytest.fixture,
|
||||
asset_processor: pytest.fixture,
|
||||
workspace: pytest.fixture,
|
||||
aws_utils: pytest.fixture,
|
||||
cdk: pytest.fixture,
|
||||
resource_mappings: pytest.fixture,
|
||||
stacks: typing.List,
|
||||
aws_metrics_utils: pytest.fixture):
|
||||
"""
|
||||
Verify that the metrics events are sent to CloudWatch and S3 for analytics.
|
||||
"""
|
||||
# Start Kinesis analytics application on a separate thread to avoid blocking the test.
|
||||
kinesis_analytics_application_thread = AWSMetricsThread(target=start_kinesis_analytics_application,
|
||||
args=(aws_metrics_utils, cdk.stacks[0]))
|
||||
kinesis_analytics_application_thread = AWSMetricsThread(target=update_kinesis_analytics_application_status,
|
||||
args=(aws_metrics_utils, resource_mappings, True))
|
||||
kinesis_analytics_application_thread.start()
|
||||
|
||||
# Clear the analytics bucket objects before sending new metrics.
|
||||
aws_metrics_utils.empty_bucket(
|
||||
resource_mappings.get_resource_name_id('AWSMetrics.AnalyticsBucketName'))
|
||||
|
||||
log_monitor = setup(launcher, asset_processor)
|
||||
|
||||
# Kinesis analytics application needs to be in the running state before we start the game launcher.
|
||||
@@ -177,18 +189,22 @@ class TestAWSMetricsWindows(object):
|
||||
start_time)
|
||||
logger.info('Real-time metrics are sent to CloudWatch.')
|
||||
|
||||
# Run time-consuming verifications on separate threads to avoid blocking the test.
|
||||
verification_threads = list()
|
||||
verification_threads.append(
|
||||
AWSMetricsThread(target=query_metrics_from_s3, args=(aws_metrics_utils, cdk.stacks[0])))
|
||||
verification_threads.append(
|
||||
AWSMetricsThread(target=verify_operational_metrics, args=(aws_metrics_utils, cdk.stacks[0], start_time)))
|
||||
for thread in verification_threads:
|
||||
# Run time-consuming operations on separate threads to avoid blocking the test.
|
||||
operational_threads = list()
|
||||
operational_threads.append(
|
||||
AWSMetricsThread(target=query_metrics_from_s3,
|
||||
args=(aws_metrics_utils, resource_mappings, stacks[0])))
|
||||
operational_threads.append(
|
||||
AWSMetricsThread(target=verify_operational_metrics,
|
||||
args=(aws_metrics_utils, stacks[0], start_time)))
|
||||
operational_threads.append(
|
||||
AWSMetricsThread(target=update_kinesis_analytics_application_status,
|
||||
args=(aws_metrics_utils, resource_mappings, False)))
|
||||
for thread in operational_threads:
|
||||
thread.start()
|
||||
for thread in verification_threads:
|
||||
for thread in operational_threads:
|
||||
thread.join()
|
||||
|
||||
@pytest.mark.parametrize('destroy_stacks_on_teardown', [True])
|
||||
def test_unauthorized_user_request_rejected(self,
|
||||
level: str,
|
||||
launcher: pytest.fixture,
|
||||
|
||||
@@ -198,7 +198,7 @@ class AWSMetricsUtils:
|
||||
|
||||
assert state == 'SUCCEEDED', f'Failed to run the named query {named_query.get("Name", {})}'
|
||||
|
||||
def empty_batch_analytics_bucket(self, bucket_name: str) -> None:
|
||||
def empty_bucket(self, bucket_name: str) -> None:
|
||||
"""
|
||||
Empty the S3 bucket following:
|
||||
https://boto3.amazonaws.com/v1/documentation/api/latest/guide/migrations3.html
|
||||
@@ -211,25 +211,18 @@ class AWSMetricsUtils:
|
||||
for key in bucket.objects.all():
|
||||
key.delete()
|
||||
|
||||
def get_analytics_bucket_name(self, stack_name: str) -> str:
|
||||
def delete_table(self, database_name: str, table_name: str) -> None:
|
||||
"""
|
||||
Get the name of the deployed S3 bucket.
|
||||
:param stack_name: Name of the CloudFormation stack.
|
||||
:return: Name of the deployed S3 bucket.
|
||||
Delete an existing Glue table.
|
||||
|
||||
:param database_name: Name of the Glue database.
|
||||
:param table_name: Name of the table to delete.
|
||||
"""
|
||||
|
||||
client = self._aws_util.client('cloudformation')
|
||||
|
||||
response = client.describe_stack_resources(
|
||||
StackName=stack_name
|
||||
client = self._aws_util.client('glue')
|
||||
client.delete_table(
|
||||
DatabaseName=database_name,
|
||||
Name=table_name
|
||||
)
|
||||
resources = response.get('StackResources', [])
|
||||
|
||||
for resource in resources:
|
||||
if resource.get('ResourceType') == 'AWS::S3::Bucket':
|
||||
return resource.get('PhysicalResourceId', '')
|
||||
|
||||
return ''
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
|
||||
@@ -45,7 +45,8 @@ class KinesisAnalyticsApplicationUpdatedWaiter(CustomWaiter):
|
||||
class GlueCrawlerReadyWaiter(CustomWaiter):
|
||||
"""
|
||||
Subclass of the base custom waiter class.
|
||||
Wait for the Glue crawler to finish its processing.
|
||||
Wait for the Glue crawler to finish its processing. Return when the crawler is in the "Stopping" status
|
||||
to avoid wasting too much time in the automation tests on its shutdown process.
|
||||
"""
|
||||
def __init__(self, client: botocore.client):
|
||||
"""
|
||||
@@ -57,7 +58,7 @@ class GlueCrawlerReadyWaiter(CustomWaiter):
|
||||
'GlueCrawlerReady',
|
||||
'GetCrawler',
|
||||
'Crawler.State',
|
||||
{'READY': WaitState.SUCCESS},
|
||||
{'STOPPING': WaitState.SUCCESS},
|
||||
client)
|
||||
|
||||
def wait(self, crawler_name):
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
@@ -1,248 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import boto3
|
||||
import uuid
|
||||
import logging
|
||||
import subprocess
|
||||
import botocore
|
||||
|
||||
import ly_test_tools.environment.process_utils as process_utils
|
||||
from typing import List
|
||||
|
||||
BOOTSTRAP_STACK_NAME = 'CDKToolkit'
|
||||
BOOTSTRAP_STAGING_BUCKET_LOGIC_ID = 'StagingBucket'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Cdk:
|
||||
"""
|
||||
Cdk class that provides methods to run cdk application commands.
|
||||
Expects system to have NodeJS, AWS CLI and CDK installed globally and have their paths setup as env variables.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._cdk_env = ''
|
||||
self._stacks = []
|
||||
self._cdk_path = os.path.dirname(os.path.realpath(__file__))
|
||||
self._session = ''
|
||||
|
||||
cdk_npm_latest_version_cmd = ['npm', 'view', 'aws-cdk', 'version']
|
||||
|
||||
output = process_utils.check_output(
|
||||
cdk_npm_latest_version_cmd,
|
||||
cwd=self._cdk_path,
|
||||
shell=True)
|
||||
cdk_npm_latest_version = output.split()[0]
|
||||
|
||||
cdk_version_cmd = ['cdk', 'version']
|
||||
output = process_utils.check_output(
|
||||
cdk_version_cmd,
|
||||
cwd=self._cdk_path,
|
||||
shell=True)
|
||||
cdk_version = output.split()[0]
|
||||
logger.info(f'Current CDK version {cdk_version}')
|
||||
|
||||
if cdk_version != cdk_npm_latest_version:
|
||||
try:
|
||||
logger.info(f'Updating CDK to latest')
|
||||
# uninstall and reinstall cdk in case npm has been updated.
|
||||
output = process_utils.check_output(
|
||||
'npm uninstall -g aws-cdk',
|
||||
cwd=self._cdk_path,
|
||||
shell=True)
|
||||
|
||||
logger.info(f'Uninstall CDK output: {output}')
|
||||
|
||||
output = process_utils.check_output(
|
||||
'npm install -g aws-cdk@latest',
|
||||
cwd=self._cdk_path,
|
||||
shell=True)
|
||||
|
||||
logger.info(f'Install CDK output: {output}')
|
||||
except subprocess.CalledProcessError as error:
|
||||
logger.warning(f'Failed reinstalling latest CDK on npm'
|
||||
f'\nError:{error.stderr}')
|
||||
|
||||
def setup(self, cdk_path: str, project: str, account_id: str,
|
||||
workspace: pytest.fixture, session: boto3.session.Session):
|
||||
"""
|
||||
:param cdk_path: Path where cdk app.py is stored.
|
||||
:param project: Project name used for cdk project name env variable.
|
||||
:param account_id: AWS account id to use with cdk application.
|
||||
:param workspace: ly_test_tools workspace fixture.
|
||||
:param session: Current boto3 session, provides credentials and region.
|
||||
"""
|
||||
self._cdk_env = os.environ.copy()
|
||||
unique_id = uuid.uuid4().hex[-4:]
|
||||
self._cdk_env['O3DE_AWS_PROJECT_NAME'] = project[:4] + unique_id if len(project) > 4 else project + unique_id
|
||||
self._cdk_env['O3DE_AWS_DEPLOY_REGION'] = session.region_name
|
||||
self._cdk_env['O3DE_AWS_DEPLOY_ACCOUNT'] = account_id
|
||||
self._cdk_env['PATH'] = f'{workspace.paths.engine_root()}\\python;' + self._cdk_env['PATH']
|
||||
|
||||
credentials = session.get_credentials().get_frozen_credentials()
|
||||
self._cdk_env['AWS_ACCESS_KEY_ID'] = credentials.access_key
|
||||
self._cdk_env['AWS_SECRET_ACCESS_KEY'] = credentials.secret_key
|
||||
self._cdk_env['AWS_SESSION_TOKEN'] = credentials.token
|
||||
self._cdk_path = cdk_path
|
||||
|
||||
self._session = session
|
||||
|
||||
output = process_utils.check_output(
|
||||
'python -m pip install -r requirements.txt',
|
||||
cwd=self._cdk_path,
|
||||
env=self._cdk_env,
|
||||
shell=True)
|
||||
|
||||
logger.info(f'Installing cdk python dependencies: {output}')
|
||||
|
||||
self.bootstrap()
|
||||
|
||||
def bootstrap(self) -> None:
|
||||
"""
|
||||
Deploy the bootstrap stack.
|
||||
"""
|
||||
try:
|
||||
bootstrap_cmd = ['cdk', 'bootstrap',
|
||||
f'aws://{self._cdk_env["O3DE_AWS_DEPLOY_ACCOUNT"]}/{self._cdk_env["O3DE_AWS_DEPLOY_REGION"]}']
|
||||
|
||||
process_utils.check_call(
|
||||
bootstrap_cmd,
|
||||
cwd=self._cdk_path,
|
||||
env=self._cdk_env,
|
||||
shell=True)
|
||||
except botocore.exceptions.ClientError as clientError:
|
||||
logger.warning(f'Failed creating Bootstrap stack {BOOTSTRAP_STACK_NAME} not found. '
|
||||
f'\nError:{clientError["Error"]["Message"]}')
|
||||
|
||||
def list(self, deployment_params: List[str] = None) -> List[str]:
|
||||
"""
|
||||
lists cdk stack names.
|
||||
:param deployment_params: Deployment parameters like --all can be passed in this way.
|
||||
:return List of cdk stack names.
|
||||
"""
|
||||
if not self._cdk_path:
|
||||
return []
|
||||
|
||||
list_cdk_application_cmd = ['cdk', 'list']
|
||||
if deployment_params:
|
||||
list_cdk_application_cmd.extend(deployment_params)
|
||||
|
||||
output = process_utils.check_output(
|
||||
list_cdk_application_cmd,
|
||||
cwd=self._cdk_path,
|
||||
env=self._cdk_env,
|
||||
shell=True)
|
||||
|
||||
return output.splitlines()
|
||||
|
||||
def synthesize(self, deployment_params: List[str] = None) -> None:
|
||||
"""
|
||||
Synthesizes all cdk stacks.
|
||||
:param deployment_params: Deployment parameters like --all can be passed in this way.
|
||||
"""
|
||||
if not self._cdk_path:
|
||||
return
|
||||
|
||||
synth_cdk_application_cmd = ['cdk', 'synth']
|
||||
if deployment_params:
|
||||
synth_cdk_application_cmd.extend(deployment_params)
|
||||
|
||||
process_utils.check_output(
|
||||
synth_cdk_application_cmd,
|
||||
cwd=self._cdk_path,
|
||||
env=self._cdk_env,
|
||||
shell=True)
|
||||
|
||||
def deploy(self, deployment_params: List[str] = None) -> List[str]:
|
||||
"""
|
||||
Deploys all the CDK stacks.
|
||||
:param deployment_params: Deployment parameters like --all can be passed in this way.
|
||||
:return List of deployed stack arns.
|
||||
"""
|
||||
if not self._cdk_path:
|
||||
return []
|
||||
|
||||
deploy_cdk_application_cmd = ['cdk', 'deploy', '--require-approval', 'never']
|
||||
if deployment_params:
|
||||
deploy_cdk_application_cmd.extend(deployment_params)
|
||||
|
||||
output = process_utils.check_output(
|
||||
deploy_cdk_application_cmd,
|
||||
cwd=self._cdk_path,
|
||||
env=self._cdk_env,
|
||||
shell=True)
|
||||
|
||||
for line in output.splitlines():
|
||||
line_sections = line.split('/')
|
||||
assert len(line_sections), 3
|
||||
self._stacks.append(line.split('/')[-2])
|
||||
|
||||
return self._stacks
|
||||
|
||||
def destroy(self, deployment_params: List[str] = None) -> None:
|
||||
"""
|
||||
Destroys the cdk application.
|
||||
:param deployment_params: Deployment parameters like --all can be passed in this way.
|
||||
"""
|
||||
|
||||
logger.info(f'CDK Path {self._cdk_path}')
|
||||
destroy_cdk_application_cmd = ['cdk', 'destroy', '-f']
|
||||
if deployment_params:
|
||||
destroy_cdk_application_cmd.extend(deployment_params)
|
||||
|
||||
try:
|
||||
process_utils.check_output(
|
||||
destroy_cdk_application_cmd,
|
||||
cwd=self._cdk_path,
|
||||
env=self._cdk_env,
|
||||
shell=True)
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
logger.error(e.output)
|
||||
raise e
|
||||
|
||||
self._stacks = []
|
||||
|
||||
def remove_bootstrap_stack(self) -> None:
|
||||
"""
|
||||
Remove the CDK bootstrap stack.
|
||||
:param aws_utils: aws_utils fixture.
|
||||
"""
|
||||
# Check if the bootstrap stack exists.
|
||||
response = self._session.client('cloudformation').describe_stacks(
|
||||
StackName=BOOTSTRAP_STACK_NAME
|
||||
)
|
||||
stacks = response.get('Stacks', [])
|
||||
if not stacks or len(stacks) is 0:
|
||||
return
|
||||
|
||||
# Clear the bootstrap staging bucket before deleting the bootstrap stack.
|
||||
response = self._session.client('cloudformation').describe_stack_resource(
|
||||
StackName=BOOTSTRAP_STACK_NAME,
|
||||
LogicalResourceId=BOOTSTRAP_STAGING_BUCKET_LOGIC_ID
|
||||
)
|
||||
|
||||
staging_bucket_name = response.get('StackResourceDetail', {}).get('PhysicalResourceId', '')
|
||||
if staging_bucket_name:
|
||||
s3 = self._session.resource('s3')
|
||||
bucket = s3.Bucket(staging_bucket_name)
|
||||
for key in bucket.objects.all():
|
||||
key.delete()
|
||||
|
||||
# Delete the bootstrap stack.
|
||||
# Should not need to delete the stack if S3 bucket can be cleaned.
|
||||
# self._session.client('cloudformation').delete_stack(
|
||||
# StackName=BOOTSTRAP_STACK_NAME
|
||||
# )
|
||||
|
||||
@property
|
||||
def stacks(self):
|
||||
return self._stacks
|
||||
+33
-28
@@ -4,45 +4,42 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
import pytest
|
||||
import os
|
||||
|
||||
import logging
|
||||
import os
|
||||
import pytest
|
||||
|
||||
import ly_test_tools.log.log_monitor
|
||||
|
||||
from AWS.common import constants
|
||||
|
||||
# fixture imports
|
||||
from assetpipeline.ap_fixtures.asset_processor_fixture import asset_processor
|
||||
|
||||
AWS_PROJECT_NAME = 'AWS-AutomationTest'
|
||||
AWS_CLIENT_AUTH_FEATURE_NAME = 'AWSClientAuth'
|
||||
AWS_CLIENT_AUTH_DEFAULT_PROFILE_NAME = 'default'
|
||||
|
||||
GAME_LOG_NAME = 'Game.log'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.usefixtures('automatic_process_killer')
|
||||
@pytest.mark.usefixtures('asset_processor')
|
||||
@pytest.mark.usefixtures('workspace')
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.usefixtures('cdk')
|
||||
@pytest.mark.parametrize('feature_name', [AWS_CLIENT_AUTH_FEATURE_NAME])
|
||||
@pytest.mark.usefixtures('resource_mappings')
|
||||
@pytest.mark.parametrize('resource_mappings_filename', ['default_aws_resource_mappings.json'])
|
||||
@pytest.mark.usefixtures('automatic_process_killer')
|
||||
@pytest.mark.usefixtures('aws_utils')
|
||||
@pytest.mark.parametrize('region_name', ['us-west-2'])
|
||||
@pytest.mark.parametrize('assume_role_arn', ['arn:aws:iam::645075835648:role/o3de-automation-tests'])
|
||||
@pytest.mark.parametrize('session_name', ['o3de-Automation-session'])
|
||||
@pytest.mark.usefixtures('cdk')
|
||||
@pytest.mark.parametrize('deployment_params', [[]])
|
||||
@pytest.mark.usefixtures('workspace')
|
||||
@pytest.mark.parametrize('assume_role_arn', [constants.ASSUME_ROLE_ARN])
|
||||
@pytest.mark.parametrize('feature_name', [AWS_CLIENT_AUTH_FEATURE_NAME])
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.usefixtures('resource_mappings')
|
||||
@pytest.mark.parametrize('resource_mappings_filename', [constants.AWS_RESOURCE_MAPPING_FILE_NAME])
|
||||
@pytest.mark.parametrize('region_name', [constants.AWS_REGION])
|
||||
@pytest.mark.parametrize('session_name', [constants.SESSION_NAME])
|
||||
@pytest.mark.parametrize('stacks', [[f'{constants.AWS_PROJECT_NAME}-{AWS_CLIENT_AUTH_FEATURE_NAME}-Stack-{constants.AWS_REGION}']])
|
||||
class TestAWSClientAuthWindows(object):
|
||||
"""
|
||||
Test class to verify AWS Client Auth gem features on Windows.
|
||||
"""
|
||||
|
||||
@pytest.mark.parametrize('level', ['AWS/ClientAuth'])
|
||||
@pytest.mark.parametrize('destroy_stacks_on_teardown', [False])
|
||||
def test_anonymous_credentials(self,
|
||||
level: str,
|
||||
launcher: pytest.fixture,
|
||||
@@ -53,14 +50,14 @@ class TestAWSClientAuthWindows(object):
|
||||
"""
|
||||
Test to verify AWS Cognito Identity pool anonymous authorization.
|
||||
|
||||
Setup: Deploys cdk and updates resource mapping file.
|
||||
Setup: Updates resource mapping file using existing CloudFormation stacks.
|
||||
Tests: Getting credentials when no credentials are configured
|
||||
Verification: Log monitor looks for success credentials log.
|
||||
"""
|
||||
asset_processor.start()
|
||||
asset_processor.wait_for_idle()
|
||||
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), GAME_LOG_NAME)
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), constants.GAME_LOG_NAME)
|
||||
log_monitor = ly_test_tools.log.log_monitor.LogMonitor(launcher=launcher, log_file_path=file_to_monitor)
|
||||
|
||||
launcher.args = ['+LoadLevel', level]
|
||||
@@ -74,10 +71,8 @@ class TestAWSClientAuthWindows(object):
|
||||
)
|
||||
assert result, 'Anonymous credentials fetched successfully.'
|
||||
|
||||
@pytest.mark.parametrize('destroy_stacks_on_teardown', [True])
|
||||
def test_password_signin_credentials(self,
|
||||
launcher: pytest.fixture,
|
||||
cdk: pytest.fixture,
|
||||
resource_mappings: pytest.fixture,
|
||||
workspace: pytest.fixture,
|
||||
asset_processor: pytest.fixture,
|
||||
@@ -86,16 +81,29 @@ class TestAWSClientAuthWindows(object):
|
||||
"""
|
||||
Test to verify AWS Cognito IDP Password sign in and Cognito Identity pool authenticated authorization.
|
||||
|
||||
Setup: Deploys cdk and updates resource mapping file.
|
||||
Setup: Updates resource mapping file using existing CloudFormation stacks.
|
||||
Tests: Sign up new test user, admin confirm the user, sign in and get aws credentials.
|
||||
Verification: Log monitor looks for success credentials log.
|
||||
"""
|
||||
asset_processor.start()
|
||||
asset_processor.wait_for_idle()
|
||||
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), GAME_LOG_NAME)
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), constants.GAME_LOG_NAME)
|
||||
log_monitor = ly_test_tools.log.log_monitor.LogMonitor(launcher=launcher, log_file_path=file_to_monitor)
|
||||
|
||||
cognito_idp = aws_utils.client('cognito-idp')
|
||||
user_pool_id = resource_mappings.get_resource_name_id(f'{AWS_CLIENT_AUTH_FEATURE_NAME}.CognitoUserPoolId')
|
||||
logger.info(f'UserPoolId:{user_pool_id}')
|
||||
|
||||
# Remove the user if already exists
|
||||
try:
|
||||
cognito_idp.admin_delete_user(
|
||||
UserPoolId=user_pool_id,
|
||||
Username='test1'
|
||||
)
|
||||
except cognito_idp.exceptions.UserNotFoundException:
|
||||
pass
|
||||
|
||||
launcher.args = ['+LoadLevel', 'AWS/ClientAuthPasswordSignUp']
|
||||
launcher.args.extend(['-rhi=null'])
|
||||
|
||||
@@ -109,9 +117,6 @@ class TestAWSClientAuthWindows(object):
|
||||
|
||||
launcher.stop()
|
||||
|
||||
cognito_idp = aws_utils.client('cognito-idp')
|
||||
user_pool_id = resource_mappings.get_resource_name_id(f'{AWS_CLIENT_AUTH_FEATURE_NAME}.CognitoUserPoolId')
|
||||
print(f'UserPoolId:{user_pool_id}')
|
||||
cognito_idp.admin_confirm_sign_up(
|
||||
UserPoolId=user_pool_id,
|
||||
Username='test1'
|
||||
|
||||
+15
-17
@@ -5,10 +5,11 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import logging
|
||||
import typing
|
||||
import os
|
||||
import shutil
|
||||
import typing
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
import pytest
|
||||
import ly_test_tools
|
||||
@@ -16,16 +17,15 @@ import ly_test_tools.log.log_monitor
|
||||
import ly_test_tools.environment.process_utils as process_utils
|
||||
import ly_test_tools.o3de.asset_processor_utils as asset_processor_utils
|
||||
|
||||
from botocore.exceptions import ClientError
|
||||
from AWS.common import constants
|
||||
|
||||
# fixture imports
|
||||
from assetpipeline.ap_fixtures.asset_processor_fixture import asset_processor
|
||||
|
||||
AWS_CORE_FEATURE_NAME = 'AWSCore'
|
||||
AWS_RESOURCE_MAPPING_FILE_NAME = 'default_aws_resource_mappings.json'
|
||||
|
||||
process_utils.kill_processes_named("o3de", ignore_extensions=True) # Kill ProjectManager windows
|
||||
|
||||
GAME_LOG_NAME = 'Game.log'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ def setup(launcher: pytest.fixture, asset_processor: pytest.fixture) -> typing.T
|
||||
asset_processor.start()
|
||||
asset_processor.wait_for_idle()
|
||||
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), GAME_LOG_NAME)
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), constants.GAME_LOG_NAME)
|
||||
log_monitor = ly_test_tools.log.log_monitor.LogMonitor(launcher=launcher, log_file_path=file_to_monitor)
|
||||
|
||||
return log_monitor, s3_download_dir
|
||||
@@ -58,7 +58,7 @@ def write_test_data_to_dynamodb_table(resource_mappings: pytest.fixture, aws_uti
|
||||
:param resource_mappings: resource_mappings fixture.
|
||||
:param aws_utils: aws_utils fixture.
|
||||
"""
|
||||
table_name = resource_mappings.get_resource_name_id("AWSCore.ExampleDynamoTableOutput")
|
||||
table_name = resource_mappings.get_resource_name_id(f'{AWS_CORE_FEATURE_NAME}.ExampleDynamoTableOutput')
|
||||
try:
|
||||
aws_utils.client('dynamodb').put_item(
|
||||
TableName=table_name,
|
||||
@@ -77,21 +77,19 @@ def write_test_data_to_dynamodb_table(resource_mappings: pytest.fixture, aws_uti
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.usefixtures('automatic_process_killer')
|
||||
@pytest.mark.usefixtures('asset_processor')
|
||||
@pytest.mark.usefixtures('cdk')
|
||||
@pytest.mark.parametrize('feature_name', [AWS_CORE_FEATURE_NAME])
|
||||
@pytest.mark.parametrize('region_name', ['us-west-2'])
|
||||
@pytest.mark.parametrize('assume_role_arn', ['arn:aws:iam::645075835648:role/o3de-automation-tests'])
|
||||
@pytest.mark.parametrize('session_name', ['o3de-Automation-session'])
|
||||
@pytest.mark.parametrize('region_name', [constants.AWS_REGION])
|
||||
@pytest.mark.parametrize('assume_role_arn', [constants.ASSUME_ROLE_ARN])
|
||||
@pytest.mark.parametrize('session_name', [constants.SESSION_NAME])
|
||||
@pytest.mark.usefixtures('workspace')
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['AWS/Core'])
|
||||
@pytest.mark.usefixtures('resource_mappings')
|
||||
@pytest.mark.parametrize('resource_mappings_filename', [AWS_RESOURCE_MAPPING_FILE_NAME])
|
||||
@pytest.mark.parametrize('resource_mappings_filename', [constants.AWS_RESOURCE_MAPPING_FILE_NAME])
|
||||
@pytest.mark.parametrize('stacks', [[f'{constants.AWS_PROJECT_NAME}-{AWS_CORE_FEATURE_NAME}',
|
||||
f'{constants.AWS_PROJECT_NAME}-{AWS_CORE_FEATURE_NAME}-Example-{constants.AWS_REGION}']])
|
||||
@pytest.mark.usefixtures('aws_credentials')
|
||||
@pytest.mark.parametrize('profile_name', ['AWSAutomationTest'])
|
||||
@pytest.mark.usefixtures('cdk')
|
||||
@pytest.mark.parametrize('deployment_params', [['--all']])
|
||||
@pytest.mark.parametrize('destroy_stacks_on_teardown', [True])
|
||||
class TestAWSCoreAWSResourceInteraction(object):
|
||||
"""
|
||||
Test class to verify the scripting behavior for the AWSCore gem.
|
||||
@@ -119,7 +117,7 @@ class TestAWSCoreAWSResourceInteraction(object):
|
||||
expected_lines: typing.List[str],
|
||||
unexpected_lines: typing.List[str]):
|
||||
"""
|
||||
Setup: Deploys cdk and updates resource mapping file.
|
||||
Setup: Updates resource mapping file using existing CloudFormation stacks.
|
||||
Tests: Interact with AWS S3, DynamoDB and Lambda services.
|
||||
Verification: Script canvas nodes can communicate with AWS services successfully.
|
||||
"""
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
@@ -0,0 +1,21 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
# ARN of the IAM role to assume for retrieving temporary AWS credentials
|
||||
ASSUME_ROLE_ARN = os.environ.get('ASSUME_ROLE_ARN', 'arn:aws:iam::645075835648:role/o3de-automation-tests')
|
||||
# Name of the AWS project deployed by the CDK applications
|
||||
AWS_PROJECT_NAME = os.environ.get('O3DE_AWS_PROJECT_NAME', 'AWSAUTO')
|
||||
# Region for the existing CloudFormation stacks used by the automation tests
|
||||
AWS_REGION = os.environ.get('O3DE_AWS_DEPLOY_REGION', 'us-east-1')
|
||||
# Name of the default resource mapping config file used by the automation tests
|
||||
AWS_RESOURCE_MAPPING_FILE_NAME = 'default_aws_resource_mappings.json'
|
||||
# Name of the game launcher log
|
||||
GAME_LOG_NAME = 'Game.log'
|
||||
# Name of the IAM role session for retrieving temporary AWS credentials
|
||||
SESSION_NAME = 'o3de-Automation-session'
|
||||
+5
-9
@@ -6,9 +6,9 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import json
|
||||
import logging
|
||||
from AWS.common import constants
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -22,18 +22,14 @@ class ResourceMappings:
|
||||
ResourceMappings class that handles writing Cloud formation outputs to resource mappings json file in a project.
|
||||
"""
|
||||
|
||||
def __init__(self, file_path: str, region: str, feature_name: str, account_id: str, workspace: pytest.fixture,
|
||||
cloud_formation_client):
|
||||
def __init__(self, file_path: str, region: str, feature_name: str, account_id: str, cloud_formation_client):
|
||||
"""
|
||||
:param file_path: Path for the resource mapping file.
|
||||
:param region: Region value for the resource mapping file.
|
||||
:param feature_name: Feature gem name to use to append name to mappings key.
|
||||
:param account_id: AWS account id value for the resource mapping file.
|
||||
:param workspace: ly_test_tools workspace fixture.
|
||||
:param cloud_formation_client: AWS cloud formation client.
|
||||
"""
|
||||
self._cdk_env = os.environ.copy()
|
||||
self._cdk_env['PATH'] = f'{workspace.paths.engine_root()}\\python;' + self._cdk_env['PATH']
|
||||
self._resource_mapping_file_path = file_path
|
||||
self._region = region
|
||||
self._feature_name = feature_name
|
||||
@@ -44,7 +40,7 @@ class ResourceMappings:
|
||||
f'Invalid resource mapping file path {self._resource_mapping_file_path}'
|
||||
self._client = cloud_formation_client
|
||||
|
||||
def populate_output_keys(self, stacks=[]) -> None:
|
||||
def populate_output_keys(self, stacks=None) -> None:
|
||||
"""
|
||||
Calls describe stacks on cloud formation service and persists outputs to resource mappings file.
|
||||
:param stacks List of stack arns to describe and populate resource mappings with.
|
||||
@@ -58,7 +54,7 @@ class ResourceMappings:
|
||||
|
||||
self._write_resource_mappings(stacks[0].get('Outputs', []))
|
||||
|
||||
def _write_resource_mappings(self, outputs, append_feature_name = True) -> None:
|
||||
def _write_resource_mappings(self, outputs, append_feature_name=True) -> None:
|
||||
with open(self._resource_mapping_file_path) as file_content:
|
||||
resource_mappings = json.load(file_content)
|
||||
|
||||
@@ -91,7 +87,7 @@ class ResourceMappings:
|
||||
resource_mappings = json.load(file_content)
|
||||
|
||||
resource_mappings[AWS_RESOURCE_MAPPINGS_ACCOUNT_ID_KEY] = ''
|
||||
resource_mappings[AWS_RESOURCE_MAPPINGS_REGION_KEY] = 'us-west-2'
|
||||
resource_mappings[AWS_RESOURCE_MAPPINGS_REGION_KEY] = constants.AWS_REGION
|
||||
|
||||
# Append new mappings.
|
||||
resource_mappings[AWS_RESOURCE_MAPPINGS_KEY] = resource_mappings.get(AWS_RESOURCE_MAPPINGS_KEY, {})
|
||||
@@ -11,8 +11,7 @@ import typing
|
||||
|
||||
from AWS.common.aws_utils import AwsUtils
|
||||
from AWS.common.aws_credentials import AwsCredentials
|
||||
from AWS.Windows.cdk.cdk_utils import Cdk
|
||||
from AWS.Windows.resource_mappings.resource_mappings import ResourceMappings
|
||||
from AWS.common.resource_mappings import ResourceMappings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -52,6 +51,7 @@ def resource_mappings(
|
||||
project: str,
|
||||
feature_name: str,
|
||||
resource_mappings_filename: str,
|
||||
stacks: typing.List,
|
||||
workspace: pytest.fixture,
|
||||
aws_utils: pytest.fixture) -> ResourceMappings:
|
||||
"""
|
||||
@@ -61,6 +61,7 @@ def resource_mappings(
|
||||
:param project: Project to find resource mapping file.
|
||||
:param feature_name: AWS Gem name that is prepended to resource mapping keys.
|
||||
:param resource_mappings_filename: Name of resource mapping file.
|
||||
:param stacks: List of stack names to describe and populate resource mappings with.
|
||||
:param workspace: ly_test_tools workspace fixture.
|
||||
:param aws_utils: AWS utils fixture.
|
||||
:return: ResourceMappings class object.
|
||||
@@ -70,8 +71,8 @@ def resource_mappings(
|
||||
logger.info(f'Resource mapping path : {path}')
|
||||
logger.info(f'Resource mapping resolved path : {abspath(path)}')
|
||||
resource_mappings_obj = ResourceMappings(abspath(path), aws_utils.assume_session().region_name, feature_name,
|
||||
aws_utils.assume_account_id(), workspace,
|
||||
aws_utils.client('cloudformation'))
|
||||
aws_utils.assume_account_id(), aws_utils.client('cloudformation'))
|
||||
resource_mappings_obj.populate_output_keys(stacks)
|
||||
|
||||
def teardown():
|
||||
resource_mappings_obj.clear_output_keys()
|
||||
@@ -81,56 +82,6 @@ def resource_mappings(
|
||||
return resource_mappings_obj
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def cdk(
|
||||
request: pytest.fixture,
|
||||
project: str,
|
||||
feature_name: str,
|
||||
workspace: pytest.fixture,
|
||||
aws_utils: pytest.fixture,
|
||||
resource_mappings: pytest.fixture,
|
||||
deployment_params: typing.List[str],
|
||||
destroy_stacks_on_teardown: bool) -> Cdk:
|
||||
"""
|
||||
Fixture for setting up a Cdk
|
||||
:param request: _pytest.fixtures.SubRequest class that handles getting
|
||||
a pytest fixture from a pytest function/fixture.
|
||||
:param project: Project name used for cdk project name env variable.
|
||||
:param feature_name: Feature gem name to expect cdk folder in.
|
||||
:param workspace: ly_test_tools workspace fixture.
|
||||
:param aws_utils: aws_utils fixture.
|
||||
:param resource_mappings: resource_mappings fixture.
|
||||
:param deployment_params: Parameters for the CDK application deployment.
|
||||
:param destroy_stacks_on_teardown: option to control calling destroy ot the end of test.
|
||||
:return Cdk class object.
|
||||
"""
|
||||
|
||||
cdk_path = f'{workspace.paths.engine_root()}/Gems/{feature_name}/cdk'
|
||||
logger.info(f'CDK Path {cdk_path}')
|
||||
|
||||
if pytest.cdk_obj is None:
|
||||
pytest.cdk_obj = Cdk()
|
||||
pytest.cdk_obj.setup(cdk_path, project, aws_utils.assume_account_id(), workspace, aws_utils.assume_session())
|
||||
|
||||
stacks = pytest.cdk_obj.deploy(deployment_params=deployment_params)
|
||||
|
||||
logger.info(f'Cdk stack names:\n{stacks}')
|
||||
resource_mappings.populate_output_keys(stacks)
|
||||
|
||||
def teardown():
|
||||
if destroy_stacks_on_teardown:
|
||||
pytest.cdk_obj.destroy(deployment_params=deployment_params)
|
||||
# Enable after https://github.com/aws/aws-cdk/issues/986 is fixed.
|
||||
# Until then clean the bootstrap bucket manually.
|
||||
# pytest.cdk_obj.remove_bootstrap_stack()
|
||||
|
||||
pytest.cdk_obj = None
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
return pytest.cdk_obj
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def aws_credentials(request: pytest.fixture, aws_utils: pytest.fixture, profile_name: str):
|
||||
"""
|
||||
|
||||
@@ -12,7 +12,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
TEST_SUITE main
|
||||
TEST_SERIAL TRUE
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Active.py
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
|
||||
@@ -8,7 +8,7 @@ INTRODUCTION
|
||||
------------
|
||||
|
||||
EditorPythonBindings is a Python project that contains a collection of editor testing tools
|
||||
developed by the Lumberyard feature teams. The project contains tools for system level
|
||||
developed by the O3DE feature teams. The project contains tools for system level
|
||||
editor tests.
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ installed on your system.
|
||||
|
||||
INSTALL
|
||||
-----------
|
||||
It is recommended to set up these these tools with Lumberyard's CMake build commands.
|
||||
It is recommended to set up these these tools with O3DE's CMake build commands.
|
||||
Assuming CMake is already setup on your operating system, below are some sample build commands:
|
||||
cd /path/to/od3e/
|
||||
mkdir windows_vs2019
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
# Built-in Imports
|
||||
from __future__ import annotations
|
||||
|
||||
# Open 3D Engine Imports
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.asset as azasset
|
||||
import azlmbr.math as math
|
||||
|
||||
|
||||
class Asset:
|
||||
"""
|
||||
Used to find Asset Id by its path and path of asset by its Id
|
||||
If a component has any asset property, then this class object can be called as:
|
||||
asset_id = editor_python_test_tools.editor_entity_utils.EditorComponent.get_component_property_value(<arguments>)
|
||||
asset = asset_utils.Asset(asset_id)
|
||||
"""
|
||||
def __init__(self, id: azasset.AssetId):
|
||||
self.id: azasset.AssetId = id
|
||||
|
||||
# Creation functions
|
||||
@classmethod
|
||||
def find_asset_by_path(cls, path: str, RegisterType: bool = False) -> Asset:
|
||||
"""
|
||||
:param path: Absolute file path of the asset
|
||||
:param RegisterType: Whether to register the asset if it's not in the database,
|
||||
default to false for the general case
|
||||
:return: Asset object associated with file path
|
||||
"""
|
||||
asset_id = azasset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", path, math.Uuid(), RegisterType)
|
||||
assert asset_id.is_valid(), f"Couldn't find Asset with path: {path}"
|
||||
asset = cls(asset_id)
|
||||
return asset
|
||||
|
||||
# Methods
|
||||
def get_path(self) -> str:
|
||||
"""
|
||||
:return: Absolute file path of Asset
|
||||
"""
|
||||
assert self.id.is_valid(), "Invalid Asset Id"
|
||||
return azasset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetPathById", self.id)
|
||||
+30
@@ -8,6 +8,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.object
|
||||
|
||||
from typing import List
|
||||
@@ -428,3 +429,32 @@ def get_component_type_id_map(component_name_list):
|
||||
type_ids_by_component[component_names[i]] = typeId
|
||||
|
||||
return type_ids_by_component
|
||||
|
||||
|
||||
def attach_component_to_entity(entity_id, component_name):
|
||||
# type: (azlmbr.entity.EntityId, str) -> azlmbr.entity.EntityComponentIdPair
|
||||
"""
|
||||
Adds the component if not added already.
|
||||
:param entity_id: EntityId of the entity to attach the component to
|
||||
:param component_name: name of the component
|
||||
:return: If successful, returns the EntityComponentIdPair, otherwise returns None.
|
||||
"""
|
||||
type_ids_list = editor.EditorComponentAPIBus(
|
||||
bus.Broadcast, 'FindComponentTypeIdsByEntityType', [component_name], 0)
|
||||
general.log(f"Components found = {len(type_ids_list)}")
|
||||
if len(type_ids_list) < 1:
|
||||
general.log(f"ERROR: A component class with name {component_name} doesn't exist")
|
||||
return None
|
||||
elif len(type_ids_list) > 1:
|
||||
general.log(f"ERROR: Found more than one component classes with same name: {component_name}")
|
||||
return None
|
||||
# Before adding the component let's check if it is already attached to the entity.
|
||||
component_outcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', entity_id, type_ids_list[0])
|
||||
if component_outcome.IsSuccess():
|
||||
return component_outcome.GetValue() # In this case the value is not a list.
|
||||
component_outcome = editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentsOfType', entity_id, type_ids_list)
|
||||
if component_outcome.IsSuccess():
|
||||
general.log(f"{component_name} Component added to entity.")
|
||||
return component_outcome.GetValue()[0]
|
||||
general.log(f"ERROR: Failed to add component [{component_name}] to entity")
|
||||
return None
|
||||
|
||||
+13
-2
@@ -29,7 +29,7 @@ def teardown_editor(editor):
|
||||
|
||||
def launch_and_validate_results(request, test_directory, editor, editor_script, expected_lines, unexpected_lines=[],
|
||||
halt_on_unexpected=False, run_python="--runpythontest", auto_test_mode=True, null_renderer=True, cfg_args=[],
|
||||
timeout=300):
|
||||
timeout=300, log_file_name="Editor.log"):
|
||||
"""
|
||||
Runs the Editor with the specified script, and monitors for expected log lines.
|
||||
:param request: Special fixture providing information of the requesting test function.
|
||||
@@ -44,6 +44,7 @@ def launch_and_validate_results(request, test_directory, editor, editor_script,
|
||||
:param null_renderer: Specifies the test does not require the renderer. Defaults to True.
|
||||
:param cfg_args: Additional arguments for CFG, such as LevelName.
|
||||
:param timeout: Length of time for test to run. Default is 60.
|
||||
:param log_file_name: Name of the log file created by the editor. Defaults to 'Editor.log'
|
||||
"""
|
||||
test_case = os.path.join(test_directory, editor_script)
|
||||
request.addfinalizer(lambda: teardown_editor(editor))
|
||||
@@ -58,7 +59,17 @@ def launch_and_validate_results(request, test_directory, editor, editor_script,
|
||||
|
||||
with editor.start():
|
||||
|
||||
editorlog_file = os.path.join(editor.workspace.paths.project_log(), 'Editor.log')
|
||||
editorlog_file = os.path.join(editor.workspace.paths.project_log(), log_file_name)
|
||||
|
||||
# Log monitor requires the file to exist.
|
||||
logger.debug(f"Waiting until log file <{editorlog_file}> exists...")
|
||||
waiter.wait_for(
|
||||
lambda: os.path.exists(editorlog_file),
|
||||
timeout=60,
|
||||
exc=f"Log file '{editorlog_file}' was never created by another process.",
|
||||
interval=1,
|
||||
)
|
||||
logger.debug(f"Done! log file <{editorlog_file}> exists.")
|
||||
|
||||
# Initialize the log monitor and set time to wait for log creation
|
||||
log_monitor = ly_test_tools.log.log_monitor.LogMonitor(launcher=editor, log_file_path=editorlog_file)
|
||||
|
||||
@@ -13,7 +13,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
TEST_REQUIRES gpu
|
||||
TEST_SERIAL
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Active.py
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
|
||||
@@ -27,19 +27,19 @@ class TestPythonAssetProcessing(object):
|
||||
unexpected_lines = []
|
||||
expected_lines = [
|
||||
'Mock asset exists',
|
||||
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive.azmodel) found',
|
||||
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative.azmodel) found',
|
||||
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive.azmodel) found',
|
||||
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative.azmodel) found',
|
||||
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive.azmodel) found',
|
||||
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative.azmodel) found',
|
||||
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel) found'
|
||||
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive_1.azmodel) found',
|
||||
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative_1.azmodel) found',
|
||||
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive_1.azmodel) found',
|
||||
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative_1.azmodel) found',
|
||||
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive_1.azmodel) found',
|
||||
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative_1.azmodel) found',
|
||||
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center_1.azmodel) found'
|
||||
]
|
||||
timeout = 180
|
||||
halt_on_unexpected = False
|
||||
test_directory = os.path.join(os.path.dirname(__file__))
|
||||
testFile = os.path.join(test_directory, 'AssetBuilder_test_case.py')
|
||||
editor.args.extend(['-NullRenderer', "--skipWelcomeScreenDialog", "--autotest_mode", "--runpythontest", testFile])
|
||||
editor.args.extend(['-NullRenderer', '-rhi=Null', "--skipWelcomeScreenDialog", "--autotest_mode", "--runpythontest", testFile])
|
||||
|
||||
with editor.start():
|
||||
editorlog_file = os.path.join(editor.workspace.paths.project_log(), 'Editor.log')
|
||||
|
||||
@@ -29,21 +29,21 @@ if (assetIdString.endswith(':528cca58') is False):
|
||||
print ('Mock asset exists')
|
||||
|
||||
# These tests detect if the geom_group.fbx file turns into a number of azmodel product assets
|
||||
def test_azmodel_product(generatedModelAssetPath, expectedSubId):
|
||||
def test_azmodel_product(generatedModelAssetPath):
|
||||
azModelAssetType = azlmbr.math.Uuid_CreateString('{2C7477B6-69C5-45BE-8163-BCD6A275B6D8}', 0)
|
||||
assetId = azlmbr.asset.AssetCatalogRequestBus(azlmbr.bus.Broadcast, 'GetAssetIdByPath', generatedModelAssetPath, azModelAssetType, False)
|
||||
assetIdString = assetId.to_string()
|
||||
if (assetIdString.endswith(':' + expectedSubId) is False):
|
||||
raise_and_stop(f'Asset at path {generatedModelAssetPath} has unexpected asset ID ({assetIdString}) for ({generatedModelAssetPath}), expected {expectedSubId}!')
|
||||
if (assetId.is_valid()):
|
||||
print(f'AssetId found for asset ({generatedModelAssetPath}) found')
|
||||
else:
|
||||
print(f'Expected subId for asset ({generatedModelAssetPath}) found')
|
||||
raise_and_stop(f'Asset at path {generatedModelAssetPath} has unexpected asset ID ({assetIdString})!')
|
||||
|
||||
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive.azmodel', '1024be55')
|
||||
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative.azmodel', '1052c94e')
|
||||
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive.azmodel', '10130556')
|
||||
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative.azmodel', '1065724d')
|
||||
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive.azmodel', '10d16e68')
|
||||
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative.azmodel', '10a71973')
|
||||
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel', '10412075')
|
||||
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive_1.azmodel')
|
||||
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative_1.azmodel')
|
||||
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive_1.azmodel')
|
||||
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative_1.azmodel')
|
||||
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive_1.azmodel')
|
||||
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative_1.azmodel')
|
||||
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center_1.azmodel')
|
||||
|
||||
azlmbr.editor.EditorToolsApplicationRequestBus(azlmbr.bus.Broadcast, 'ExitNoPrompt')
|
||||
|
||||
@@ -12,7 +12,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
TEST_SUITE periodic
|
||||
TEST_SERIAL
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
|
||||
@@ -12,7 +12,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
TEST_SUITE main
|
||||
TEST_SERIAL
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Active.py
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
|
||||
+1
-1
@@ -342,7 +342,7 @@ def bundler_batch_setup_fixture(request, workspace, asset_processor, timeout) ->
|
||||
# Run a full scan to ENSURE that both caches (pc and osx) are COMPLETELY POPULATED
|
||||
# Needed for asset bundling
|
||||
# fmt:off
|
||||
assert asset_processor.batch_process(fastscan=False, timeout=timeout * len(platforms), platforms=platforms_list), \
|
||||
assert asset_processor.batch_process(fastscan=True, timeout=timeout * len(platforms), platforms=platforms_list), \
|
||||
"AP Batch failed to process in bundler_batch_fixture"
|
||||
# fmt:on
|
||||
|
||||
|
||||
@@ -97,26 +97,12 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/asset_bundler_batch_tests.py
|
||||
EXCLUDE_TEST_RUN_TARGET_FROM_IDE
|
||||
TEST_SERIAL
|
||||
TIMEOUT 2400
|
||||
TEST_SUITE periodic
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
AZ::AssetBundlerBatch
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AssetPipelineTests.AssetBundler_SandBox
|
||||
TEST_SUITE sandbox
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/asset_bundler_batch_tests.py
|
||||
PYTEST_MARKS "SUITE_sandbox" # run only sandbox tests in this file
|
||||
EXCLUDE_TEST_RUN_TARGET_FROM_IDE
|
||||
TEST_SERIAL
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
AZ::AssetBundlerBatch
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AssetPipelineTests.AssetBuilder
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/asset_builder_tests.py
|
||||
@@ -133,7 +119,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/missing_dependency_tests.py
|
||||
EXCLUDE_TEST_RUN_TARGET_FROM_IDE
|
||||
TEST_SERIAL
|
||||
TIMEOUT 1500
|
||||
TEST_SUITE periodic
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessorBatch
|
||||
|
||||
@@ -39,7 +39,7 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedT
|
||||
TEST_SUITE main
|
||||
TEST_REQUIRES gpu
|
||||
TEST_SERIAL
|
||||
TIMEOUT 800
|
||||
TIMEOUT 1200
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/test_Atom_GPUTests.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
AssetProcessor
|
||||
|
||||
+2
-2
@@ -206,8 +206,8 @@ def run():
|
||||
# PostFX Layer Component
|
||||
ComponentTests("PostFX Layer")
|
||||
|
||||
# Radius Weight Modifier Component
|
||||
ComponentTests("Radius Weight Modifier")
|
||||
# PostFX Radius Weight Modifier Component
|
||||
ComponentTests("PostFX Radius Weight Modifier")
|
||||
|
||||
# Light Component
|
||||
ComponentTests("Light")
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import azlmbr.legacy.general as general
|
||||
sys.path.append(os.path.join(azlmbr.paths.devassets, "Gem", "PythonTests"))
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from atom_renderer.atom_utils.atom_component_helper import LIGHT_TYPES
|
||||
from atom_renderer.atom_utils.atom_constants import LIGHT_TYPES
|
||||
|
||||
LIGHT_TYPE_PROPERTY = 'Controller|Configuration|Light type'
|
||||
SPHERE_AND_SPOT_DISK_LIGHT_PROPERTIES = [
|
||||
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
import azlmbr.materialeditor will fail with a ModuleNotFound error when using this script with Editor.exe
|
||||
This is because azlmbr.materialeditor only binds to MaterialEditor.exe and not Editor.exe
|
||||
You need to launch this script with MaterialEditor.exe in order for azlmbr.materialeditor to appear.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devassets, "Gem", "PythonTests"))
|
||||
|
||||
import atom_renderer.atom_utils.material_editor_utils as material_editor
|
||||
|
||||
NEW_MATERIAL = "test_material.material"
|
||||
NEW_MATERIAL_1 = "test_material_1.material"
|
||||
NEW_MATERIAL_2 = "test_material_2.material"
|
||||
TEST_MATERIAL_1 = "001_DefaultWhite.material"
|
||||
TEST_MATERIAL_2 = "002_BaseColorLerp.material"
|
||||
TEST_MATERIAL_3 = "003_MetalMatte.material"
|
||||
TEST_DATA_PATH = os.path.join(
|
||||
azlmbr.paths.devroot, "Gems", "Atom", "TestData", "TestData", "Materials", "StandardPbrTestCases"
|
||||
)
|
||||
MATERIAL_TYPE_PATH = os.path.join(
|
||||
azlmbr.paths.devroot, "Gems", "Atom", "Feature", "Common", "Assets",
|
||||
"Materials", "Types", "StandardPBR.materialtype",
|
||||
)
|
||||
|
||||
|
||||
def run():
|
||||
"""
|
||||
Summary:
|
||||
Material Editor basic tests including the below
|
||||
1. Opening an Existing Asset
|
||||
2. Creating a New Asset
|
||||
3. Closing Selected Material
|
||||
4. Closing All Materials
|
||||
5. Closing all but Selected Material
|
||||
6. Saving Material
|
||||
7. Saving as a New Material
|
||||
8. Saving as a Child Material
|
||||
9. Saving all Open Materials
|
||||
|
||||
Expected Result:
|
||||
All the above functions work as expected in Material Editor.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# 1) Test Case: Opening an Existing Asset
|
||||
document_id = material_editor.open_material(MATERIAL_TYPE_PATH)
|
||||
print(f"Material opened: {material_editor.is_open(document_id)}")
|
||||
|
||||
# Verify if the test material exists initially
|
||||
target_path = os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Materials", NEW_MATERIAL)
|
||||
print(f"Test asset doesn't exist initially: {not os.path.exists(target_path)}")
|
||||
|
||||
# 2) Test Case: Creating a New Material Using Existing One
|
||||
material_editor.save_document_as_child(document_id, target_path)
|
||||
material_editor.wait_for_condition(lambda: os.path.exists(target_path), 2.0)
|
||||
print(f"New asset created: {os.path.exists(target_path)}")
|
||||
|
||||
# Verify if the newly created document is open
|
||||
new_document_id = material_editor.open_material(target_path)
|
||||
material_editor.wait_for_condition(lambda: material_editor.is_open(new_document_id))
|
||||
print(f"New Material opened: {material_editor.is_open(new_document_id)}")
|
||||
|
||||
# 3) Test Case: Closing Selected Material
|
||||
print(f"Material closed: {material_editor.close_document(new_document_id)}")
|
||||
|
||||
# Open materials initially
|
||||
document1_id, document2_id, document3_id = (
|
||||
material_editor.open_material(os.path.join(TEST_DATA_PATH, material))
|
||||
for material in [TEST_MATERIAL_1, TEST_MATERIAL_2, TEST_MATERIAL_3]
|
||||
)
|
||||
|
||||
# 4) Test Case: Closing All Materials
|
||||
print(f"All documents closed: {material_editor.close_all_documents()}")
|
||||
|
||||
# 5) Test Case: Closing all but Selected Material
|
||||
document1_id, document2_id, document3_id = (
|
||||
material_editor.open_material(os.path.join(TEST_DATA_PATH, material))
|
||||
for material in [TEST_MATERIAL_1, TEST_MATERIAL_2, TEST_MATERIAL_3]
|
||||
)
|
||||
result = material_editor.close_all_except_selected(document1_id)
|
||||
print(f"Close All Except Selected worked as expected: {result and material_editor.is_open(document1_id)}")
|
||||
|
||||
# 6) Test Case: Saving Material
|
||||
document_id = material_editor.open_material(os.path.join(TEST_DATA_PATH, TEST_MATERIAL_1))
|
||||
property_name = azlmbr.name.Name("baseColor.color")
|
||||
initial_color = material_editor.get_property(document_id, property_name)
|
||||
# Assign new color to the material file and save the actual material
|
||||
expected_color = math.Color(0.25, 0.25, 0.25, 1.0)
|
||||
material_editor.set_property(document_id, property_name, expected_color)
|
||||
material_editor.save_document(document_id)
|
||||
|
||||
# 7) Test Case: Saving as a New Material
|
||||
# Assign new color to the material file and save the document as copy
|
||||
expected_color_1 = math.Color(0.5, 0.5, 0.5, 1.0)
|
||||
material_editor.set_property(document_id, property_name, expected_color_1)
|
||||
target_path_1 = os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Materials", NEW_MATERIAL_1)
|
||||
material_editor.save_document_as_copy(document_id, target_path_1)
|
||||
time.sleep(2.0)
|
||||
|
||||
# 8) Test Case: Saving as a Child Material
|
||||
# Assign new color to the material file save the document as child
|
||||
expected_color_2 = math.Color(0.75, 0.75, 0.75, 1.0)
|
||||
material_editor.set_property(document_id, property_name, expected_color_2)
|
||||
target_path_2 = os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Materials", NEW_MATERIAL_2)
|
||||
material_editor.save_document_as_child(document_id, target_path_2)
|
||||
time.sleep(2.0)
|
||||
|
||||
# Close/Reopen documents
|
||||
material_editor.close_all_documents()
|
||||
document_id = material_editor.open_material(os.path.join(TEST_DATA_PATH, TEST_MATERIAL_1))
|
||||
document1_id = material_editor.open_material(target_path_1)
|
||||
document2_id = material_editor.open_material(target_path_2)
|
||||
|
||||
# Verify if the changes are saved in the actual document
|
||||
actual_color = material_editor.get_property(document_id, property_name)
|
||||
print(f"Actual Document saved with changes: {material_editor.compare_colors(actual_color, expected_color)}")
|
||||
|
||||
# Verify if the changes are saved in the document saved as copy
|
||||
actual_color = material_editor.get_property(document1_id, property_name)
|
||||
result_copy = material_editor.compare_colors(actual_color, expected_color_1)
|
||||
print(f"Document saved as copy is saved with changes: {result_copy}")
|
||||
|
||||
# Verify if the changes are saved in the document saved as child
|
||||
actual_color = material_editor.get_property(document2_id, property_name)
|
||||
result_child = material_editor.compare_colors(actual_color, expected_color_2)
|
||||
print(f"Document saved as child is saved with changes: {result_child}")
|
||||
|
||||
# Revert back the changes in the actual document
|
||||
material_editor.set_property(document_id, property_name, initial_color)
|
||||
material_editor.save_document(document_id)
|
||||
material_editor.close_all_documents()
|
||||
|
||||
# 9) Test Case: Saving all Open Materials
|
||||
# Open first material and make change to the values
|
||||
document1_id = material_editor.open_material(os.path.join(TEST_DATA_PATH, TEST_MATERIAL_1))
|
||||
property1_name = azlmbr.name.Name("metallic.factor")
|
||||
initial_metallic_factor = material_editor.get_property(document1_id, property1_name)
|
||||
expected_metallic_factor = 0.444
|
||||
material_editor.set_property(document1_id, property1_name, expected_metallic_factor)
|
||||
|
||||
# Open second material and make change to the values
|
||||
document2_id = material_editor.open_material(os.path.join(TEST_DATA_PATH, TEST_MATERIAL_2))
|
||||
property2_name = azlmbr.name.Name("baseColor.color")
|
||||
initial_color = material_editor.get_property(document2_id, property2_name)
|
||||
expected_color = math.Color(0.4156, 0.0196, 0.6862, 1.0)
|
||||
material_editor.set_property(document2_id, property2_name, expected_color)
|
||||
|
||||
# Save all and close all documents
|
||||
material_editor.save_all()
|
||||
material_editor.close_all_documents()
|
||||
|
||||
# Reopen materials and verify values
|
||||
document1_id = material_editor.open_material(os.path.join(TEST_DATA_PATH, TEST_MATERIAL_1))
|
||||
result = material_editor.is_close(
|
||||
material_editor.get_property(document1_id, property1_name), expected_metallic_factor, 0.00001
|
||||
)
|
||||
document2_id = material_editor.open_material(os.path.join(TEST_DATA_PATH, TEST_MATERIAL_2))
|
||||
result = result and material_editor.compare_colors(
|
||||
expected_color, material_editor.get_property(document2_id, property2_name))
|
||||
print(f"Save All worked as expected: {result}")
|
||||
|
||||
# Revert the changes made
|
||||
material_editor.set_property(document1_id, property1_name, initial_metallic_factor)
|
||||
material_editor.set_property(document2_id, property2_name, initial_color)
|
||||
material_editor.save_all()
|
||||
material_editor.close_all_documents()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
+1
@@ -93,6 +93,7 @@ def run():
|
||||
general.idle_wait_frames(100)
|
||||
for i in range(1, 101):
|
||||
benchmarker.capture_pass_timestamp(i)
|
||||
benchmarker.capture_cpu_frame_time(i)
|
||||
general.exit_game_mode()
|
||||
helper.wait_for_condition(function=lambda: not general.is_in_game_mode(), timeout_in_seconds=2.0)
|
||||
general.log("Capturing complete.")
|
||||
|
||||
+267
@@ -0,0 +1,267 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
Hydra script that is used to create an entity with a Light component attached.
|
||||
It then updates the property values of the Light component and takes a screenshot.
|
||||
The screenshot is compared against an expected golden image for test verification.
|
||||
|
||||
See the run() function for more in-depth test info.
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests"))
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from atom_renderer.atom_utils import atom_component_helper, atom_constants, screenshot_utils
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
helper = EditorTestHelper(log_prefix="Atom_EditorTestHelper")
|
||||
|
||||
LEVEL_NAME = "auto_test"
|
||||
LIGHT_COMPONENT = "Light"
|
||||
LIGHT_TYPE_PROPERTY = 'Controller|Configuration|Light type'
|
||||
DEGREE_RADIAN_FACTOR = 0.0174533
|
||||
|
||||
|
||||
def run():
|
||||
"""
|
||||
Sets up the tests by making sure the required level is created & setup correctly.
|
||||
It then executes 2 test cases - see each associated test function's docstring for more info.
|
||||
|
||||
Finally prints the string "Light component tests completed" after completion
|
||||
|
||||
Tests will fail immediately if any of these log lines are found:
|
||||
1. Trace::Assert
|
||||
2. Trace::Error
|
||||
3. Traceback (most recent call last):
|
||||
|
||||
:return: None
|
||||
"""
|
||||
atom_component_helper.create_basic_atom_level(level_name=LEVEL_NAME)
|
||||
|
||||
# Run tests.
|
||||
area_light_test()
|
||||
spot_light_test()
|
||||
general.log("Light component tests completed.")
|
||||
|
||||
|
||||
def area_light_test():
|
||||
"""
|
||||
Basic test for the "Light" component attached to an "area_light" entity.
|
||||
|
||||
Test Case - Light Component: Capsule, Spot (disk), and Point (sphere):
|
||||
1. Creates "area_light" entity w/ a Light component that has a Capsule Light type w/ the color set to 255, 0, 0
|
||||
2. Enters game mode to take a screenshot for comparison, then exits game mode.
|
||||
3. Sets the Light component Intensity Mode to Lumens (default).
|
||||
4. Ensures the Light component Mode is Automatic (default).
|
||||
5. Sets the Intensity value of the Light component to 0.0
|
||||
6. Enters game mode again, takes another screenshot for comparison, then exits game mode.
|
||||
7. Updates the Intensity value of the Light component to 1000.0
|
||||
8. Enters game mode again, takes another screenshot for comparison, then exits game mode.
|
||||
9. Swaps the Capsule light type option to Spot (disk) light type on the Light component
|
||||
10. Updates "area_light" entity Transform rotate value to x: 90.0, y:0.0, z:0.0
|
||||
11. Enters game mode again, takes another screenshot for comparison, then exits game mode.
|
||||
12. Swaps the Spot (disk) light type for the Point (sphere) light type in the Light component.
|
||||
13. Enters game mode again, takes another screenshot for comparison, then exits game mode.
|
||||
14. Deletes the Light component from the "area_light" entity and verifies its successful.
|
||||
"""
|
||||
# Create an "area_light" entity with "Light" component using Light type of "Capsule"
|
||||
area_light_entity_name = "area_light"
|
||||
area_light = hydra.Entity(area_light_entity_name)
|
||||
area_light.create_entity(math.Vector3(-1.0, -2.0, 3.0), [LIGHT_COMPONENT])
|
||||
general.log(
|
||||
f"{area_light_entity_name}_test: Component added to the entity: "
|
||||
f"{hydra.has_components(area_light.id, [LIGHT_COMPONENT])}")
|
||||
light_component_id_pair = hydra.attach_component_to_entity(area_light.id, LIGHT_COMPONENT)
|
||||
|
||||
# Select the "Capsule" light type option.
|
||||
azlmbr.editor.EditorComponentAPIBus(
|
||||
azlmbr.bus.Broadcast,
|
||||
'SetComponentProperty',
|
||||
light_component_id_pair,
|
||||
LIGHT_TYPE_PROPERTY,
|
||||
atom_constants.LIGHT_TYPES['capsule']
|
||||
)
|
||||
|
||||
# Update color and take screenshot in game mode
|
||||
color = math.Color(255.0, 0.0, 0.0, 0.0)
|
||||
area_light.get_set_test(0, "Controller|Configuration|Color", color)
|
||||
general.idle_wait(1.0)
|
||||
screenshot_utils.take_screenshot_game_mode("AreaLight_1", area_light_entity_name)
|
||||
|
||||
# Update intensity value to 0.0 and take screenshot in game mode
|
||||
area_light.get_set_test(0, "Controller|Configuration|Attenuation Radius|Mode", 1)
|
||||
area_light.get_set_test(0, "Controller|Configuration|Intensity", 0.0)
|
||||
general.idle_wait(1.0)
|
||||
screenshot_utils.take_screenshot_game_mode("AreaLight_2", area_light_entity_name)
|
||||
|
||||
# Update intensity value to 1000.0 and take screenshot in game mode
|
||||
area_light.get_set_test(0, "Controller|Configuration|Intensity", 1000.0)
|
||||
general.idle_wait(1.0)
|
||||
screenshot_utils.take_screenshot_game_mode("AreaLight_3", area_light_entity_name)
|
||||
|
||||
# Swap the "Capsule" light type option to "Spot (disk)" light type
|
||||
azlmbr.editor.EditorComponentAPIBus(
|
||||
azlmbr.bus.Broadcast,
|
||||
'SetComponentProperty',
|
||||
light_component_id_pair,
|
||||
LIGHT_TYPE_PROPERTY,
|
||||
atom_constants.LIGHT_TYPES['spot_disk']
|
||||
)
|
||||
area_light_rotation = math.Vector3(DEGREE_RADIAN_FACTOR * 90.0, 0.0, 0.0)
|
||||
azlmbr.components.TransformBus(azlmbr.bus.Event, "SetLocalRotation", area_light.id, area_light_rotation)
|
||||
general.idle_wait(1.0)
|
||||
screenshot_utils.take_screenshot_game_mode("AreaLight_4", area_light_entity_name)
|
||||
|
||||
# Swap the "Spot (disk)" light type to the "Point (sphere)" light type and take screenshot.
|
||||
azlmbr.editor.EditorComponentAPIBus(
|
||||
azlmbr.bus.Broadcast,
|
||||
'SetComponentProperty',
|
||||
light_component_id_pair,
|
||||
LIGHT_TYPE_PROPERTY,
|
||||
atom_constants.LIGHT_TYPES['sphere']
|
||||
)
|
||||
general.idle_wait(1.0)
|
||||
screenshot_utils.take_screenshot_game_mode("AreaLight_5", area_light_entity_name)
|
||||
|
||||
editor.ToolsApplicationRequestBus(bus.Broadcast, "DeleteEntityById", area_light.id)
|
||||
|
||||
|
||||
def spot_light_test():
|
||||
"""
|
||||
Basic test for the Light component attached to a "spot_light" entity.
|
||||
|
||||
Test Case - Light Component: Spot (disk) with shadows & colors:
|
||||
1. Creates "spot_light" entity w/ a Light component attached to it.
|
||||
2. Selects the "directional_light" entity already present in the level and disables it.
|
||||
3. Selects the "global_skylight" entity already present in the level and disables the HDRi Skybox component,
|
||||
as well as the Global Skylight (IBL) component.
|
||||
4. Enters game mode to take a screenshot for comparison, then exits game mode.
|
||||
5. Selects the "ground_plane" entity and changes updates the material to a new material.
|
||||
6. Enters game mode to take a screenshot for comparison, then exits game mode.
|
||||
7. Selects the "spot_light" entity and increases the Light component Intensity to 800 lm
|
||||
8. Enters game mode to take a screenshot for comparison, then exits game mode.
|
||||
9. Selects the "spot_light" entity and sets the Light component Color to 47, 75, 37
|
||||
10. Enters game mode to take a screenshot for comparison, then exits game mode.
|
||||
11. Selects the "spot_light" entity and modifies the Shutter controls to the following values:
|
||||
- Enable shutters: True
|
||||
- Inner Angle: 60.0
|
||||
- Outer Angle: 75.0
|
||||
12. Enters game mode to take a screenshot for comparison, then exits game mode.
|
||||
13. Selects the "spot_light" entity and modifies the Shadow controls to the following values:
|
||||
- Enable Shadow: True
|
||||
- ShadowmapSize: 256
|
||||
14. Modifies the world translate position of the "spot_light" entity to 0.7, -2.0, 1.9 (for casting shadows better)
|
||||
15. Enters game mode to take a screenshot for comparison, then exits game mode.
|
||||
"""
|
||||
# Disable "Directional Light" component for the "directional_light" entity
|
||||
# "directional_light" entity is created by the create_basic_atom_level() function by default.
|
||||
directional_light_entity_id = hydra.find_entity_by_name("directional_light")
|
||||
directional_light = hydra.Entity(name='directional_light', id=directional_light_entity_id)
|
||||
directional_light_component_type = azlmbr.editor.EditorComponentAPIBus(
|
||||
azlmbr.bus.Broadcast, 'FindComponentTypeIdsByEntityType', ["Directional Light"], 0)[0]
|
||||
directional_light_component = azlmbr.editor.EditorComponentAPIBus(
|
||||
azlmbr.bus.Broadcast, 'GetComponentOfType', directional_light.id, directional_light_component_type
|
||||
).GetValue()
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, "DisableComponents", [directional_light_component])
|
||||
general.idle_wait(0.5)
|
||||
|
||||
# Disable "Global Skylight (IBL)" and "HDRi Skybox" components for the "global_skylight" entity
|
||||
global_skylight_entity_id = hydra.find_entity_by_name("global_skylight")
|
||||
global_skylight = hydra.Entity(name='global_skylight', id=global_skylight_entity_id)
|
||||
global_skylight_component_type = azlmbr.editor.EditorComponentAPIBus(
|
||||
azlmbr.bus.Broadcast, 'FindComponentTypeIdsByEntityType', ["Global Skylight (IBL)"], 0)[0]
|
||||
global_skylight_component = azlmbr.editor.EditorComponentAPIBus(
|
||||
azlmbr.bus.Broadcast, 'GetComponentOfType', global_skylight.id, global_skylight_component_type
|
||||
).GetValue()
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, "DisableComponents", [global_skylight_component])
|
||||
hdri_skybox_component_type = azlmbr.editor.EditorComponentAPIBus(
|
||||
azlmbr.bus.Broadcast, 'FindComponentTypeIdsByEntityType', ["HDRi Skybox"], 0)[0]
|
||||
hdri_skybox_component = azlmbr.editor.EditorComponentAPIBus(
|
||||
azlmbr.bus.Broadcast, 'GetComponentOfType', global_skylight.id, hdri_skybox_component_type
|
||||
).GetValue()
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, "DisableComponents", [hdri_skybox_component])
|
||||
general.idle_wait(0.5)
|
||||
|
||||
# Create a "spot_light" entity with "Light" component using Light Type of "Spot (disk)"
|
||||
spot_light_entity_name = "spot_light"
|
||||
spot_light = hydra.Entity(spot_light_entity_name)
|
||||
spot_light.create_entity(math.Vector3(0.7, -2.0, 1.0), [LIGHT_COMPONENT])
|
||||
general.log(
|
||||
f"{spot_light_entity_name}_test: Component added to the entity: "
|
||||
f"{hydra.has_components(spot_light.id, [LIGHT_COMPONENT])}")
|
||||
rotation = math.Vector3(DEGREE_RADIAN_FACTOR * 300.0, 0.0, 0.0)
|
||||
azlmbr.components.TransformBus(azlmbr.bus.Event, "SetLocalRotation", spot_light.id, rotation)
|
||||
light_component_type = hydra.attach_component_to_entity(spot_light.id, LIGHT_COMPONENT)
|
||||
editor.EditorComponentAPIBus(
|
||||
azlmbr.bus.Broadcast,
|
||||
'SetComponentProperty',
|
||||
light_component_type,
|
||||
LIGHT_TYPE_PROPERTY,
|
||||
atom_constants.LIGHT_TYPES['spot_disk']
|
||||
)
|
||||
|
||||
general.idle_wait(1.0)
|
||||
screenshot_utils.take_screenshot_game_mode("SpotLight_1", spot_light_entity_name)
|
||||
|
||||
# Change default material of ground plane entity and take screenshot
|
||||
ground_plane_entity_id = hydra.find_entity_by_name("ground_plane")
|
||||
ground_plane = hydra.Entity(name='ground_plane', id=ground_plane_entity_id)
|
||||
ground_plane_asset_path = os.path.join("Materials", "Presets", "MacBeth", "22_neutral_5-0_0-70d.azmaterial")
|
||||
ground_plane_asset_value = asset.AssetCatalogRequestBus(
|
||||
bus.Broadcast, "GetAssetIdByPath", ground_plane_asset_path, math.Uuid(), False)
|
||||
material_property_path = "Default Material|Material Asset"
|
||||
material_component_type = azlmbr.editor.EditorComponentAPIBus(
|
||||
azlmbr.bus.Broadcast, 'FindComponentTypeIdsByEntityType', ["Material"], 0)[0]
|
||||
material_component = azlmbr.editor.EditorComponentAPIBus(
|
||||
azlmbr.bus.Broadcast, 'GetComponentOfType', ground_plane.id, material_component_type).GetValue()
|
||||
editor.EditorComponentAPIBus(
|
||||
azlmbr.bus.Broadcast,
|
||||
'SetComponentProperty',
|
||||
material_component,
|
||||
material_property_path,
|
||||
ground_plane_asset_value
|
||||
)
|
||||
general.idle_wait(1.0)
|
||||
screenshot_utils.take_screenshot_game_mode("SpotLight_2", spot_light_entity_name)
|
||||
|
||||
# Increase intensity value of the Spot light and take screenshot in game mode
|
||||
spot_light.get_set_test(0, "Controller|Configuration|Intensity", 800.0)
|
||||
general.idle_wait(1.0)
|
||||
screenshot_utils.take_screenshot_game_mode("SpotLight_3", spot_light_entity_name)
|
||||
|
||||
# Update the Spot light color and take screenshot in game mode
|
||||
color_value = math.Color(47.0 / 255.0, 75.0 / 255.0, 37.0 / 255.0, 255.0 / 255.0)
|
||||
spot_light.get_set_test(0, "Controller|Configuration|Color", color_value)
|
||||
general.idle_wait(1.0)
|
||||
screenshot_utils.take_screenshot_game_mode("SpotLight_4", spot_light_entity_name)
|
||||
|
||||
# Update the Shutter controls of the Light component and take screenshot
|
||||
spot_light.get_set_test(0, "Controller|Configuration|Shutters|Enable shutters", True)
|
||||
spot_light.get_set_test(0, "Controller|Configuration|Shutters|Inner angle", 60.0)
|
||||
spot_light.get_set_test(0, "Controller|Configuration|Shutters|Outer angle", 75.0)
|
||||
general.idle_wait(1.0)
|
||||
screenshot_utils.take_screenshot_game_mode("SpotLight_5", spot_light_entity_name)
|
||||
|
||||
# Update the Shadow controls, move the spot_light entity world translate position and take screenshot
|
||||
spot_light.get_set_test(0, "Controller|Configuration|Shadows|Enable shadow", True)
|
||||
spot_light.get_set_test(0, "Controller|Configuration|Shadows|Shadowmap size", 256.0)
|
||||
azlmbr.components.TransformBus(
|
||||
azlmbr.bus.Event, "SetWorldTranslation", spot_light.id, math.Vector3(0.7, -2.0, 1.9))
|
||||
general.idle_wait(1.0)
|
||||
screenshot_utils.take_screenshot_game_mode("SpotLight_6", spot_light_entity_name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
+179
-12
@@ -3,17 +3,184 @@ Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
File to assist with common hydra component functions or constants used across various Atom tests.
|
||||
File to assist with common hydra component functions used across various Atom tests.
|
||||
"""
|
||||
import os
|
||||
|
||||
# Light type options for the Light component.
|
||||
LIGHT_TYPES = {
|
||||
'unknown': 0,
|
||||
'sphere': 1,
|
||||
'spot_disk': 2,
|
||||
'capsule': 3,
|
||||
'quad': 4,
|
||||
'polygon': 5,
|
||||
'simple_point': 6,
|
||||
'simple_spot': 7,
|
||||
}
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
helper = EditorTestHelper(log_prefix="Atom_EditorTestHelper")
|
||||
|
||||
|
||||
def create_basic_atom_level(level_name):
|
||||
"""
|
||||
Creates a new level inside the Editor matching level_name & adds the following:
|
||||
1. "default_level" entity to hold all other entities.
|
||||
2. Adds Grid, Global Skylight (IBL), ground Mesh, Directional Light, Sphere w/ material+mesh, & Camera components.
|
||||
3. Each of these components has its settings tweaked slightly to match the ideal scene to test Atom rendering.
|
||||
:param level_name: name of the level to create and apply this basic setup to.
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.camera as camera
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.object
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
|
||||
# Create a new level.
|
||||
new_level_name = level_name
|
||||
heightmap_resolution = 512
|
||||
heightmap_meters_per_pixel = 1
|
||||
terrain_texture_resolution = 412
|
||||
use_terrain = False
|
||||
|
||||
# Return codes are ECreateLevelResult defined in CryEdit.h
|
||||
return_code = general.create_level_no_prompt(
|
||||
new_level_name, heightmap_resolution, heightmap_meters_per_pixel, terrain_texture_resolution, use_terrain)
|
||||
if return_code == 1:
|
||||
general.log(f"{new_level_name} level already exists")
|
||||
elif return_code == 2:
|
||||
general.log("Failed to create directory")
|
||||
elif return_code == 3:
|
||||
general.log("Directory length is too long")
|
||||
elif return_code != 0:
|
||||
general.log("Unknown error, failed to create level")
|
||||
else:
|
||||
general.log(f"{new_level_name} level created successfully")
|
||||
|
||||
# Enable idle and update viewport.
|
||||
general.idle_enable(True)
|
||||
general.idle_wait(1.0)
|
||||
general.update_viewport()
|
||||
general.idle_wait(0.5) # half a second is more than enough for updating the viewport.
|
||||
|
||||
# Close out problematic windows, FPS meters, and anti-aliasing.
|
||||
if general.is_helpers_shown(): # Turn off the helper gizmos if visible
|
||||
general.toggle_helpers()
|
||||
general.idle_wait(1.0)
|
||||
if general.is_pane_visible("Error Report"): # Close Error Report windows that block focus.
|
||||
general.close_pane("Error Report")
|
||||
if general.is_pane_visible("Error Log"): # Close Error Log windows that block focus.
|
||||
general.close_pane("Error Log")
|
||||
general.idle_wait(1.0)
|
||||
general.run_console("r_displayInfo=0")
|
||||
general.run_console("r_antialiasingmode=0")
|
||||
general.idle_wait(1.0)
|
||||
|
||||
# Delete all existing entities & create default_level entity
|
||||
search_filter = azlmbr.entity.SearchFilter()
|
||||
all_entities = entity.SearchBus(azlmbr.bus.Broadcast, "SearchEntities", search_filter)
|
||||
editor.ToolsApplicationRequestBus(bus.Broadcast, "DeleteEntities", all_entities)
|
||||
default_level = hydra.Entity("default_level")
|
||||
default_position = math.Vector3(0.0, 0.0, 0.0)
|
||||
default_level.create_entity(default_position, ["Grid"])
|
||||
default_level.get_set_test(0, "Controller|Configuration|Secondary Grid Spacing", 1.0)
|
||||
|
||||
# Set the viewport up correctly after adding the parent default_level entity.
|
||||
screen_width = 1280
|
||||
screen_height = 720
|
||||
degree_radian_factor = 0.0174533 # Used by "Rotation" property for the Transform component.
|
||||
general.set_viewport_size(screen_width, screen_height)
|
||||
general.update_viewport()
|
||||
helper.wait_for_condition(
|
||||
function=lambda: helper.isclose(a=general.get_viewport_size().x, b=screen_width, rel_tol=0.1)
|
||||
and helper.isclose(a=general.get_viewport_size().y, b=screen_height, rel_tol=0.1),
|
||||
timeout_in_seconds=4.0
|
||||
)
|
||||
result = helper.isclose(a=general.get_viewport_size().x, b=screen_width, rel_tol=0.1) and helper.isclose(
|
||||
a=general.get_viewport_size().y, b=screen_height, rel_tol=0.1)
|
||||
general.log(general.get_viewport_size().x)
|
||||
general.log(general.get_viewport_size().y)
|
||||
general.log(general.get_viewport_size().z)
|
||||
general.log(f"Viewport is set to the expected size: {result}")
|
||||
general.log("Basic level created")
|
||||
general.run_console("r_DisplayInfo = 0")
|
||||
|
||||
# Create global_skylight entity and set the properties
|
||||
global_skylight = hydra.Entity("global_skylight")
|
||||
global_skylight.create_entity(
|
||||
entity_position=default_position,
|
||||
components=["HDRi Skybox", "Global Skylight (IBL)"],
|
||||
parent_id=default_level.id)
|
||||
global_skylight_asset_path = os.path.join(
|
||||
"LightingPresets", "greenwich_park_02_4k_iblskyboxcm_iblspecular.exr.streamingimage")
|
||||
global_skylight_asset_value = asset.AssetCatalogRequestBus(
|
||||
bus.Broadcast, "GetAssetIdByPath", global_skylight_asset_path, math.Uuid(), False)
|
||||
global_skylight.get_set_test(0, "Controller|Configuration|Cubemap Texture", global_skylight_asset_value)
|
||||
global_skylight.get_set_test(1, "Controller|Configuration|Diffuse Image", global_skylight_asset_value)
|
||||
global_skylight.get_set_test(1, "Controller|Configuration|Specular Image", global_skylight_asset_value)
|
||||
|
||||
# Create ground_plane entity and set the properties
|
||||
ground_plane = hydra.Entity("ground_plane")
|
||||
ground_plane.create_entity(
|
||||
entity_position=default_position,
|
||||
components=["Material"],
|
||||
parent_id=default_level.id)
|
||||
azlmbr.components.TransformBus(azlmbr.bus.Event, "SetLocalUniformScale", ground_plane.id, 32.0)
|
||||
ground_plane_material_asset_path = os.path.join(
|
||||
"Materials", "Presets", "PBR", "metal_chrome.azmaterial")
|
||||
ground_plane_material_asset_value = asset.AssetCatalogRequestBus(
|
||||
bus.Broadcast, "GetAssetIdByPath", ground_plane_material_asset_path, math.Uuid(), False)
|
||||
ground_plane.get_set_test(0, "Default Material|Material Asset", ground_plane_material_asset_value)
|
||||
|
||||
# Work around to add the correct Atom Mesh component
|
||||
mesh_type_id = azlmbr.globals.property.EditorMeshComponentTypeId
|
||||
ground_plane.components.append(
|
||||
editor.EditorComponentAPIBus(
|
||||
bus.Broadcast, "AddComponentsOfType", ground_plane.id, [mesh_type_id]
|
||||
).GetValue()[0]
|
||||
)
|
||||
ground_plane_mesh_asset_path = os.path.join("Models", "plane.azmodel")
|
||||
ground_plane_mesh_asset_value = asset.AssetCatalogRequestBus(
|
||||
bus.Broadcast, "GetAssetIdByPath", ground_plane_mesh_asset_path, math.Uuid(), False)
|
||||
ground_plane.get_set_test(1, "Controller|Configuration|Mesh Asset", ground_plane_mesh_asset_value)
|
||||
|
||||
# Create directional_light entity and set the properties
|
||||
directional_light = hydra.Entity("directional_light")
|
||||
directional_light.create_entity(
|
||||
entity_position=math.Vector3(0.0, 0.0, 10.0),
|
||||
components=["Directional Light"],
|
||||
parent_id=default_level.id)
|
||||
directional_light_rotation = math.Vector3(degree_radian_factor * -90.0, 0.0, 0.0)
|
||||
azlmbr.components.TransformBus(
|
||||
azlmbr.bus.Event, "SetLocalRotation", directional_light.id, directional_light_rotation)
|
||||
|
||||
# Create sphere entity and set the properties
|
||||
sphere_entity = hydra.Entity("sphere")
|
||||
sphere_entity.create_entity(
|
||||
entity_position=math.Vector3(0.0, 0.0, 1.0),
|
||||
components=["Material"],
|
||||
parent_id=default_level.id)
|
||||
sphere_material_asset_path = os.path.join("Materials", "Presets", "PBR", "metal_brass_polished.azmaterial")
|
||||
sphere_material_asset_value = asset.AssetCatalogRequestBus(
|
||||
bus.Broadcast, "GetAssetIdByPath", sphere_material_asset_path, math.Uuid(), False)
|
||||
sphere_entity.get_set_test(0, "Default Material|Material Asset", sphere_material_asset_value)
|
||||
|
||||
# Work around to add the correct Atom Mesh component
|
||||
sphere_entity.components.append(
|
||||
editor.EditorComponentAPIBus(
|
||||
bus.Broadcast, "AddComponentsOfType", sphere_entity.id, [mesh_type_id]
|
||||
).GetValue()[0]
|
||||
)
|
||||
sphere_mesh_asset_path = os.path.join("Models", "sphere.azmodel")
|
||||
sphere_mesh_asset_value = asset.AssetCatalogRequestBus(
|
||||
bus.Broadcast, "GetAssetIdByPath", sphere_mesh_asset_path, math.Uuid(), False)
|
||||
sphere_entity.get_set_test(1, "Controller|Configuration|Mesh Asset", sphere_mesh_asset_value)
|
||||
|
||||
# Create camera component and set the properties
|
||||
camera_entity = hydra.Entity("camera")
|
||||
camera_entity.create_entity(
|
||||
entity_position=math.Vector3(5.5, -12.0, 9.0),
|
||||
components=["Camera"],
|
||||
parent_id=default_level.id)
|
||||
rotation = math.Vector3(
|
||||
degree_radian_factor * -27.0, degree_radian_factor * -12.0, degree_radian_factor * 25.0
|
||||
)
|
||||
azlmbr.components.TransformBus(azlmbr.bus.Event, "SetLocalRotation", camera_entity.id, rotation)
|
||||
camera_entity.get_set_test(0, "Controller|Configuration|Field of view", 60.0)
|
||||
camera.EditorCameraViewRequestBus(azlmbr.bus.Event, "ToggleCameraAsActiveView", camera_entity.id)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
Hold constants used across both hydra and non-hydra scripts.
|
||||
"""
|
||||
|
||||
# Light type options for the Light component.
|
||||
LIGHT_TYPES = {
|
||||
'unknown': 0,
|
||||
'sphere': 1,
|
||||
'spot_disk': 2,
|
||||
'capsule': 3,
|
||||
'quad': 4,
|
||||
'polygon': 5,
|
||||
'simple_point': 6,
|
||||
'simple_spot': 7,
|
||||
}
|
||||
@@ -61,6 +61,25 @@ class BenchmarkHelper(object):
|
||||
general.log('Failed to capture pass timestamps.')
|
||||
return self.capturedData
|
||||
|
||||
def capture_cpu_frame_time(self, frame_number):
|
||||
"""
|
||||
Capture CPU frame times and block further execution until it has been written to the disk.
|
||||
"""
|
||||
self.handler = azlmbr.atom.ProfilingCaptureNotificationBusHandler()
|
||||
self.handler.connect()
|
||||
self.handler.add_callback('OnCaptureCpuFrameTimeFinished', self.on_data_captured)
|
||||
|
||||
self.done = False
|
||||
self.capturedData = False
|
||||
success = azlmbr.atom.ProfilingCaptureRequestBus(
|
||||
azlmbr.bus.Broadcast, "CaptureCpuFrameTime", f'{self.output_path}/cpu_frame{frame_number}_time.json')
|
||||
if success:
|
||||
self.wait_until_data()
|
||||
general.log('CPU frame time captured.')
|
||||
else:
|
||||
general.log('Failed to capture CPU frame time.')
|
||||
return self.capturedData
|
||||
|
||||
def on_data_captured(self, parameters):
|
||||
# the parameters come in as a tuple
|
||||
if parameters[0]:
|
||||
|
||||
@@ -0,0 +1,274 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
import azlmbr.materialeditor will fail with a ModuleNotFound error when using this script with Editor.exe
|
||||
This is because azlmbr.materialeditor only binds to MaterialEditor.exe and not Editor.exe
|
||||
You need to launch this script with MaterialEditor.exe in order for azlmbr.materialeditor to appear.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import azlmbr.atom
|
||||
import azlmbr.atomtools as atomtools
|
||||
import azlmbr.materialeditor as materialeditor
|
||||
import azlmbr.bus as bus
|
||||
|
||||
|
||||
def is_close(actual, expected, buffer=sys.float_info.min):
|
||||
"""
|
||||
:param actual: actual value
|
||||
:param expected: expected value
|
||||
:param buffer: acceptable variation from expected
|
||||
:return: bool
|
||||
"""
|
||||
return abs(actual - expected) < buffer
|
||||
|
||||
|
||||
def compare_colors(color1, color2, buffer=0.00001):
|
||||
"""
|
||||
Compares the red, green and blue properties of a color allowing a slight variance of buffer
|
||||
:param color1: first color to compare
|
||||
:param color2: second color
|
||||
:param buffer: allowed variance in individual color value
|
||||
:return: bool
|
||||
"""
|
||||
return (
|
||||
is_close(color1.r, color2.r, buffer)
|
||||
and is_close(color1.g, color2.g, buffer)
|
||||
and is_close(color1.b, color2.b, buffer)
|
||||
)
|
||||
|
||||
|
||||
def open_material(file_path):
|
||||
"""
|
||||
:return: uuid of material document opened
|
||||
"""
|
||||
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(bus.Broadcast, "OpenDocument", file_path)
|
||||
|
||||
|
||||
def is_open(document_id):
|
||||
"""
|
||||
:return: bool
|
||||
"""
|
||||
return azlmbr.atomtools.AtomToolsDocumentRequestBus(bus.Event, "IsOpen", document_id)
|
||||
|
||||
|
||||
def save_document(document_id):
|
||||
"""
|
||||
:return: bool success
|
||||
"""
|
||||
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(bus.Broadcast, "SaveDocument", document_id)
|
||||
|
||||
|
||||
def save_document_as_copy(document_id, target_path):
|
||||
"""
|
||||
:return: bool success
|
||||
"""
|
||||
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(
|
||||
bus.Broadcast, "SaveDocumentAsCopy", document_id, target_path
|
||||
)
|
||||
|
||||
|
||||
def save_document_as_child(document_id, target_path):
|
||||
"""
|
||||
:return: bool success
|
||||
"""
|
||||
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(
|
||||
bus.Broadcast, "SaveDocumentAsChild", document_id, target_path
|
||||
)
|
||||
|
||||
|
||||
def save_all():
|
||||
"""
|
||||
:return: bool success
|
||||
"""
|
||||
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(bus.Broadcast, "SaveAllDocuments")
|
||||
|
||||
|
||||
def close_document(document_id):
|
||||
"""
|
||||
:return: bool success
|
||||
"""
|
||||
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(bus.Broadcast, "CloseDocument", document_id)
|
||||
|
||||
|
||||
def close_all_documents():
|
||||
"""
|
||||
:return: bool success
|
||||
"""
|
||||
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(bus.Broadcast, "CloseAllDocuments")
|
||||
|
||||
|
||||
def close_all_except_selected(document_id):
|
||||
"""
|
||||
:return: bool success
|
||||
"""
|
||||
return azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(bus.Broadcast, "CloseAllDocumentsExcept", document_id)
|
||||
|
||||
|
||||
def get_property(document_id, property_name):
|
||||
"""
|
||||
:return: property value or invalid value if the document is not open or the property_name can't be found
|
||||
"""
|
||||
return azlmbr.atomtools.AtomToolsDocumentRequestBus(bus.Event, "GetPropertyValue", document_id, property_name)
|
||||
|
||||
|
||||
def set_property(document_id, property_name, value):
|
||||
azlmbr.atomtools.AtomToolsDocumentRequestBus(bus.Event, "SetPropertyValue", document_id, property_name, value)
|
||||
|
||||
|
||||
def is_pane_visible(pane_name):
|
||||
"""
|
||||
:return: bool
|
||||
"""
|
||||
return atomtools.AtomToolsWindowRequestBus(bus.Broadcast, "IsDockWidgetVisible", pane_name)
|
||||
|
||||
|
||||
def set_pane_visibility(pane_name, value):
|
||||
atomtools.AtomToolsWindowRequestBus(bus.Broadcast, "SetDockWidgetVisible", pane_name, value)
|
||||
|
||||
|
||||
def select_lighting_config(config_name):
|
||||
azlmbr.materialeditor.MaterialViewportRequestBus(azlmbr.bus.Broadcast, "SelectLightingPresetByName", config_name)
|
||||
|
||||
|
||||
def set_grid_enable_disable(value):
|
||||
azlmbr.materialeditor.MaterialViewportRequestBus(azlmbr.bus.Broadcast, "SetGridEnabled", value)
|
||||
|
||||
|
||||
def get_grid_enable_disable():
|
||||
"""
|
||||
:return: bool
|
||||
"""
|
||||
return azlmbr.materialeditor.MaterialViewportRequestBus(azlmbr.bus.Broadcast, "GetGridEnabled")
|
||||
|
||||
|
||||
def set_shadowcatcher_enable_disable(value):
|
||||
azlmbr.materialeditor.MaterialViewportRequestBus(azlmbr.bus.Broadcast, "SetShadowCatcherEnabled", value)
|
||||
|
||||
|
||||
def get_shadowcatcher_enable_disable():
|
||||
"""
|
||||
:return: bool
|
||||
"""
|
||||
return azlmbr.materialeditor.MaterialViewportRequestBus(azlmbr.bus.Broadcast, "GetShadowCatcherEnabled")
|
||||
|
||||
|
||||
def select_model_config(configname):
|
||||
azlmbr.materialeditor.MaterialViewportRequestBus(azlmbr.bus.Broadcast, "SelectModelPresetByName", configname)
|
||||
|
||||
|
||||
def wait_for_condition(function, timeout_in_seconds=1.0):
|
||||
# type: (function, float) -> bool
|
||||
"""
|
||||
Function to run until it returns True or timeout is reached
|
||||
the function can have no parameters and
|
||||
waiting idle__wait_* is handled here not in the function
|
||||
|
||||
:param function: a function that returns a boolean indicating a desired condition is achieved
|
||||
:param timeout_in_seconds: when reached, function execution is abandoned and False is returned
|
||||
"""
|
||||
with Timeout(timeout_in_seconds) as t:
|
||||
while True:
|
||||
try:
|
||||
azlmbr.atomtools.general.idle_wait_frames(1)
|
||||
except Exception:
|
||||
print("WARNING: Couldn't wait for frame")
|
||||
|
||||
if t.timed_out:
|
||||
return False
|
||||
|
||||
ret = function()
|
||||
if not isinstance(ret, bool):
|
||||
raise TypeError("return value for wait_for_condition function must be a bool")
|
||||
if ret:
|
||||
return True
|
||||
|
||||
|
||||
class Timeout:
|
||||
# type: (float) -> None
|
||||
"""
|
||||
contextual timeout
|
||||
:param seconds: float seconds to allow before timed_out is True
|
||||
"""
|
||||
|
||||
def __init__(self, seconds):
|
||||
self.seconds = seconds
|
||||
|
||||
def __enter__(self):
|
||||
self.die_after = time.time() + self.seconds
|
||||
return self
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
pass
|
||||
|
||||
@property
|
||||
def timed_out(self):
|
||||
return time.time() > self.die_after
|
||||
|
||||
|
||||
screenshotsFolder = os.path.join(azlmbr.paths.devroot, "AtomTest", "Cache" "pc", "Screenshots")
|
||||
|
||||
|
||||
class ScreenshotHelper:
|
||||
"""
|
||||
A helper to capture screenshots and wait for them.
|
||||
"""
|
||||
|
||||
def __init__(self, idle_wait_frames_callback):
|
||||
super().__init__()
|
||||
self.done = False
|
||||
self.capturedScreenshot = False
|
||||
self.max_frames_to_wait = 60
|
||||
|
||||
self.idle_wait_frames_callback = idle_wait_frames_callback
|
||||
|
||||
def capture_screenshot_blocking(self, filename):
|
||||
"""
|
||||
Capture a screenshot and block the execution until the screenshot has been written to the disk.
|
||||
"""
|
||||
self.handler = azlmbr.atom.FrameCaptureNotificationBusHandler()
|
||||
self.handler.connect()
|
||||
self.handler.add_callback("OnCaptureFinished", self.on_screenshot_captured)
|
||||
|
||||
self.done = False
|
||||
self.capturedScreenshot = False
|
||||
success = azlmbr.atom.FrameCaptureRequestBus(azlmbr.bus.Broadcast, "CaptureScreenshot", filename)
|
||||
if success:
|
||||
self.wait_until_screenshot()
|
||||
print("Screenshot taken.")
|
||||
else:
|
||||
print("screenshot failed")
|
||||
return self.capturedScreenshot
|
||||
|
||||
def on_screenshot_captured(self, parameters):
|
||||
# the parameters come in as a tuple
|
||||
if parameters[0]:
|
||||
print("screenshot saved: {}".format(parameters[1]))
|
||||
self.capturedScreenshot = True
|
||||
else:
|
||||
print("screenshot failed: {}".format(parameters[1]))
|
||||
self.done = True
|
||||
self.handler.disconnect()
|
||||
|
||||
def wait_until_screenshot(self):
|
||||
frames_waited = 0
|
||||
while self.done == False:
|
||||
self.idle_wait_frames_callback(1)
|
||||
if frames_waited > self.max_frames_to_wait:
|
||||
print("timeout while waiting for the screenshot to be written")
|
||||
self.handler.disconnect()
|
||||
break
|
||||
else:
|
||||
frames_waited = frames_waited + 1
|
||||
print("(waited {} frames)".format(frames_waited))
|
||||
|
||||
|
||||
def capture_screenshot(file_path):
|
||||
return ScreenshotHelper(azlmbr.atomtools.general.idle_wait_frames).capture_screenshot_blocking(
|
||||
os.path.join(file_path)
|
||||
)
|
||||
@@ -91,3 +91,20 @@ class ScreenshotHelper(object):
|
||||
else:
|
||||
frames_waited = frames_waited + 1
|
||||
general.log(f"(waited {frames_waited} frames)")
|
||||
|
||||
|
||||
def take_screenshot_game_mode(screenshot_name, entity_name=None):
|
||||
"""
|
||||
Enters game mode & takes a screenshot, then exits game mode after.
|
||||
:param screenshot_name: name to give the captured screenshot .ppm file.
|
||||
:param entity_name: name of the entity being tested (for generating unique log lines).
|
||||
:return: None
|
||||
"""
|
||||
general.enter_game_mode()
|
||||
helper.wait_for_condition(lambda: general.is_in_game_mode(), 2.0)
|
||||
general.log(f"{entity_name}_test: Entered game mode: {general.is_in_game_mode()}")
|
||||
ScreenshotHelper(general.idle_wait_frames).capture_screenshot_blocking(f"{screenshot_name}.ppm")
|
||||
general.idle_wait(1.0)
|
||||
general.exit_game_mode()
|
||||
helper.wait_for_condition(lambda: not general.is_in_game_mode(), 2.0)
|
||||
general.log(f"{entity_name}_test: Exit game mode: {not general.is_in_game_mode()}")
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:954d7d0df47c840a24e313893800eb3126d0c0d47c3380926776b51833778db7
|
||||
size 6220817
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e81c19128f42ba362a2d5f3ccf159dfbc942d67ceeb1ac8c21f295a6fd9d2ce5
|
||||
size 6220817
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5e20801213e065b6ea8c95ede81c23faa9b6dc70a2002dc5bced293e1bed989f
|
||||
size 6220817
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e250f812e594e5152bf2d6f23caa8b53b78276bfdf344d7a8d355dd96cb995c0
|
||||
size 6220817
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:95be359041f8291c74b335297a4dfe9902a180510f24a181b15e1a5ba4d3b024
|
||||
size 6220817
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:118e43e4b915e262726183467cc4b82f244565213fea5b6bfe02be07f0851ab1
|
||||
size 6220817
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:dc2ce3256a6552975962c9e113c52c1a22bf3817d417151f6f60640dd568e0fa
|
||||
size 6220817
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:287d98890b35427688999760f9d066bcbff1a3bc9001534241dc212b32edabd8
|
||||
size 6220817
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:66e91c92c868167c850078cd91714db47e10a96e23cc30191994486bd79c353f
|
||||
size 6220817
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d950d173f5101820c5e18205401ca08ce5feeff2302ac2920b292750d86a8fa4
|
||||
size 6220817
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:72eddb7126eae0c839b933886e0fb69d78229f72d49ef13199de28df2b7879db
|
||||
size 6220817
|
||||
@@ -15,11 +15,11 @@ import pytest
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
from ly_test_tools.image.screenshot_compare_qssim import qssim as compare_screenshots
|
||||
from ly_test_tools.benchmark.data_aggregator import BenchmarkDataAggregator
|
||||
|
||||
import editor_python_test_tools.hydra_test_utils as hydra
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
DEFAULT_SUBFOLDER_PATH = 'user/PythonTests/Automated/Screenshots'
|
||||
EDITOR_TIMEOUT = 600
|
||||
TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "atom_hydra_scripts")
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ class TestAllComponentsIndepthTests(object):
|
||||
"Trace::Assert",
|
||||
"Trace::Error",
|
||||
"Traceback (most recent call last):",
|
||||
"Screenshot failed"
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
@@ -74,7 +75,7 @@ class TestAllComponentsIndepthTests(object):
|
||||
TEST_DIRECTORY,
|
||||
editor,
|
||||
"hydra_GPUTest_BasicLevelSetup.py",
|
||||
timeout=EDITOR_TIMEOUT,
|
||||
timeout=180,
|
||||
expected_lines=level_creation_expected_lines,
|
||||
unexpected_lines=unexpected_lines,
|
||||
halt_on_unexpected=True,
|
||||
@@ -85,6 +86,60 @@ class TestAllComponentsIndepthTests(object):
|
||||
for test_screenshot, golden_screenshot in zip(test_screenshots, golden_images):
|
||||
compare_screenshots(test_screenshot, golden_screenshot)
|
||||
|
||||
def test_LightComponent_ScreenshotMatchesGoldenImage(
|
||||
self, request, editor, workspace, project, launcher_platform, level):
|
||||
"""
|
||||
Please review the hydra script run by this test for more specific test info.
|
||||
Tests that the Light component screenshots in a rendered level appear the same as the golden images.
|
||||
"""
|
||||
screenshot_names = [
|
||||
"AreaLight_1.ppm",
|
||||
"AreaLight_2.ppm",
|
||||
"AreaLight_3.ppm",
|
||||
"AreaLight_4.ppm",
|
||||
"AreaLight_5.ppm",
|
||||
"SpotLight_1.ppm",
|
||||
"SpotLight_2.ppm",
|
||||
"SpotLight_3.ppm",
|
||||
"SpotLight_4.ppm",
|
||||
"SpotLight_5.ppm",
|
||||
"SpotLight_6.ppm",
|
||||
]
|
||||
test_screenshots = []
|
||||
for screenshot in screenshot_names:
|
||||
screenshot_path = os.path.join(workspace.paths.project(), DEFAULT_SUBFOLDER_PATH, screenshot)
|
||||
test_screenshots.append(screenshot_path)
|
||||
file_system.delete(test_screenshots, True, True)
|
||||
|
||||
golden_images = []
|
||||
for golden_image in screenshot_names:
|
||||
golden_image_path = os.path.join(golden_images_directory(), golden_image)
|
||||
golden_images.append(golden_image_path)
|
||||
|
||||
expected_lines = ["Light component tests completed."]
|
||||
unexpected_lines = [
|
||||
"Trace::Assert",
|
||||
"Trace::Error",
|
||||
"Traceback (most recent call last):",
|
||||
"Screenshot failed",
|
||||
]
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
TEST_DIRECTORY,
|
||||
editor,
|
||||
"hydra_GPUTest_LightComponent.py",
|
||||
timeout=180,
|
||||
expected_lines=expected_lines,
|
||||
unexpected_lines=unexpected_lines,
|
||||
halt_on_unexpected=True,
|
||||
cfg_args=[level],
|
||||
null_renderer=False,
|
||||
)
|
||||
|
||||
for test_screenshot, golden_screenshot in zip(test_screenshots, golden_images):
|
||||
compare_screenshots(test_screenshot, golden_screenshot)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('rhi', ['dx12', 'vulkan'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
@pytest.mark.parametrize("launcher_platform", ["windows_editor"])
|
||||
@@ -99,6 +154,7 @@ class TestPerformanceBenchmarkSuite(object):
|
||||
expected_lines = [
|
||||
"Benchmark metadata captured.",
|
||||
"Pass timestamps captured.",
|
||||
"CPU frame time captured.",
|
||||
"Capturing complete.",
|
||||
"Captured data successfully."
|
||||
]
|
||||
@@ -106,6 +162,7 @@ class TestPerformanceBenchmarkSuite(object):
|
||||
unexpected_lines = [
|
||||
"Failed to capture data.",
|
||||
"Failed to capture pass timestamps.",
|
||||
"Failed to capture CPU frame time.",
|
||||
"Failed to capture benchmark metadata."
|
||||
]
|
||||
|
||||
@@ -114,7 +171,7 @@ class TestPerformanceBenchmarkSuite(object):
|
||||
TEST_DIRECTORY,
|
||||
editor,
|
||||
"hydra_GPUTest_AtomFeatureIntegrationBenchmark.py",
|
||||
timeout=EDITOR_TIMEOUT,
|
||||
timeout=600,
|
||||
expected_lines=expected_lines,
|
||||
unexpected_lines=unexpected_lines,
|
||||
halt_on_unexpected=True,
|
||||
@@ -124,3 +181,39 @@ class TestPerformanceBenchmarkSuite(object):
|
||||
|
||||
aggregator = BenchmarkDataAggregator(workspace, logger, 'periodic')
|
||||
aggregator.upload_metrics(rhi)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_generic'])
|
||||
@pytest.mark.system
|
||||
class TestMaterialEditor(object):
|
||||
|
||||
@pytest.mark.parametrize("cfg_args", ["-rhi=dx12", "-rhi=Vulkan"])
|
||||
@pytest.mark.parametrize("exe_file_name", ["MaterialEditor"])
|
||||
def test_MaterialEditorLaunch_AllRHIOptionsSucceed(
|
||||
self, request, workspace, project, launcher_platform, generic_launcher, exe_file_name, cfg_args):
|
||||
"""
|
||||
Tests each valid RHI option (Null RHI excluded) can be launched with the MaterialEditor.
|
||||
Checks for the "Finished loading viewport configurtions." success message post lounch.
|
||||
"""
|
||||
expected_lines = ["Finished loading viewport configurtions."]
|
||||
unexpected_lines = [
|
||||
# "Trace::Assert",
|
||||
# "Trace::Error",
|
||||
"Traceback (most recent call last):",
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
TEST_DIRECTORY,
|
||||
generic_launcher,
|
||||
editor_script="",
|
||||
run_python="--runpython",
|
||||
timeout=30,
|
||||
expected_lines=expected_lines,
|
||||
unexpected_lines=unexpected_lines,
|
||||
halt_on_unexpected=False,
|
||||
null_renderer=False,
|
||||
cfg_args=[cfg_args],
|
||||
log_file_name="MaterialEditor.log"
|
||||
)
|
||||
|
||||
@@ -11,8 +11,9 @@ import os
|
||||
|
||||
import pytest
|
||||
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
import editor_python_test_tools.hydra_test_utils as hydra
|
||||
from atom_renderer.atom_utils.atom_component_helper import LIGHT_TYPES
|
||||
from atom_renderer.atom_utils.atom_constants import LIGHT_TYPES
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
EDITOR_TIMEOUT = 120
|
||||
@@ -31,7 +32,7 @@ class TestAtomEditorComponentsMain(object):
|
||||
Tests the following Atom components and verifies all "expected_lines" appear in Editor.log:
|
||||
1. Display Mapper
|
||||
2. Light
|
||||
3. Radius Weight Modifier
|
||||
3. PostFX Radius Weight Modifier
|
||||
4. PostFX Layer
|
||||
5. Physical Sky
|
||||
6. Global Skylight (IBL)
|
||||
@@ -125,18 +126,18 @@ class TestAtomEditorComponentsMain(object):
|
||||
"PostFX Layer_test: Entity deleted: True",
|
||||
"PostFX Layer_test: UNDO entity deletion works: True",
|
||||
"PostFX Layer_test: REDO entity deletion works: True",
|
||||
# Radius Weight Modifier Component
|
||||
"Radius Weight Modifier Entity successfully created",
|
||||
"Radius Weight Modifier_test: Component added to the entity: True",
|
||||
"Radius Weight Modifier_test: Component removed after UNDO: True",
|
||||
"Radius Weight Modifier_test: Component added after REDO: True",
|
||||
"Radius Weight Modifier_test: Entered game mode: True",
|
||||
"Radius Weight Modifier_test: Exit game mode: True",
|
||||
"Radius Weight Modifier_test: Entity is hidden: True",
|
||||
"Radius Weight Modifier_test: Entity is shown: True",
|
||||
"Radius Weight Modifier_test: Entity deleted: True",
|
||||
"Radius Weight Modifier_test: UNDO entity deletion works: True",
|
||||
"Radius Weight Modifier_test: REDO entity deletion works: True",
|
||||
# PostFX Radius Weight Modifier Component
|
||||
"PostFX Radius Weight Modifier Entity successfully created",
|
||||
"PostFX Radius Weight Modifier_test: Component added to the entity: True",
|
||||
"PostFX Radius Weight Modifier_test: Component removed after UNDO: True",
|
||||
"PostFX Radius Weight Modifier_test: Component added after REDO: True",
|
||||
"PostFX Radius Weight Modifier_test: Entered game mode: True",
|
||||
"PostFX Radius Weight Modifier_test: Exit game mode: True",
|
||||
"PostFX Radius Weight Modifier_test: Entity is hidden: True",
|
||||
"PostFX Radius Weight Modifier_test: Entity is shown: True",
|
||||
"PostFX Radius Weight Modifier_test: Entity deleted: True",
|
||||
"PostFX Radius Weight Modifier_test: UNDO entity deletion works: True",
|
||||
"PostFX Radius Weight Modifier_test: REDO entity deletion works: True",
|
||||
# Light Component
|
||||
"Light Entity successfully created",
|
||||
"Light_test: Component added to the entity: True",
|
||||
@@ -242,3 +243,66 @@ class TestAtomEditorComponentsMain(object):
|
||||
null_renderer=True,
|
||||
cfg_args=cfg_args,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_generic'])
|
||||
@pytest.mark.system
|
||||
class TestMaterialEditorBasicTests(object):
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_teardown(self, request, workspace, project):
|
||||
def delete_files():
|
||||
file_system.delete(
|
||||
[
|
||||
os.path.join(workspace.paths.project(), "Materials", "test_material.material"),
|
||||
os.path.join(workspace.paths.project(), "Materials", "test_material_1.material"),
|
||||
os.path.join(workspace.paths.project(), "Materials", "test_material_2.material"),
|
||||
],
|
||||
True,
|
||||
True,
|
||||
)
|
||||
# Cleanup our newly created materials
|
||||
delete_files()
|
||||
|
||||
def teardown():
|
||||
# Cleanup our newly created materials
|
||||
delete_files()
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
@pytest.mark.parametrize("exe_file_name", ["MaterialEditor"])
|
||||
def test_MaterialEditorBasicTests(
|
||||
self, request, workspace, project, launcher_platform, generic_launcher, exe_file_name):
|
||||
|
||||
expected_lines = [
|
||||
"Material opened: True",
|
||||
"Test asset doesn't exist initially: True",
|
||||
"New asset created: True",
|
||||
"New Material opened: True",
|
||||
"Material closed: True",
|
||||
"All documents closed: True",
|
||||
"Close All Except Selected worked as expected: True",
|
||||
"Actual Document saved with changes: True",
|
||||
"Document saved as copy is saved with changes: True",
|
||||
"Document saved as child is saved with changes: True",
|
||||
"Save All worked as expected: True",
|
||||
]
|
||||
unexpected_lines = [
|
||||
# "Trace::Assert",
|
||||
# "Trace::Error",
|
||||
"Traceback (most recent call last):"
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
TEST_DIRECTORY,
|
||||
generic_launcher,
|
||||
"hydra_AtomMaterialEditor_BasicTests.py",
|
||||
run_python="--runpython",
|
||||
timeout=80,
|
||||
expected_lines=expected_lines,
|
||||
unexpected_lines=unexpected_lines,
|
||||
halt_on_unexpected=True,
|
||||
null_renderer=True,
|
||||
log_file_name="MaterialEditor.log",
|
||||
)
|
||||
|
||||
@@ -51,8 +51,8 @@ class TestAutomationBase:
|
||||
cls.asset_processor.teardown()
|
||||
cls._kill_ly_processes()
|
||||
|
||||
|
||||
def _run_test(self, request, workspace, editor, testcase_module, extra_cmdline_args=[], use_null_renderer=True):
|
||||
def _run_test(self, request, workspace, editor, testcase_module, extra_cmdline_args=[], batch_mode=True,
|
||||
autotest_mode=True, use_null_renderer=True):
|
||||
test_starttime = time.time()
|
||||
self.logger = logging.getLogger(__name__)
|
||||
errors = []
|
||||
@@ -90,9 +90,13 @@ class TestAutomationBase:
|
||||
editor_starttime = time.time()
|
||||
self.logger.debug("Running automated test")
|
||||
testcase_module_filepath = self._get_testcase_module_filepath(testcase_module)
|
||||
pycmd = ["--runpythontest", testcase_module_filepath, "-BatchMode", "-autotest_mode", f"-pythontestcase={request.node.originalname}"]
|
||||
pycmd = ["--runpythontest", testcase_module_filepath, f"-pythontestcase={request.node.originalname}"]
|
||||
if use_null_renderer:
|
||||
pycmd += ["-rhi=null"]
|
||||
if batch_mode:
|
||||
pycmd += ["-BatchMode"]
|
||||
if autotest_mode:
|
||||
pycmd += ["-autotest_mode"]
|
||||
pycmd += extra_cmdline_args
|
||||
editor.args.extend(pycmd) # args are added to the WinLauncher start command
|
||||
editor.start(backupFiles = False, launch_ap = False)
|
||||
|
||||
@@ -11,24 +11,8 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
NAME AutomatedTesting::EditorTests_Main
|
||||
TEST_SUITE main
|
||||
TEST_SERIAL
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}
|
||||
PYTEST_MARKS "SUITE_main and not REQUIRES_gpu"
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
Editor
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::EditorTests_Periodic
|
||||
TEST_SUITE periodic
|
||||
TEST_SERIAL
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}
|
||||
PYTEST_MARKS "SUITE_periodic and not REQUIRES_gpu"
|
||||
TIMEOUT 1500
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Main.py
|
||||
PYTEST_MARKS "not REQUIRES_gpu"
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
@@ -42,9 +26,21 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
TEST_SUITE main
|
||||
TEST_SERIAL
|
||||
TEST_REQUIRES gpu
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}
|
||||
PYTEST_MARKS "SUITE_main and REQUIRES_gpu"
|
||||
TIMEOUT 1500
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Main.py
|
||||
PYTEST_MARKS "REQUIRES_gpu"
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
Editor
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::EditorTests_Periodic
|
||||
TEST_SUITE periodic
|
||||
TEST_SERIAL
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Periodic.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
@@ -57,9 +53,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
NAME AutomatedTesting::EditorTests_Sandbox
|
||||
TEST_SUITE sandbox
|
||||
TEST_SERIAL
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}
|
||||
PYTEST_MARKS "SUITE_sandbox"
|
||||
TIMEOUT 1500
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Sandbox.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
@@ -67,4 +61,47 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
COMPONENT
|
||||
Editor
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::EditorTests_Main_Optimized
|
||||
TEST_SUITE main
|
||||
TEST_SERIAL
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Main_Optimized.py
|
||||
PYTEST_MARKS "not REQUIRES_gpu"
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
Editor
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::EditorTests_Main_GPU_Optimized
|
||||
TEST_SUITE main
|
||||
TEST_SERIAL
|
||||
TEST_REQUIRES gpu
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Main_Optimized.py
|
||||
PYTEST_MARKS "REQUIRES_gpu"
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
Editor
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::EditorTests_Sandbox_Optimized
|
||||
TEST_SUITE sandbox
|
||||
TEST_SERIAL
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Sandbox_Optimized.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
Editor
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
+56
-51
@@ -5,30 +5,24 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
"""
|
||||
C13660194 : Asset Browser - Filtering
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from PySide2 import QtWidgets, QtTest, QtCore
|
||||
from PySide2.QtCore import Qt
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
class Tests:
|
||||
asset_filtered = (
|
||||
"Asset was filtered to in the Asset Browser",
|
||||
"Failed to filter to the expected asset"
|
||||
)
|
||||
asset_type_filtered = (
|
||||
"Expected asset type was filtered to in the Asset Browser",
|
||||
"Failed to filter to the expected asset type"
|
||||
)
|
||||
|
||||
|
||||
class AssetBrowserSearchFilteringTest(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="AssetBrowser_SearchFiltering", args=["level"])
|
||||
def AssetBrowser_SearchFiltering():
|
||||
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
|
||||
@pyside_utils.wrap_async
|
||||
async def run_test(self):
|
||||
async def run_test():
|
||||
"""
|
||||
Summary:
|
||||
Asset Browser - Filtering
|
||||
@@ -60,7 +54,13 @@ class AssetBrowserSearchFilteringTest(EditorTestHelper):
|
||||
:return: None
|
||||
"""
|
||||
|
||||
self.incorrect_file_found = False
|
||||
from PySide2 import QtWidgets, QtTest, QtCore
|
||||
from PySide2.QtCore import Qt
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
def verify_files_appeared(model, allowed_asset_extentions, parent_index=QtCore.QModelIndex()):
|
||||
indexes = [parent_index]
|
||||
@@ -74,25 +74,24 @@ class AssetBrowserSearchFilteringTest(EditorTestHelper):
|
||||
and (cur_data.lower().split(".")[-1] not in allowed_asset_extentions)
|
||||
and not cur_data[-1] == ")"
|
||||
):
|
||||
print(f"Incorrect file found: {cur_data}")
|
||||
self.incorrect_file_found = True
|
||||
indexes = list()
|
||||
break
|
||||
Report.info(f"Incorrect file found: {cur_data}")
|
||||
return False
|
||||
indexes.append(cur_index)
|
||||
return True
|
||||
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# 1) Open level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# 2) Open Asset Browser
|
||||
general.close_pane("Asset Browser")
|
||||
general.open_pane("Asset Browser")
|
||||
# 2) Open Asset Browser (if not opened already)
|
||||
editor_window = pyside_utils.get_editor_main_window()
|
||||
asset_browser_open = general.is_pane_visible("Asset Browser")
|
||||
if not asset_browser_open:
|
||||
Report.info("Opening Asset Browser")
|
||||
action = pyside_utils.get_action_for_menu_path(editor_window, "Tools", "Asset Browser")
|
||||
action.trigger()
|
||||
else:
|
||||
Report.info("Asset Browser is already open")
|
||||
editor_window = pyside_utils.get_editor_main_window()
|
||||
app = QtWidgets.QApplication.instance()
|
||||
|
||||
@@ -103,10 +102,9 @@ class AssetBrowserSearchFilteringTest(EditorTestHelper):
|
||||
asset_browser_tree = asset_browser.findChild(QtWidgets.QTreeView, "m_assetBrowserTreeViewWidget")
|
||||
model_index = pyside_utils.find_child_by_pattern(asset_browser_tree, "cedar.fbx")
|
||||
pyside_utils.item_view_index_mouse_click(asset_browser_tree, model_index)
|
||||
is_filtered = pyside_utils.wait_for_condition(
|
||||
is_filtered = await pyside_utils.wait_for_condition(
|
||||
lambda: asset_browser_tree.indexBelow(asset_browser_tree.currentIndex()) == QtCore.QModelIndex(), 5.0)
|
||||
if is_filtered:
|
||||
print("cedar.fbx asset is filtered in Asset Browser")
|
||||
Report.result(Tests.asset_filtered, is_filtered)
|
||||
|
||||
# 4) Click the "X" in the search bar.
|
||||
clear_search = asset_browser.findChild(QtWidgets.QToolButton, "ClearToolButton")
|
||||
@@ -122,40 +120,47 @@ class AssetBrowserSearchFilteringTest(EditorTestHelper):
|
||||
tree.model().setData(animation_model_index, 2, Qt.CheckStateRole)
|
||||
general.idle_wait(1.0)
|
||||
# check asset types after clicking on Animation filter
|
||||
verify_files_appeared(asset_browser_tree.model(), ["i_caf", "fbx", "xml", "animgraph", "motionset"])
|
||||
print(f"Animation file type(s) is present in the file tree: {not self.incorrect_file_found}")
|
||||
asset_type_filter = verify_files_appeared(asset_browser_tree.model(), ["i_caf", "fbx", "xml", "animgraph", "motionset"])
|
||||
Report.result(Tests.asset_type_filtered, asset_type_filter)
|
||||
|
||||
# 6) Add additional filter(FileTag) from the filter menu
|
||||
self.incorrect_file_found = False
|
||||
line_edit.setText("FileTag")
|
||||
filetag_model_index = await pyside_utils.wait_for_child_by_pattern(tree, "FileTag")
|
||||
tree.model().setData(filetag_model_index, 2, Qt.CheckStateRole)
|
||||
general.idle_wait(1.0)
|
||||
# check asset types after clicking on FileTag filter
|
||||
verify_files_appeared(
|
||||
more_types_filtered = verify_files_appeared(
|
||||
asset_browser_tree.model(), ["i_caf", "fbx", "xml", "animgraph", "motionset", "filetag"]
|
||||
)
|
||||
print(f"FileTag file type(s) and Animation file type(s) is present in the file tree: {not self.incorrect_file_found}")
|
||||
Report.result(Tests.asset_type_filtered, more_types_filtered)
|
||||
|
||||
# 7) Remove one of the filtered asset types from the list of applied filters
|
||||
self.incorrect_file_found = False
|
||||
filter_layout = asset_browser.findChild(QtWidgets.QFrame, "filteredLayout")
|
||||
animation_close_button = filter_layout.children()[1]
|
||||
first_close_button = animation_close_button.findChild(QtWidgets.QPushButton, "closeTag")
|
||||
first_close_button.click()
|
||||
general.idle_wait(1.0)
|
||||
# check asset types after removing Animation filter
|
||||
verify_files_appeared(asset_browser_tree.model(), ["filetag"])
|
||||
print(f"FileTag file type(s) is present in the file tree after removing Animation filter: {not self.incorrect_file_found}")
|
||||
remove_filtered = verify_files_appeared(asset_browser_tree.model(), ["filetag"])
|
||||
Report.result(Tests.asset_type_filtered, remove_filtered)
|
||||
|
||||
# 8) Remove all of the filter asset types from the list of filters
|
||||
filetag_close_button = filter_layout.children()[1]
|
||||
second_close_button = filetag_close_button.findChild(QtWidgets.QPushButton, "closeTag")
|
||||
second_close_button.click()
|
||||
|
||||
# 9) Close the asset browser
|
||||
asset_browser.close()
|
||||
# Click off of the Asset Browser filter window to close it
|
||||
QtTest.QTest.mouseClick(tree, Qt.LeftButton, Qt.NoModifier)
|
||||
|
||||
# 9) Restore Asset Browser tool state and
|
||||
if not asset_browser_open:
|
||||
Report.info("Closing Asset Browser")
|
||||
general.close_pane("Asset Browser")
|
||||
|
||||
run_test()
|
||||
|
||||
|
||||
test = AssetBrowserSearchFilteringTest()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AssetBrowser_SearchFiltering)
|
||||
|
||||
+95
-100
@@ -5,124 +5,119 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
"""
|
||||
C13660195: Asset Browser - File Tree Navigation
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from PySide2 import QtWidgets, QtTest, QtCore
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
class Tests:
|
||||
collapse_expand = (
|
||||
"Asset Browser hierarchy successfully collapsed/expanded",
|
||||
"Failed to collapse/expand Asset Browser hierarchy"
|
||||
)
|
||||
asset_visible = (
|
||||
"Expected asset is visible in the Asset Browser hierarchy",
|
||||
"Failed to find expected asset in the Asset Browser hierarchy"
|
||||
)
|
||||
scrollbar_visible = (
|
||||
"Scrollbar is visible",
|
||||
"Scrollbar was not found"
|
||||
)
|
||||
|
||||
|
||||
class AssetBrowserTreeNavigationTest(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="AssetBrowser_TreeNavigation", args=["level"])
|
||||
def AssetBrowser_TreeNavigation():
|
||||
"""
|
||||
Summary:
|
||||
Verify if we are able to expand a file hierarchy in the Asset Browser and ScrollBar appears
|
||||
appropriately.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
Verify if we are able to expand a file hierarchy in the Asset Browser and ScrollBar appears
|
||||
appropriately.
|
||||
Expected Behavior:
|
||||
The folder list is expanded to display the children of the selected folder.
|
||||
A scroll bar appears to allow scrolling up and down through the asset browser.
|
||||
Assets are present in the Asset Browser.
|
||||
|
||||
Expected Behavior:
|
||||
The folder list is expanded to display the children of the selected folder.
|
||||
A scroll bar appears to allow scrolling up and down through the asset browser.
|
||||
Assets are present in the Asset Browser.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Asset Browser
|
||||
3) Collapse all files initially
|
||||
4) Get all Model Indexes
|
||||
5) Expand each of the folder and verify if it is opened
|
||||
6) Verify if the ScrollBar appears after expanding the tree
|
||||
|
||||
Test Steps:
|
||||
1) Open a new level
|
||||
2) Open Asset Browser
|
||||
3) Collapse all files initially
|
||||
4) Get all Model Indexes
|
||||
5) Expand each of the folder and verify if it is opened
|
||||
6) Verify if the ScrollBar appears after expanding the tree
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
from PySide2 import QtWidgets, QtTest, QtCore
|
||||
|
||||
def collapse_expand_and_verify(model_index, hierarchy_level):
|
||||
tree.collapse(model_index)
|
||||
collapse_success = not tree.isExpanded(model_index)
|
||||
self.log(f"Level {hierarchy_level} collapsed: {collapse_success}")
|
||||
tree.expand(model_index)
|
||||
expand_success = tree.isExpanded(model_index)
|
||||
self.log(f"Level {hierarchy_level} expanded: {expand_success}")
|
||||
return collapse_success and expand_success
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
# This is the hierarchy we are expanding (4 steps inside)
|
||||
self.file_path = ("AutomatedTesting", "Assets", "ImageGradients", "image_grad_test_gsi.png")
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# 1) Open a new level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
def collapse_expand_and_verify(model_index, hierarchy_level):
|
||||
tree.collapse(model_index)
|
||||
collapse_success = not tree.isExpanded(model_index)
|
||||
Report.info(f"Level {hierarchy_level} collapsed: {collapse_success}")
|
||||
tree.expand(model_index)
|
||||
expand_success = tree.isExpanded(model_index)
|
||||
Report.info(f"Level {hierarchy_level} expanded: {expand_success}")
|
||||
return collapse_success and expand_success
|
||||
|
||||
# 2) Open Asset Browser (if not opened already)
|
||||
editor_window = pyside_utils.get_editor_main_window()
|
||||
asset_browser_open = general.is_pane_visible("Asset Browser")
|
||||
if not asset_browser_open:
|
||||
self.log("Opening Asset Browser")
|
||||
action = pyside_utils.get_action_for_menu_path(editor_window, "Tools", "Asset Browser")
|
||||
action.trigger()
|
||||
else:
|
||||
self.log("Asset Browser is already open")
|
||||
# This is the hierarchy we are expanding (4 steps inside)
|
||||
file_path = ("AutomatedTesting", "Assets", "ImageGradients", "image_grad_test_gsi.png")
|
||||
|
||||
# 3) Collapse all files initially
|
||||
main_window = editor_window.findChild(QtWidgets.QMainWindow)
|
||||
asset_browser = pyside_utils.find_child_by_hierarchy(main_window, ..., "Asset Browser")
|
||||
tree = pyside_utils.find_child_by_hierarchy(asset_browser, ..., "m_assetBrowserTreeViewWidget")
|
||||
scroll_area = tree.findChild(QtWidgets.QWidget, "qt_scrollarea_vcontainer")
|
||||
scroll_bar = scroll_area.findChild(QtWidgets.QScrollBar)
|
||||
tree.collapseAll()
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# 4) Get all Model Indexes
|
||||
model_index_1 = pyside_utils.find_child_by_hierarchy(tree, self.file_path[0])
|
||||
model_index_2 = pyside_utils.find_child_by_hierarchy(model_index_1, self.file_path[1])
|
||||
model_index_3 = pyside_utils.find_child_by_hierarchy(model_index_2, self.file_path[2])
|
||||
model_index_4 = pyside_utils.find_child_by_hierarchy(model_index_3, self.file_path[3])
|
||||
# 2) Open Asset Browser (if not opened already)
|
||||
editor_window = pyside_utils.get_editor_main_window()
|
||||
asset_browser_open = general.is_pane_visible("Asset Browser")
|
||||
if not asset_browser_open:
|
||||
Report.info("Opening Asset Browser")
|
||||
action = pyside_utils.get_action_for_menu_path(editor_window, "Tools", "Asset Browser")
|
||||
action.trigger()
|
||||
else:
|
||||
Report.info("Asset Browser is already open")
|
||||
|
||||
# 5) Verify each level of the hierarchy to the file can be collapsed/expanded
|
||||
self.test_success = collapse_expand_and_verify(model_index_1, 1) and self.test_success
|
||||
self.test_success = collapse_expand_and_verify(model_index_2, 2) and self.test_success
|
||||
self.test_success = collapse_expand_and_verify(model_index_3, 3) and self.test_success
|
||||
self.log(f"Collapse/Expand tests: {self.test_success}")
|
||||
# 3) Collapse all files initially
|
||||
main_window = editor_window.findChild(QtWidgets.QMainWindow)
|
||||
asset_browser = pyside_utils.find_child_by_hierarchy(main_window, ..., "Asset Browser")
|
||||
tree = pyside_utils.find_child_by_hierarchy(asset_browser, ..., "m_assetBrowserTreeViewWidget")
|
||||
scroll_area = tree.findChild(QtWidgets.QWidget, "qt_scrollarea_vcontainer")
|
||||
scroll_bar = scroll_area.findChild(QtWidgets.QScrollBar)
|
||||
tree.collapseAll()
|
||||
|
||||
# Select the asset
|
||||
tree.scrollTo(model_index_4)
|
||||
pyside_utils.item_view_index_mouse_click(tree, model_index_4)
|
||||
# 4) Get all Model Indexes
|
||||
model_index_1 = pyside_utils.find_child_by_hierarchy(tree, file_path[0])
|
||||
model_index_2 = pyside_utils.find_child_by_hierarchy(model_index_1, file_path[1])
|
||||
model_index_3 = pyside_utils.find_child_by_hierarchy(model_index_2, file_path[2])
|
||||
model_index_4 = pyside_utils.find_child_by_hierarchy(model_index_3, file_path[3])
|
||||
|
||||
# Verify if the currently selected item model index is same as the Asset Model index
|
||||
# to prove that it is visible
|
||||
asset_visible = tree.currentIndex() == model_index_4
|
||||
self.test_success = asset_visible and self.test_success
|
||||
self.log(f"Asset visibility test: {asset_visible}")
|
||||
# 5) Verify each level of the hierarchy to the file can be collapsed/expanded
|
||||
Report.result(Tests.collapse_expand, collapse_expand_and_verify(model_index_1, 1) and
|
||||
collapse_expand_and_verify(model_index_2, 2) and collapse_expand_and_verify(model_index_3, 3))
|
||||
|
||||
# 6) Verify if the ScrollBar appears after expanding the tree
|
||||
scrollbar_visible = scroll_bar.isVisible()
|
||||
self.test_success = scrollbar_visible and self.test_success
|
||||
self.log(f"Scrollbar visibility test: {scrollbar_visible}")
|
||||
# Select the asset
|
||||
tree.scrollTo(model_index_4)
|
||||
pyside_utils.item_view_index_mouse_click(tree, model_index_4)
|
||||
|
||||
# 7) Restore Asset Browser tool state
|
||||
if not asset_browser_open:
|
||||
self.log("Closing Asset Browser")
|
||||
general.close_pane("Asset Browser")
|
||||
# Verify if the currently selected item model index is same as the Asset Model index
|
||||
# to prove that it is visible
|
||||
Report.result(Tests.asset_visible, tree.currentIndex() == model_index_4)
|
||||
|
||||
# 6) Verify if the ScrollBar appears after expanding the tree
|
||||
Report.result(Tests.scrollbar_visible, scroll_bar.isVisible())
|
||||
|
||||
# 7) Restore Asset Browser tool state
|
||||
if not asset_browser_open:
|
||||
Report.info("Closing Asset Browser")
|
||||
general.close_pane("Asset Browser")
|
||||
|
||||
|
||||
test = AssetBrowserTreeNavigationTest()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AssetBrowser_TreeNavigation)
|
||||
|
||||
@@ -5,33 +5,13 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
"""
|
||||
C13751579: Asset Picker UI/UX
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from PySide2 import QtWidgets, QtTest, QtCore
|
||||
from PySide2.QtCore import Qt
|
||||
def AssetPicker_UI_UX():
|
||||
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.paths
|
||||
import azlmbr.math as math
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
|
||||
class AssetPickerUIUXTest(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="AssetPicker_UI_UX", args=["level"])
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
|
||||
@pyside_utils.wrap_async
|
||||
async def run_test(self):
|
||||
async def run_test():
|
||||
"""
|
||||
Summary:
|
||||
Verify the functionality of Asset Picker and UI/UX properties
|
||||
@@ -45,7 +25,7 @@ class AssetPickerUIUXTest(EditorTestHelper):
|
||||
The asset picker is closed and the selected asset is assigned to the mesh component.
|
||||
|
||||
Test Steps:
|
||||
1) Open a new level
|
||||
1) Open a simple level
|
||||
2) Create entity and add Mesh component
|
||||
3) Access Entity Inspector
|
||||
4) Click Asset Picker (Mesh Asset)
|
||||
@@ -61,17 +41,27 @@ class AssetPickerUIUXTest(EditorTestHelper):
|
||||
5) Verify if Mesh Asset is assigned via both OK/Enter options
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Lumberyard Editor command terminal
|
||||
- This test file must be called from the O3DE Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
self.file_path = ["AutomatedTesting", "Assets", "Objects", "Foliage"]
|
||||
self.incorrect_file_found = False
|
||||
self.mesh_asset = "cedar.azmodel"
|
||||
self.prefix = ""
|
||||
import os
|
||||
from PySide2 import QtWidgets, QtTest, QtCore
|
||||
from PySide2.QtCore import Qt
|
||||
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
file_path = ["AutomatedTesting", "Assets", "Objects", "Foliage"]
|
||||
|
||||
def is_asset_assigned(component, interaction_option):
|
||||
path = os.path.join("assets", "objects", "foliage", "cedar.azmodel")
|
||||
@@ -80,7 +70,7 @@ class AssetPickerUIUXTest(EditorTestHelper):
|
||||
result = hydra.get_component_property_value(component, "Controller|Configuration|Mesh Asset")
|
||||
expected_asset_str = expected_asset_id.invoke("ToString")
|
||||
result_str = result.invoke("ToString")
|
||||
print(f"Asset assigned for {interaction_option} option: {expected_asset_str == result_str}")
|
||||
Report.info(f"Asset assigned for {interaction_option} option: {expected_asset_str == result_str}")
|
||||
return expected_asset_str == result_str
|
||||
|
||||
def move_and_resize_widget(widget):
|
||||
@@ -89,9 +79,11 @@ class AssetPickerUIUXTest(EditorTestHelper):
|
||||
x, y = initial_position.x() + 5, initial_position.y() + 5
|
||||
widget.move(x, y)
|
||||
curr_position = widget.pos()
|
||||
move_success = curr_position.x() == x and curr_position.y() == y
|
||||
self.test_success = move_success and self.test_success
|
||||
self.log(f"Widget Move Test: {move_success}")
|
||||
asset_picker_moved = (
|
||||
"Asset Picker widget moved successfully",
|
||||
"Failed to move Asset Picker widget"
|
||||
)
|
||||
Report.result(asset_picker_moved, curr_position.x() == x and curr_position.y() == y)
|
||||
|
||||
# Resize the widget and verify size
|
||||
width, height = (
|
||||
@@ -99,9 +91,36 @@ class AssetPickerUIUXTest(EditorTestHelper):
|
||||
widget.geometry().height() + 10,
|
||||
)
|
||||
widget.resize(width, height)
|
||||
resize_success = widget.geometry().width() == width and widget.geometry().height() == height
|
||||
self.test_success = resize_success and self.test_success
|
||||
self.log(f"Widget Resize Test: {resize_success}")
|
||||
asset_picker_resized = (
|
||||
"Resized Asset Picker widget successfully",
|
||||
"Failed to resize Asset Picker widget"
|
||||
)
|
||||
Report.result(asset_picker_resized, widget.geometry().width() == width and widget.geometry().height() ==
|
||||
height)
|
||||
|
||||
def verify_expand(model_index, tree):
|
||||
initially_collapsed = (
|
||||
"Folder initially collapsed",
|
||||
"Folder unexpectedly expanded"
|
||||
)
|
||||
expanded = (
|
||||
"Folder expanded successfully",
|
||||
"Failed to expand folder"
|
||||
)
|
||||
# Check initial collapse
|
||||
Report.result(initially_collapsed, not tree.isExpanded(model_index))
|
||||
# Expand at the specified index
|
||||
tree.expand(model_index)
|
||||
# Verify expansion
|
||||
Report.result(expanded, tree.isExpanded(model_index))
|
||||
|
||||
def verify_collapse(model_index, tree):
|
||||
collapsed = (
|
||||
"Folder hierarchy collapsed successfully",
|
||||
"Failed to collapse folder hierarchy"
|
||||
)
|
||||
tree.collapse(model_index)
|
||||
Report.result(collapsed, not tree.isExpanded(model_index))
|
||||
|
||||
def verify_files_appeared(model, allowed_asset_extensions, parent_index=QtCore.QModelIndex()):
|
||||
indices = [parent_index]
|
||||
@@ -115,22 +134,20 @@ class AssetPickerUIUXTest(EditorTestHelper):
|
||||
and (cur_data.lower().split(".")[-1] not in allowed_asset_extensions)
|
||||
and not cur_data[-1] == ")"
|
||||
):
|
||||
print(f"Incorrect file found: {cur_data}")
|
||||
self.incorrect_file_found = True
|
||||
indices = list()
|
||||
break
|
||||
Report.info(f"Incorrect file found: {cur_data}")
|
||||
return False
|
||||
indices.append(cur_index)
|
||||
self.test_success = not self.incorrect_file_found and self.test_success
|
||||
return True
|
||||
|
||||
def print_message_prefix(message):
|
||||
print(f"{self.prefix}: {message}")
|
||||
|
||||
async def asset_picker(prefix, allowed_asset_extensions, asset, interaction_option):
|
||||
async def asset_picker(allowed_asset_extensions, asset, interaction_option):
|
||||
active_modal_widget = await pyside_utils.wait_for_modal_widget()
|
||||
if active_modal_widget and self.prefix == "":
|
||||
self.prefix = prefix
|
||||
if active_modal_widget:
|
||||
dialog = active_modal_widget.findChildren(QtWidgets.QDialog, "AssetPickerDialogClass")[0]
|
||||
print_message_prefix(f"Asset Picker title for Mesh: {dialog.windowTitle()}")
|
||||
asset_picker_title = (
|
||||
"Asset Picker window is titled as expected",
|
||||
"Asset Picker window has an unexpected title"
|
||||
)
|
||||
Report.result(asset_picker_title, dialog.windowTitle() == "Pick ModelAsset")
|
||||
tree = dialog.findChildren(QtWidgets.QTreeView, "m_assetBrowserTreeViewWidget")[0]
|
||||
scroll_area = tree.findChild(QtWidgets.QWidget, "qt_scrollarea_vcontainer")
|
||||
scroll_bar = scroll_area.findChild(QtWidgets.QScrollBar)
|
||||
@@ -138,39 +155,42 @@ class AssetPickerUIUXTest(EditorTestHelper):
|
||||
# a) Collapse all the files initially and verify if scroll bar is not visible
|
||||
tree.collapseAll()
|
||||
await pyside_utils.wait_for_condition(lambda: not scroll_bar.isVisible(), 0.5)
|
||||
print_message_prefix(
|
||||
f"Scroll Bar is not visible before expanding the tree: {not scroll_bar.isVisible()}"
|
||||
scroll_bar_hidden = (
|
||||
"Scroll Bar is not visible before tree expansion",
|
||||
"Scroll Bar is visible before tree expansion"
|
||||
)
|
||||
Report.result(scroll_bar_hidden, not scroll_bar.isVisible())
|
||||
|
||||
# Get Model Index of the file paths
|
||||
model_index_1 = pyside_utils.find_child_by_pattern(tree, self.file_path[0])
|
||||
print(model_index_1.model())
|
||||
model_index_2 = pyside_utils.find_child_by_pattern(model_index_1, self.file_path[1])
|
||||
model_index_1 = pyside_utils.find_child_by_pattern(tree, file_path[0])
|
||||
model_index_2 = pyside_utils.find_child_by_pattern(model_index_1, file_path[1])
|
||||
|
||||
# b) Expand/Verify Top folder of file path
|
||||
print_message_prefix(f"Top level folder initially collapsed: {not tree.isExpanded(model_index_1)}")
|
||||
tree.expand(model_index_1)
|
||||
print_message_prefix(f"Top level folder expanded: {tree.isExpanded(model_index_1)}")
|
||||
verify_expand(model_index_1, tree)
|
||||
|
||||
# c) Expand/Verify Nested folder of file path
|
||||
print_message_prefix(f"Nested folder initially collapsed: {not tree.isExpanded(model_index_2)}")
|
||||
tree.expand(model_index_2)
|
||||
print_message_prefix(f"Nested folder expanded: {tree.isExpanded(model_index_2)}")
|
||||
verify_expand(model_index_2, tree)
|
||||
|
||||
# d) Verify if the ScrollBar appears after expanding folders
|
||||
tree.expandAll()
|
||||
await pyside_utils.wait_for_condition(lambda: scroll_bar.isVisible(), 0.5)
|
||||
print_message_prefix(f"Scroll Bar appeared after expanding tree: {scroll_bar.isVisible()}")
|
||||
scroll_bar_visible = (
|
||||
"Scroll Bar is visible after tree expansion",
|
||||
"Scroll Bar is not visible after tree expansion"
|
||||
)
|
||||
Report.result(scroll_bar_visible, scroll_bar.isVisible())
|
||||
|
||||
# e) Collapse Nested and Top Level folders and verify if collapsed
|
||||
tree.collapse(model_index_2)
|
||||
print_message_prefix(f"Nested folder collapsed: {not tree.isExpanded(model_index_2)}")
|
||||
tree.collapse(model_index_1)
|
||||
print_message_prefix(f"Top level folder collapsed: {not tree.isExpanded(model_index_1)}")
|
||||
verify_collapse(model_index_2, tree)
|
||||
verify_collapse(model_index_1, tree)
|
||||
|
||||
# f) Verify if the correct files are appearing in the Asset Picker
|
||||
verify_files_appeared(tree.model(), allowed_asset_extensions)
|
||||
print_message_prefix(f"Expected Assets populated in the file picker: {not self.incorrect_file_found}")
|
||||
asset_picker_correct_files_appear = (
|
||||
"Expected assets populated in the file picker",
|
||||
"Found unexpected assets in the file picker"
|
||||
)
|
||||
Report.result(asset_picker_correct_files_appear, verify_files_appeared(tree.model(),
|
||||
allowed_asset_extensions))
|
||||
|
||||
# While we are here we can also check if we can resize and move the widget
|
||||
move_and_resize_widget(active_modal_widget)
|
||||
@@ -193,16 +213,10 @@ class AssetPickerUIUXTest(EditorTestHelper):
|
||||
await pyside_utils.click_button_async(ok_button)
|
||||
elif interaction_option == "enter":
|
||||
QtTest.QTest.keyClick(tree, Qt.Key_Enter, Qt.NoModifier)
|
||||
self.prefix = ""
|
||||
|
||||
# 1) Open a new level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# 2) Create entity and add Mesh component
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
@@ -222,7 +236,7 @@ class AssetPickerUIUXTest(EditorTestHelper):
|
||||
|
||||
# Assign Mesh Asset via OK button
|
||||
pyside_utils.click_button_async(attached_button)
|
||||
await asset_picker("Mesh Asset", ["azmodel", "fbx"], "cedar (ModelAsset)", "ok")
|
||||
await asset_picker(["azmodel", "fbx"], "cedar (ModelAsset)", "ok")
|
||||
|
||||
# 5) Verify if Mesh Asset is assigned
|
||||
try:
|
||||
@@ -231,7 +245,11 @@ class AssetPickerUIUXTest(EditorTestHelper):
|
||||
except pyside_utils.EventLoopTimeoutException as err:
|
||||
print(err)
|
||||
mesh_success = False
|
||||
self.test_success = mesh_success and self.test_success
|
||||
mesh_asset_assigned_ok = (
|
||||
"Successfully assigned Mesh asset via OK button",
|
||||
"Failed to assign Mesh asset via OK button"
|
||||
)
|
||||
Report.result(mesh_asset_assigned_ok, mesh_success)
|
||||
|
||||
# Clear Mesh Asset
|
||||
hydra.get_set_test(entity, 0, "Controller|Configuration|Mesh Asset", None)
|
||||
@@ -242,7 +260,7 @@ class AssetPickerUIUXTest(EditorTestHelper):
|
||||
|
||||
# Assign Mesh Asset via Enter
|
||||
pyside_utils.click_button_async(attached_button)
|
||||
await asset_picker("Mesh Asset", ["azmodel", "fbx"], "cedar (ModelAsset)", "enter")
|
||||
await asset_picker(["azmodel", "fbx"], "cedar (ModelAsset)", "enter")
|
||||
|
||||
# 5) Verify if Mesh Asset is assigned
|
||||
try:
|
||||
@@ -251,8 +269,16 @@ class AssetPickerUIUXTest(EditorTestHelper):
|
||||
except pyside_utils.EventLoopTimeoutException as err:
|
||||
print(err)
|
||||
mesh_success = False
|
||||
self.test_success = mesh_success and self.test_success
|
||||
mesh_asset_assigned_enter = (
|
||||
"Successfully assigned Mesh asset via Enter button",
|
||||
"Failed to assign Mesh asset via Enter button"
|
||||
)
|
||||
Report.result(mesh_asset_assigned_enter, mesh_success)
|
||||
|
||||
run_test()
|
||||
|
||||
|
||||
test = AssetPickerUIUXTest()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AssetPicker_UI_UX)
|
||||
|
||||
+72
-55
@@ -5,39 +5,47 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
"""
|
||||
C6351273: Create a new level
|
||||
C6384955: Basic Workflow: Entity Manipulation in the Outliner
|
||||
C16929880: Add Delete Components
|
||||
C15167490: Save a level
|
||||
C15167491: Export a level
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from PySide2 import QtWidgets
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
class Tests:
|
||||
level_created = (
|
||||
"New level created successfully",
|
||||
"Failed to create new level"
|
||||
)
|
||||
new_entity_created = (
|
||||
"New entity created successfully",
|
||||
"Failed to create a new entity"
|
||||
)
|
||||
child_entity_created = (
|
||||
"New child entity created successfully",
|
||||
"Failed to create new child entity"
|
||||
)
|
||||
component_added = (
|
||||
"Component added to entity successfully",
|
||||
"Failed to add component to entity"
|
||||
)
|
||||
component_updated = (
|
||||
"Component property updated successfully",
|
||||
"Failed to update component property"
|
||||
)
|
||||
component_removed = (
|
||||
"Component removed from entity successfully",
|
||||
"Failed to remove component from entity"
|
||||
)
|
||||
level_saved_and_exported = (
|
||||
"Level saved and exported successfully",
|
||||
"Failed to save/export level"
|
||||
)
|
||||
|
||||
|
||||
class TestBasicEditorWorkflows(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="BasicEditorWorkflows_LevelEntityComponent", args=["level"])
|
||||
def BasicEditorWorkflows_LevelEntityComponentCRUD():
|
||||
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
|
||||
@pyside_utils.wrap_async
|
||||
async def run_test(self):
|
||||
async def run_test():
|
||||
"""
|
||||
Summary:
|
||||
Open Lumberyard editor and check if basic Editor workflows are completable.
|
||||
Open O3DE editor and check if basic Editor workflows are completable.
|
||||
|
||||
Expected Behavior:
|
||||
- A new level can be created
|
||||
@@ -48,13 +56,25 @@ class TestBasicEditorWorkflows(EditorTestHelper):
|
||||
- Level can be exported
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Lumberyard Editor command terminal
|
||||
- This test file must be called from the O3DE Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import os
|
||||
from PySide2 import QtWidgets
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
|
||||
def find_entity_by_name(entity_name):
|
||||
search_filter = entity.SearchFilter()
|
||||
search_filter.names = [entity_name]
|
||||
@@ -64,6 +84,7 @@ class TestBasicEditorWorkflows(EditorTestHelper):
|
||||
return None
|
||||
|
||||
# 1) Create a new level
|
||||
level = "tmp_level"
|
||||
editor_window = pyside_utils.get_editor_main_window()
|
||||
new_level_action = pyside_utils.get_action_for_menu_path(editor_window, "File", "New Level")
|
||||
pyside_utils.trigger_action_async(new_level_action)
|
||||
@@ -71,21 +92,17 @@ class TestBasicEditorWorkflows(EditorTestHelper):
|
||||
new_level_dlg = active_modal_widget.findChild(QtWidgets.QWidget, "CNewLevelDialog")
|
||||
if new_level_dlg:
|
||||
if new_level_dlg.windowTitle() == "New Level":
|
||||
self.log("New Level dialog opened")
|
||||
Report.info("New Level dialog opened")
|
||||
grp_box = new_level_dlg.findChild(QtWidgets.QGroupBox, "STATIC_GROUP1")
|
||||
level_name = grp_box.findChild(QtWidgets.QLineEdit, "LEVEL")
|
||||
level_name.setText(self.args["level"])
|
||||
level_name.setText(level)
|
||||
button_box = new_level_dlg.findChild(QtWidgets.QDialogButtonBox, "buttonBox")
|
||||
button_box.button(QtWidgets.QDialogButtonBox.Ok).click()
|
||||
|
||||
# Verify new level was created successfully
|
||||
level_create_success = await pyside_utils.wait_for_condition(lambda: editor.EditorToolsApplicationRequestBus(
|
||||
bus.Broadcast, "GetCurrentLevelName") == self.args["level"], 5.0)
|
||||
self.test_success = level_create_success
|
||||
self.log(f"Create and load new level: {level_create_success}")
|
||||
|
||||
# Execute EditorTestHelper setup since level was created outside of EditorTestHelper's methods
|
||||
self.test_success = self.test_success and self.after_level_load()
|
||||
bus.Broadcast, "GetCurrentLevelName") == level, 5.0)
|
||||
Report.critical_result(Tests.level_created, level_create_success)
|
||||
|
||||
# 2) Delete existing entities, and create and manipulate new entities via Entity Inspector
|
||||
search_filter = azlmbr.entity.SearchFilter()
|
||||
@@ -99,8 +116,7 @@ class TestBasicEditorWorkflows(EditorTestHelper):
|
||||
# Find the new entity
|
||||
parent_entity_id = find_entity_by_name("Entity1")
|
||||
parent_entity_success = await pyside_utils.wait_for_condition(lambda: parent_entity_id is not None, 5.0)
|
||||
self.test_success = self.test_success and parent_entity_success
|
||||
self.log(f"New entity creation: {parent_entity_success}")
|
||||
Report.critical_result(Tests.new_entity_created, parent_entity_success)
|
||||
|
||||
# TODO: Replace Hydra call to creates child entity and add components with context menu triggering - LYN-3951
|
||||
# Create a new child entity
|
||||
@@ -111,29 +127,27 @@ class TestBasicEditorWorkflows(EditorTestHelper):
|
||||
|
||||
# Verify entity hierarchy
|
||||
child_entity.get_parent_info()
|
||||
self.test_success = self.test_success and child_entity.parent_id == parent_entity_id
|
||||
self.log(f"Create entity hierarchy: {child_entity.parent_id == parent_entity_id}")
|
||||
Report.result(Tests.child_entity_created, child_entity.parent_id == parent_entity_id)
|
||||
|
||||
# 3) Add/configure a component on an entity
|
||||
# Add component and verify success
|
||||
child_entity.add_component("Box Shape")
|
||||
component_add_success = self.wait_for_condition(lambda: hydra.has_components(child_entity.id, ["Box Shape"]), 5.0)
|
||||
self.test_success = self.test_success and component_add_success
|
||||
self.log(f"Add component: {component_add_success}")
|
||||
component_add_success = await pyside_utils.wait_for_condition(lambda: hydra.has_components(child_entity.id,
|
||||
["Box Shape"]), 5.0)
|
||||
Report.result(Tests.component_added, component_add_success)
|
||||
|
||||
# Update the component
|
||||
dimensions_to_set = math.Vector3(16.0, 16.0, 16.0)
|
||||
child_entity.get_set_test(0, "Box Shape|Box Configuration|Dimensions", dimensions_to_set)
|
||||
box_shape_dimensions = hydra.get_component_property_value(child_entity.components[0], "Box Shape|Box Configuration|Dimensions")
|
||||
self.test_success = self.test_success and box_shape_dimensions == dimensions_to_set
|
||||
self.log(f"Component update: {box_shape_dimensions == dimensions_to_set}")
|
||||
box_shape_dimensions = hydra.get_component_property_value(child_entity.components[0],
|
||||
"Box Shape|Box Configuration|Dimensions")
|
||||
Report.result(Tests.component_updated, box_shape_dimensions == dimensions_to_set)
|
||||
|
||||
# Remove the component
|
||||
child_entity.remove_component("Box Shape")
|
||||
component_rem_success = self.wait_for_condition(lambda: not hydra.has_components(child_entity.id, ["Box Shape"]),
|
||||
5.0)
|
||||
self.test_success = self.test_success and component_rem_success
|
||||
self.log(f"Remove component: {component_rem_success}")
|
||||
component_rem_success = await pyside_utils.wait_for_condition(lambda: not hydra.has_components(child_entity.id,
|
||||
["Box Shape"]), 5.0)
|
||||
Report.result(Tests.component_removed, component_rem_success)
|
||||
|
||||
# 4) Save the level
|
||||
save_level_action = pyside_utils.get_action_for_menu_path(editor_window, "File", "Save")
|
||||
@@ -143,12 +157,15 @@ class TestBasicEditorWorkflows(EditorTestHelper):
|
||||
export_action = pyside_utils.get_action_for_menu_path(editor_window, "Game", "Export to Engine")
|
||||
pyside_utils.trigger_action_async(export_action)
|
||||
level_pak_file = os.path.join(
|
||||
"AutomatedTesting", "Levels", self.args["level"], "level.pak"
|
||||
"AutomatedTesting", "Levels", level, "level.pak"
|
||||
)
|
||||
export_success = self.wait_for_condition(lambda: os.path.exists(level_pak_file), 5.0)
|
||||
self.test_success = self.test_success and export_success
|
||||
self.log(f"Save and Export: {export_success}")
|
||||
export_success = await pyside_utils.wait_for_condition(lambda: os.path.exists(level_pak_file), 5.0)
|
||||
Report.result(Tests.level_saved_and_exported, export_success)
|
||||
|
||||
run_test()
|
||||
|
||||
|
||||
test = TestBasicEditorWorkflows()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(BasicEditorWorkflows_LevelEntityComponentCRUD)
|
||||
|
||||
+55
-44
@@ -5,37 +5,39 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
"""
|
||||
C16929880: Add Delete Components
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from PySide2 import QtWidgets, QtTest, QtCore
|
||||
from PySide2.QtCore import Qt
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
class Tests:
|
||||
entity_created = (
|
||||
"Entity created successfully",
|
||||
"Failed to create entity"
|
||||
)
|
||||
box_component_added = (
|
||||
"Box Shape component added to entity",
|
||||
"Failed to add Box Shape component to entity"
|
||||
)
|
||||
mesh_component_added = (
|
||||
"Mesh component added to entity",
|
||||
"Failed to add Mesh component to entity"
|
||||
)
|
||||
mesh_component_deleted = (
|
||||
"Mesh component removed from entity",
|
||||
"Failed to remove Mesh component from entity"
|
||||
)
|
||||
mesh_component_delete_undo = (
|
||||
"Mesh component removal was successfully undone",
|
||||
"Failed to undo Mesh component removal"
|
||||
)
|
||||
|
||||
|
||||
class AddDeleteComponentsTest(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="ComponentCRUD_Add_Delete_Components", args=["level"])
|
||||
def ComponentCRUD_Add_Delete_Components():
|
||||
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
|
||||
@pyside_utils.wrap_async
|
||||
async def run_test(self):
|
||||
async def run_test():
|
||||
"""
|
||||
Summary:
|
||||
Add/Delete Components to an entity.
|
||||
Add/Delete Components to/from an entity.
|
||||
|
||||
Expected Behavior:
|
||||
1) Components can be added to an entity.
|
||||
@@ -61,36 +63,43 @@ class AddDeleteComponentsTest(EditorTestHelper):
|
||||
:return: None
|
||||
"""
|
||||
|
||||
from PySide2 import QtWidgets, QtTest, QtCore
|
||||
from PySide2.QtCore import Qt
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.math as math
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
async def add_component(component_name):
|
||||
pyside_utils.click_button_async(add_comp_btn)
|
||||
popup = await pyside_utils.wait_for_popup_widget()
|
||||
tree = popup.findChild(QtWidgets.QTreeView, "Tree")
|
||||
component_index = pyside_utils.find_child_by_pattern(tree, component_name)
|
||||
if component_index.isValid():
|
||||
print(f"{component_name} found")
|
||||
Report.info(f"{component_name} found")
|
||||
tree.expand(component_index)
|
||||
tree.setCurrentIndex(component_index)
|
||||
QtTest.QTest.keyClick(tree, Qt.Key_Enter, Qt.NoModifier)
|
||||
|
||||
# 1) Open level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# 2) Create entity
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
entity_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, entity.EntityId()
|
||||
)
|
||||
if entity_id.IsValid():
|
||||
print("Entity Created")
|
||||
Report.critical_result(Tests.entity_created, entity_id.IsValid())
|
||||
|
||||
# 3) Select the newly created entity
|
||||
general.select_object("Entity2")
|
||||
general.select_object("Entity1")
|
||||
|
||||
# Give the Entity Inspector time to fully create its contents
|
||||
general.idle_wait(0.5)
|
||||
@@ -100,11 +109,11 @@ class AddDeleteComponentsTest(EditorTestHelper):
|
||||
entity_inspector = editor_window.findChild(QtWidgets.QDockWidget, "Entity Inspector")
|
||||
add_comp_btn = entity_inspector.findChild(QtWidgets.QPushButton, "m_addComponentButton")
|
||||
await add_component("Box Shape")
|
||||
print(f"Box Shape Component added: {hydra.has_components(entity_id, ['Box Shape'])}")
|
||||
Report.result(Tests.box_component_added, hydra.has_components(entity_id, ['Box Shape']))
|
||||
|
||||
# 5) Add/verify Mesh component
|
||||
await add_component("Mesh")
|
||||
print(f"Mesh Component added: {hydra.has_components(entity_id, ['Mesh'])}")
|
||||
Report.result(Tests.mesh_component_added, hydra.has_components(entity_id, ['Mesh']))
|
||||
|
||||
# 6) Delete Mesh Component
|
||||
general.idle_wait(0.5)
|
||||
@@ -116,15 +125,17 @@ class AddDeleteComponentsTest(EditorTestHelper):
|
||||
QtTest.QTest.mouseClick(mesh_frame, Qt.LeftButton, Qt.NoModifier)
|
||||
QtTest.QTest.keyClick(mesh_frame, Qt.Key_Delete, Qt.NoModifier)
|
||||
success = await pyside_utils.wait_for_condition(lambda: not hydra.has_components(entity_id, ['Mesh']), 5.0)
|
||||
if success:
|
||||
print(f"Mesh Component deleted: {not hydra.has_components(entity_id, ['Mesh'])}")
|
||||
Report.result(Tests.mesh_component_deleted, success)
|
||||
|
||||
# 7) Undo deletion of component
|
||||
QtTest.QTest.keyPress(entity_inspector, Qt.Key_Z, Qt.ControlModifier)
|
||||
success = await pyside_utils.wait_for_condition(lambda: hydra.has_components(entity_id, ['Mesh']), 5.0)
|
||||
if success:
|
||||
print(f"Mesh Component deletion undone: {hydra.has_components(entity_id, ['Mesh'])}")
|
||||
Report.result(Tests.mesh_component_delete_undo, success)
|
||||
|
||||
run_test()
|
||||
|
||||
|
||||
test = AddDeleteComponentsTest()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(ComponentCRUD_Add_Delete_Components)
|
||||
|
||||
@@ -7,27 +7,32 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
C6376081: Basic Function: Docked/Undocked Tools
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from PySide2 import QtWidgets, QtTest, QtCore
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
class Tests:
|
||||
all_tools_docked = (
|
||||
"The tools are all docked together in a tabbed widget",
|
||||
"Failed to dock all tools together"
|
||||
)
|
||||
docked_outliner_works = (
|
||||
"Entity Outliner works when docked, can select an Entity",
|
||||
"Failed to select an Entity in the Outliner while docked"
|
||||
)
|
||||
docked_inspector_works = (
|
||||
"Entity Inspector works when docked, Entity name changed",
|
||||
"Failed to change Entity name in the Inspector while docked"
|
||||
)
|
||||
docked_console_works = (
|
||||
"Console works when docked, sent a Console Command",
|
||||
"Failed to send Console Command in the Console while docked"
|
||||
)
|
||||
|
||||
|
||||
class TestDockingBasicDockedTools(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="Docking_BasicDockedTools", args=["level"])
|
||||
def Docking_BasicDockedTools():
|
||||
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
|
||||
@pyside_utils.wrap_async
|
||||
async def run_test(self):
|
||||
async def run_test():
|
||||
"""
|
||||
Summary:
|
||||
Test that tools still work as expected when docked together.
|
||||
@@ -50,14 +55,19 @@ class TestDockingBasicDockedTools(EditorTestHelper):
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# Create a level since we are going to be dealing with an Entity.
|
||||
self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
from PySide2 import QtWidgets, QtTest, QtCore
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Make sure the Entity Outliner, Entity Inspector and Console tools are open
|
||||
general.open_pane("Entity Outliner (PREVIEW)")
|
||||
@@ -101,12 +111,14 @@ class TestDockingBasicDockedTools(EditorTestHelper):
|
||||
entity_inspector_parent = entity_inspector.parentWidget()
|
||||
entity_outliner_parent = entity_outliner.parentWidget()
|
||||
console_parent = console.parentWidget()
|
||||
print(f"Entity Inspector parent = {entity_inspector_parent}, Entity Outliner parent = {entity_outliner_parent}, Console parent = {console_parent}")
|
||||
return isinstance(entity_inspector_parent, QtWidgets.QStackedWidget) and (entity_inspector_parent == entity_outliner_parent) and (entity_outliner_parent == console_parent)
|
||||
Report.info(f"Entity Inspector parent = {entity_inspector_parent}, Entity Outliner parent = "
|
||||
f"{entity_outliner_parent}, Console parent = {console_parent}")
|
||||
return isinstance(entity_inspector_parent, QtWidgets.QStackedWidget) and \
|
||||
(entity_inspector_parent == entity_outliner_parent) and \
|
||||
(entity_outliner_parent == console_parent)
|
||||
|
||||
success = await pyside_utils.wait_for(check_all_panes_tabbed, timeout=3.0)
|
||||
if success:
|
||||
print("The tools are all docked together in a tabbed widget")
|
||||
Report.result(Tests.all_tools_docked, success)
|
||||
|
||||
# 2.1,2) Select an Entity in the Entity Outliner.
|
||||
entity_inspector = editor_window.findChild(QtWidgets.QDockWidget, "Entity Inspector")
|
||||
@@ -116,8 +128,7 @@ class TestDockingBasicDockedTools(EditorTestHelper):
|
||||
test_entity_index = pyside_utils.find_child_by_pattern(object_tree, entity_original_name)
|
||||
object_tree.clearSelection()
|
||||
object_tree.setCurrentIndex(test_entity_index)
|
||||
if object_tree.currentIndex():
|
||||
print("Entity Outliner works when docked, can select an Entity")
|
||||
Report.result(Tests.docked_outliner_works, object_tree.currentIndex() == test_entity_index)
|
||||
|
||||
# 2.3,4) Change the name of the selected Entity via the Entity Inspector.
|
||||
entity_inspector_name_field = entity_inspector.findChild(QtWidgets.QLineEdit, "m_entityNameEditor")
|
||||
@@ -125,14 +136,23 @@ class TestDockingBasicDockedTools(EditorTestHelper):
|
||||
entity_inspector_name_field.setText(expected_new_name)
|
||||
QtTest.QTest.keyClick(entity_inspector_name_field, QtCore.Qt.Key_Enter)
|
||||
entity_new_name = editor.EditorEntityInfoRequestBus(bus.Event, "GetName", entity_id)
|
||||
if entity_new_name == expected_new_name:
|
||||
print(f"Entity Inspector works when docked, Entity name changed to {entity_new_name}")
|
||||
Report.result(Tests.docked_inspector_works, entity_new_name == expected_new_name)
|
||||
|
||||
# 2.5,6) Send a console command.
|
||||
console_line_edit = console.findChild(QtWidgets.QLineEdit, "lineEdit")
|
||||
console_line_edit.setText("Hello, world!")
|
||||
console_line_edit.setText("t_Scale 2")
|
||||
QtTest.QTest.keyClick(console_line_edit, QtCore.Qt.Key_Enter)
|
||||
general.get_cvar("t_Scale")
|
||||
Report.result(Tests.docked_console_works, general.get_cvar("t_Scale") == "2")
|
||||
|
||||
# Reset the altered cvar
|
||||
console_line_edit.setText("t_Scale 1")
|
||||
QtTest.QTest.keyClick(console_line_edit, QtCore.Qt.Key_Enter)
|
||||
|
||||
run_test()
|
||||
|
||||
test = TestDockingBasicDockedTools()
|
||||
test.run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(Docking_BasicDockedTools)
|
||||
|
||||
+51
-42
@@ -5,32 +5,36 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
"""
|
||||
C1506881: Adding/Removing Event Groups
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from PySide2 import QtWidgets
|
||||
class Tests:
|
||||
asset_editor_opened = (
|
||||
"Successfully opened the Asset Editor",
|
||||
"Failed to open the Asset Editor"
|
||||
)
|
||||
event_groups_added = (
|
||||
"Successfully added event groups via +",
|
||||
"Failed to add event groups"
|
||||
)
|
||||
single_event_group_deleted = (
|
||||
"Successfully deleted an event group",
|
||||
"Failed to delete event group"
|
||||
)
|
||||
all_event_groups_deleted = (
|
||||
"Successfully deleted all event groups",
|
||||
"Failed to delete all event groups"
|
||||
)
|
||||
asset_editor_closed = (
|
||||
"Successfully closed the Asset Editor",
|
||||
"Failed to close the Asset Editor"
|
||||
)
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
def InputBindings_Add_Remove_Input_Events():
|
||||
|
||||
class AddRemoveInputEventsTest(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="InputBindings_Add_Remove_Input_Events", args=["level"])
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
|
||||
@pyside_utils.wrap_async
|
||||
async def run_test(self):
|
||||
async def run_test():
|
||||
"""
|
||||
Summary:
|
||||
Verify if we are able add/remove input events in inputbindings file.
|
||||
@@ -42,7 +46,7 @@ class AddRemoveInputEventsTest(EditorTestHelper):
|
||||
|
||||
|
||||
Test Steps:
|
||||
1) Open a new level
|
||||
1) Open an existing level
|
||||
2) Open Asset Editor
|
||||
3) Access Asset Editor
|
||||
4) Create a new .inputbindings file and add event groups
|
||||
@@ -61,6 +65,13 @@ class AddRemoveInputEventsTest(EditorTestHelper):
|
||||
:return: None
|
||||
"""
|
||||
|
||||
from PySide2 import QtWidgets
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
def open_asset_editor():
|
||||
general.open_pane("Asset Editor")
|
||||
return general.is_pane_visible("Asset Editor")
|
||||
@@ -69,17 +80,12 @@ class AddRemoveInputEventsTest(EditorTestHelper):
|
||||
general.close_pane("Asset Editor")
|
||||
return not general.is_pane_visible("Asset Editor")
|
||||
|
||||
# 1) Open a new level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# 2) Open Asset Editor
|
||||
print(f"Asset Editor opened: {open_asset_editor()}")
|
||||
Report.result(Tests.asset_editor_opened, open_asset_editor())
|
||||
|
||||
# 3) Access Asset Editor
|
||||
editor_window = pyside_utils.get_editor_main_window()
|
||||
@@ -103,8 +109,7 @@ class AddRemoveInputEventsTest(EditorTestHelper):
|
||||
# 5) Verify if there are 3 elements in the Input Event Groups label
|
||||
no_of_elements_label = input_event_groups.findChild(QtWidgets.QLabel, "DefaultLabel")
|
||||
success = await pyside_utils.wait_for_condition(lambda: "3 elements" in no_of_elements_label.text(), 2.0)
|
||||
if success:
|
||||
print("New Event Groups added when + is clicked")
|
||||
Report.result(Tests.event_groups_added, success)
|
||||
|
||||
# 6) Delete one event group
|
||||
event = asset_editor_widget.findChildren(QtWidgets.QFrame, "<Unspecified Event>")[0]
|
||||
@@ -121,11 +126,11 @@ class AddRemoveInputEventsTest(EditorTestHelper):
|
||||
input_event_group = input_event_groups[1]
|
||||
no_of_elements_label = input_event_group.findChild(QtWidgets.QLabel, "DefaultLabel")
|
||||
return no_of_elements_label.text()
|
||||
return ""
|
||||
|
||||
return "";
|
||||
success = await pyside_utils.wait_for_condition(lambda: "2 elements" in get_elements_label_text(asset_editor_widget), 2.0)
|
||||
if success:
|
||||
print("Event Group deleted when the Delete button is clicked on an Event Group")
|
||||
success = await pyside_utils.wait_for_condition(lambda: "2 elements" in
|
||||
get_elements_label_text(asset_editor_widget), 2.0)
|
||||
Report.result(Tests.single_event_group_deleted, success)
|
||||
|
||||
# 8) Click on Delete button to delete all the Event Groups
|
||||
# First QToolButton child of active input_event_groups is +, Second QToolButton is Delete
|
||||
@@ -141,13 +146,17 @@ class AddRemoveInputEventsTest(EditorTestHelper):
|
||||
yes_button.click()
|
||||
|
||||
# 9) Verify if all the elements are deleted
|
||||
success = await pyside_utils.wait_for_condition(lambda: "0 elements" in get_elements_label_text(asset_editor_widget), 2.0)
|
||||
if success:
|
||||
print("All event groups deleted on clicking the Delete button")
|
||||
success = await pyside_utils.wait_for_condition(lambda: "0 elements" in
|
||||
get_elements_label_text(asset_editor_widget), 2.0)
|
||||
Report.result(Tests.all_event_groups_deleted, success)
|
||||
|
||||
# 10) Close Asset Editor
|
||||
print(f"Asset Editor closed: {close_asset_editor()}")
|
||||
Report.result(Tests.asset_editor_closed, close_asset_editor())
|
||||
|
||||
run_test()
|
||||
|
||||
|
||||
test = AddRemoveInputEventsTest()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(InputBindings_Add_Remove_Input_Events)
|
||||
|
||||
@@ -5,93 +5,78 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
"""
|
||||
C24064529: Base Edit Menu Options
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
def Menus_EditMenuOptions_Work():
|
||||
"""
|
||||
Summary:
|
||||
Interact with Edit Menu options and verify if all the options are working.
|
||||
|
||||
import azlmbr.paths
|
||||
Expected Behavior:
|
||||
The Edit menu functions normally.
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
Test Steps:
|
||||
1) Open an existing level
|
||||
2) Interact with Edit Menu options
|
||||
|
||||
Note:
|
||||
- This test file must be called from the O3DE Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
class TestEditMenuOptions(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="Menus_EditMenuOptions", args=["level"])
|
||||
:return: None
|
||||
"""
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
Interact with Edit Menu options and verify if all the options are working.
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
Expected Behavior:
|
||||
The Edit menu functions normally.
|
||||
edit_menu_options = [
|
||||
("Undo",),
|
||||
("Redo",),
|
||||
("Duplicate",),
|
||||
("Delete",),
|
||||
("Select All",),
|
||||
("Invert Selection",),
|
||||
("Toggle Pivot Location",),
|
||||
("Reset Entity Transform",),
|
||||
("Reset Manipulator",),
|
||||
("Reset Transform (Local)",),
|
||||
("Reset Transform (World)",),
|
||||
("Hide Selection",),
|
||||
("Show All",),
|
||||
("Modify", "Snap", "Snap angle"),
|
||||
("Modify", "Transform Mode", "Move"),
|
||||
("Modify", "Transform Mode", "Rotate"),
|
||||
("Modify", "Transform Mode", "Scale"),
|
||||
("Editor Settings", "Global Preferences"),
|
||||
("Editor Settings", "Editor Settings Manager"),
|
||||
("Editor Settings", "Keyboard Customization", "Customize Keyboard"),
|
||||
("Editor Settings", "Keyboard Customization", "Export Keyboard Settings"),
|
||||
("Editor Settings", "Keyboard Customization", "Import Keyboard Settings"),
|
||||
]
|
||||
|
||||
Test Steps:
|
||||
1) Create a temp level
|
||||
2) Interact with Edit Menu options
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Lumberyard Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
edit_menu_options = [
|
||||
("Undo",),
|
||||
("Redo",),
|
||||
("Duplicate",),
|
||||
("Delete",),
|
||||
("Select All",),
|
||||
("Invert Selection",),
|
||||
("Toggle Pivot Location",),
|
||||
("Reset Entity Transform",),
|
||||
("Reset Manipulator",),
|
||||
("Reset Transform (Local)",),
|
||||
("Reset Transform (World)",),
|
||||
("Hide Selection",),
|
||||
("Show All",),
|
||||
("Modify", "Snap", "Snap angle"),
|
||||
("Modify", "Transform Mode", "Move"),
|
||||
("Modify", "Transform Mode", "Rotate"),
|
||||
("Modify", "Transform Mode", "Scale"),
|
||||
("Editor Settings", "Global Preferences"),
|
||||
("Editor Settings", "Editor Settings Manager"),
|
||||
("Editor Settings", "Keyboard Customization", "Customize Keyboard"),
|
||||
("Editor Settings", "Keyboard Customization", "Export Keyboard Settings"),
|
||||
("Editor Settings", "Keyboard Customization", "Import Keyboard Settings"),
|
||||
]
|
||||
|
||||
# 1) Create and open the temp level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
def on_action_triggered(action_name):
|
||||
print(f"{action_name} Action triggered")
|
||||
|
||||
# 2) Interact with Edit Menu options
|
||||
# 2) Interact with Edit Menu options
|
||||
editor_window = pyside_utils.get_editor_main_window()
|
||||
for option in edit_menu_options:
|
||||
try:
|
||||
editor_window = pyside_utils.get_editor_main_window()
|
||||
for option in edit_menu_options:
|
||||
action = pyside_utils.get_action_for_menu_path(editor_window, "Edit", *option)
|
||||
trig_func = lambda: on_action_triggered(action.iconText())
|
||||
action.triggered.connect(trig_func)
|
||||
action.trigger()
|
||||
action.triggered.disconnect(trig_func)
|
||||
action = pyside_utils.get_action_for_menu_path(editor_window, "Edit", *option)
|
||||
action.trigger()
|
||||
action_triggered = True
|
||||
except Exception as e:
|
||||
self.test_success = False
|
||||
action_triggered = False
|
||||
print(e)
|
||||
menu_action_triggered = (
|
||||
f"{action.iconText()} action triggered successfully",
|
||||
f"Failed to trigger {action.iconText()} action"
|
||||
)
|
||||
Report.result(menu_action_triggered, action_triggered)
|
||||
|
||||
|
||||
test = TestEditMenuOptions()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(Menus_EditMenuOptions_Work)
|
||||
|
||||
@@ -5,80 +5,69 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.paths
|
||||
def Menus_FileMenuOptions_Work():
|
||||
"""
|
||||
Summary:
|
||||
Interact with File Menu options and verify if all the options are working.
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
Expected Behavior:
|
||||
The File menu functions normally.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Interact with File Menu options
|
||||
|
||||
class TestFileMenuOptions(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="file_menu_options: ", args=["level"])
|
||||
Note:
|
||||
- This test file must be called from the O3DE Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
Interact with File Menu options and verify if all the options are working.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Expected Behavior:
|
||||
The File menu functions normally.
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Interact with File Menu options
|
||||
file_menu_options = [
|
||||
("New Level",),
|
||||
("Open Level",),
|
||||
("Import",),
|
||||
("Save",),
|
||||
("Save As",),
|
||||
("Save Level Statistics",),
|
||||
("Edit Project Settings",),
|
||||
("Edit Platform Settings",),
|
||||
("New Project",),
|
||||
("Open Project",),
|
||||
("Show Log File",),
|
||||
("Resave All Slices",),
|
||||
("Exit",),
|
||||
]
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Lumberyard Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
:return: None
|
||||
"""
|
||||
file_menu_options = [
|
||||
("New Level",),
|
||||
("Open Level",),
|
||||
("Import",),
|
||||
("Save",),
|
||||
("Save As",),
|
||||
("Save Level Statistics",),
|
||||
("Edit Project Settings",),
|
||||
("Edit Platform Settings",),
|
||||
("New Project",),
|
||||
("Open Project",),
|
||||
("Show Log File",),
|
||||
("Resave All Slices",),
|
||||
("Exit",),
|
||||
]
|
||||
|
||||
# 1) Open level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
def on_action_triggered(action_name):
|
||||
print(f"{action_name} Action triggered")
|
||||
|
||||
# 2) Interact with File Menu options
|
||||
# 2) Interact with File Menu options
|
||||
editor_window = pyside_utils.get_editor_main_window()
|
||||
for option in file_menu_options:
|
||||
try:
|
||||
editor_window = pyside_utils.get_editor_main_window()
|
||||
for option in file_menu_options:
|
||||
action = pyside_utils.get_action_for_menu_path(editor_window, "File", *option)
|
||||
trig_func = lambda: on_action_triggered(action.iconText())
|
||||
action.triggered.connect(trig_func)
|
||||
action.trigger()
|
||||
action.triggered.disconnect(trig_func)
|
||||
action = pyside_utils.get_action_for_menu_path(editor_window, "File", *option)
|
||||
action.trigger()
|
||||
action_triggered = True
|
||||
except Exception as e:
|
||||
self.test_success = False
|
||||
action_triggered = False
|
||||
print(e)
|
||||
menu_action_triggered = (
|
||||
f"{action.iconText()} action triggered successfully",
|
||||
f"Failed to trigger {action.iconText()} action"
|
||||
)
|
||||
Report.result(menu_action_triggered, action_triggered)
|
||||
|
||||
|
||||
test = TestFileMenuOptions()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(Menus_FileMenuOptions_Work)
|
||||
|
||||
@@ -5,81 +5,66 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
"""
|
||||
C24064534: The View menu options function normally
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
def Menus_ViewMenuOptions_Work():
|
||||
"""
|
||||
Summary:
|
||||
Interact with View Menu options and verify if all the options are working.
|
||||
|
||||
import azlmbr.paths
|
||||
Expected Behavior:
|
||||
The View menu functions normally.
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
Test Steps:
|
||||
1) Open an existing level
|
||||
2) Interact with View Menu options
|
||||
|
||||
Note:
|
||||
- This test file must be called from the O3DE Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
class TestViewMenuOptions(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="Menus_EditMenuOptions", args=["level"])
|
||||
:return: None
|
||||
"""
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
Interact with View Menu options and verify if all the options are working.
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
Expected Behavior:
|
||||
The View menu functions normally.
|
||||
view_menu_options = [
|
||||
("Center on Selection",),
|
||||
("Show Quick Access Bar",),
|
||||
("Viewport", "Configure Layout"),
|
||||
("Viewport", "Go to Position"),
|
||||
("Viewport", "Center on Selection"),
|
||||
("Viewport", "Go to Location"),
|
||||
("Viewport", "Remember Location"),
|
||||
("Viewport", "Switch Camera"),
|
||||
("Viewport", "Show/Hide Helpers"),
|
||||
("Refresh Style",),
|
||||
]
|
||||
|
||||
Test Steps:
|
||||
1) Create a temp level
|
||||
2) Interact with View Menu options
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Lumberyard Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
view_menu_options = [
|
||||
("Center on Selection",),
|
||||
("Show Quick Access Bar",),
|
||||
("Viewport", "Configure Layout"),
|
||||
("Viewport", "Go to Position"),
|
||||
("Viewport", "Center on Selection"),
|
||||
("Viewport", "Go to Location"),
|
||||
("Viewport", "Remember Location"),
|
||||
("Viewport", "Switch Camera"),
|
||||
("Viewport", "Show/Hide Helpers"),
|
||||
("Refresh Style",),
|
||||
]
|
||||
|
||||
# 1) Create and open the temp level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
def on_action_triggered(action_name):
|
||||
print(f"{action_name} Action triggered")
|
||||
|
||||
# 2) Interact with View Menu options
|
||||
# 2) Interact with View Menu options
|
||||
editor_window = pyside_utils.get_editor_main_window()
|
||||
for option in view_menu_options:
|
||||
try:
|
||||
editor_window = pyside_utils.get_editor_main_window()
|
||||
for option in view_menu_options:
|
||||
action = pyside_utils.get_action_for_menu_path(editor_window, "View", *option)
|
||||
trig_func = lambda: on_action_triggered(action.iconText())
|
||||
action.triggered.connect(trig_func)
|
||||
action.trigger()
|
||||
action.triggered.disconnect(trig_func)
|
||||
action = pyside_utils.get_action_for_menu_path(editor_window, "View", *option)
|
||||
action.trigger()
|
||||
action_triggered = True
|
||||
except Exception as e:
|
||||
self.test_success = False
|
||||
action_triggered = False
|
||||
print(e)
|
||||
menu_action_triggered = (
|
||||
f"{action.iconText()} action triggered successfully",
|
||||
f"Failed to trigger {action.iconText()} action"
|
||||
)
|
||||
Report.result(menu_action_triggered, action_triggered)
|
||||
|
||||
|
||||
test = TestViewMenuOptions()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(Menus_ViewMenuOptions_Work)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../automatedtesting_shared')
|
||||
from base import TestAutomationBase
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def remove_test_level(request, workspace, project):
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", "tmp_level")], True, True)
|
||||
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", "tmp_level")], True, True)
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
|
||||
@pytest.mark.SUITE_main
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomation(TestAutomationBase):
|
||||
|
||||
def test_BasicEditorWorkflows_LevelEntityComponentCRUD(self, request, workspace, editor, launcher_platform,
|
||||
remove_test_level):
|
||||
from .EditorScripts import BasicEditorWorkflows_LevelEntityComponentCRUD as test_module
|
||||
self._run_test(request, workspace, editor, test_module, batch_mode=False, autotest_mode=False)
|
||||
|
||||
@pytest.mark.REQUIRES_gpu
|
||||
def test_BasicEditorWorkflows_GPU_LevelEntityComponentCRUD(self, request, workspace, editor, launcher_platform,
|
||||
remove_test_level):
|
||||
from .EditorScripts import BasicEditorWorkflows_LevelEntityComponentCRUD as test_module
|
||||
self._run_test(request, workspace, editor, test_module, batch_mode=False, autotest_mode=False,
|
||||
use_null_renderer=False)
|
||||
@@ -0,0 +1,75 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
from ly_test_tools.o3de.editor_test import EditorSingleTest, EditorSharedTest, EditorParallelTest, EditorTestSuite
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason="Optimized tests are experimental, we will enable xfail and monitor them temporarily.")
|
||||
@pytest.mark.SUITE_main
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomationNoAutoTestMode(EditorTestSuite):
|
||||
|
||||
# Disable -autotest_mode and -BatchMode. Tests cannot run in -BatchMode due to UI interactions, and these tests
|
||||
# interact with modal dialogs
|
||||
global_extra_cmdline_args = []
|
||||
|
||||
class test_BasicEditorWorkflows_LevelEntityComponentCRUD(EditorSingleTest):
|
||||
# Custom teardown to remove slice asset created during test
|
||||
def teardown(self, request, workspace, editor, editor_test_results, launcher_platform):
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), "AutomatedTesting", "Levels", "tmp_level")],
|
||||
True, True)
|
||||
from .EditorScripts import BasicEditorWorkflows_LevelEntityComponentCRUD as test_module
|
||||
|
||||
@pytest.mark.REQUIRES_gpu
|
||||
class test_BasicEditorWorkflows_GPU_LevelEntityComponentCRUD(EditorSingleTest):
|
||||
# Disable null renderer
|
||||
use_null_renderer = False
|
||||
|
||||
# Custom teardown to remove slice asset created during test
|
||||
def teardown(self, request, workspace, editor, editor_test_results, launcher_platform):
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), "AutomatedTesting", "Levels", "tmp_level")],
|
||||
True, True)
|
||||
from .EditorScripts import BasicEditorWorkflows_LevelEntityComponentCRUD as test_module
|
||||
|
||||
class test_InputBindings_Add_Remove_Input_Events(EditorSharedTest):
|
||||
from .EditorScripts import InputBindings_Add_Remove_Input_Events as test_module
|
||||
|
||||
@pytest.mark.skip(reason="Crashes Editor: ATOM-15493")
|
||||
class test_AssetPicker_UI_UX(EditorSharedTest):
|
||||
from .EditorScripts import AssetPicker_UI_UX as test_module
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason="Optimized tests are experimental, we will enable xfail and monitor them temporarily.")
|
||||
@pytest.mark.SUITE_main
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomationAutoTestMode(EditorTestSuite):
|
||||
|
||||
# Enable only -autotest_mode for these tests. Tests cannot run in -BatchMode due to UI interactions
|
||||
global_extra_cmdline_args = ["-autotest_mode"]
|
||||
|
||||
class test_AssetBrowser_TreeNavigation(EditorSharedTest):
|
||||
from .EditorScripts import AssetBrowser_TreeNavigation as test_module
|
||||
|
||||
@pytest.mark.skip(reason="Crashes Editor: ATOM-15493")
|
||||
class test_AssetBrowser_SearchFiltering(EditorSharedTest):
|
||||
from .EditorScripts import AssetBrowser_SearchFiltering as test_module
|
||||
|
||||
class test_ComponentCRUD_Add_Delete_Components(EditorSharedTest):
|
||||
from .EditorScripts import ComponentCRUD_Add_Delete_Components as test_module
|
||||
|
||||
class test_Menus_ViewMenuOptions_Work(EditorSharedTest):
|
||||
from .EditorScripts import Menus_ViewMenuOptions as test_module
|
||||
|
||||
@pytest.mark.skip(reason="Times out due to dialogs failing to dismiss: LYN-4208")
|
||||
class test_Menus_FileMenuOptions_Work(EditorSharedTest):
|
||||
from .EditorScripts import Menus_FileMenuOptions as test_module
|
||||
@@ -0,0 +1,62 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../automatedtesting_shared')
|
||||
from base import TestAutomationBase
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def remove_test_level(request, workspace, project):
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", "tmp_level")], True, True)
|
||||
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", "tmp_level")], True, True)
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomation(TestAutomationBase):
|
||||
|
||||
def test_AssetBrowser_TreeNavigation(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import AssetBrowser_TreeNavigation as test_module
|
||||
self._run_test(request, workspace, editor, test_module, batch_mode=False)
|
||||
|
||||
@pytest.mark.skip(reason="Crashes Editor: ATOM-15493")
|
||||
def test_AssetBrowser_SearchFiltering(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import AssetBrowser_SearchFiltering as test_module
|
||||
self._run_test(request, workspace, editor, test_module, batch_mode=False)
|
||||
|
||||
@pytest.mark.skip(reason="Crashes Editor: ATOM-15493")
|
||||
def test_AssetPicker_UI_UX(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import AssetPicker_UI_UX as test_module
|
||||
self._run_test(request, workspace, editor, test_module, autotest_mode=False, batch_mode=False)
|
||||
|
||||
def test_ComponentCRUD_Add_Delete_Components(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import ComponentCRUD_Add_Delete_Components as test_module
|
||||
self._run_test(request, workspace, editor, test_module, batch_mode=False)
|
||||
|
||||
def test_InputBindings_Add_Remove_Input_Events(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import InputBindings_Add_Remove_Input_Events as test_module
|
||||
self._run_test(request, workspace, editor, test_module, batch_mode=False, autotest_mode=False)
|
||||
|
||||
def test_Menus_ViewMenuOptions_Work(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import Menus_ViewMenuOptions as test_module
|
||||
self._run_test(request, workspace, editor, test_module, batch_mode=False)
|
||||
|
||||
@pytest.mark.skip(reason="Times out due to dialogs failing to dismiss: LYN-4208")
|
||||
def test_Menus_FileMenuOptions_Work(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import Menus_FileMenuOptions as test_module
|
||||
self._run_test(request, workspace, editor, test_module, batch_mode=False)
|
||||
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../automatedtesting_shared')
|
||||
from base import TestAutomationBase
|
||||
|
||||
|
||||
@pytest.mark.SUITE_sandbox
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomation(TestAutomationBase):
|
||||
|
||||
def test_Menus_EditMenuOptions_Work(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import Menus_EditMenuOptions as test_module
|
||||
self._run_test(request, workspace, editor, test_module, batch_mode=False)
|
||||
|
||||
def test_Docking_BasicDockedTools(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import Docking_BasicDockedTools as test_module
|
||||
self._run_test(request, workspace, editor, test_module, batch_mode=False)
|
||||
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
from ly_test_tools.o3de.editor_test import EditorSingleTest, EditorSharedTest, EditorParallelTest, EditorTestSuite
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason="Optimized tests are experimental, we will enable xfail and monitor them temporarily.")
|
||||
@pytest.mark.SUITE_sandbox
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomationAutoTestMode(EditorTestSuite):
|
||||
|
||||
# Enable only -autotest_mode for these tests. Tests cannot run in -BatchMode due to UI interactions
|
||||
global_extra_cmdline_args = ["-autotest_mode"]
|
||||
|
||||
class test_Docking_BasicDockedTools(EditorSharedTest):
|
||||
from .EditorScripts import Docking_BasicDockedTools as test_module
|
||||
|
||||
class test_Menus_EditMenuOptions_Work(EditorSharedTest):
|
||||
from .EditorScripts import Menus_EditMenuOptions as test_module
|
||||
@@ -1,89 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
"""
|
||||
C13660195: Asset Browser - File Tree Navigation
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
# Bail on the test if ly_test_tools doesn't exist.
|
||||
pytest.importorskip('ly_test_tools')
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
import editor_python_test_tools.hydra_test_utils as hydra
|
||||
|
||||
test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts")
|
||||
log_monitor_timeout = 180
|
||||
|
||||
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['tmp_level'])
|
||||
@pytest.mark.usefixtures("automatic_process_killer")
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
class TestAssetBrowser(object):
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_teardown(self, request, workspace, project, level):
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
@pytest.mark.test_case_id("C13660195")
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_AssetBrowser_TreeNavigation(self, request, editor, level, launcher_platform):
|
||||
expected_lines = [
|
||||
"Collapse/Expand tests: True",
|
||||
"Asset visibility test: True",
|
||||
"Scrollbar visibility test: True",
|
||||
"AssetBrowser_TreeNavigation: result=SUCCESS"
|
||||
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"AssetBrowser_TreeNavigation.py",
|
||||
expected_lines,
|
||||
run_python="--runpython",
|
||||
cfg_args=[level],
|
||||
timeout=log_monitor_timeout
|
||||
)
|
||||
|
||||
@pytest.mark.test_case_id("C13660194")
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_AssetBrowser_SearchFiltering(self, request, editor, level, launcher_platform):
|
||||
expected_lines = [
|
||||
"cedar.fbx asset is filtered in Asset Browser",
|
||||
"Animation file type(s) is present in the file tree: True",
|
||||
"FileTag file type(s) and Animation file type(s) is present in the file tree: True",
|
||||
"FileTag file type(s) is present in the file tree after removing Animation filter: True",
|
||||
]
|
||||
|
||||
unexpected_lines = [
|
||||
"Asset Browser opened: False",
|
||||
"Animation file type(s) is present in the file tree: False",
|
||||
"FileTag file type(s) and Animation file type(s) is present in the file tree: False",
|
||||
"FileTag file type(s) is present in the file tree after removing Animation filter: False",
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"AssetBrowser_SearchFiltering.py",
|
||||
expected_lines,
|
||||
unexpected_lines=unexpected_lines,
|
||||
cfg_args=[level],
|
||||
auto_test_mode=False,
|
||||
run_python="--runpython",
|
||||
timeout=log_monitor_timeout,
|
||||
)
|
||||
@@ -1,74 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
"""
|
||||
C13751579: Asset Picker UI/UX
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
# Bail on the test if ly_test_tools doesn't exist.
|
||||
pytest.importorskip('ly_test_tools')
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
import editor_python_test_tools.hydra_test_utils as hydra
|
||||
|
||||
test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts")
|
||||
log_monitor_timeout = 90
|
||||
|
||||
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['tmp_level'])
|
||||
@pytest.mark.usefixtures("automatic_process_killer")
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
class TestAssetPicker(object):
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_teardown(self, request, workspace, project, level):
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
@pytest.mark.test_case_id("C13751579", "C1508814")
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.xfail # ATOM-15493
|
||||
def test_AssetPicker_UI_UX(self, request, editor, level, launcher_platform):
|
||||
expected_lines = [
|
||||
"TestEntity Entity successfully created",
|
||||
"Mesh component was added to entity",
|
||||
"Entity has a Mesh component",
|
||||
"Mesh Asset: Asset Picker title for Mesh: Pick ModelAsset",
|
||||
"Mesh Asset: Scroll Bar is not visible before expanding the tree: True",
|
||||
"Mesh Asset: Top level folder initially collapsed: True",
|
||||
"Mesh Asset: Top level folder expanded: True",
|
||||
"Mesh Asset: Nested folder initially collapsed: True",
|
||||
"Mesh Asset: Nested folder expanded: True",
|
||||
"Mesh Asset: Scroll Bar appeared after expanding tree: True",
|
||||
"Mesh Asset: Nested folder collapsed: True",
|
||||
"Mesh Asset: Top level folder collapsed: True",
|
||||
"Mesh Asset: Expected Assets populated in the file picker: True",
|
||||
"Widget Move Test: True",
|
||||
"Widget Resize Test: True",
|
||||
"Asset assigned for ok option: True",
|
||||
"Asset assigned for enter option: True",
|
||||
"AssetPicker_UI_UX: result=SUCCESS"
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"AssetPicker_UI_UX.py",
|
||||
expected_lines,
|
||||
cfg_args=[level],
|
||||
run_python="--runpython",
|
||||
auto_test_mode=False,
|
||||
timeout=log_monitor_timeout,
|
||||
)
|
||||
@@ -1,96 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
# Bail on the test if ly_test_tools doesn't exist.
|
||||
pytest.importorskip('ly_test_tools')
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
import ly_test_tools._internal.pytest_plugin as internal_plugin
|
||||
import editor_python_test_tools.hydra_test_utils as hydra
|
||||
|
||||
test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts")
|
||||
log_monitor_timeout = 180
|
||||
|
||||
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['tmp_level'])
|
||||
@pytest.mark.usefixtures("automatic_process_killer")
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
class TestBasicEditorWorkflows(object):
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_teardown(self, request, workspace, project, level):
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
@pytest.mark.test_case_id("C6351273", "C6384955", "C16929880", "C15167490", "C15167491")
|
||||
@pytest.mark.SUITE_main
|
||||
def test_BasicEditorWorkflows_LevelEntityComponentCRUD(self, request, editor, level, launcher_platform):
|
||||
|
||||
# Skip test if running against Debug build
|
||||
if "debug" in internal_plugin.build_directory:
|
||||
pytest.skip("Does not execute against debug builds.")
|
||||
|
||||
expected_lines = [
|
||||
"Create and load new level: True",
|
||||
"New entity creation: True",
|
||||
"Create entity hierarchy: True",
|
||||
"Add component: True",
|
||||
"Component update: True",
|
||||
"Remove component: True",
|
||||
"Save and Export: True",
|
||||
"BasicEditorWorkflows_LevelEntityComponent: result=SUCCESS",
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"BasicEditorWorkflows_LevelEntityComponentCRUD.py",
|
||||
expected_lines,
|
||||
cfg_args=[level],
|
||||
timeout=log_monitor_timeout,
|
||||
auto_test_mode=False
|
||||
)
|
||||
|
||||
@pytest.mark.test_case_id("C6351273", "C6384955", "C16929880", "C15167490", "C15167491")
|
||||
@pytest.mark.SUITE_main
|
||||
@pytest.mark.REQUIRES_gpu
|
||||
def test_BasicEditorWorkflows_GPU_LevelEntityComponentCRUD(self, request, editor, level, launcher_platform):
|
||||
|
||||
# Skip test if running against Debug build
|
||||
if "debug" in internal_plugin.build_directory:
|
||||
pytest.skip("Does not execute against debug builds.")
|
||||
|
||||
expected_lines = [
|
||||
"Create and load new level: True",
|
||||
"New entity creation: True",
|
||||
"Create entity hierarchy: True",
|
||||
"Add component: True",
|
||||
"Component update: True",
|
||||
"Remove component: True",
|
||||
"Save and Export: True",
|
||||
"BasicEditorWorkflows_LevelEntityComponent: result=SUCCESS",
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"BasicEditorWorkflows_LevelEntityComponentCRUD.py",
|
||||
expected_lines,
|
||||
cfg_args=[level],
|
||||
timeout=log_monitor_timeout,
|
||||
auto_test_mode=False,
|
||||
null_renderer=False
|
||||
)
|
||||
@@ -1,62 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
"""
|
||||
C16929880: Add Delete Components
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
# Bail on the test if ly_test_tools doesn't exist.
|
||||
pytest.importorskip('ly_test_tools')
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
import editor_python_test_tools.hydra_test_utils as hydra
|
||||
|
||||
test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts")
|
||||
log_monitor_timeout = 180
|
||||
|
||||
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['tmp_level'])
|
||||
@pytest.mark.usefixtures("automatic_process_killer")
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
class TestComponentCRUD(object):
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_teardown(self, request, workspace, project, level):
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
@pytest.mark.test_case_id("C16929880", "C16877220")
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.BAT
|
||||
def test_ComponentCRUD_Add_Delete_Components(self, request, editor, level, launcher_platform):
|
||||
expected_lines = [
|
||||
"Entity Created",
|
||||
"Box Shape found",
|
||||
"Box Shape Component added: True",
|
||||
"Mesh found",
|
||||
"Mesh Component added: True",
|
||||
"Mesh Component deleted: True",
|
||||
"Mesh Component deletion undone: True",
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"ComponentCRUD_Add_Delete_Components.py",
|
||||
expected_lines,
|
||||
cfg_args=[level],
|
||||
auto_test_mode=False,
|
||||
timeout=log_monitor_timeout
|
||||
)
|
||||
@@ -1,55 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
C6376081: Basic Function: Docked/Undocked Tools
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
# Bail on the test if ly_test_tools doesn't exist.
|
||||
pytest.importorskip('ly_test_tools')
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
import editor_python_test_tools.hydra_test_utils as hydra
|
||||
|
||||
test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts")
|
||||
log_monitor_timeout = 180
|
||||
|
||||
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['tmp_level'])
|
||||
@pytest.mark.usefixtures("automatic_process_killer")
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
class TestDocking(object):
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_teardown(self, request, workspace, project, level):
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
@pytest.mark.test_case_id("C6376081")
|
||||
@pytest.mark.SUITE_sandbox
|
||||
def test_Docking_BasicDockedTools(self, request, editor, level, launcher_platform):
|
||||
expected_lines = [
|
||||
"The tools are all docked together in a tabbed widget",
|
||||
"Entity Outliner works when docked, can select an Entity",
|
||||
"Entity Inspector works when docked, Entity name changed to DifferentName",
|
||||
"Hello, world!" # This line verifies the Console is working while docked
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"Docking_BasicDockedTools.py",
|
||||
expected_lines,
|
||||
cfg_args=[level],
|
||||
timeout=log_monitor_timeout,
|
||||
)
|
||||
@@ -1,66 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
"""
|
||||
C1506881: Adding/Removing Event Groups
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
# Bail on the test if ly_test_tools doesn't exist.
|
||||
pytest.importorskip('ly_test_tools')
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
import editor_python_test_tools.hydra_test_utils as hydra
|
||||
|
||||
test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts")
|
||||
log_monitor_timeout = 180
|
||||
|
||||
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['tmp_level'])
|
||||
@pytest.mark.usefixtures("automatic_process_killer")
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
class TestInputBindings(object):
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_teardown(self, request, workspace, project, level):
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
@pytest.mark.test_case_id("C1506881")
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_InputBindings_Add_Remove_Input_Events(self, request, editor, level, launcher_platform):
|
||||
expected_lines = [
|
||||
"Asset Editor opened: True",
|
||||
"New Event Groups added when + is clicked",
|
||||
"Event Group deleted when the Delete button is clicked on an Event Group",
|
||||
"All event groups deleted on clicking the Delete button",
|
||||
"Asset Editor closed: True",
|
||||
]
|
||||
|
||||
unexpected_lines = [
|
||||
"Asset Editor opened: False",
|
||||
"Asset Editor closed: False",
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"InputBindings_Add_Remove_Input_Events.py",
|
||||
expected_lines,
|
||||
unexpected_lines=unexpected_lines,
|
||||
cfg_args=[level],
|
||||
run_python="--runpython",
|
||||
auto_test_mode=False,
|
||||
timeout=log_monitor_timeout,
|
||||
)
|
||||
@@ -1,132 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
# Bail on the test if ly_test_tools doesn't exist.
|
||||
pytest.importorskip('ly_test_tools')
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
import ly_test_tools.environment.process_utils as process_utils
|
||||
import editor_python_test_tools.hydra_test_utils as hydra
|
||||
|
||||
test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts")
|
||||
log_monitor_timeout = 180
|
||||
|
||||
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['tmp_level'])
|
||||
@pytest.mark.usefixtures("automatic_process_killer")
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
class TestMenus(object):
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_teardown(self, request, workspace, project, level):
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
process_utils.kill_processes_named("o3de", ignore_extensions=True) # Kill ProjectManager windows
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
@pytest.mark.test_case_id("C16780783", "C2174438")
|
||||
@pytest.mark.SUITE_sandbox
|
||||
def test_Menus_EditMenuOptions_Work(self, request, editor, level, launcher_platform):
|
||||
expected_lines = [
|
||||
"Undo Action triggered",
|
||||
"Redo Action triggered",
|
||||
"Duplicate Action triggered",
|
||||
"Delete Action triggered",
|
||||
"Select All Action triggered",
|
||||
"Invert Selection Action triggered",
|
||||
"Toggle Pivot Location Action triggered",
|
||||
"Reset Entity Transform",
|
||||
"Reset Manipulator",
|
||||
"Reset Transform (Local) Action triggered",
|
||||
"Reset Transform (World) Action triggered",
|
||||
"Hide Selection Action triggered",
|
||||
"Show All Action triggered",
|
||||
"Snap angle Action triggered",
|
||||
"Move Action triggered",
|
||||
"Rotate Action triggered",
|
||||
"Scale Action triggered",
|
||||
"Global Preferences Action triggered",
|
||||
"Editor Settings Manager Action triggered",
|
||||
"Customize Keyboard Action triggered",
|
||||
"Export Keyboard Settings Action triggered",
|
||||
"Import Keyboard Settings Action triggered",
|
||||
"Menus_EditMenuOptions: result=SUCCESS"
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"Menus_EditMenuOptions.py",
|
||||
expected_lines,
|
||||
cfg_args=[level],
|
||||
run_python="--runpython",
|
||||
timeout=log_monitor_timeout
|
||||
)
|
||||
|
||||
@pytest.mark.test_case_id("C16780807")
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_Menus_ViewMenuOptions_Work(self, request, editor, level, launcher_platform):
|
||||
expected_lines = [
|
||||
"Center on Selection Action triggered",
|
||||
"Show Quick Access Bar Action triggered",
|
||||
"Configure Layout Action triggered",
|
||||
"Go to Position Action triggered",
|
||||
"Center on Selection Action triggered",
|
||||
"Go to Location Action triggered",
|
||||
"Remember Location Action triggered",
|
||||
"Switch Camera Action triggered",
|
||||
"Show/Hide Helpers Action triggered",
|
||||
"Refresh Style Action triggered",
|
||||
]
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"Menus_ViewMenuOptions.py",
|
||||
expected_lines,
|
||||
cfg_args=[level],
|
||||
run_python="--runpython",
|
||||
timeout=log_monitor_timeout
|
||||
)
|
||||
|
||||
@pytest.mark.test_case_id("C16780778")
|
||||
@pytest.mark.SUITE_sandbox
|
||||
@pytest.mark.xfail # LYN-4208
|
||||
def test_Menus_FileMenuOptions_Work(self, request, editor, level, launcher_platform):
|
||||
expected_lines = [
|
||||
"New Level Action triggered",
|
||||
"Open Level Action triggered",
|
||||
"Import Action triggered",
|
||||
"Save Action triggered",
|
||||
"Save As Action triggered",
|
||||
"Save Level Statistics Action triggered",
|
||||
"Edit Project Settings Action triggered",
|
||||
"Edit Platform Settings Action triggered",
|
||||
"New Project Action triggered",
|
||||
"Open Project Action triggered",
|
||||
"Show Log File Action triggered",
|
||||
"Resave All Slices Action triggered",
|
||||
"Exit Action triggered",
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"Menus_FileMenuOptions.py",
|
||||
expected_lines,
|
||||
cfg_args=[level],
|
||||
run_python="--runpython",
|
||||
timeout=log_monitor_timeout
|
||||
)
|
||||
@@ -16,7 +16,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
TEST_SUITE main
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/dyn_veg
|
||||
PYTEST_MARKS "not SUITE_sandbox and not SUITE_periodic and not SUITE_benchmark"
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
@@ -33,7 +32,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
TEST_SUITE sandbox
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/dyn_veg
|
||||
PYTEST_MARKS "SUITE_sandbox"
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
@@ -49,7 +47,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
TEST_SUITE periodic
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/dyn_veg
|
||||
PYTEST_MARKS "SUITE_periodic and dynveg_filter"
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
@@ -64,7 +61,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
TEST_SUITE periodic
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/dyn_veg
|
||||
PYTEST_MARKS "SUITE_periodic and dynveg_modifier"
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
@@ -79,7 +75,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
TEST_SUITE periodic
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/dyn_veg
|
||||
PYTEST_MARKS "SUITE_periodic and dynveg_regression"
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
@@ -94,7 +89,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
TEST_SUITE periodic
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/dyn_veg
|
||||
PYTEST_MARKS "SUITE_periodic and dynveg_area"
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
@@ -109,7 +103,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
TEST_SUITE periodic
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/dyn_veg
|
||||
PYTEST_MARKS "SUITE_periodic and dynveg_misc"
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
@@ -124,7 +117,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
TEST_SUITE periodic
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/dyn_veg
|
||||
PYTEST_MARKS "SUITE_periodic and dynveg_surfacetagemitter"
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
@@ -132,15 +124,14 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
COMPONENT
|
||||
LargeWorlds
|
||||
)
|
||||
|
||||
## LandscapeCanvas ##
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::LandscapeCanvasTests_Main
|
||||
TEST_SERIAL
|
||||
TEST_SUITE main
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/landscape_canvas
|
||||
PYTEST_MARKS "not SUITE_sandbox and not SUITE_periodic and not SUITE_benchmark"
|
||||
TIMEOUT 1500
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/landscape_canvas/TestSuite_Main.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
@@ -153,9 +144,20 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
NAME AutomatedTesting::LandscapeCanvasTests_Periodic
|
||||
TEST_SERIAL
|
||||
TEST_SUITE periodic
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/landscape_canvas
|
||||
PYTEST_MARKS "SUITE_periodic"
|
||||
TIMEOUT 1500
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/landscape_canvas/TestSuite_Periodic.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
LargeWorlds
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::LandscapeCanvasTests_Main_Optimized
|
||||
TEST_SERIAL
|
||||
TEST_SUITE main
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/landscape_canvas/TestSuite_Main_Optimized.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
@@ -165,12 +167,25 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
)
|
||||
|
||||
## GradientSignal ##
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::GradientSignalTests_Periodic
|
||||
TEST_SERIAL
|
||||
TEST_SUITE periodic
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/gradient_signal
|
||||
TIMEOUT 1500
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/gradient_signal/TestSuite_Periodic.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
LargeWorlds
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::GradientSignalTests_Periodic_Optimized
|
||||
TEST_SERIAL
|
||||
TEST_SUITE periodic
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/gradient_signal/TestSuite_Periodic_Optimized.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
|
||||
+16
-9
@@ -10,6 +10,7 @@ import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.math as math
|
||||
@@ -107,7 +108,7 @@ class TestPhysXColliderSurfaceTagEmitter(EditorTestHelper):
|
||||
# Create an entity with a PhysX Collider and our PhysX Collider Surface Tag Emitter
|
||||
collider_entity = hydra.Entity("Collider Surface")
|
||||
collider_entity.create_entity(
|
||||
entity_center_point,
|
||||
entity_center_point,
|
||||
["PhysX Collider", "PhysX Collider Surface Tag Emitter"]
|
||||
)
|
||||
if collider_entity.id.IsValid():
|
||||
@@ -153,23 +154,29 @@ class TestPhysXColliderSurfaceTagEmitter(EditorTestHelper):
|
||||
self.test_success = self.test_success and baseline_success
|
||||
|
||||
# Setup collider entity with a PhysX Mesh
|
||||
test_physx_mesh_asset_path = asset.AssetCatalogRequestBus(
|
||||
test_physx_mesh_asset_id = asset.AssetCatalogRequestBus(
|
||||
bus.Broadcast, "GetAssetIdByPath", os.path.join("levels", "physics",
|
||||
"c4044697_material_perfacematerialvalidation",
|
||||
"test.pxmesh"), math.Uuid(), False)
|
||||
hydra.get_set_test(collider_entity, 0, "Shape Configuration|Shape", 7)
|
||||
hydra.get_set_test(collider_entity, 0, "Shape Configuration|Asset|PhysX Mesh", test_physx_mesh_asset_path)
|
||||
|
||||
# Remove/re-add component due to LYN-5496
|
||||
collider_entity.remove_component("PhysX Collider")
|
||||
collider_entity.add_component("PhysX Collider")
|
||||
self.wait_for_condition(lambda: editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled',
|
||||
collider_entity.components[1]), 5.0)
|
||||
hydra.get_set_test(collider_entity, 1, "Shape Configuration|Shape", 7)
|
||||
hydra.get_set_test(collider_entity, 1, "Shape Configuration|Asset|PhysX Mesh", test_physx_mesh_asset_id)
|
||||
|
||||
# Set the asset scale to match the test heights of the shapes tested
|
||||
asset_scale = math.Vector3(1.0, 1.0, 9.0)
|
||||
collider_entity.get_set_test(0, "Shape Configuration|Asset|Configuration|Asset Scale", asset_scale)
|
||||
collider_entity.get_set_test(1, "Shape Configuration|Asset|Configuration|Asset Scale", asset_scale)
|
||||
|
||||
# Test: Generate a new surface on the collider.
|
||||
# There should be one instance at the very top of the collider mesh, and none on the baseline surface
|
||||
# (We use a small query box to only check for one placed instance point)
|
||||
self.log("Starting PhysX Mesh Collider Test")
|
||||
hydra.get_set_test(collider_entity, 1, "Configuration|Generated Tags", [surface_tag])
|
||||
hydra.get_set_test(collider_entity, 1, "Configuration|Extended Tags", [invalid_tag])
|
||||
hydra.get_set_test(collider_entity, 0, "Configuration|Generated Tags", [surface_tag])
|
||||
hydra.get_set_test(collider_entity, 0, "Configuration|Extended Tags", [invalid_tag])
|
||||
top_point_success = self.wait_for_condition(lambda: dynveg.validate_instance_count(top_point, 0.25, 1), 5.0)
|
||||
self.test_success = self.test_success and top_point_success
|
||||
baseline_success = self.wait_for_condition(lambda: dynveg.validate_instance_count(baseline_surface_point,
|
||||
@@ -180,8 +187,8 @@ class TestPhysXColliderSurfaceTagEmitter(EditorTestHelper):
|
||||
# There should be no instances at the very top of the collider mesh, and none on the baseline surface within
|
||||
# our query box as PhysX meshes are treated as hollow shells, not solid volumes.
|
||||
# (We use a small query box to only check for one placed instance point)
|
||||
hydra.get_set_test(collider_entity, 1, "Configuration|Generated Tags", [invalid_tag])
|
||||
hydra.get_set_test(collider_entity, 1, "Configuration|Extended Tags", [surface_tag])
|
||||
hydra.get_set_test(collider_entity, 0, "Configuration|Generated Tags", [invalid_tag])
|
||||
hydra.get_set_test(collider_entity, 0, "Configuration|Extended Tags", [surface_tag])
|
||||
top_point_success = self.wait_for_condition(lambda: dynveg.validate_instance_count(top_point, 0.25, 0), 5.0)
|
||||
self.test_success = self.test_success and top_point_success
|
||||
baseline_success = self.wait_for_condition(lambda: dynveg.validate_instance_count(baseline_surface_point,
|
||||
|
||||
+96
-102
@@ -4,124 +4,118 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
|
||||
class TestGradientGeneratorIncompatibilities(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientGeneratorIncompatibilities", args=["level"])
|
||||
def GradientGenerators_Incompatibilities():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that components are disabled when conflicting components are present on the same entity.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that components are disabled when conflicting components are present on the same entity.
|
||||
Expected Behavior:
|
||||
Gradient Generator components are incompatible with Vegetation area components.
|
||||
|
||||
Expected Behavior:
|
||||
Gradient Generator components are incompatible with Vegetation area components.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Create a new entity in the level
|
||||
3) Add each Gradient Generator component to an entity, and add a Vegetation Area component to the same entity
|
||||
4) Verify that components are only enabled when entity is free of a conflicting component
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Create a new entity in the level
|
||||
3) Add each Gradient Generator component to an entity, and add a Vegetation Area component to the same entity
|
||||
4) Verify that components are only enabled when entity is free of a conflicting component
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
|
||||
gradient_generators = [
|
||||
'Altitude Gradient',
|
||||
'Constant Gradient',
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient',
|
||||
'Shape Falloff Gradient',
|
||||
'Slope Gradient',
|
||||
'Surface Mask Gradient'
|
||||
]
|
||||
require_transform_modifiers = [
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient'
|
||||
]
|
||||
vegetation_areas = [
|
||||
'Vegetation Layer Spawner',
|
||||
'Vegetation Layer Blender',
|
||||
'Vegetation Layer Blocker',
|
||||
'Vegetation Layer Blocker (Mesh)'
|
||||
]
|
||||
area_dependencies = {
|
||||
'Vegetation Layer Spawner': 'Vegetation Asset List',
|
||||
'Vegetation Layer Blocker (Mesh)': 'Mesh'
|
||||
}
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
gradient_generators = [
|
||||
'Altitude Gradient',
|
||||
'Constant Gradient',
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient',
|
||||
'Shape Falloff Gradient',
|
||||
'Slope Gradient',
|
||||
'Surface Mask Gradient'
|
||||
]
|
||||
require_transform_modifiers = [
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient'
|
||||
]
|
||||
vegetation_areas = [
|
||||
'Vegetation Layer Spawner',
|
||||
'Vegetation Layer Blender',
|
||||
'Vegetation Layer Blocker',
|
||||
'Vegetation Layer Blocker (Mesh)'
|
||||
]
|
||||
area_dependencies = {
|
||||
'Vegetation Layer Spawner': 'Vegetation Asset List',
|
||||
'Vegetation Layer Blocker (Mesh)': 'Mesh'
|
||||
}
|
||||
|
||||
# For every gradient generator component, verify that they are incompatible
|
||||
# which each vegetation area component
|
||||
for component_name in gradient_generators:
|
||||
for vegetation_area_name in vegetation_areas:
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Most of these need a shape, so use a Box Shape
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
# For every gradient generator component, verify that they are incompatible
|
||||
# which each vegetation area component
|
||||
for component_name in gradient_generators:
|
||||
for vegetation_area_name in vegetation_areas:
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Add the specific vegetation area dependencies (if necessary)
|
||||
if vegetation_area_name in area_dependencies:
|
||||
hydra.add_component(area_dependencies[vegetation_area_name], entity_id)
|
||||
# Most of these need a shape, so use a Box Shape
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
|
||||
# Add the vegetation area component we are validating against, then add the
|
||||
# gradient generator afterwards, so that the gradient generator will actually
|
||||
# be disabled (if it was present before, it would only get deactivated instead of disabled
|
||||
# by the vegetation area)
|
||||
area_component = hydra.add_component(vegetation_area_name, entity_id)
|
||||
gradient_component = hydra.add_component(component_name, entity_id)
|
||||
# Add the specific vegetation area dependencies (if necessary)
|
||||
if vegetation_area_name in area_dependencies:
|
||||
hydra.add_component(area_dependencies[vegetation_area_name], entity_id)
|
||||
|
||||
# Verify the gradient generator component is disabled since the vegetation area is incompatible
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
self.test_success = self.test_success and not active
|
||||
if not active:
|
||||
self.log(f"{component_name} is disabled before removing {vegetation_area_name} component")
|
||||
# Add the vegetation area component we are validating against, then add the
|
||||
# gradient generator afterwards, so that the gradient generator will actually
|
||||
# be disabled (if it was present before, it would only get deactivated instead of disabled
|
||||
# by the vegetation area)
|
||||
area_component = hydra.add_component(vegetation_area_name, entity_id)
|
||||
gradient_component = hydra.add_component(component_name, entity_id)
|
||||
|
||||
# Remove the vegetation area component
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [area_component])
|
||||
# Verify the gradient generator component is disabled since the vegetation area is incompatible
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
component_is_disabled = (
|
||||
f"{component_name} is disabled before removing {vegetation_area_name} component",
|
||||
f"{component_name} is unexpectedly enabled before removing {vegetation_area_name} component"
|
||||
)
|
||||
Report.result(component_is_disabled, not active)
|
||||
|
||||
# Add required dependencies for our gradient generators after the vegetation
|
||||
# area has been removed, because the transform modifier is also incompatible
|
||||
# with the vegetation areas
|
||||
if component_name in require_transform_modifiers:
|
||||
hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
# Remove the vegetation area component
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [area_component])
|
||||
|
||||
# Verify the gradient generator component is enabled now that the vegetation area is gone
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
self.test_success = self.test_success and active
|
||||
if active:
|
||||
self.log(f"{component_name} is enabled after removing {vegetation_area_name} component")
|
||||
# Add required dependencies for our gradient generators after the vegetation
|
||||
# area has been removed, because the transform modifier is also incompatible
|
||||
# with the vegetation areas
|
||||
if component_name in require_transform_modifiers:
|
||||
hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
|
||||
# Verify the gradient generator component is enabled now that the vegetation area is gone
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
component_is_enabled = (
|
||||
f"{component_name} is enabled after removing {vegetation_area_name} component",
|
||||
f"{component_name} is unexpectedly disabled after removing {vegetation_area_name} component"
|
||||
)
|
||||
Report.result(component_is_enabled, active)
|
||||
|
||||
|
||||
test = TestGradientGeneratorIncompatibilities()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientGenerators_Incompatibilities)
|
||||
|
||||
+133
-135
@@ -4,164 +4,162 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
|
||||
class TestGradientModifiersIncompatibilities(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientModifiersIncompatibilities", args=["level"])
|
||||
def GradientModifiers_Incompatibilities():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that components are disabled when conflicting components are present on the same entity.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that components are disabled when conflicting components are present on the same entity.
|
||||
Expected Behavior:
|
||||
Gradient Modifier components are incompatible with Vegetation area components.
|
||||
|
||||
Expected Behavior:
|
||||
Gradient Modifier components are incompatible with Vegetation area components.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Create a new entity in the level
|
||||
3) Add each Gradient Modifier component to an entity, and add a Vegetation Area component to the same entity
|
||||
4) Verify that components are only enabled when entity is free of a conflicting component
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Create a new entity in the level
|
||||
3) Add each Gradient Modifier component to an entity, and add a Vegetation Area component to the same entity
|
||||
4) Verify that components are only enabled when entity is free of a conflicting component
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
|
||||
gradient_generators = [
|
||||
'Altitude Gradient',
|
||||
'Constant Gradient',
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient',
|
||||
'Shape Falloff Gradient',
|
||||
'Slope Gradient',
|
||||
'Surface Mask Gradient'
|
||||
]
|
||||
require_transform_modifiers = [
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient'
|
||||
]
|
||||
gradient_modifiers = [
|
||||
'Dither Gradient Modifier',
|
||||
'Gradient Mixer',
|
||||
'Invert Gradient Modifier',
|
||||
'Levels Gradient Modifier',
|
||||
'Posterize Gradient Modifier',
|
||||
'Smooth-Step Gradient Modifier',
|
||||
'Threshold Gradient Modifier'
|
||||
]
|
||||
vegetation_areas = [
|
||||
'Vegetation Layer Spawner',
|
||||
'Vegetation Layer Blender',
|
||||
'Vegetation Layer Blocker',
|
||||
'Vegetation Layer Blocker (Mesh)'
|
||||
]
|
||||
area_dependencies = {
|
||||
'Vegetation Layer Spawner': 'Vegetation Asset List',
|
||||
'Vegetation Layer Blocker (Mesh)': 'Mesh'
|
||||
}
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
gradient_generators = [
|
||||
'Altitude Gradient',
|
||||
'Constant Gradient',
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient',
|
||||
'Shape Falloff Gradient',
|
||||
'Slope Gradient',
|
||||
'Surface Mask Gradient'
|
||||
]
|
||||
require_transform_modifiers = [
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient'
|
||||
]
|
||||
gradient_modifiers = [
|
||||
'Dither Gradient Modifier',
|
||||
'Gradient Mixer',
|
||||
'Invert Gradient Modifier',
|
||||
'Levels Gradient Modifier',
|
||||
'Posterize Gradient Modifier',
|
||||
'Smooth-Step Gradient Modifier',
|
||||
'Threshold Gradient Modifier'
|
||||
]
|
||||
vegetation_areas = [
|
||||
'Vegetation Layer Spawner',
|
||||
'Vegetation Layer Blender',
|
||||
'Vegetation Layer Blocker',
|
||||
'Vegetation Layer Blocker (Mesh)'
|
||||
]
|
||||
area_dependencies = {
|
||||
'Vegetation Layer Spawner': 'Vegetation Asset List',
|
||||
'Vegetation Layer Blocker (Mesh)': 'Mesh'
|
||||
}
|
||||
|
||||
# For every gradient modifier component, verify that they are incompatible
|
||||
# which each vegetation area and gradient generator/modifier component
|
||||
all_gradients = gradient_modifiers + gradient_generators
|
||||
for component_name in gradient_modifiers:
|
||||
for vegetation_area_name in vegetation_areas:
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Most of these need a shape, so use a Box Shape
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
# For every gradient modifier component, verify that they are incompatible
|
||||
# which each vegetation area and gradient generator/modifier component
|
||||
all_gradients = gradient_modifiers + gradient_generators
|
||||
for component_name in gradient_modifiers:
|
||||
for vegetation_area_name in vegetation_areas:
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Add the specific vegetation area dependencies (if necessary)
|
||||
if vegetation_area_name in area_dependencies:
|
||||
hydra.add_component(area_dependencies[vegetation_area_name], entity_id)
|
||||
# Most of these need a shape, so use a Box Shape
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
|
||||
# Add the vegetation area component we are validating against, then add the
|
||||
# gradient modifier afterwards, so that the gradient modifier will actually
|
||||
# be disabled (if it was present before, it would only get deactivated instead of disabled
|
||||
# by the vegetation area)
|
||||
area_component = hydra.add_component(vegetation_area_name, entity_id)
|
||||
gradient_component = hydra.add_component(component_name, entity_id)
|
||||
# Add the specific vegetation area dependencies (if necessary)
|
||||
if vegetation_area_name in area_dependencies:
|
||||
hydra.add_component(area_dependencies[vegetation_area_name], entity_id)
|
||||
|
||||
# Verify the gradient modifier component is disabled since the vegetation area is incompatible
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
self.test_success = self.test_success and not active
|
||||
if not active:
|
||||
self.log("{gradient} is disabled before removing {vegetation_area} component".format(gradient=component_name, vegetation_area=vegetation_area_name))
|
||||
# Add the vegetation area component we are validating against, then add the
|
||||
# gradient modifier afterwards, so that the gradient modifier will actually
|
||||
# be disabled (if it was present before, it would only get deactivated instead of disabled
|
||||
# by the vegetation area)
|
||||
area_component = hydra.add_component(vegetation_area_name, entity_id)
|
||||
gradient_component = hydra.add_component(component_name, entity_id)
|
||||
|
||||
# Remove the vegetation area component
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [area_component])
|
||||
# Verify the gradient modifier component is disabled since the vegetation area is incompatible
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
component_is_disabled = (
|
||||
f"{component_name} is disabled before removing {vegetation_area_name} component",
|
||||
f"{component_name} is unexpectedly enabled before removing {vegetation_area_name} component"
|
||||
)
|
||||
Report.result(component_is_disabled, not active)
|
||||
|
||||
# Verify the gradient modifier component is enabled now that the vegetation area is gone
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
self.test_success = self.test_success and active
|
||||
if active:
|
||||
self.log("{gradient} is enabled after removing {vegetation_area} component".format(gradient=component_name, vegetation_area=vegetation_area_name))
|
||||
# Remove the vegetation area component
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [area_component])
|
||||
|
||||
for gradient_name in all_gradients:
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
# Verify the gradient modifier component is enabled now that the vegetation area is gone
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
component_is_enabled = (
|
||||
f"{component_name} is enabled after removing {vegetation_area_name} component",
|
||||
f"{component_name} is unexpectedly disabled after removing {vegetation_area_name} component"
|
||||
)
|
||||
Report.result(component_is_enabled, active)
|
||||
|
||||
# Most of these need a shape, so use a Box Shape
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
for gradient_name in all_gradients:
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Add the specific gradient generator dependencies (if necessary)
|
||||
conflicting_components = []
|
||||
if gradient_name in require_transform_modifiers:
|
||||
component = hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
conflicting_components.append(component)
|
||||
# Most of these need a shape, so use a Box Shape
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
|
||||
# Add the gradient component we are validating against, then add the
|
||||
# gradient modifier afterwards, so that the gradient modifier will actually
|
||||
# be disabled (if it was present before, it would only get deactivated instead of disabled
|
||||
# by the other gradient)
|
||||
component = hydra.add_component(gradient_name, entity_id)
|
||||
# Add the specific gradient generator dependencies (if necessary)
|
||||
conflicting_components = []
|
||||
if gradient_name in require_transform_modifiers:
|
||||
component = hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
conflicting_components.append(component)
|
||||
gradient_component = hydra.add_component(component_name, entity_id)
|
||||
|
||||
# Verify the gradient modifier component is disabled since the other gradient is incompatible
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
self.test_success = self.test_success and not active
|
||||
if not active:
|
||||
self.log("{gradient} is disabled before removing {conflicting_gradient} component".format(gradient=component_name, conflicting_gradient=gradient_name))
|
||||
# Add the gradient component we are validating against, then add the
|
||||
# gradient modifier afterwards, so that the gradient modifier will actually
|
||||
# be disabled (if it was present before, it would only get deactivated instead of disabled
|
||||
# by the other gradient)
|
||||
component = hydra.add_component(gradient_name, entity_id)
|
||||
conflicting_components.append(component)
|
||||
gradient_component = hydra.add_component(component_name, entity_id)
|
||||
|
||||
# Remove the conflicting gradient component (and transform modifier if it was added)
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', conflicting_components)
|
||||
# Verify the gradient modifier component is disabled since the other gradient is incompatible
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
component_is_disabled = (
|
||||
f"{component_name} is disabled before removing {gradient_name} component",
|
||||
f"{component_name} is unexpectedly enabled before removing {gradient_name} component"
|
||||
)
|
||||
Report.result(component_is_disabled, not active)
|
||||
|
||||
# Verify the gradient modifier component is enabled now that the other gradient is gone
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
self.test_success = self.test_success and active
|
||||
if active:
|
||||
self.log("{gradient} is enabled after removing {conflicting_gradient} component".format(gradient=component_name, conflicting_gradient=gradient_name))
|
||||
# Remove the conflicting gradient component (and transform modifier if it was added)
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', conflicting_components)
|
||||
|
||||
# Verify the gradient modifier component is enabled now that the other gradient is gone
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
component_is_enabled = (
|
||||
f"{component_name} is enabled after removing {gradient_name} component",
|
||||
f"{component_name} is unexpectedly disabled after removing {gradient_name} component"
|
||||
)
|
||||
Report.result(component_is_enabled, active)
|
||||
|
||||
|
||||
test = TestGradientModifiersIncompatibilities()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientModifiers_Incompatibilities)
|
||||
|
||||
+98
-102
@@ -5,129 +5,125 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
import azlmbr.entity as EntityId
|
||||
def GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin():
|
||||
"""
|
||||
Summary:
|
||||
A temporary level is created. An entity for each test case is created and added with the corresponding
|
||||
components to verify if the gradient transform is set to the world origin.
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
Expected Behavior:
|
||||
1) Preview image updates to reflect change in transform of the gradient sampler.
|
||||
2) New Preview Position property is exposed, and set to 0,0,0 (world origin).
|
||||
3) Preview Size is set to 1,1,1 by default.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create entity with Random Noise gradient and verify gradient position after clearing pinned entity
|
||||
3) Create entity with Levels Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
4) Create entity with Posterize Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
5) Create entity with Smooth-Step Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
6) Create entity with Threshold Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
7) Create entity with FastNoise Gradient and verify gradient position after clearing pinned entity
|
||||
8) Create entity with Dither Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
9) Create entity with Invert Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
10) Create entity with Perlin Noise Gradient and verify gradient position after clearing pinned entity
|
||||
|
||||
class TestGradientPreviewSettings(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientPreviewSettings_ClearPinnedEntity", args=["level"])
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
A temporary level is created. An entity for each test case is created and added with the corresponding
|
||||
components to verify if the gradient transform is set to the world origin.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Expected Behavior:
|
||||
1) Preview image updates to reflect change in transform of the gradient sampler.
|
||||
2) New Preview Position property is exposed, and set to 0,0,0 (world origin).
|
||||
3) Preview Size is set to 1,1,1 by default.
|
||||
import sys
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create entity with Random Noise gradient and verify gradient position after clearing pinned entity
|
||||
3) Create entity with Levels Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
4) Create entity with Posterize Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
5) Create entity with Smooth-Step Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
6) Create entity with Threshold Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
7) Create entity with FastNoise Gradient and verify gradient position after clearing pinned entity
|
||||
8) Create entity with Dither Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
9) Create entity with Invert Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
10) Create entity with Perlin Noise Gradient and verify gradient position after clearing pinned entity
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.entity as EntityId
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
:return: None
|
||||
"""
|
||||
WORLD_ORIGIN = math.Vector3(0.0, 0.0, 0.0)
|
||||
EXPECTED_SIZE = math.Vector3(1.0, 1.0, 1.0)
|
||||
CLOSE_THRESHOLD = sys.float_info.min
|
||||
|
||||
WORLD_ORIGIN = math.Vector3(0.0, 0.0, 0.0)
|
||||
EXPECTED_SIZE = math.Vector3(1.0, 1.0, 1.0)
|
||||
CLOSE_THRESHOLD = sys.float_info.min
|
||||
def create_entity(entity_name, components_to_add):
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
entity_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
entity = hydra.Entity(entity_name, entity_id)
|
||||
if entity_id.IsValid():
|
||||
print(f"{entity_name} entity Created")
|
||||
entity.components = []
|
||||
for component in components_to_add:
|
||||
entity.components.append(hydra.add_component(component, entity_id))
|
||||
return entity
|
||||
|
||||
def create_entity(enity_name, components_to_add):
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
entity_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
def clear_entityid_check_position(entity_name, components_to_add, check_preview_size=False):
|
||||
entity = create_entity(entity_name, components_to_add)
|
||||
hydra.get_set_test(entity, 0, "Preview Settings|Pin Preview to Shape", EntityId.EntityId())
|
||||
preview_position = hydra.get_component_property_value(
|
||||
entity.components[0], "Preview Settings|Preview Position"
|
||||
)
|
||||
preview_set_to_origin = (
|
||||
f"{entity_name}: Preview Position set to world origin",
|
||||
f"{entity_name}: Preview Position set to unexpected coords"
|
||||
)
|
||||
Report.result(preview_set_to_origin, preview_position.IsClose(WORLD_ORIGIN, CLOSE_THRESHOLD))
|
||||
if check_preview_size:
|
||||
preview_size = hydra.get_component_property_value(entity.components[0], "Preview Settings|Preview Size")
|
||||
preview_size_default_set = (
|
||||
f"{entity_name}: Preview Size set as expected",
|
||||
f"{entity_name}: Preview Size set to unexpected value. Expected {EXPECTED_SIZE}, Found {preview_size}"
|
||||
)
|
||||
entity = hydra.Entity(enity_name, entity_id)
|
||||
if entity_id.IsValid():
|
||||
print(f"{enity_name} entity Created")
|
||||
entity.components = []
|
||||
for component in components_to_add:
|
||||
entity.components.append(hydra.add_component(component, entity_id))
|
||||
return entity
|
||||
Report.result(preview_size_default_set, preview_size.IsClose(EXPECTED_SIZE, CLOSE_THRESHOLD))
|
||||
return entity
|
||||
|
||||
def clear_entityid_check_position(entity_name, components_to_add, check_preview_size=False):
|
||||
entity = create_entity(entity_name, components_to_add)
|
||||
hydra.get_set_test(entity, 0, "Preview Settings|Pin Preview to Shape", EntityId.EntityId())
|
||||
preview_position = hydra.get_component_property_value(
|
||||
entity.components[0], "Preview Settings|Preview Position"
|
||||
)
|
||||
if preview_position.IsClose(WORLD_ORIGIN, CLOSE_THRESHOLD):
|
||||
print(f"{entity_name} --- Preview Position set to world origin")
|
||||
if check_preview_size:
|
||||
preview_size = hydra.get_component_property_value(entity.components[0], "Preview Settings|Preview Size")
|
||||
if preview_size.IsClose(EXPECTED_SIZE, CLOSE_THRESHOLD):
|
||||
print(f"{entity_name} --- Preview Size set to (1, 1, 1)")
|
||||
return entity
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# 1) Open level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
# 2) Create entity with Random Noise gradient and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position(
|
||||
"Random Noise Gradient", ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"], True
|
||||
)
|
||||
|
||||
# 2) Create entity with Random Noise gradient and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position(
|
||||
"Random Noise Gradient", ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"], True
|
||||
)
|
||||
# 3) Create entity with Levels Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Levels Gradient Modifier", ["Levels Gradient Modifier"])
|
||||
|
||||
# 3) Create entity with Levels Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Levels Gradient Modifier", ["Levels Gradient Modifier"])
|
||||
# 4) Create entity with Posterize Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Posterize Gradient Modifier", ["Posterize Gradient Modifier"])
|
||||
|
||||
# 4) Create entity with Posterize Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Posterize Gradient Modifier", ["Posterize Gradient Modifier"])
|
||||
# 5) Create entity with Smooth-Step Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Smooth-Step Gradient Modifier", ["Smooth-Step Gradient Modifier"])
|
||||
|
||||
# 5) Create entity with Smooth-Step Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Smooth-Step Gradient Modifier", ["Smooth-Step Gradient Modifier"])
|
||||
# 6) Create entity with Threshold Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Threshold Gradient Modifier", ["Threshold Gradient Modifier"])
|
||||
|
||||
# 6) Create entity with Threshold Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Threshold Gradient Modifier", ["Threshold Gradient Modifier"])
|
||||
# 7) Create entity with FastNoise Gradient and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position(
|
||||
"FastNoise Gradient", ["FastNoise Gradient", "Gradient Transform Modifier", "Box Shape"], True
|
||||
)
|
||||
|
||||
# 7) Create entity with FastNoise Gradient and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position(
|
||||
"FastNoise Gradient", ["FastNoise Gradient", "Gradient Transform Modifier", "Box Shape"], True
|
||||
)
|
||||
# 8) Create entity with Dither Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Dither Gradient Modifier", ["Dither Gradient Modifier"], True)
|
||||
|
||||
# 8) Create entity with Dither Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Dither Gradient Modifier", ["Dither Gradient Modifier"], True)
|
||||
# 9) Create entity with Invert Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Invert Gradient Modifier", ["Invert Gradient Modifier"])
|
||||
|
||||
# 9) Create entity with Invert Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Invert Gradient Modifier", ["Invert Gradient Modifier"])
|
||||
|
||||
# 10) Create entity with Perlin Noise Gradient and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position(
|
||||
"Perlin Noise Gradient", ["Perlin Noise Gradient", "Gradient Transform Modifier", "Box Shape"], True
|
||||
)
|
||||
# 10) Create entity with Perlin Noise Gradient and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position(
|
||||
"Perlin Noise Gradient", ["Perlin Noise Gradient", "Gradient Transform Modifier", "Box Shape"], True
|
||||
)
|
||||
|
||||
|
||||
test = TestGradientPreviewSettings()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin)
|
||||
|
||||
+70
-79
@@ -5,18 +5,6 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
|
||||
class Scoped:
|
||||
def __init__(self, constructor, destructor, *args):
|
||||
@@ -33,81 +21,84 @@ class TestParams:
|
||||
self.accessed_component = accessed_component
|
||||
|
||||
|
||||
class TestGradientPreviewSettings(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientPreviewSettings_DefaultPinnedEntity", args=["level"])
|
||||
def GradientPreviewSettings_DefaultPinnedEntityIsSelf():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies default values for the pinned entity for Gradient Preview settings.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies default values for the pinned entity for Gradient Preview settings.
|
||||
Expected Behavior:
|
||||
Pinned entity is self for all gradient generator/modifiers.
|
||||
|
||||
Expected Behavior:
|
||||
Pinned entity is self for all gradient generator/modifiers.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Create a new entity in the level
|
||||
3) Add each Gradient Generator component to an entity, and verify the Pin Preview to Shape property is set to
|
||||
self
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Create a new entity in the level
|
||||
3) Add each Gradient Generator component to an entity, and verify the Pin Preview to Shape property is set to
|
||||
self
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
|
||||
def execute_test(test_id, function, *args):
|
||||
if function(*args):
|
||||
self.log(test_id + ' has Preview pinned to own Entity result: SUCCESS')
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
def create_entity():
|
||||
return editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
def delete_entity(entity_id):
|
||||
editor.ToolsApplicationRequestBus(bus.Broadcast, 'DeleteEntityAndAllDescendants', entity_id)
|
||||
|
||||
def attach_components(component_list, entity_id):
|
||||
components = []
|
||||
for i in component_list:
|
||||
components.append(hydra.add_component(i, entity_id))
|
||||
return components
|
||||
|
||||
def validate_id_is_current(param):
|
||||
entity_ptr = Scoped(create_entity, delete_entity)
|
||||
added_components = attach_components(param.required_components, entity_ptr.data)
|
||||
value = hydra.get_component_property_value(added_components[param.accessed_component],
|
||||
'Preview Settings|Pin Preview to Shape')
|
||||
self.test_success = self.test_success and entity_ptr.data.Equal(value)
|
||||
return entity_ptr.data.Equal(value)
|
||||
|
||||
param_list = [
|
||||
TestParams(['Gradient Transform Modifier', 'Box Shape', 'Perlin Noise Gradient'], 2),
|
||||
TestParams(['Random Noise Gradient', 'Gradient Transform Modifier', 'Box Shape'], 0),
|
||||
TestParams(['FastNoise Gradient', 'Gradient Transform Modifier', 'Box Shape'], 0),
|
||||
TestParams(['Dither Gradient Modifier'], 0),
|
||||
TestParams(['Invert Gradient Modifier'], 0),
|
||||
TestParams(['Levels Gradient Modifier'], 0),
|
||||
TestParams(['Posterize Gradient Modifier'], 0),
|
||||
TestParams(['Smooth-Step Gradient Modifier'], 0),
|
||||
TestParams(['Threshold Gradient Modifier'], 0)
|
||||
]
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
def execute_test(test_id, function, *args):
|
||||
pinned_to_self = (
|
||||
f"{test_id} has Preview pinned to self",
|
||||
f"{test_id} has Preview pinned to a different entity"
|
||||
)
|
||||
Report.result(pinned_to_self, function(*args))
|
||||
|
||||
for param in param_list:
|
||||
execute_test(param.required_components[param.accessed_component],
|
||||
validate_id_is_current, param)
|
||||
def create_entity():
|
||||
return editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
def delete_entity(entity_id):
|
||||
editor.ToolsApplicationRequestBus(bus.Broadcast, 'DeleteEntityAndAllDescendants', entity_id)
|
||||
|
||||
def attach_components(component_list, entity_id):
|
||||
components = []
|
||||
for i in component_list:
|
||||
components.append(hydra.add_component(i, entity_id))
|
||||
return components
|
||||
|
||||
def validate_id_is_current(param):
|
||||
entity_ptr = Scoped(create_entity, delete_entity)
|
||||
added_components = attach_components(param.required_components, entity_ptr.data)
|
||||
value = hydra.get_component_property_value(added_components[param.accessed_component],
|
||||
'Preview Settings|Pin Preview to Shape')
|
||||
return entity_ptr.data.Equal(value)
|
||||
|
||||
param_list = [
|
||||
TestParams(['Gradient Transform Modifier', 'Box Shape', 'Perlin Noise Gradient'], 2),
|
||||
TestParams(['Random Noise Gradient', 'Gradient Transform Modifier', 'Box Shape'], 0),
|
||||
TestParams(['FastNoise Gradient', 'Gradient Transform Modifier', 'Box Shape'], 0),
|
||||
TestParams(['Dither Gradient Modifier'], 0),
|
||||
TestParams(['Invert Gradient Modifier'], 0),
|
||||
TestParams(['Levels Gradient Modifier'], 0),
|
||||
TestParams(['Posterize Gradient Modifier'], 0),
|
||||
TestParams(['Smooth-Step Gradient Modifier'], 0),
|
||||
TestParams(['Threshold Gradient Modifier'], 0)
|
||||
]
|
||||
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
for param in param_list:
|
||||
execute_test(param.required_components[param.accessed_component],
|
||||
validate_id_is_current, param)
|
||||
|
||||
|
||||
test = TestGradientPreviewSettings()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientPreviewSettings_DefaultPinnedEntityIsSelf)
|
||||
|
||||
+67
-77
@@ -5,92 +5,82 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
import azlmbr.entity as EntityId
|
||||
def GradientSampling_GradientReferencesAddRemoveSuccessfully():
|
||||
"""
|
||||
Summary:
|
||||
An existing gradient generator can be pinned and cleared to/from the Gradient Entity Id field
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
Expected Behavior:
|
||||
Gradient generator is assigned to the Gradient Entity Id field.
|
||||
Gradient generator is removed from the field.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with components "Random Noise Gradient", "Gradient Transform Modifier" and "Box Shape"
|
||||
3) Create a new entity with Gradient Modifier's, pin and clear the random noise entity id to the Gradient Id
|
||||
field in Gradient Modifier
|
||||
|
||||
class TestGradientSampling(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientSampling_GradientReferences", args=["level"])
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
An existing gradient generator can be pinned and cleared to/from the Gradient Entity Id field
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Expected Behavior:
|
||||
Gradient generator is assigned to the Gradient Entity Id field.
|
||||
Gradient generator is removed from the field.
|
||||
import azlmbr.math as math
|
||||
import azlmbr.entity as EntityId
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with components "Random Noise Gradient", "Gradient Transform Modifier" and "Box Shape"
|
||||
3) Create a new entity with Gradient Modifier's, pin and clear the random noise entity id to the Gradient Id
|
||||
field in Gradient Modifier
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
def modifier_pin_clear_to_gradiententityid(modifier):
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
component_to_add = [modifier]
|
||||
gradient_modifier = hydra.Entity(modifier)
|
||||
gradient_modifier.create_entity(entity_position, component_to_add)
|
||||
gradient_modifier.get_set_test(0, "Configuration|Gradient|Gradient Entity Id", random_noise.id)
|
||||
entity = hydra.get_component_property_value(
|
||||
gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id"
|
||||
)
|
||||
if entity.Equal(random_noise.id):
|
||||
print(f"Gradient Generator is pinned to the {modifier} successfully")
|
||||
else:
|
||||
print(f"Failed to pin Gradient Generator to the {modifier}")
|
||||
hydra.get_set_test(gradient_modifier, 0, "Configuration|Gradient|Gradient Entity Id", EntityId.EntityId())
|
||||
entity = hydra.get_component_property_value(
|
||||
gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id"
|
||||
)
|
||||
if entity.Equal(EntityId.EntityId()):
|
||||
print(f"Gradient Generator is cleared from the {modifier} successfully")
|
||||
else:
|
||||
print(f"Failed to clear Gradient Generator from the {modifier}")
|
||||
|
||||
# 1) Open level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# 2) Create a new entity with components "Random Noise Gradient", "Gradient Transform Modifier" and "Box Shape"
|
||||
def modifier_pin_clear_to_gradiententityid(modifier):
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"]
|
||||
random_noise = hydra.Entity("Random_Noise")
|
||||
random_noise.create_entity(entity_position, components_to_add)
|
||||
component_to_add = [modifier]
|
||||
gradient_modifier = hydra.Entity(modifier)
|
||||
gradient_modifier.create_entity(entity_position, component_to_add)
|
||||
gradient_modifier.get_set_test(0, "Configuration|Gradient|Gradient Entity Id", random_noise.id)
|
||||
entity = hydra.get_component_property_value(
|
||||
gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id"
|
||||
)
|
||||
gradient_pinned_to_modifier = (
|
||||
f"Gradient Generator is pinned to the {modifier} successfully",
|
||||
f"Failed to pin Gradient Generator to the {modifier}"
|
||||
)
|
||||
Report.result(gradient_pinned_to_modifier, entity.Equal(random_noise.id))
|
||||
hydra.get_set_test(gradient_modifier, 0, "Configuration|Gradient|Gradient Entity Id", EntityId.EntityId())
|
||||
entity = hydra.get_component_property_value(
|
||||
gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id"
|
||||
)
|
||||
gradient_cleared_from_modifier = (
|
||||
f"Gradient Generator is cleared from the {modifier} successfully",
|
||||
f"Failed to clear Gradient Generator from the {modifier}"
|
||||
)
|
||||
Report.result(gradient_cleared_from_modifier, entity.Equal(EntityId.EntityId()))
|
||||
|
||||
# 3) Create a new entity with Gradient Modifier's, pin and clear the random noise entity id to the Gradient Id
|
||||
# field in Gradient Modifier
|
||||
modifier_pin_clear_to_gradiententityid("Dither Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Invert Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Levels Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Posterize Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Smooth-Step Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Threshold Gradient Modifier")
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# 2) Create a new entity with components "Random Noise Gradient", "Gradient Transform Modifier" and "Box Shape"
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"]
|
||||
random_noise = hydra.Entity("Random_Noise")
|
||||
random_noise.create_entity(entity_position, components_to_add)
|
||||
|
||||
# 3) Create a new entity with Gradient Modifier's, pin and clear the random noise entity id to the Gradient Id
|
||||
# field in Gradient Modifier
|
||||
modifier_pin_clear_to_gradiententityid("Dither Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Invert Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Levels Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Posterize Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Smooth-Step Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Threshold Gradient Modifier")
|
||||
|
||||
|
||||
test = TestGradientSampling()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientSampling_GradientReferencesAddRemoveSuccessfully)
|
||||
|
||||
+95
-105
@@ -5,114 +5,104 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import azlmbr.math as math
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
import azlmbr.editor as editor
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests"))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
|
||||
class TestGradientSurfaceTagEmitterDependencies(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(
|
||||
self, log_prefix="GradientSurfaceTagEmitter_ComponentDependencies", args=["level"]
|
||||
def GradientSurfaceTagEmitter_ComponentDependencies():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Gradient Surface Tag Emitter component is dependent on a gradient component.
|
||||
|
||||
Expected Result:
|
||||
Gradient Surface Tag Emitter component is disabled until a Gradient Generator, Modifier or Gradient Reference
|
||||
component (and any sub-dependencies) is added to the entity.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with a Gradient Surface Tag Emitter component
|
||||
3) Verify the component is disabled until a dependent component is also added to the entity
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.math as math
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.editor as editor
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
def is_enabled(EntityComponentIdPair):
|
||||
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Create an entity with Gradient Surface Tag Emitter component
|
||||
position = math.Vector3(512.0, 512.0, 32.0)
|
||||
gradient = hydra.Entity("gradient")
|
||||
gradient.create_entity(position, ["Gradient Surface Tag Emitter"])
|
||||
|
||||
# Make sure Gradient Surface Tag Emitter is disabled
|
||||
gradient_surface_tag_disabled = (
|
||||
"Gradient Surface Tag Emitter is Disabled",
|
||||
"Gradient Surface Tag Emitter is Enabled, but should be Disabled without dependencies met"
|
||||
)
|
||||
Report.result(gradient_surface_tag_disabled, not is_enabled(gradient.components[0]))
|
||||
|
||||
# Verify Gradient Surface Tag Emitter component is enabled after adding Gradient, Generator, Modifier
|
||||
# or Reference component
|
||||
new_components_to_add = [
|
||||
"Dither Gradient Modifier",
|
||||
"Gradient Mixer",
|
||||
"Invert Gradient Modifier",
|
||||
"Levels Gradient Modifier",
|
||||
"Posterize Gradient Modifier",
|
||||
"Smooth-Step Gradient Modifier",
|
||||
"Threshold Gradient Modifier",
|
||||
"Altitude Gradient",
|
||||
"Constant Gradient",
|
||||
"FastNoise Gradient",
|
||||
"Image Gradient",
|
||||
"Perlin Noise Gradient",
|
||||
"Random Noise Gradient",
|
||||
"Reference Gradient",
|
||||
"Shape Falloff Gradient",
|
||||
"Slope Gradient",
|
||||
"Surface Mask Gradient",
|
||||
]
|
||||
for component in new_components_to_add:
|
||||
component_list = ["FastNoise Gradient", "Image Gradient", "Perlin Noise Gradient", "Random Noise Gradient"]
|
||||
if component in component_list:
|
||||
for Component in ["Gradient Transform Modifier", "Box Shape"]:
|
||||
hydra.add_component(Component, gradient.id)
|
||||
typeIdsList = editor.EditorComponentAPIBus(bus.Broadcast, 'FindComponentTypeIdsByEntityType', [component],
|
||||
entity.EntityType().Game)
|
||||
ComponentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentsOfType', gradient.id, [typeIdsList[0]])
|
||||
Components = ComponentOutcome.GetValue()
|
||||
ComponentIdPair = Components[0]
|
||||
gradient_enabled = is_enabled(gradient.components[0])
|
||||
new_components_enabled = is_enabled(ComponentIdPair)
|
||||
dependencies_met = (
|
||||
f"{component} and Gradient Surface Tag Emitter are enabled",
|
||||
f"{component} and Gradient Surface Tag Emitter are disabled"
|
||||
)
|
||||
Report.result(dependencies_met, new_components_enabled and gradient_enabled)
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Gradient Surface Tag Emitter component is dependent on a gradient component.
|
||||
|
||||
Expected Result:
|
||||
Gradient Surface Tag Emitter component is disabled until a Gradient Generator, Modifier or Gradient Reference
|
||||
component (and any sub-dependencies) is added to the entity.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with a Gradient Surface Tag Emitter component
|
||||
3) Verify the component is disabled until a dependent component is also added to the entity
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
def is_enabled(EntityComponentIdPair):
|
||||
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
|
||||
|
||||
# Create empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# Create an entity with Gradient Surface Tag Emitter component
|
||||
position = math.Vector3(512.0, 512.0, 32.0)
|
||||
gradient = hydra.Entity("gradient")
|
||||
gradient.create_entity(position, ["Gradient Surface Tag Emitter"])
|
||||
|
||||
# Make sure Gradient Surface Tag Emitter is disabled
|
||||
is_enable = is_enabled(gradient.components[0])
|
||||
if not is_enable:
|
||||
self.log("Gradient Surface Tag Emitter is Disabled")
|
||||
elif not is_enable:
|
||||
self.log("Gradient Surface Tag Emitter is Enabled, but should be Disabled without dependencies met")
|
||||
|
||||
# Verify Gradient Surface Tag Emitter component is enabled after adding Gradient, Generator, Modifier
|
||||
# or Reference component
|
||||
new_components_to_add = [
|
||||
"Dither Gradient Modifier",
|
||||
"Gradient Mixer",
|
||||
"Invert Gradient Modifier",
|
||||
"Levels Gradient Modifier",
|
||||
"Posterize Gradient Modifier",
|
||||
"Smooth-Step Gradient Modifier",
|
||||
"Threshold Gradient Modifier",
|
||||
"Altitude Gradient",
|
||||
"Constant Gradient",
|
||||
"FastNoise Gradient",
|
||||
"Image Gradient",
|
||||
"Perlin Noise Gradient",
|
||||
"Random Noise Gradient",
|
||||
"Reference Gradient",
|
||||
"Shape Falloff Gradient",
|
||||
"Slope Gradient",
|
||||
"Surface Mask Gradient",
|
||||
]
|
||||
for component in new_components_to_add:
|
||||
component_list = ["FastNoise Gradient", "Image Gradient", "Perlin Noise Gradient", "Random Noise Gradient"]
|
||||
if component in component_list:
|
||||
for Component in ["Gradient Transform Modifier", "Box Shape"]:
|
||||
hydra.add_component(Component, gradient.id)
|
||||
typeIdsList = editor.EditorComponentAPIBus(bus.Broadcast, 'FindComponentTypeIdsByEntityType', [component],
|
||||
entity.EntityType().Game)
|
||||
ComponentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentsOfType', gradient.id, [typeIdsList[0]])
|
||||
Components = ComponentOutcome.GetValue()
|
||||
ComponentIdPair = Components[0]
|
||||
gradient_enabled = new_components_enabled = False
|
||||
gradient_enabled = is_enabled(gradient.components[0])
|
||||
new_components_enabled = is_enabled(ComponentIdPair)
|
||||
if new_components_enabled and gradient_enabled:
|
||||
self.log(f"{component} and Gradient Surface Tag Emitter are enabled")
|
||||
else:
|
||||
self.log(f"{component} and Gradient Surface Tag Emitter are disabled")
|
||||
if component in component_list:
|
||||
hydra.remove_component("Gradient Transform Modifier", gradient.id)
|
||||
hydra.remove_component("Box Shape", gradient.id)
|
||||
hydra.remove_component(component, gradient.id)
|
||||
if component in component_list:
|
||||
hydra.remove_component("Gradient Transform Modifier", gradient.id)
|
||||
hydra.remove_component("Box Shape", gradient.id)
|
||||
hydra.remove_component(component, gradient.id)
|
||||
|
||||
|
||||
test = TestGradientSurfaceTagEmitterDependencies()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientSurfaceTagEmitter_ComponentDependencies)
|
||||
|
||||
+60
-66
@@ -5,75 +5,69 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
import azlmbr.surface_data as surface_data
|
||||
def GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully():
|
||||
"""
|
||||
Summary:
|
||||
Entity with Gradient Surface Tag Emitter and Reference Gradient components is created.
|
||||
And new surface tag has been added and removed.
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
Expected Behavior:
|
||||
A new Surface Tag can be added and removed from the component
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create an entity with Gradient Surface Tag Emitter and Reference Gradient components.
|
||||
3) Add/ remove Surface Tags
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.math as math
|
||||
import azlmbr.surface_data as surface_data
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# 2) Create an entity with Gradient Surface Tag Emitter and Reference Gradient components.
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Gradient Surface Tag Emitter", "Reference Gradient"]
|
||||
entity = hydra.Entity("entity")
|
||||
entity.create_entity(entity_position, components_to_add)
|
||||
|
||||
# 3) Add/ remove Surface Tags
|
||||
tag = surface_data.SurfaceTag()
|
||||
tag.SetTag("water")
|
||||
pte = hydra.get_property_tree(entity.components[0])
|
||||
path = "Configuration|Extended Tags"
|
||||
pte.add_container_item(path, 0, tag)
|
||||
success = helper.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 1, 1.0)
|
||||
tag_added_to_container = (
|
||||
"Successfully added surface tag",
|
||||
"Failed to add surface tag"
|
||||
)
|
||||
Report.result(tag_added_to_container, success)
|
||||
pte.remove_container_item(path, 0)
|
||||
success = helper.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 0, 1.0)
|
||||
tag_removed_from_container = (
|
||||
"Successfully removed surface tag",
|
||||
"Failed to remove surface tag"
|
||||
)
|
||||
Report.result(tag_removed_from_container, success)
|
||||
|
||||
|
||||
class TestGradientSurfaceTagEmitter(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSucessfully",
|
||||
args=["level"])
|
||||
if __name__ == "__main__":
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
Entity with Gradient Surface Tag Emitter and Reference Gradient components is created.
|
||||
And new surface tag has been added and removed.
|
||||
|
||||
Expected Behavior:
|
||||
A new Surface Tag can be added and removed from the component
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully)
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create an entity with Gradient Surface Tag Emitter and Reference Gradient components.
|
||||
3) Add/ remove Surface Tags
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# 1) Open level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# 2) Create an entity with Gradient Surface Tag Emitter and Reference Gradient components.
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Gradient Surface Tag Emitter", "Reference Gradient"]
|
||||
entity = hydra.Entity("entity")
|
||||
entity.create_entity(entity_position, components_to_add)
|
||||
|
||||
# 3) Add/ remove Surface Tags
|
||||
tag = surface_data.SurfaceTag()
|
||||
tag.SetTag("water")
|
||||
pte = hydra.get_property_tree(entity.components[0])
|
||||
path = "Configuration|Extended Tags"
|
||||
pte.add_container_item(path, 0, tag)
|
||||
success = self.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 1)
|
||||
self.test_success = self.test_success and success
|
||||
print(f"Added SurfaceTag: container count is {pte.get_container_count(path).GetValue()}")
|
||||
pte.remove_container_item(path, 0)
|
||||
success = self.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 0)
|
||||
self.test_success = self.test_success and success
|
||||
print(f"Removed SurfaceTag: container count is {pte.get_container_count(path).GetValue()}")
|
||||
|
||||
|
||||
test = TestGradientSurfaceTagEmitter()
|
||||
test.run()
|
||||
|
||||
+81
-97
@@ -5,118 +5,102 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.entity as EntityId
|
||||
def GradientTransform_ComponentIncompatibleWithExpectedGradients():
|
||||
"""
|
||||
Summary:
|
||||
A New level is created. A New entity is created with components Gradient Transform Modifier and Box Shape.
|
||||
Adding components Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
|
||||
Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity.
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
Expected Behavior:
|
||||
All added components are disabled and inform the user that they are incompatible with the Gradient Transform
|
||||
Modifier
|
||||
|
||||
Test Steps:
|
||||
1) Create level
|
||||
2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
3) Make sure all components are enabled in Entity
|
||||
4) Add Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
|
||||
Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity
|
||||
5) Make sure all newly added components are disabled
|
||||
|
||||
class TestGradientTransform_ComponentIncompatibleWithExpectedGradients(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientTransform_ComponentIncompatibleWithExpectedGradients",
|
||||
args=["level"])
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
A New level is created. A New entity is created with components Gradient Transform Modifier and Box Shape.
|
||||
Adding components Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
|
||||
Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Expected Behavior:
|
||||
All added components are disabled and inform the user that they are incompatible with the Gradient Transform
|
||||
Modifier
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.entity as EntityId
|
||||
|
||||
Test Steps:
|
||||
1) Create level
|
||||
2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
3) Make sure all components are enabled in Entity
|
||||
4) Add Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
|
||||
Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity
|
||||
5) Make sure all newly added components are disabled
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
def is_enabled(EntityComponentIdPair):
|
||||
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
def is_enabled(EntityComponentIdPair):
|
||||
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
|
||||
# 2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Gradient Transform Modifier", "Box Shape"]
|
||||
gradient_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
gradient = hydra.Entity("gradient", gradient_id)
|
||||
|
||||
# 1) Create level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
gradient.components = []
|
||||
|
||||
for component in components_to_add:
|
||||
gradient.components.append(hydra.add_component(component, gradient_id))
|
||||
entity_created = (
|
||||
"Entity created successfully",
|
||||
"Failed to create entity"
|
||||
)
|
||||
Report.critical_result(entity_created, gradient_id.isValid())
|
||||
|
||||
# 3) Make sure all components are enabled in Entity
|
||||
index = 0
|
||||
for component in components_to_add:
|
||||
components_enabled = (
|
||||
f"{component} is enabled",
|
||||
f"{component} is unexpectedly disabled"
|
||||
)
|
||||
Report.critical_result(components_enabled, is_enabled(gradient.components[index]))
|
||||
index += 1
|
||||
|
||||
# 2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Gradient Transform Modifier", "Box Shape"]
|
||||
gradient_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
# 4) Add Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
|
||||
# Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity
|
||||
new_components_to_add = [
|
||||
"Constant Gradient",
|
||||
"Altitude Gradient",
|
||||
"Gradient Mixer",
|
||||
"Reference Gradient",
|
||||
"Shape Falloff Gradient",
|
||||
"Slope Gradient",
|
||||
"Surface Mask Gradient",
|
||||
]
|
||||
new_components_enabled = False
|
||||
for component in new_components_to_add:
|
||||
gradient.components.append(hydra.add_component(component, gradient_id))
|
||||
gradient_components_disabled = (
|
||||
f"{component} is disabled",
|
||||
f"{component} is enabled, but should be disabled"
|
||||
)
|
||||
gradient = hydra.Entity("gradient", gradient_id)
|
||||
|
||||
gradient.components = []
|
||||
|
||||
for component in components_to_add:
|
||||
gradient.components.append(hydra.add_component(component, gradient_id))
|
||||
if gradient_id.isValid():
|
||||
self.log("New Entity Created")
|
||||
|
||||
# 3) Make sure all components are enabled in Entity
|
||||
index = 0
|
||||
for component in components_to_add:
|
||||
is_enable = is_enabled(gradient.components[index])
|
||||
if is_enable:
|
||||
self.log(f"{component} is Enabled")
|
||||
self.test_success = self.test_success and is_enable
|
||||
elif not is_enable:
|
||||
self.log(f"{component} is disabled, but it should be enabled")
|
||||
self.test_success = self.test_success and is_enable
|
||||
break
|
||||
index += 1
|
||||
|
||||
# 4) Add Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
|
||||
# Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity
|
||||
new_components_to_add = [
|
||||
"Constant Gradient",
|
||||
"Altitude Gradient",
|
||||
"Gradient Mixer",
|
||||
"Reference Gradient",
|
||||
"Shape Falloff Gradient",
|
||||
"Slope Gradient",
|
||||
"Surface Mask Gradient",
|
||||
]
|
||||
index = 2
|
||||
new_components_enabled = False
|
||||
for component in new_components_to_add:
|
||||
gradient.components.append(hydra.add_component(component, gradient_id))
|
||||
new_components_enabled = is_enabled(gradient.components[index])
|
||||
if new_components_enabled:
|
||||
self.log(f"{component} is enabled, but should be disabled")
|
||||
break
|
||||
Report.result(gradient_components_disabled, not is_enabled(gradient.components[2]))
|
||||
if not is_enabled(gradient.components[2]):
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, "RemoveComponents", component)
|
||||
|
||||
# 5) Make sure all newly added components are disabled
|
||||
if not new_components_enabled:
|
||||
self.log("All newly added components are incompatible and disabled")
|
||||
self.test_success = self.test_success and not new_components_enabled
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
test = TestGradientTransform_ComponentIncompatibleWithExpectedGradients()
|
||||
test.run()
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientTransform_ComponentIncompatibleWithExpectedGradients)
|
||||
|
||||
+69
-85
@@ -5,104 +5,88 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.entity as EntityId
|
||||
def GradientTransform_ComponentIncompatibleWithSpawners():
|
||||
"""
|
||||
Summary:
|
||||
A simple level is opened. A New entity is created with components Gradient Transform Modifier and Box Shape.
|
||||
Adding a component Vegetation Layer Spawner to the same entity.
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
Expected Behavior:
|
||||
The Vegetation Layer Spawner is deactivated and it is communicated that it is incompatible with Gradient
|
||||
Transform Modifier
|
||||
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
3) Make sure all components are enabled in Entity
|
||||
4) Add Vegetation Layer Spawner to the same entity
|
||||
5) Make sure newly added component is disabled
|
||||
|
||||
class TestGradientTransform_ComponentIncompatibleWithSpawners(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientTransform_ComponentIncompatibleWithSpawners",
|
||||
args=["level"])
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
A New level is created. A New entity is created with components Gradient Transform Modifier and Box Shape.
|
||||
Adding a component Vegetation Layer Spawner to the same entity.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Expected Behavior:
|
||||
The Vegetation Layer Spawner is deactivated and it is communicated that it is incompatible with Gradient
|
||||
Transform Modifier
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.entity as EntityId
|
||||
|
||||
Test Steps:
|
||||
1) Create level
|
||||
2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
3) Make sure all components are enabled in Entity
|
||||
4) Add Vegetation Layer Spawner to the same entity
|
||||
5) Make sure newly added component is disabled
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
def is_enabled(EntityComponentIdPair):
|
||||
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
def is_enabled(EntityComponentIdPair):
|
||||
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
|
||||
# 2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Gradient Transform Modifier", "Box Shape"]
|
||||
gradient_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
gradient = hydra.Entity("gradient", gradient_id)
|
||||
|
||||
# 1) Create level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
gradient.components = []
|
||||
|
||||
for component in components_to_add:
|
||||
gradient.components.append(hydra.add_component(component, gradient_id))
|
||||
entity_created = (
|
||||
"Entity created successfully",
|
||||
"Failed to create entity"
|
||||
)
|
||||
Report.critical_result(entity_created, gradient_id.isValid())
|
||||
|
||||
# 3) Make sure all components are enabled in Entity
|
||||
index = 0
|
||||
for component in components_to_add:
|
||||
components_enabled = (
|
||||
f"{component} is enabled",
|
||||
f"{component} is unexpectedly disabled"
|
||||
)
|
||||
Report.critical_result(components_enabled, is_enabled(gradient.components[index]))
|
||||
index += 1
|
||||
|
||||
# 2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Gradient Transform Modifier", "Box Shape"]
|
||||
gradient_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
gradient = hydra.Entity("gradient", gradient_id)
|
||||
# 4) Add Vegetation Layer Spawner to the same entity
|
||||
gradient.components.append(hydra.add_component("Vegetation Layer Spawner", gradient_id))
|
||||
|
||||
gradient.components = []
|
||||
|
||||
for component in components_to_add:
|
||||
gradient.components.append(hydra.add_component(component, gradient_id))
|
||||
if gradient_id.isValid():
|
||||
self.log("New Entity Created")
|
||||
|
||||
# 3) Make sure all components are enabled in Entity
|
||||
index = 0
|
||||
for component in components_to_add:
|
||||
is_enable = is_enabled(gradient.components[index])
|
||||
if is_enable:
|
||||
self.log(f"{component} is Enabled")
|
||||
self.test_success = self.test_success and is_enable
|
||||
elif not is_enable:
|
||||
self.log(f"{component} is Disabled. But It should be Enabled in an Entity")
|
||||
self.test_success = self.test_success and is_enable
|
||||
break
|
||||
index += 1
|
||||
|
||||
# 4) Add Vegetation Layer Spawner to the same entity
|
||||
new_component_to_add = "Vegetation Layer Spawner"
|
||||
index = 2
|
||||
gradient.components.append(hydra.add_component(new_component_to_add, gradient_id))
|
||||
new_component_enabled = is_enabled(gradient.components[index])
|
||||
|
||||
# 5) Make sure newly added component is disabled
|
||||
if not new_component_enabled:
|
||||
self.log(f"{new_component_to_add} is incompatible and disabled")
|
||||
self.test_success = self.test_success and not new_component_enabled
|
||||
elif new_component_enabled:
|
||||
self.log(f"{new_component_to_add} is compatible and enabled. But It should be Incompatible and disabled")
|
||||
self.test_success = self.test_success and new_component_enabled
|
||||
# 5) Make sure newly added component is disabled
|
||||
spawner_component_disabled = (
|
||||
"Spawner component is disabled",
|
||||
"Spawner component is unexpectedly enabled"
|
||||
)
|
||||
Report.result(spawner_component_disabled, not is_enabled(gradient.components[2]))
|
||||
|
||||
|
||||
test = TestGradientTransform_ComponentIncompatibleWithSpawners()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientTransform_ComponentIncompatibleWithSpawners)
|
||||
|
||||
+64
-69
@@ -5,87 +5,82 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
"""
|
||||
C3430292: Frequency Zoom can manually be set higher than 8.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
import azlmbr.entity as EntityId
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
class Tests:
|
||||
entity_created = (
|
||||
"Entity created successfully",
|
||||
"Failed to create entity"
|
||||
)
|
||||
components_added = (
|
||||
"All expected components added to entity",
|
||||
"Failed to add expected components to entity"
|
||||
)
|
||||
higher_zoom_value_set = (
|
||||
"Frequency Zoom is equal to expected value",
|
||||
"Frequency Zoom is not equal to expected value"
|
||||
)
|
||||
|
||||
|
||||
class TestGradientTransformFrequencyZoom(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientTransform_FrequencyZoomBeyondSliders", args=["level"])
|
||||
def GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange():
|
||||
"""
|
||||
Summary:
|
||||
Frequency Zoom can manually be set higher than 8 in a random noise gradient
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
Frequency Zoom can manually be set higher than 8 in a random noise gradient
|
||||
Expected Behavior:
|
||||
The value properly changes, despite the value being outside of the slider limit
|
||||
|
||||
Expected Behavior:
|
||||
The value properly changes, despite the value being outside of the slider limit
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create entity
|
||||
3) Add components to the entity
|
||||
4) Set the frequency value of the component
|
||||
5) Verify if the frequency value is set to higher value
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create entity
|
||||
3) Add components to the entity
|
||||
4) Set the frequency value of the component
|
||||
5) Verify if the frequency value is set to higher value
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.entity as EntityId
|
||||
|
||||
# 1) Open level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# 2) Create entity
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
entity_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
if entity_id.IsValid():
|
||||
print("Entity Created")
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# 3) Add components to the entity
|
||||
components_to_add = ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"]
|
||||
entity = hydra.Entity("entity", entity_id)
|
||||
entity.components = []
|
||||
for component in components_to_add:
|
||||
entity.components.append(hydra.add_component(component, entity_id))
|
||||
print("Components added to the entity")
|
||||
# 2) Create entity
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
entity_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
Report.critical_result(Tests.entity_created, entity_id.IsValid())
|
||||
|
||||
# 4) Set the frequency value of the component
|
||||
hydra.get_set_test(entity, 1, "Configuration|Frequency Zoom", 10)
|
||||
# 3) Add components to the entity
|
||||
components_to_add = ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"]
|
||||
entity = hydra.Entity("entity", entity_id)
|
||||
entity.components = []
|
||||
for component in components_to_add:
|
||||
entity.components.append(hydra.add_component(component, entity_id))
|
||||
Report.critical_result(Tests.components_added, len(entity.components) == 3)
|
||||
|
||||
# 5) Verify if the frequency value is set to higher value
|
||||
curr_value = hydra.get_component_property_value(entity.components[1], "Configuration|Frequency Zoom")
|
||||
if curr_value == 10.0:
|
||||
print("Frequency Zoom is equal to expected value")
|
||||
else:
|
||||
print("Frequency Zoom is not equal to expected value")
|
||||
# 4) Set the frequency value of the component
|
||||
hydra.get_set_test(entity, 1, "Configuration|Frequency Zoom", 10)
|
||||
|
||||
# 5) Verify if the frequency value is set to higher value
|
||||
curr_value = hydra.get_component_property_value(entity.components[1], "Configuration|Frequency Zoom")
|
||||
Report.result(Tests.higher_zoom_value_set, curr_value == 10.0)
|
||||
|
||||
|
||||
test = TestGradientTransformFrequencyZoom()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange)
|
||||
|
||||
+64
-66
@@ -4,73 +4,71 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
|
||||
class TestGradientTransformRequiresShape(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientTransformRequiresShape", args=["level"])
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Gradient Transform Modifier component is dependent on a shape component.
|
||||
|
||||
Expected Result:
|
||||
Gradient Transform Modifier component is disabled until a shape component is added to the entity.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with a Gradient Transform Modifier component
|
||||
3) Verify the component is disabled until a shape component is also added to the entity
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Add a Gradient Transform Component (that will be disabled since there is no shape on the Entity)
|
||||
gradient_transform_component = hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
|
||||
# Verify the Gradient Transform Component is not active before adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_transform_component)
|
||||
self.test_success = self.test_success and not active
|
||||
if not active:
|
||||
self.log("Gradient Transform component is not active without a Shape component on the Entity")
|
||||
|
||||
# Add a Shape component to the same Entity
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
|
||||
# Check if the Gradient Transform Component is active now after adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_transform_component)
|
||||
self.test_success = self.test_success and active
|
||||
if active:
|
||||
self.log("Gradient Transform Modifier component is active now that the Entity has a Shape")
|
||||
class Tests:
|
||||
disabled_without_shape = (
|
||||
"Gradient Transform Modifier component is disabled without a Shape component on the Entity",
|
||||
"Gradient Transform Modifier component is unexpectedly enabled without a Shape component on the Entity",
|
||||
)
|
||||
enabled_with_shape = (
|
||||
"Gradient Transform Modifier component is enabled now that the Entity has a Shape",
|
||||
"Gradient Transform Modifier component is still disabled alongside a Shape component",
|
||||
)
|
||||
|
||||
|
||||
test = TestGradientTransformRequiresShape()
|
||||
test.run()
|
||||
def GradientTransform_RequiresShape():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Gradient Transform Modifier component is dependent on a shape component.
|
||||
|
||||
Expected Result:
|
||||
Gradient Transform Modifier component is disabled until a shape component is added to the entity.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with a Gradient Transform Modifier component
|
||||
3) Verify the component is disabled until a shape component is also added to the entity
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Add a Gradient Transform Component (that will be disabled since there is no shape on the Entity)
|
||||
gradient_transform_component = hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
|
||||
# Verify the Gradient Transform Component is not active before adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_transform_component)
|
||||
Report.result(Tests.disabled_without_shape, not active)
|
||||
|
||||
# Add a Shape component to the same Entity
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
|
||||
# Check if the Gradient Transform Component is active now after adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_transform_component)
|
||||
Report.result(Tests.enabled_with_shape, active)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientTransform_RequiresShape)
|
||||
|
||||
+73
-71
@@ -5,89 +5,91 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.entity as EntityId
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
class Tests:
|
||||
image_gradient_entity_created = (
|
||||
"Image Gradient entity created",
|
||||
"Failed to create Image Gradient entity",
|
||||
)
|
||||
image_gradient_asset_found = (
|
||||
"image_grad_test_gsi.png was found in the workspace",
|
||||
"image_grad_test_gsi.png was not found in the workspace"
|
||||
)
|
||||
image_gradient_assigned = (
|
||||
"Successfully assigned image gradient asset",
|
||||
"Failed to assign image gradient asset"
|
||||
)
|
||||
|
||||
|
||||
class TestImageGradient(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="ImageGradient_ProcessedImageAssignedSucessfully",
|
||||
args=["level"])
|
||||
def ImageGradient_ProcessedImageAssignedSuccessfully():
|
||||
"""
|
||||
Summary:
|
||||
Level created with Entity having Image Gradient and Gradient Transform Modifier components.
|
||||
Save any new image to your workspace with the suffix "_gsi" and assign as image asset.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
Level created with Entity having Image Gradient and Gradient Transform Modifier components.
|
||||
Save any new image to your workspace with the suffix "_gsi" and assign as image asset.
|
||||
|
||||
Expected Behavior:
|
||||
Image can be assigned as the Image Asset for the Image as Gradient component.
|
||||
Expected Behavior:
|
||||
Image can be assigned as the Image Asset for the Image as Gradient component.
|
||||
|
||||
Test Steps:
|
||||
1) Create level
|
||||
2) Create an entity with Image Gradient and Gradient Transform Modifier components.
|
||||
3) Assign the newly processed gradient image as Image asset.
|
||||
Test Steps:
|
||||
1) Open a level
|
||||
2) Create an entity with Image Gradient and Gradient Transform Modifier components.
|
||||
3) Assign the newly processed gradient image as Image asset.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# 1) Create level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
import os
|
||||
|
||||
# 2) Create an entity with Image Gradient and Gradient Transform Modifier components
|
||||
components_to_add = ["Image Gradient", "Gradient Transform Modifier", "Box Shape"]
|
||||
entity_position = math.Vector3(512.0, 512.0, 32.0)
|
||||
new_entity_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
if new_entity_id.IsValid():
|
||||
print("Image Gradient Entity created")
|
||||
image_gradient_entity = hydra.Entity("Image Gradient Entity", new_entity_id)
|
||||
image_gradient_entity.components = []
|
||||
for component in components_to_add:
|
||||
image_gradient_entity.add_component(component)
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.entity as EntityId
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
|
||||
# 3) Assign the processed gradient signal image as the Image Gradient's image asset and verify success
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# First, check for the base image in the workspace
|
||||
base_image = "image_grad_test_gsi.png"
|
||||
base_image_path = os.path.join("AutomatedTesting", "Assets", "ImageGradients", base_image)
|
||||
if os.path.isfile(base_image_path):
|
||||
print(f"{base_image} was found in the workspace")
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Next, assign the processed image to the Image Gradient's Image Asset property
|
||||
processed_image_path = os.path.join("Assets", "ImageGradients", "image_grad_test_gsi.gradimage")
|
||||
asset_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", processed_image_path, math.Uuid(),
|
||||
False)
|
||||
hydra.get_set_test(image_gradient_entity, 0, "Configuration|Image Asset", asset_id)
|
||||
# 2) Create an entity with Image Gradient and Gradient Transform Modifier components
|
||||
components_to_add = ["Image Gradient", "Gradient Transform Modifier", "Box Shape"]
|
||||
entity_position = math.Vector3(512.0, 512.0, 32.0)
|
||||
new_entity_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
Report.critical_result(Tests.image_gradient_entity_created, new_entity_id.IsValid())
|
||||
image_gradient_entity = hydra.Entity("Image Gradient Entity", new_entity_id)
|
||||
image_gradient_entity.components = []
|
||||
for component in components_to_add:
|
||||
image_gradient_entity.add_component(component)
|
||||
|
||||
# Finally, verify if the gradient image is assigned as the Image Asset
|
||||
success = hydra.get_component_property_value(image_gradient_entity.components[0], "Configuration|Image Asset") == asset_id
|
||||
self.test_success = self.test_success and success
|
||||
# 3) Assign the processed gradient signal image as the Image Gradient's image asset and verify success
|
||||
|
||||
# First, check for the base image in the workspace
|
||||
base_image = "image_grad_test_gsi.png"
|
||||
base_image_path = os.path.join("AutomatedTesting", "Assets", "ImageGradients", base_image)
|
||||
Report.critical_result(Tests.image_gradient_asset_found, os.path.isfile(base_image_path))
|
||||
|
||||
# Next, assign the processed image to the Image Gradient's Image Asset property
|
||||
processed_image_path = os.path.join("Assets", "ImageGradients", "image_grad_test_gsi.gradimage")
|
||||
asset_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", processed_image_path, math.Uuid(),
|
||||
False)
|
||||
hydra.get_set_test(image_gradient_entity, 0, "Configuration|Image Asset", asset_id)
|
||||
|
||||
# Finally, verify if the gradient image is assigned as the Image Asset
|
||||
success = hydra.get_component_property_value(image_gradient_entity.components[0], "Configuration|Image Asset") == asset_id
|
||||
Report.result(Tests.image_gradient_assigned, success)
|
||||
|
||||
|
||||
test = TestImageGradient()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(ImageGradient_ProcessedImageAssignedSuccessfully)
|
||||
|
||||
+65
-67
@@ -4,74 +4,72 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
|
||||
class TestImageGradientRequiresShape(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="ImageGradientRequiresShape", args=["level"])
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Image Gradient component is dependent on a shape component.
|
||||
|
||||
Expected Result:
|
||||
Gradient Transform Modifier component is disabled until a shape component is added to the entity.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with a Image Gradient component
|
||||
3) Verify the component is disabled until a shape component is also added to the entity
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Add an Image Gradient and Gradient Transform Component (should be disabled until a Shape exists on the Entity)
|
||||
image_gradient_component = hydra.add_component('Image Gradient', entity_id)
|
||||
hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
|
||||
# Verify the Image Gradient Component is not active before adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', image_gradient_component)
|
||||
self.test_success = self.test_success and not active
|
||||
if not active:
|
||||
self.log("Image Gradient component is not active without a Shape component on the Entity")
|
||||
|
||||
# Add a Shape component to the same Entity
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
|
||||
# Check if the Image Gradient Component is active now after adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', image_gradient_component)
|
||||
self.test_success = self.test_success and active
|
||||
if active:
|
||||
self.log("Image Gradient component is active now that the Entity has a Shape")
|
||||
class Tests:
|
||||
disabled_without_shape = (
|
||||
"Image Gradient component is disabled without a Shape component on the Entity",
|
||||
"Image Gradient component is unexpectedly enabled without a Shape component on the Entity",
|
||||
)
|
||||
enabled_with_shape = (
|
||||
"Image Gradient component is enabled now that the Entity has a Shape",
|
||||
"Image Gradient component is still disabled alongside a Shape component",
|
||||
)
|
||||
|
||||
|
||||
test = TestImageGradientRequiresShape()
|
||||
test.run()
|
||||
def ImageGradient_RequiresShape():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Image Gradient component is dependent on a shape component.
|
||||
|
||||
Expected Result:
|
||||
Gradient Transform Modifier component is disabled until a shape component is added to the entity.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with a Image Gradient component
|
||||
3) Verify the component is disabled until a shape component is also added to the entity
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Add an Image Gradient and Gradient Transform Component (should be disabled until a Shape exists on the Entity)
|
||||
image_gradient_component = hydra.add_component('Image Gradient', entity_id)
|
||||
hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
|
||||
# Verify the Image Gradient Component is not active before adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', image_gradient_component)
|
||||
Report.result(Tests.disabled_without_shape, not active)
|
||||
|
||||
# Add a Shape component to the same Entity
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
|
||||
# Check if the Image Gradient Component is active now after adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', image_gradient_component)
|
||||
Report.result(Tests.enabled_with_shape, active)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(ImageGradient_RequiresShape)
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../../automatedtesting_shared')
|
||||
from base import TestAutomationBase
|
||||
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomation(TestAutomationBase):
|
||||
|
||||
def test_GradientGenerators_Incompatibilities(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientGenerators_Incompatibilities as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientModifiers_Incompatibilities(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientModifiers_Incompatibilities as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientPreviewSettings_DefaultPinnedEntityIsSelf(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientPreviewSettings_DefaultPinnedEntityIsSelf as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientSampling_GradientReferencesAddRemoveSuccessfully(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientSampling_GradientReferencesAddRemoveSuccessfully as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientSurfaceTagEmitter_ComponentDependencies(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientSurfaceTagEmitter_ComponentDependencies as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientTransform_RequiresShape(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientTransform_RequiresShape as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientTransform_ComponentIncompatibleWithSpawners(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientTransform_ComponentIncompatibleWithSpawners as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientTransform_ComponentIncompatibleWithExpectedGradients(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientTransform_ComponentIncompatibleWithExpectedGradients as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_ImageGradient_RequiresShape(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import ImageGradient_RequiresShape as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_ImageGradient_ProcessedImageAssignedSuccessfully(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import ImageGradient_ProcessedImageAssignedSuccessfully as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from ly_test_tools.o3de.editor_test import EditorSingleTest, EditorSharedTest, EditorParallelTest, EditorTestSuite
|
||||
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomation(EditorTestSuite):
|
||||
|
||||
class test_GradientGenerators_Incompatibilities(EditorSharedTest):
|
||||
from .EditorScripts import GradientGenerators_Incompatibilities as test_module
|
||||
|
||||
class test_GradientModifiers_Incompatibilities(EditorSharedTest):
|
||||
from .EditorScripts import GradientModifiers_Incompatibilities as test_module
|
||||
|
||||
class test_GradientPreviewSettings_DefaultPinnedEntityIsSelf(EditorSharedTest):
|
||||
from .EditorScripts import GradientPreviewSettings_DefaultPinnedEntityIsSelf as test_module
|
||||
|
||||
class test_GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin(EditorSharedTest):
|
||||
from .EditorScripts import GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin as test_module
|
||||
|
||||
class test_GradientSampling_GradientReferencesAddRemoveSuccessfully(EditorSharedTest):
|
||||
from .EditorScripts import GradientSampling_GradientReferencesAddRemoveSuccessfully as test_module
|
||||
|
||||
class test_GradientSurfaceTagEmitter_ComponentDependencies(EditorSharedTest):
|
||||
from .EditorScripts import GradientSurfaceTagEmitter_ComponentDependencies as test_module
|
||||
|
||||
class test_GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully(EditorSharedTest):
|
||||
from .EditorScripts import GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully as test_module
|
||||
|
||||
class test_GradientTransform_RequiresShape(EditorSharedTest):
|
||||
from .EditorScripts import GradientTransform_RequiresShape as test_module
|
||||
|
||||
class test_GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange(EditorSharedTest):
|
||||
from .EditorScripts import GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange as test_module
|
||||
|
||||
class test_GradientTransform_ComponentIncompatibleWithSpawners(EditorSharedTest):
|
||||
from .EditorScripts import GradientTransform_ComponentIncompatibleWithSpawners as test_module
|
||||
|
||||
class test_GradientTransform_ComponentIncompatibleWithExpectedGradients(EditorSharedTest):
|
||||
from .EditorScripts import GradientTransform_ComponentIncompatibleWithExpectedGradients as test_module
|
||||
|
||||
class test_ImageGradient_RequiresShape(EditorSharedTest):
|
||||
from .EditorScripts import ImageGradient_RequiresShape as test_module
|
||||
|
||||
class test_ImageGradient_ProcessedImageAssignedSuccessfully(EditorSharedTest):
|
||||
from .EditorScripts import ImageGradient_ProcessedImageAssignedSuccessfully as test_module
|
||||
-103
@@ -1,103 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
|
||||
"""
|
||||
Tests that the Gradient Generator components are incompatible with Vegetation Area components
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
pytest.importorskip('ly_test_tools')
|
||||
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
import editor_python_test_tools.hydra_test_utils as hydra
|
||||
|
||||
test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts')
|
||||
|
||||
gradient_generators = [
|
||||
'Altitude Gradient',
|
||||
'Constant Gradient',
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient',
|
||||
'Shape Falloff Gradient',
|
||||
'Slope Gradient',
|
||||
'Surface Mask Gradient'
|
||||
]
|
||||
|
||||
gradient_modifiers = [
|
||||
'Dither Gradient Modifier',
|
||||
'Gradient Mixer',
|
||||
'Invert Gradient Modifier',
|
||||
'Levels Gradient Modifier',
|
||||
'Posterize Gradient Modifier',
|
||||
'Smooth-Step Gradient Modifier',
|
||||
'Threshold Gradient Modifier'
|
||||
]
|
||||
|
||||
vegetation_areas = [
|
||||
'Vegetation Layer Spawner',
|
||||
'Vegetation Layer Blender',
|
||||
'Vegetation Layer Blocker',
|
||||
'Vegetation Layer Blocker (Mesh)'
|
||||
]
|
||||
|
||||
all_gradients = gradient_modifiers + gradient_generators
|
||||
|
||||
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['tmp_level'])
|
||||
@pytest.mark.usefixtures("automatic_process_killer")
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
class TestGradientIncompatibilities(object):
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_teardown(self, request, workspace, project, level):
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
@pytest.mark.test_case_id('C2691648', 'C2691649', 'C2691650', 'C2691651',
|
||||
'C2691653', 'C2691656', 'C2691657', 'C2691658',
|
||||
'C2691647', 'C2691655')
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_GradientGenerators_Incompatibilities(self, request, editor, level, launcher_platform):
|
||||
cfg_args = [level]
|
||||
|
||||
expected_lines = []
|
||||
for gradient_generator in gradient_generators:
|
||||
for vegetation_area in vegetation_areas:
|
||||
expected_lines.append(f"{gradient_generator} is disabled before removing {vegetation_area} component")
|
||||
expected_lines.append(f"{gradient_generator} is enabled after removing {vegetation_area} component")
|
||||
expected_lines.append("GradientGeneratorIncompatibilities: result=SUCCESS")
|
||||
hydra.launch_and_validate_results(request, test_directory, editor,
|
||||
'GradientGenerators_Incompatibilities.py',
|
||||
expected_lines=expected_lines, cfg_args=cfg_args)
|
||||
|
||||
@pytest.mark.test_case_id('C3416464', 'C3416546', 'C3961318', 'C3961319',
|
||||
'C3961323', 'C3961324', 'C3980656', 'C3980657',
|
||||
'C3980661', 'C3980662', 'C3980666', 'C3980667',
|
||||
'C2691652')
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_GradientModifiers_Incompatibilities(self, request, editor, level, launcher_platform):
|
||||
cfg_args = [level]
|
||||
|
||||
expected_lines = []
|
||||
for gradient_modifier in gradient_modifiers:
|
||||
for vegetation_area in vegetation_areas:
|
||||
expected_lines.append(f"{gradient_modifier} is disabled before removing {vegetation_area} component")
|
||||
expected_lines.append(f"{gradient_modifier} is enabled after removing {vegetation_area} component")
|
||||
|
||||
for conflicting_gradient in all_gradients:
|
||||
expected_lines.append(f"{gradient_modifier} is disabled before removing {conflicting_gradient} component")
|
||||
expected_lines.append(f"{gradient_modifier} is enabled after removing {conflicting_gradient} component")
|
||||
expected_lines.append("GradientModifiersIncompatibilities: result=SUCCESS")
|
||||
hydra.launch_and_validate_results(request, test_directory, editor,
|
||||
'GradientModifiers_Incompatibilities.py',
|
||||
expected_lines=expected_lines, cfg_args=cfg_args)
|
||||
-118
@@ -1,118 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
# Bail on the test if ly_test_tools doesn't exist.
|
||||
pytest.importorskip('ly_test_tools')
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
import editor_python_test_tools.hydra_test_utils as hydra
|
||||
|
||||
test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['tmp_level'])
|
||||
@pytest.mark.usefixtures("automatic_process_killer")
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
class TestGradientPreviewSettings(object):
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_teardown(self, request, workspace, project, level):
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
@pytest.mark.test_case_id('C3980668', 'C2676825', 'C2676828', 'C2676822', 'C3416547', 'C3961320', 'C3961325',
|
||||
'C3980658', 'C3980663')
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_GradientPreviewSettings_DefaultPinnedEntityIsSelf(self, request, editor, level, launcher_platform):
|
||||
|
||||
expected_lines = [
|
||||
"Perlin Noise Gradient has Preview pinned to own Entity result: SUCCESS",
|
||||
"Random Noise Gradient has Preview pinned to own Entity result: SUCCESS",
|
||||
"FastNoise Gradient has Preview pinned to own Entity result: SUCCESS",
|
||||
"Dither Gradient Modifier has Preview pinned to own Entity result: SUCCESS",
|
||||
"Invert Gradient Modifier has Preview pinned to own Entity result: SUCCESS",
|
||||
"Levels Gradient Modifier has Preview pinned to own Entity result: SUCCESS",
|
||||
"Posterize Gradient Modifier has Preview pinned to own Entity result: SUCCESS",
|
||||
"Smooth-Step Gradient Modifier has Preview pinned to own Entity result: SUCCESS",
|
||||
"Threshold Gradient Modifier has Preview pinned to own Entity result: SUCCESS",
|
||||
"GradientPreviewSettings_DefaultPinnedEntity: result=SUCCESS"
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"GradientPreviewSettings_DefaultPinnedEntityIsSelf.py",
|
||||
expected_lines,
|
||||
cfg_args=[level]
|
||||
)
|
||||
|
||||
@pytest.mark.test_case_id("C2676829", "C3961326", "C3980659", "C3980664", "C3980669", "C3416548", "C2676823",
|
||||
"C3961321", "C2676826")
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin(self, request, editor, level,
|
||||
launcher_platform):
|
||||
|
||||
expected_lines = [
|
||||
"Random Noise Gradient entity Created",
|
||||
"Entity has a Random Noise Gradient component",
|
||||
"Entity has a Gradient Transform Modifier component",
|
||||
"Entity has a Box Shape component",
|
||||
"Random Noise Gradient Preview Settings|Pin Preview to Shape: SUCCESS",
|
||||
"Random Noise Gradient --- Preview Position set to world origin",
|
||||
"Random Noise Gradient --- Preview Size set to (1, 1, 1)",
|
||||
"Levels Gradient Modifier entity Created",
|
||||
"Entity has a Levels Gradient Modifier component",
|
||||
"Levels Gradient Modifier Preview Settings|Pin Preview to Shape: SUCCESS",
|
||||
"Levels Gradient Modifier --- Preview Position set to world origin",
|
||||
"Posterize Gradient Modifier entity Created",
|
||||
"Entity has a Posterize Gradient Modifier component",
|
||||
"Posterize Gradient Modifier Preview Settings|Pin Preview to Shape: SUCCESS",
|
||||
"Posterize Gradient Modifier --- Preview Position set to world origin",
|
||||
"Smooth-Step Gradient Modifier entity Created",
|
||||
"Entity has a Smooth-Step Gradient Modifier component",
|
||||
"Smooth-Step Gradient Modifier Preview Settings|Pin Preview to Shape: SUCCESS",
|
||||
"Smooth-Step Gradient Modifier --- Preview Position set to world origin",
|
||||
"Threshold Gradient Modifier entity Created",
|
||||
"Entity has a Threshold Gradient Modifier component",
|
||||
"Threshold Gradient Modifier Preview Settings|Pin Preview to Shape: SUCCESS",
|
||||
"Threshold Gradient Modifier --- Preview Position set to world origin",
|
||||
"FastNoise Gradient entity Created",
|
||||
"Entity has a FastNoise Gradient component",
|
||||
"FastNoise Gradient Preview Settings|Pin Preview to Shape: SUCCESS",
|
||||
"FastNoise Gradient --- Preview Position set to world origin",
|
||||
"FastNoise Gradient --- Preview Size set to (1, 1, 1)",
|
||||
"Dither Gradient Modifier entity Created",
|
||||
"Entity has a Dither Gradient Modifier component",
|
||||
"Dither Gradient Modifier Preview Settings|Pin Preview to Shape: SUCCESS",
|
||||
"Dither Gradient Modifier --- Preview Position set to world origin",
|
||||
"Dither Gradient Modifier --- Preview Size set to (1, 1, 1)",
|
||||
"Invert Gradient Modifier entity Created",
|
||||
"Entity has a Invert Gradient Modifier component",
|
||||
"Invert Gradient Modifier Preview Settings|Pin Preview to Shape: SUCCESS",
|
||||
"Invert Gradient Modifier --- Preview Position set to world origin",
|
||||
"Perlin Noise Gradient entity Created",
|
||||
"Entity has a Perlin Noise Gradient component",
|
||||
"Perlin Noise Gradient Preview Settings|Pin Preview to Shape: SUCCESS",
|
||||
"Perlin Noise Gradient --- Preview Position set to world origin",
|
||||
"Perlin Noise Gradient --- Preview Size set to (1, 1, 1)",
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin.py",
|
||||
expected_lines,
|
||||
cfg_args=[level]
|
||||
)
|
||||
@@ -1,86 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import logging
|
||||
|
||||
# Bail on the test if ly_test_tools doesn't exist.
|
||||
pytest.importorskip("ly_test_tools")
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
import editor_python_test_tools.hydra_test_utils as hydra
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts")
|
||||
|
||||
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['tmp_level'])
|
||||
@pytest.mark.usefixtures("automatic_process_killer")
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
class TestGradientSampling(object):
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_teardown(self, request, workspace, project, level):
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
@pytest.mark.test_case_id("C3526311")
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_GradientSampling_GradientReferencesAddRemoveSuccessfully(self, request, editor, level, launcher_platform):
|
||||
|
||||
expected_lines = [
|
||||
"Entity has a Random Noise Gradient component",
|
||||
"Entity has a Gradient Transform Modifier component",
|
||||
"Entity has a Box Shape component",
|
||||
"Entity has a Dither Gradient Modifier component",
|
||||
"Gradient Generator is pinned to the Dither Gradient Modifier successfully",
|
||||
"Gradient Generator is cleared from the Dither Gradient Modifier successfully",
|
||||
"Entity has a Invert Gradient Modifier component",
|
||||
"Gradient Generator is pinned to the Invert Gradient Modifier successfully",
|
||||
"Gradient Generator is cleared from the Invert Gradient Modifier successfully",
|
||||
"Entity has a Levels Gradient Modifier component",
|
||||
"Gradient Generator is pinned to the Levels Gradient Modifier successfully",
|
||||
"Gradient Generator is cleared from the Levels Gradient Modifier successfully",
|
||||
"Entity has a Posterize Gradient Modifier component",
|
||||
"Gradient Generator is pinned to the Posterize Gradient Modifier successfully",
|
||||
"Gradient Generator is cleared from the Posterize Gradient Modifier successfully",
|
||||
"Entity has a Smooth-Step Gradient Modifier component",
|
||||
"Gradient Generator is pinned to the Smooth-Step Gradient Modifier successfully",
|
||||
"Gradient Generator is cleared from the Smooth-Step Gradient Modifier successfully",
|
||||
"Entity has a Threshold Gradient Modifier component",
|
||||
"Gradient Generator is pinned to the Threshold Gradient Modifier successfully",
|
||||
"Gradient Generator is cleared from the Threshold Gradient Modifier successfully",
|
||||
]
|
||||
|
||||
unexpected_lines = [
|
||||
"Failed to pin Gradient Generator to the Dither Gradient Modifier",
|
||||
"Failed to clear Gradient Generator from the Dither Gradient Modifier",
|
||||
"Failed to pin Gradient Generator to the Invert Gradient Modifier",
|
||||
"Failed to clear Gradient Generator from the Invert Gradient Modifier",
|
||||
"Failed to pin Gradient Generator to the Levels Gradient Modifier",
|
||||
"Failed to clear Gradient Generator from the Levels Gradient Modifier",
|
||||
"Failed to pin Gradient Generator to the Posterize Gradient Modifier",
|
||||
"Failed to clear Gradient Generator from the Posterize Gradient Modifier",
|
||||
"Failed to pin Gradient Generator to the Smooth-Step Gradient Modifier",
|
||||
"Failed to clear Gradient Generator from the Smooth-Step Gradient Modifier",
|
||||
"Failed to pin Gradient Generator to the Threshold Gradient Modifier",
|
||||
"Failed to clear Gradient Generator from the Threshold Gradient Modifier",
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"GradientSampling_GradientReferencesAddRemoveSuccessfully.py",
|
||||
expected_lines,
|
||||
unexpected_lines,
|
||||
cfg_args=[level]
|
||||
)
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import logging
|
||||
|
||||
# Bail on the test if ly_test_tools doesn't exist.
|
||||
pytest.importorskip("ly_test_tools")
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
import editor_python_test_tools.hydra_test_utils as hydra
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
@pytest.mark.parametrize("level", ["tmp_level"])
|
||||
@pytest.mark.usefixtures("automatic_process_killer")
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
class TestGradientSurfaceTagEmitter(object):
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_teardown(self, request, workspace, project, level):
|
||||
# Cleanup temp level before and after test runs
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
@pytest.mark.test_case_id("C3297302")
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_GradientSurfaceTagEmitter_ComponentDependencies(self, request, editor, level, workspace,
|
||||
launcher_platform):
|
||||
cfg_args = [level]
|
||||
|
||||
expected_lines = [
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: test started",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Gradient Surface Tag Emitter is Disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Dither Gradient Modifier and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Gradient Mixer and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Invert Gradient Modifier and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Levels Gradient Modifier and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Posterize Gradient Modifier and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Smooth-Step Gradient Modifier and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Threshold Gradient Modifier and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Altitude Gradient and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Constant Gradient and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: FastNoise Gradient and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Image Gradient and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Perlin Noise Gradient and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Random Noise Gradient and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Reference Gradient and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Shape Falloff Gradient and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Slope Gradient and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Surface Mask Gradient and Gradient Surface Tag Emitter are enabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: result=SUCCESS",
|
||||
]
|
||||
|
||||
unexpected_lines = [
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Gradient Surface Tag Emitter is Enabled, but should be Disabled without dependencies met",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Dither Gradient Modifier and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Gradient Mixer and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Invert Gradient Modifier and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Levels Gradient Modifier and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Posterize Gradient Modifier and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Smooth-Step Gradient Modifier and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Threshold Gradient Modifier and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Altitude Gradient and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Constant Gradient and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: FastNoise Gradient and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Image Gradient and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Perlin Noise Gradient and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Random Noise Gradient and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Reference Gradient and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Shape Falloff Gradient and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Slope Gradient and Gradient Surface Tag Emitter are disabled",
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies: Surface Mask Gradient and Gradient Surface Tag Emitter are disabled",
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"GradientSurfaceTagEmitter_ComponentDependencies.py",
|
||||
expected_lines=expected_lines,
|
||||
unexpected_lines=unexpected_lines,
|
||||
cfg_args=cfg_args
|
||||
)
|
||||
|
||||
@pytest.mark.test_case_id("C3297303")
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully(self, request, editor, level,
|
||||
launcher_platform):
|
||||
|
||||
expected_lines = [
|
||||
"Entity has a Gradient Surface Tag Emitter component",
|
||||
"Entity has a Reference Gradient component",
|
||||
"Added SurfaceTag: container count is 1",
|
||||
"Removed SurfaceTag: container count is 0",
|
||||
"GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSucessfully: result=SUCCESS"
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully.py",
|
||||
expected_lines,
|
||||
cfg_args=[level]
|
||||
)
|
||||
-157
@@ -1,157 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
|
||||
"""
|
||||
Tests that the Gradient Transform Modifier component isn't enabled unless it has a component on
|
||||
the same Entity that provides the ShapeService (e.g. box shape, or reference shape)
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
# Bail on the test if ly_test_tools doesn't exist.
|
||||
pytest.importorskip('ly_test_tools')
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
import editor_python_test_tools.hydra_test_utils as hydra
|
||||
|
||||
test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['tmp_level'])
|
||||
@pytest.mark.usefixtures("automatic_process_killer")
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
class TestGradientTransformRequiresShape(object):
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_teardown(self, request, workspace, project, level):
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
|
||||
|
||||
@pytest.mark.test_case_id('C3430289')
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_GradientTransform_RequiresShape(self, request, editor, level, launcher_platform):
|
||||
|
||||
expected_lines = [
|
||||
"Gradient Transform Modifier component was added to entity, but the component is disabled",
|
||||
"Gradient Transform component is not active without a Shape component on the Entity",
|
||||
"Box Shape component was added to entity",
|
||||
"Gradient Transform Modifier component is active now that the Entity has a Shape",
|
||||
"GradientTransformRequiresShape: result=SUCCESS"
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"GradientTransform_RequiresShape.py",
|
||||
expected_lines,
|
||||
cfg_args=[level]
|
||||
)
|
||||
|
||||
@pytest.mark.test_case_id("C3430292")
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange(self, request, editor, level, launcher_platform):
|
||||
|
||||
expected_lines = [
|
||||
"Entity Created",
|
||||
"Entity has a Random Noise Gradient component",
|
||||
"Entity has a Gradient Transform Modifier component",
|
||||
"Entity has a Box Shape component",
|
||||
"Components added to the entity",
|
||||
"entity Configuration|Frequency Zoom: SUCCESS",
|
||||
"Frequency Zoom is equal to expected value",
|
||||
]
|
||||
|
||||
unexpected_lines = ["Frequency Zoom is not equal to expected value"]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange.py",
|
||||
expected_lines,
|
||||
unexpected_lines=unexpected_lines,
|
||||
cfg_args=[level]
|
||||
)
|
||||
|
||||
@pytest.mark.test_case_id("C3430297")
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_GradientTransform_ComponentIncompatibleWithSpawners(self, request, editor, launcher_platform, level):
|
||||
# C3430297: Component cannot be active on the same Entity as an active Vegetation Layer Spawner
|
||||
expected_lines = [
|
||||
"Entity has a Gradient Transform Modifier component",
|
||||
"Entity has a Box Shape component",
|
||||
"New Entity Created",
|
||||
"Gradient Transform Modifier is Enabled",
|
||||
"Box Shape is Enabled",
|
||||
"Entity has a Vegetation Layer Spawner component",
|
||||
"Vegetation Layer Spawner is incompatible and disabled",
|
||||
"GradientTransform_ComponentIncompatibleWithSpawners: result=SUCCESS"
|
||||
]
|
||||
|
||||
unexpected_lines = [
|
||||
"Gradient Transform Modifier is Disabled. But It should be Enabled in an Entity",
|
||||
"Box Shape is Disabled. But It should be Enabled in an Entity",
|
||||
"Vegetation Layer Spawner is compatible and enabled. But It should be Incompatible and disabled",
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"GradientTransform_ComponentIncompatibleWithSpawners.py",
|
||||
expected_lines,
|
||||
unexpected_lines,
|
||||
cfg_args=[level]
|
||||
)
|
||||
|
||||
@pytest.mark.test_case_id("C4753767")
|
||||
@pytest.mark.SUITE_periodic
|
||||
def test_GradientTransform_ComponentIncompatibleWithExpectedGradients(self, request, editor, launcher_platform, level):
|
||||
expected_lines = [
|
||||
"Entity has a Gradient Transform Modifier component",
|
||||
"Entity has a Box Shape component",
|
||||
"New Entity Created",
|
||||
"Gradient Transform Modifier is Enabled",
|
||||
"Box Shape is Enabled",
|
||||
"Entity has a Constant Gradient component",
|
||||
"Entity has a Altitude Gradient component",
|
||||
"Entity has a Gradient Mixer component",
|
||||
"Entity has a Reference Gradient component",
|
||||
"Entity has a Shape Falloff Gradient component",
|
||||
"Entity has a Slope Gradient component",
|
||||
"Entity has a Surface Mask Gradient component",
|
||||
"All newly added components are incompatible and disabled",
|
||||
"GradientTransform_ComponentIncompatibleWithExpectedGradients: result=SUCCESS"
|
||||
]
|
||||
|
||||
unexpected_lines = [
|
||||
"Gradient Transform Modifier is disabled, but it should be enabled",
|
||||
"Box Shape is disabled, but it should be enabled",
|
||||
"Constant Gradient is enabled, but should be disabled",
|
||||
"Altitude Gradient is enabled, but should be disabled",
|
||||
"Gradient Mixer is enabled, but should be disabled",
|
||||
"Reference Gradient is enabled, but should be disabled",
|
||||
"Shape Falloff Gradient is enabled, but should be disabled",
|
||||
"Slope Gradient is enabled, but should be disabled",
|
||||
"Surface Mask Gradient component is enabled, but should be disabled",
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
test_directory,
|
||||
editor,
|
||||
"GradientTransform_ComponentIncompatibleWithExpectedGradients.py",
|
||||
expected_lines,
|
||||
unexpected_lines,
|
||||
cfg_args=[level]
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user