1#!/pxrpythonsubst
2#
3# Copyright 2020 Pixar
4#
5# Licensed under the Apache License, Version 2.0 (the "Apache License")
6# with the following modification; you may not use this file except in
7# compliance with the Apache License and the following modification to it:
8# Section 6. Trademarks. is deleted and replaced with:
9#
10# 6. Trademarks. This License does not grant permission to use the trade
11#    names, trademarks, service marks, or product names of the Licensor
12#    and its affiliates, except as required to comply with Section 4(c) of
13#    the License and to reproduce the content of the NOTICE file.
14#
15# You may obtain a copy of the Apache License at
16#
17#     http://www.apache.org/licenses/LICENSE-2.0
18#
19# Unless required by applicable law or agreed to in writing, software
20# distributed under the Apache License with the above modification is
21# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22# KIND, either express or implied. See the Apache License for the specific
23# language governing permissions and limitations under the Apache License.
24#
25
26NUM_TIME_SAMPLES = 3
27START_TIME_TEXT = "1.0"
28END_TIME_TEXT = "3.0"
29
30def _testBasic(appController):
31    stageBegin   = appController._ui.stageBegin
32    stageEnd     = appController._ui.stageEnd
33    rangeBegin   = appController._ui.rangeBegin
34    rangeEnd     = appController._ui.rangeEnd
35    stepSize     = appController._ui.stepSize
36    currentFrame = appController._ui.frameField
37
38    forwardControl  = appController._ui.actionFrame_Forward.triggered
39
40    # ensure our initial variable time samples are set.
41    assert rangeBegin.text() == START_TIME_TEXT
42    assert rangeEnd.text() == END_TIME_TEXT
43
44    # ensure our static time samples are set.
45    assert stageBegin.text() == START_TIME_TEXT
46    assert stageEnd.text() == END_TIME_TEXT
47
48    def testIterateTimeRange(expectedRange, control):
49        for i in expectedRange:
50            assert currentFrame.text() == str(float(i))
51            appController._takeShot("bbox_frame_%d.png" % i)
52            control.emit()
53            appController._mainWindow.repaint()
54
55    # iterate through the default time samples by emitting our
56    # forward control signal.
57    testIterateTimeRange([1, 2, 3], forwardControl)
58
59def testUsdviewInputFunction(appController):
60    _testBasic(appController)
61