Skip to content

Commit

Permalink
Add PRESUBMIT warnings for WIDGET_OWNS_NATIVE_WIDGET and
Browse files Browse the repository at this point in the history
NATIVE_WIDGET_OWNS_WIDGET

We are refactoring Views code with an eye towards changing the ownership model of widgets to CLIENT_OWNS_WIDGET as the only ownership model. This will warn developers when they are landing code using one of these two ownership models.


Change-Id: I77c8911d3ab5669fb6f148a650465c4f43e2d09b
Bug: 339619005
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5577858
Commit-Queue: Allen Bauer <[email protected]>
Reviewed-by: Dirk Pranke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1306988}
  • Loading branch information
Allen Bauer authored and Chromium LUCI CQ committed May 28, 2024
1 parent 649e375 commit 5839eb2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,18 @@ class BanRule:
),
treat_as_error = False,
),
BanRule(
pattern = r'/WIDGET_OWNS_NATIVE_WIDGET|'
r'NATIVE_WIDGET_OWNS_WIDGET',
explanation = (
'WIDGET_OWNS_NATIVE_WIDGET and NATIVE_WIDGET_OWNS_WIDGET are in the '
'process of being deprecated. Consider using the new '
'CLIENT_OWNS_WIDGET ownership model. Eventually, this will be the only '
'available ownership model available and the associated enumeration'
'will be removed.',
),
treat_as_error = False,
),
)

_DEPRECATED_SYNC_CONSENT_FUNCTION_WARNING = (
Expand Down
6 changes: 6 additions & 0 deletions PRESUBMIT_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2978,6 +2978,10 @@ def testBannedCppFunctions(self):
['using namespace std; // nocheck']),
MockFile('some/cpp/comment/file.cc',
[' // A comment about `using namespace std;`']),
MockFile('some/cpp/problematic/file3.cc',
['params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET']),
MockFile('some/cpp/problematic/file4.cc',
['params.ownership = Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET']),
]

results = PRESUBMIT.CheckNoBannedFunctions(input_api, MockOutputApi())
Expand All @@ -2989,6 +2993,8 @@ def testBannedCppFunctions(self):
'third_party/blink/problematic/file.cc' in results[0].message)
self.assertTrue('some/cpp/ok/file.cc' not in results[1].message)
self.assertTrue('some/cpp/problematic/file2.cc' in results[0].message)
self.assertTrue('some/cpp/problematic/file3.cc' in results[0].message)
self.assertTrue('some/cpp/problematic/file4.cc' in results[0].message)
self.assertFalse('some/cpp/nocheck/file.cc' in results[0].message)
self.assertFalse('some/cpp/nocheck/file.cc' in results[1].message)
self.assertFalse('some/cpp/comment/file.cc' in results[0].message)
Expand Down

0 comments on commit 5839eb2

Please sign in to comment.