Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: tools/telemetry/telemetry/core/profile_types.py

Issue 14359012: Telemetry: Add option to create a dirty profile as part of a test run (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/core/profile_types.py
diff --git a/tools/telemetry/telemetry/core/profile_types.py b/tools/telemetry/telemetry/core/profile_types.py
index 44ac38f39e7789152ed7f1042fd5af215e7b341b..bad16a36019a1aff1d875b42583ce0430ba50be8 100644
--- a/tools/telemetry/telemetry/core/profile_types.py
+++ b/tools/telemetry/telemetry/core/profile_types.py
@@ -4,14 +4,72 @@
import os
+from telemetry.core import profile_creator
+from telemetry.test import discover
+
+BASE_PROFILE_TYPES = ['clean', 'default']
+
+PROFILE_CREATORS = {}
+
PROFILE_TYPE_MAPPING = {
'typical_user': 'chrome/test/data/extensions/profiles/content_scripts1',
'power_user': 'chrome/test/data/extensions/profiles/extension_webrequest',
}
-PROFILE_TYPES = PROFILE_TYPE_MAPPING.keys()
+
+def _DiscoverCreateableProfiles():
+ """
+ Returns a dictionary of all the profile creators we can use to create
tonyg 2013/05/13 18:21:59 Bring this up a line along with """ (same thing be
jeremy 2013/05/19 14:53:25 Done.
+ a Chrome profile for testing. The returned value consists of
+ 'class_name' -> 'test class' dictionary where class_name is the name of the
+ class with the _creator suffix removed e.g. 'small_profile_creator will be
+ 'small_profile'.
+ """
+ profile_creators_dir = os.path.join(
+ os.path.dirname(__file__), '..', '..', '..', 'perf', 'profile_creators')
tonyg 2013/05/13 18:21:59 This dep is still bad. We need to have tools/perf/
+ profile_creators_unfiltered = (
+ discover.DiscoverClasses(profile_creators_dir,
+ os.path.join(profile_creators_dir, '..'),
+ profile_creator.ProfileCreator))
+
+ # Fixup class list:
+ # * Remove '_creator' suffix from keys.
+ # * Remove base class from dictionary.
+ profile_creators = {}
+ for test_name, test_class in profile_creators_unfiltered.iteritems():
+ if (test_name == 'profile_creator'):
+ continue
+ assert test_name.endswith('_creator')
+ test_name = test_name[:-len('_creator')]
+ profile_creators[test_name] = test_class
+
+ return profile_creators
+
+def GetProfileTypes():
+ """
+ Returns a list of all command line options that can be specified for profile
+ type.
+ """
+ if not PROFILE_CREATORS:
+ PROFILE_CREATORS.update(_DiscoverCreateableProfiles())
+ return (BASE_PROFILE_TYPES + PROFILE_TYPE_MAPPING.keys() +
+ PROFILE_CREATORS.keys())
def GetProfileDir(profile_type):
+ """
+ Given a |profile_type| (as returned by GetProfileTypes()), return the
+ directory to use for that profile or None if the profile needs to be generated
+ or doesn't need a profile directory (e.g. using the browser default profile).
+ """
+ if (profile_type in BASE_PROFILE_TYPES or
+ profile_type in PROFILE_CREATORS):
+ return None
+
path = os.path.abspath(os.path.join(os.path.dirname(__file__),
'..', '..', '..', '..', *PROFILE_TYPE_MAPPING[profile_type].split('/')))
assert os.path.exists(path)
return path
+
+def GetProfileCreator(profile_type):
+ """Returns the profile creator object corresponding to the |profile_type|
+ string."""
+ return PROFILE_CREATORS.get(profile_type)

Powered by Google App Engine
This is Rietveld 408576698