Hell of a speed boost for Steam.
This commit is contained in:
@@ -95,6 +95,116 @@ class SteamReturnActivationTests(unittest.TestCase):
|
||||
performAction.assert_called_once_with(button)
|
||||
|
||||
|
||||
class SteamVirtualizedListMutationTests(unittest.TestCase):
|
||||
def test_children_added_skips_generic_web_cache_dump_for_virtualized_list_churn(self):
|
||||
testScript = steam_script.Script.__new__(steam_script.Script)
|
||||
source = object()
|
||||
focus = object()
|
||||
event = mock.Mock(
|
||||
type="object:children-changed:add",
|
||||
source=source,
|
||||
any_data=object(),
|
||||
detail1=0,
|
||||
)
|
||||
chromiumCalls = []
|
||||
|
||||
testScript.utilities = mock.Mock()
|
||||
testScript.utilities.isSteamVirtualizedList.return_value = True
|
||||
testScript.utilities.clearSteamVirtualizedListCaches = mock.Mock()
|
||||
|
||||
def chromiumOnChildrenAdded(self, addedEvent):
|
||||
chromiumCalls.append((self, addedEvent))
|
||||
return False
|
||||
|
||||
with (
|
||||
mock.patch.object(steam_script.cthulhu_state, "locusOfFocus", focus),
|
||||
mock.patch.object(steam_script.AXObject, "is_dead", return_value=False),
|
||||
mock.patch.object(steam_script.AXObject, "find_ancestor", return_value=source),
|
||||
mock.patch.object(steam_script.AXObject, "clear_cache_now") as clearCache,
|
||||
mock.patch.object(steam_script.Script, "_isSteamNotification", return_value=False),
|
||||
mock.patch.object(
|
||||
steam_script.Chromium.Script,
|
||||
"onChildrenAdded",
|
||||
new=chromiumOnChildrenAdded,
|
||||
),
|
||||
):
|
||||
self.assertTrue(testScript.onChildrenAdded(event))
|
||||
|
||||
clearCache.assert_called_once_with("children-changed event.")
|
||||
testScript.utilities.clearSteamVirtualizedListCaches.assert_called_once_with()
|
||||
self.assertEqual(chromiumCalls, [])
|
||||
|
||||
def test_children_removed_skips_generic_web_cache_dump_for_virtualized_list_churn(self):
|
||||
testScript = steam_script.Script.__new__(steam_script.Script)
|
||||
source = object()
|
||||
focus = object()
|
||||
event = mock.Mock(
|
||||
type="object:children-changed:remove",
|
||||
source=source,
|
||||
any_data=object(),
|
||||
detail1=0,
|
||||
)
|
||||
chromiumCalls = []
|
||||
|
||||
testScript.utilities = mock.Mock()
|
||||
testScript.utilities.isSteamVirtualizedList.return_value = True
|
||||
testScript.utilities.clearSteamVirtualizedListCaches = mock.Mock()
|
||||
|
||||
def chromiumOnChildrenRemoved(self, removedEvent):
|
||||
chromiumCalls.append((self, removedEvent))
|
||||
return False
|
||||
|
||||
with (
|
||||
mock.patch.object(steam_script.cthulhu_state, "locusOfFocus", focus),
|
||||
mock.patch.object(steam_script.AXObject, "is_dead", return_value=False),
|
||||
mock.patch.object(steam_script.AXObject, "find_ancestor", return_value=source),
|
||||
mock.patch.object(steam_script.AXObject, "clear_cache_now") as clearCache,
|
||||
mock.patch.object(
|
||||
steam_script.Chromium.Script,
|
||||
"onChildrenRemoved",
|
||||
new=chromiumOnChildrenRemoved,
|
||||
),
|
||||
):
|
||||
self.assertTrue(testScript.onChildrenRemoved(event))
|
||||
|
||||
clearCache.assert_called_once_with("children-changed event.")
|
||||
testScript.utilities.clearSteamVirtualizedListCaches.assert_called_once_with()
|
||||
self.assertEqual(chromiumCalls, [])
|
||||
|
||||
def test_children_removed_defers_to_generic_handler_when_focus_is_dead(self):
|
||||
testScript = steam_script.Script.__new__(steam_script.Script)
|
||||
source = object()
|
||||
focus = object()
|
||||
event = mock.Mock(
|
||||
type="object:children-changed:remove",
|
||||
source=source,
|
||||
any_data=object(),
|
||||
detail1=0,
|
||||
)
|
||||
chromiumCalls = []
|
||||
|
||||
testScript.utilities = mock.Mock()
|
||||
testScript.utilities.isSteamVirtualizedList.return_value = True
|
||||
|
||||
def chromiumOnChildrenRemoved(self, removedEvent):
|
||||
chromiumCalls.append((self, removedEvent))
|
||||
return False
|
||||
|
||||
with (
|
||||
mock.patch.object(steam_script.cthulhu_state, "locusOfFocus", focus),
|
||||
mock.patch.object(steam_script.AXObject, "is_dead", return_value=True),
|
||||
mock.patch.object(
|
||||
steam_script.Chromium.Script,
|
||||
"onChildrenRemoved",
|
||||
new=chromiumOnChildrenRemoved,
|
||||
),
|
||||
):
|
||||
self.assertFalse(testScript.onChildrenRemoved(event))
|
||||
|
||||
self.assertEqual(chromiumCalls, [(testScript, event)])
|
||||
testScript.utilities.clearSteamVirtualizedListCaches.assert_not_called()
|
||||
|
||||
|
||||
class SteamLabelRecoveryTests(unittest.TestCase):
|
||||
def test_displayed_label_recovers_friends_list_tab_text_from_parent_context(self):
|
||||
testScript = mock.Mock(generatorCache={})
|
||||
|
||||
Reference in New Issue
Block a user