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

Unified Diff: tools/android/loading/test_utils.py

Issue 1708223005: Loading model test tweak. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: push up MakeGraph Created 4 years, 10 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
« no previous file with comments | « tools/android/loading/loading_model_unittest.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/android/loading/test_utils.py
diff --git a/tools/android/loading/test_utils.py b/tools/android/loading/test_utils.py
index 654e94bdb655943f88b4163d83fb51a5e3fc74f7..aea73a76a02810194d5e46f5a8863e880fb64416 100644
--- a/tools/android/loading/test_utils.py
+++ b/tools/android/loading/test_utils.py
@@ -5,6 +5,7 @@
"""Common utilities used in unit tests, within this directory."""
import devtools_monitor
+import loading_model
import loading_trace
import page_track
import request_track
@@ -80,3 +81,33 @@ def LoadingTraceFromEvents(requests, page_events=None, trace_events=None):
tracing_track = None
return loading_trace.LoadingTrace(
None, None, page_event_track, request, tracing_track)
+
+
+class SimpleLens(object):
+ """A simple replacement for RequestDependencyLens.
+
+ Uses only the initiator url of a request for determining a dependency.
+ """
+ def __init__(self, trace):
+ self._trace = trace
+
+ def GetRequestDependencies(self):
+ url_to_rq = {}
+ deps = []
+ for rq in self._trace.request_track.GetEvents():
+ assert rq.url not in url_to_rq
+ url_to_rq[rq.url] = rq
+ for rq in self._trace.request_track.GetEvents():
+ initiating_url = rq.initiator['url']
+ if initiating_url in url_to_rq:
+ deps.append((url_to_rq[initiating_url], rq, rq.initiator['type']))
+ return deps
+
+
+class TestResourceGraph(loading_model.ResourceGraph):
+ """Replace the default request lens in a ResourceGraph with our SimpleLens."""
+ REQUEST_LENS = SimpleLens
+
+ @classmethod
+ def FromRequestList(cls, requests, page_events=None, trace_events=None):
+ return cls(LoadingTraceFromEvents(requests, page_events, trace_events))
« no previous file with comments | « tools/android/loading/loading_model_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698