-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SG-10003 Fix for incorrect parent check state (#119)
Forces a recalculation of parent item's check status after the children have been created
- Loading branch information
1 parent
00ffe57
commit 6a6d2e5
Showing
6 changed files
with
79 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Copyright (c) 2018 Shotgun Software Inc. | ||
# | ||
# CONFIDENTIAL AND PROPRIETARY | ||
# | ||
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit | ||
# Source Code License included in this distribution package. See LICENSE. | ||
# By accessing, using, copying or modifying this work you indicate your | ||
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights | ||
# not expressly granted therein are reserved by Shotgun Software Inc. | ||
|
||
from publish_api_test_base import PublishApiTestBase | ||
from tank_test.tank_test_base import setUpModule # noqa | ||
|
||
|
||
class TestPublishTreeWidget(PublishApiTestBase): | ||
def test_parent_partially_checked(self): | ||
""" | ||
If we have a bunch of active tasks followed by a bunch of inactive tasks, the addition | ||
of the inactive tasks does not trigger an update of the parent's checkbox (because the update | ||
relies on the checkbox.state_changed and the default is unchecked, so inactive tasks do not | ||
trigger a state change). Test that we are forcing a recalculation to keep the parent's check_state | ||
correct in all situations | ||
""" | ||
tree = self.manager.tree | ||
item = tree.root_item.create_item("item.parent", "Parent", "Parent") | ||
publish_plugins = self.manager._load_publish_plugins(item.context) | ||
|
||
item.add_task(publish_plugins[0]) | ||
item.add_task(publish_plugins[0]) | ||
|
||
item.tasks[0]._active = True | ||
item.tasks[1]._active = False | ||
|
||
tree_widget = self.PublishTreeWidget(None) | ||
tree_widget.set_publish_manager(self.manager) | ||
tree_widget.build_tree() | ||
|
||
project_item = tree_widget.topLevelItem(1) | ||
parent_item = project_item.child(0) | ||
self.assertEqual(parent_item.check_state, self.QtCore.Qt.PartiallyChecked) | ||
|
||
def test_parent_checked_children_unchecked(self): | ||
""" | ||
If a parent item is active and only has inactive tasks, make sure that when the | ||
tree is built the parent item's check_state is valid and is set to unchecked | ||
""" | ||
tree = self.manager.tree | ||
item = tree.root_item.create_item("item.parent", "Parent", "Parent") | ||
publish_plugins = self.manager._load_publish_plugins(item.context) | ||
|
||
item.add_task(publish_plugins[0]) | ||
item.add_task(publish_plugins[0]) | ||
|
||
item._active = True | ||
item.tasks[0]._active = False | ||
item.tasks[1]._active = False | ||
|
||
tree_widget = self.PublishTreeWidget(None) | ||
tree_widget.set_publish_manager(self.manager) | ||
tree_widget.build_tree() | ||
|
||
project_item = tree_widget.topLevelItem(1) | ||
parent_item = project_item.child(0) | ||
self.assertEqual(parent_item.check_state, self.QtCore.Qt.Unchecked) |