forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial changes that will get the "async" capability of tab_ui module…
… to work In summary, the changes revolve around making proguarding rules to keep foreign symbols used by the module. The following are the highlights: - Investigate and add many missing "keep" rules to proguard file - Fix R(esource) files to point to the appropriate location (base vs. module) - Add build argument to build tab_ui as an async module - Create file to keep proguarding rules that must be added manually - Change proguard rule generation and add unit tests Bug: 958026 Change-Id: I10904776d54a21bb292e2ef176750fdd338bcf40 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1627566 Commit-Queue: Fred Mello <fredmello@chromium.org> Reviewed-by: Yaron Friedman <yfriedman@chromium.org> Reviewed-by: Eric Stevenson <estevenson@chromium.org> Reviewed-by: Tibor Goldschwendt <tiborg@chromium.org> Cr-Commit-Position: refs/heads/master@{#665328}
- Loading branch information
Fred Mello
authored and
Commit Bot
committed
May 31, 2019
1 parent
0099c85
commit 2519a08
Showing
13 changed files
with
1,253 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Copyright 2019 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import unittest | ||
import re | ||
import os | ||
|
||
|
||
class TestProguardRuleGeneration(unittest.TestCase): | ||
""" | ||
This script is used to test a ProGuard keep rules for the purposes | ||
of maintaining compatibility between async DFMs and synchronously | ||
proguarded modules. | ||
The rules are often generated by constant_pool_refs_to_keep_rules.py | ||
This test can be run manually. Example: | ||
python build/android/constant_pool_refs_to_keep_rules_test.py -v | ||
""" | ||
|
||
# Make sure this variable is set accordingly. | ||
# It should point to a proguard file. | ||
PROGUARD_FILE_PATH = os.path.join( | ||
os.path.dirname(__file__), | ||
"../../chrome/android/features/tab_ui/proguard_async.flags") | ||
|
||
def test_TabUI_HasRules(self): | ||
""" | ||
Ensures that a few of the rules used in tabs_ui module are included. | ||
Although this is far from 100% deterministic, these rules are | ||
created by code that exercise different parts of the rule generation code. | ||
""" | ||
|
||
rules = set() | ||
with open(self.PROGUARD_FILE_PATH, 'r') as proguard_rules: | ||
for line in proguard_rules: | ||
if line.startswith('-keep'): | ||
rule = re.search('class (.+?) {', line).group(1) | ||
rules.add(rule) | ||
|
||
# The following rules test most of the use cases for | ||
# rules that can be added automatically. | ||
self.assertIn('org.chromium.ui.modelutil.PropertyModel', rules) | ||
self.assertIn('org.chromium.ui.modelutil.PropertyModel', rules) | ||
self.assertIn('org.chromium.ui.modelutil.PropertyKey', rules) | ||
self.assertIn('org.chromium.chrome.browser.toolbar.ToolbarManager', rules) | ||
self.assertIn('org.chromium.base.Supplier', rules) | ||
self.assertIn('android.support.v7.widget.helper.ItemTouchHelper', rules) | ||
self.assertIn( | ||
'android.support.v7.widget.helper.ItemTouchHelper$SimpleCallback', | ||
rules) | ||
self.assertIn('android.support.v7.widget.helper.ItemTouchHelper$Callback', | ||
rules) | ||
self.assertIn('android.support.v4.content.ContextCompat', rules) | ||
self.assertIn('android.support.v7.widget.GridLayoutManager', rules) | ||
self.assertIn('android.support.v4.content.res.ResourcesCompat', rules) | ||
self.assertIn( | ||
'org.chromium.chrome.browser.tasks.tabgroup.TabGroupModelFilter', rules) | ||
self.assertIn('android.support.v7.widget.RecyclerView$ViewHolder', rules) | ||
self.assertIn('android.support.v7.widget.RecyclerView', rules) | ||
self.assertIn('org.chromium.ui.modelutil.SimpleRecyclerViewMcpBase', rules) | ||
self.assertIn('org.chromium.ui.modelutil.RecyclerViewAdapter', rules) | ||
|
||
# The following rules need to be added manually. | ||
self.assertNotIn( | ||
'org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager' + | ||
'$FullscreenListener$$CC', rules) | ||
self.assertNotIn( | ||
'org.chromium.chrome.browser.widget.bottomsheet.BottomSheet' + | ||
'$BottomSheetContent$$CC', rules) | ||
self.assertNotIn('org.chromium.ui.widget.RoundedCornerImageView', rules) | ||
self.assertNotIn( | ||
'android.support.v4.graphics.drawable.RoundedBitmapDrawable', rules) | ||
|
||
def test_TabUI_HasNoDuplicateRules(self): | ||
""" | ||
Ensures that there are no duplicate keep rules | ||
""" | ||
|
||
rules = set() | ||
with open(self.PROGUARD_FILE_PATH, 'r') as proguard_rules: | ||
for line in proguard_rules: | ||
if line.startswith('-keep'): | ||
rule = re.search('class (.+?) {', line).group(1) | ||
self.assertNotIn(rule, rules) | ||
rules.add(rule) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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 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,11 @@ | ||
# Copyright 2019 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
declare_args() { | ||
# Controls the feature being a DFM or not. | ||
disable_tab_ui_dfm = true | ||
|
||
# Whether to create tab_ui module as an asynchronous DFM. | ||
async_tab_ui = false | ||
} |
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
Oops, something went wrong.