Chris Craik | 44c2820 | 2015-05-12 17:25:16 -0700 | [diff] [blame^] | 1 | <!DOCTYPE html> |
| 2 | <!-- |
| 3 | Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 4 | Use of this source code is governed by a BSD-style license that can be |
| 5 | found in the LICENSE file. |
| 6 | --> |
| 7 | |
| 8 | <link rel="import" href="/core/analysis/flow_classifier.html"> |
| 9 | <link rel="import" href="/core/test_utils.html"> |
| 10 | <link rel="import" href="/core/selection.html"> |
| 11 | <link rel="import" href="/base/iteration_helpers.html"> |
| 12 | <link rel="import" href="/core/trace_model/trace_model.html"> |
| 13 | |
| 14 | <script> |
| 15 | 'use strict'; |
| 16 | |
| 17 | tv.b.unittest.testSuite(function() { |
| 18 | var newFlowEventEx = tv.c.test_utils.newFlowEventEx; |
| 19 | |
| 20 | test('basic', function() { |
| 21 | var a = newFlowEventEx({ |
| 22 | 'title': 'a', start: 0, end: 10 }); |
| 23 | var b = newFlowEventEx({ |
| 24 | 'title': 'b', start: 10, end: 20 }); |
| 25 | var c = newFlowEventEx({ |
| 26 | 'title': 'c', start: 20, end: 25 }); |
| 27 | var d = newFlowEventEx({ |
| 28 | 'title': 'd', start: 30, end: 35 }); |
| 29 | |
| 30 | var fc = new tv.c.analysis.FlowClassifier(); |
| 31 | fc.addInFlow(a); |
| 32 | |
| 33 | fc.addInFlow(b); |
| 34 | fc.addOutFlow(b); |
| 35 | |
| 36 | fc.addInFlow(c); |
| 37 | fc.addOutFlow(c); |
| 38 | |
| 39 | fc.addOutFlow(d); |
| 40 | |
| 41 | function asSortedArray(selection) { |
| 42 | var events = tv.b.asArray(selection); |
| 43 | events.sort(function(a, b) { |
| 44 | return a.guid - b.guid; |
| 45 | }); |
| 46 | return events; |
| 47 | } |
| 48 | |
| 49 | assert.deepEqual(asSortedArray(fc.inFlowEvents), [a]); |
| 50 | assert.deepEqual(asSortedArray(fc.outFlowEvents), [d]); |
| 51 | assert.deepEqual(asSortedArray(fc.internalFlowEvents), [b, c]); |
| 52 | }); |
| 53 | |
| 54 | }); |
| 55 | </script> |