OLD | NEW |
---|---|
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
4 <script src="../../http/tests/inspector/timeline-test.js"></script> | 4 <script src="../../http/tests/inspector/timeline-test.js"></script> |
5 <script src="../tracing-test.js"></script> | 5 <script src="../tracing-test.js"></script> |
6 <script> | 6 <script> |
7 | 7 |
8 function test() | 8 function test() |
9 { | 9 { |
10 function runTestWithDataAndCheck(input, expectedOutput, callback) | 10 function runTestWithDataAndCheck(input, expectedOutput, callback) |
11 { | 11 { |
12 InspectorTest.tracingModel().reset(); | 12 var model = InspectorTest.tracingModel(); |
13 var model = InspectorTest.tracingTimelineModel(); | |
14 model.reset(); | 13 model.reset(); |
15 var timeline = WebInspector.panels.timeline; | 14 var timeline = WebInspector.panels.timeline; |
16 | 15 |
17 function createFileReader(file, delegate) | 16 function createFileReader(file, delegate) |
18 { | 17 { |
19 return new InspectorTest.FakeFileReader(input, delegate, () => {}); | 18 return new InspectorTest.FakeFileReader(input, delegate, () => {}); |
20 } | 19 } |
21 | 20 |
22 function checkSaveData(output) | 21 function checkSaveData(output) |
23 { | 22 { |
24 var saveData = JSON.parse(output); | 23 var saveData = JSON.parse(output); |
25 InspectorTest.addResult("Saved data is equal to restored data: " + ( JSON.stringify(expectedOutput) === JSON.stringify(saveData))); | 24 InspectorTest.addResult("Saved data is equal to restored data: " + ( JSON.stringify(expectedOutput) === JSON.stringify(saveData))); |
26 callback(); | 25 callback(); |
27 } | 26 } |
28 | 27 |
29 InspectorTest.override(WebInspector.TimelineLoader, "_createFileReader", createFileReader); | 28 InspectorTest.override(WebInspector.TimelineLoader, "_createFileReader", createFileReader); |
30 WebInspector.TimelineLoader.loadFromFile(model, {}, new WebInspector.Pro gress()); | 29 WebInspector.TimelineLoader.loadFromFile(model, {}, new WebInspector.Tim elineLifecycleDelegate()); |
alph
2016/03/02 21:03:12
Don't you want to test how the delegate is working
| |
30 model.tracingComplete(); | |
31 | 31 |
32 var saver = new WebInspector.TracingTimelineSaver(); | |
32 var stream = new InspectorTest.StringOutputStream(InspectorTest.safeWrap (checkSaveData)); | 33 var stream = new InspectorTest.StringOutputStream(InspectorTest.safeWrap (checkSaveData)); |
33 var saver = new WebInspector.TracingTimelineSaver(stream); | |
34 var storage = timeline._tracingModelBackingStorage; | 34 var storage = timeline._tracingModelBackingStorage; |
35 stream.open("", storage.writeToStream.bind(storage, stream, saver)); | 35 stream.open("", storage.writeToStream.bind(storage, stream, saver)); |
36 } | 36 } |
37 | 37 |
38 function runTestOnMalformedInput(input, callback) | 38 function runTestOnMalformedInput(input, callback) |
39 { | 39 { |
40 InspectorTest.tracingModel().reset(); | 40 var model = InspectorTest.tracingModel(); |
41 var model = InspectorTest.tracingTimelineModel(); | 41 var timeline = WebInspector.panels.timeline; |
42 | |
42 model.reset(); | 43 model.reset(); |
43 | 44 |
44 function createFileReader(file, delegate) | 45 function createFileReader(file, delegate) |
45 { | 46 { |
46 return new InspectorTest.FakeFileReader(input, delegate, checkLoaded Data); | 47 return new InspectorTest.FakeFileReader(input, delegate, checkLoaded Data); |
47 } | 48 } |
48 | 49 |
49 function checkLoadedData(data) | 50 function checkLoadedData(data) |
50 { | 51 { |
51 InspectorTest.addResult("Model is empty: " + model.isEmpty()); | 52 InspectorTest.addResult("Model is empty: " + (!model.minimumRecordTi me() && !model.maximumRecordTime())); |
alph
2016/03/02 21:03:12
why?
| |
52 callback(); | 53 callback(); |
53 } | 54 } |
54 | 55 |
55 InspectorTest.override(WebInspector.TimelineLoader, "_createFileReader", createFileReader); | 56 InspectorTest.override(WebInspector.TimelineLoader, "_createFileReader", createFileReader); |
56 WebInspector.TimelineLoader.loadFromFile(model, {}, new WebInspector.Pro gress()); | 57 timeline._loadFromFile({}); |
57 } | 58 } |
58 | 59 |
59 var data = [{"args":{"number":32},"cat":"__metadata","name":"num_cpus","ph": "M","pid":32127,"tid":0,"ts":0}, | 60 var data = [{"args":{"number":32},"cat":"__metadata","name":"num_cpus","ph": "M","pid":32127,"tid":0,"ts":0}, |
60 {"args":{"sort_index":-5},"cat":"__metadata","name":"process_sort_index" ,"ph":"M","pid":32127,"tid":12,"ts":0}, | 61 {"args":{"sort_index":-5},"cat":"__metadata","name":"process_sort_index" ,"ph":"M","pid":32127,"tid":12,"ts":0}, |
61 {"args":{"name":"Renderer"},"cat":"__metadata","name":"process_name","ph ":"M","pid":32127,"tid":12,"ts":0}, | 62 {"args":{"name":"Renderer"},"cat":"__metadata","name":"process_name","ph ":"M","pid":32127,"tid":12,"ts":0}, |
62 {"args":{"sort_index":-1},"cat":"__metadata","name":"thread_sort_index", "ph":"M","pid":32127,"tid":11,"ts":0}, | 63 {"args":{"sort_index":-1},"cat":"__metadata","name":"thread_sort_index", "ph":"M","pid":32127,"tid":11,"ts":0}, |
63 {"args":{},"cat":"disabled-by-default-devtools.timeline","name":"Program ","ph":"B","pid":32120,"tid":9,"ts":95904702436,"tts":1161841}, | 64 {"args":{},"cat":"disabled-by-default-devtools.timeline","name":"Program ","ph":"B","pid":32120,"tid":9,"ts":95904702436,"tts":1161841}, |
64 {"args":{"number":32},"cat":"__metadata","name":"num_cpus","ph":"M","pid ":32120,"tid":0,"ts":0}, | 65 {"args":{"number":32},"cat":"__metadata","name":"num_cpus","ph":"M","pid ":32120,"tid":0,"ts":0}, |
65 {"args":{"sort_index":-5},"cat":"__metadata","name":"process_sort_index" ,"ph":"M","pid":32120,"tid":10,"ts":0}, | 66 {"args":{"sort_index":-5},"cat":"__metadata","name":"process_sort_index" ,"ph":"M","pid":32120,"tid":10,"ts":0}, |
66 {"args":{"name":"Renderer"},"cat":"__metadata","name":"process_name","ph ":"M","pid":32120,"tid":10,"ts":0}, | 67 {"args":{"name":"Renderer"},"cat":"__metadata","name":"process_name","ph ":"M","pid":32120,"tid":10,"ts":0}, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 | 125 |
125 </script> | 126 </script> |
126 </head> | 127 </head> |
127 | 128 |
128 <body onload="runTest()"> | 129 <body onload="runTest()"> |
129 <p> | 130 <p> |
130 Tests tracing based Timeline save/load functionality. | 131 Tests tracing based Timeline save/load functionality. |
131 </p> | 132 </p> |
132 </body> | 133 </body> |
133 </html> | 134 </html> |
OLD | NEW |