-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HYDRA-536 & HYDRA-537 : Background color and grid tests #112
Changes from 5 commits
4e0ca8e
17a4336
35b8882
c32e27c
f1c7b3a
91b8cf1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright 2024 Autodesk | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
import maya.cmds as cmds | ||
|
||
import fixturesUtils | ||
import mtohUtils | ||
|
||
class TestBackgroundColor(mtohUtils.MayaHydraBaseTestCase): | ||
# MayaHydraBaseTestCase.setUpClass requirement. | ||
_file = __file__ | ||
|
||
IMAGE_DIFF_FAIL_THRESHOLD = 0.05 | ||
IMAGE_DIFF_FAIL_PERCENT = 1 | ||
|
||
def compareBackgroundColor(self, imageName): | ||
self.setViewport2Renderer() | ||
self.assertSnapshotClose(imageName, self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT) | ||
self.setHdStormRenderer() | ||
self.assertSnapshotClose(imageName, self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT) | ||
|
||
def test_BackgroundColor(self): | ||
cmds.displayRGBColor('background', 0.5, 0, 0) | ||
self.compareBackgroundColor("background_red.jpg") | ||
cmds.displayRGBColor('background', 0, 0.5, 0) | ||
self.compareBackgroundColor("background_green.jpg") | ||
cmds.displayRGBColor('background', 0, 0, 0.5) | ||
self.compareBackgroundColor("background_blue.jpg") | ||
|
||
cmds.displayRGBColor('background', 0, 0, 0) | ||
self.compareBackgroundColor("background_black.jpg") | ||
cmds.displayRGBColor('background', 0.5, 0.5, 0.5) | ||
self.compareBackgroundColor("background_gray.jpg") | ||
cmds.displayRGBColor('background', 1, 1, 1) | ||
self.compareBackgroundColor("background_white.jpg") | ||
|
||
if __name__ == '__main__': | ||
fixturesUtils.runTests(globals()) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright 2024 Autodesk | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
import maya.cmds as cmds | ||
|
||
import fixturesUtils | ||
import mtohUtils | ||
|
||
class TestGrid(mtohUtils.MayaHydraBaseTestCase): | ||
# MayaHydraBaseTestCase.setUpClass requirement. | ||
_file = __file__ | ||
|
||
IMAGE_DIFF_FAIL_THRESHOLD = 0.05 | ||
IMAGE_DIFF_FAIL_PERCENT = 1 | ||
|
||
def test_Grid(self): | ||
cmds.grid(toggle=True) | ||
self.assertSnapshotClose("grid_enabled.png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT) | ||
cmds.grid(toggle=False) | ||
self.assertSnapshotClose("grid_disabled.png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT) | ||
|
||
if __name__ == '__main__': | ||
fixturesUtils.runTests(globals()) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,6 @@ class TestSnapshot(mtohUtils.MayaHydraBaseTestCase): | |
_file = __file__ | ||
|
||
def test_flat_orange(self): | ||
cmds.file(new=1, f=1) | ||
|
||
Comment on lines
-29
to
-30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test hasn't been enabled in over a year; see the test CMakeLists. I updated it on principle in case we bring it back and based on how I think it should be updated, but I haven't actually run it. |
||
activeEditor = cmds.playblast(activeEditor=1) | ||
|
||
# Note that we use the default viewport2 renderer, because we're not testing | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
import maya.mel | ||
|
||
import fixturesUtils | ||
import mayaUtils | ||
import mtohUtils | ||
|
||
class TestDagChanges(mtohUtils.MayaHydraBaseTestCase): | ||
|
@@ -271,7 +272,7 @@ def test_node_creation_undo(self): | |
|
||
cmds.undoInfo(state=0) | ||
try: | ||
cmds.file(new=1, f=1) | ||
mayaUtils.openNewScene() | ||
Comment on lines
-274
to
+275
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test hasn't been enabled in over a year; see the test CMakeLists. I updated it on principle in case we bring it back and based on how I think it should be updated, but I haven't actually run it. |
||
self.setBasicCam() | ||
|
||
self.setHdStormRenderer() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,6 @@ | |
# | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed a bunch of settings changes that were happening under the hood and moved them to an optional step when opening scenes (except |
||
import os | ||
import maya.cmds as cmds | ||
import maya.mel | ||
import mayaUtils | ||
import subprocess | ||
|
||
KNOWN_FORMATS = { | ||
|
@@ -31,19 +29,8 @@ | |
'bmp': 20, | ||
'png': 32, | ||
} | ||
def resetDefaultLightIntensity(): | ||
"""If the current Maya version supports setting the default light intensity, | ||
then restore it to 1 so snapshots look equal across versions.""" | ||
if maya.mel.eval("optionVar -exists defaultLightIntensity"): | ||
maya.mel.eval("optionVar -fv defaultLightIntensity 1") | ||
if cmds.attributeQuery('defaultLightIntensity', node='hardwareRenderingGlobals', exists=True): | ||
cmds.setAttr('hardwareRenderingGlobals.defaultLightIntensity', 1.0) | ||
resetDefaultLightIntensity() | ||
|
||
def snapshot(outputPath, width=400, height=None, hud=False, grid=False, colorManagementEnabled=False, camera=None): | ||
resetDefaultLightIntensity() | ||
cmds.displayRGBColor('background', 0.36, 0.36, 0.36) | ||
|
||
def snapshot(outputPath, width=400, height=None): | ||
if height is None: | ||
height = width | ||
|
||
|
@@ -60,37 +47,15 @@ def snapshot(outputPath, width=400, height=None, hud=False, grid=False, colorMan | |
|
||
# save the old output image format | ||
oldFormat = cmds.getAttr("defaultRenderGlobals.imageFormat") | ||
# save the hud setting | ||
oldHud = cmds.headsUpDisplay(q=1, layoutVisibility=1) | ||
# save the grid setting | ||
oldGrid = cmds.grid(q=1, toggle=1) | ||
# save the old color management status | ||
oldColorManagementEnabled = cmds.colorManagementPrefs(q=1, cmEnabled=1) | ||
|
||
# Find the current model panel for playblasting | ||
# to make sure the desired camera is set, if any | ||
panel = mayaUtils.activeModelPanel() | ||
oldCamera = cmds.modelPanel(panel, q=True, cam=True) | ||
if camera: | ||
cmds.modelEditor(panel, edit=True, camera=camera) | ||
|
||
cmds.setAttr("defaultRenderGlobals.imageFormat", formatNum) | ||
cmds.headsUpDisplay(layoutVisibility=hud) | ||
cmds.grid(toggle=grid) | ||
cmds.colorManagementPrefs(edit=True, cmEnabled=colorManagementEnabled) | ||
try: | ||
cmds.refresh() | ||
cmds.playblast(cf=outputPath, viewer=False, format="image", | ||
frame=cmds.currentTime(q=1), offScreen=1, | ||
widthHeight=(width, height), percent=100) | ||
finally: | ||
cmds.setAttr("defaultRenderGlobals.imageFormat", oldFormat) | ||
cmds.headsUpDisplay(layoutVisibility=oldHud) | ||
cmds.grid(toggle=oldGrid) | ||
cmds.colorManagementPrefs(edit=True, cmEnabled=oldColorManagementEnabled) | ||
|
||
if camera: | ||
cmds.lookThru(panel, oldCamera) | ||
|
||
def imageDiff(imagePath1, imagePath2, verbose, fail, failpercent, hardfail, | ||
warn, warnpercent, hardwarn, perceptual): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we must use .jpg for playblasts to render the background color, using .png always rendered the background as transparent.